Source code for langchain_google_community.calendar.base
"""Base class for Google Calendar tools."""from__future__importannotationsfromtypingimportTYPE_CHECKINGfromlangchain_core.toolsimportBaseToolfrompydanticimportFieldfromlangchain_google_community.calendar.utilsimportbuild_resource_serviceifTYPE_CHECKING:# This is for linting and IDE typehintsfromgoogleapiclient.discoveryimportResource# type: ignore[import]else:try:# We do this so pydantic can resolve the types when instantiatingfromgoogleapiclient.discoveryimportResourceexceptImportError:pass
[docs]classCalendarBaseTool(BaseTool):# type: ignore[override]"""Base class for Google Calendar tools."""api_resource:Resource=Field(default_factory=build_resource_service)
[docs]@classmethoddeffrom_api_resource(cls,api_resource:Resource)->"CalendarBaseTool":"""Create a tool from an api resource. Args: api_resource: The api resource to use. Returns: A tool. """returncls(service=api_resource)# type: ignore[call-arg]