Source code for langchain_google_community.calendar.toolkit
from__future__importannotationsfromtypingimportTYPE_CHECKING,Listfromlangchain_core.toolsimportBaseToolfromlangchain_core.tools.baseimportBaseToolkitfrompydanticimportConfigDict,Fieldfromlangchain_google_community.calendar.create_eventimportCalendarCreateEventfromlangchain_google_community.calendar.current_datetimeimportGetCurrentDatetimefromlangchain_google_community.calendar.delete_eventimportCalendarDeleteEventfromlangchain_google_community.calendar.get_calendars_infoimportGetCalendarsInfofromlangchain_google_community.calendar.move_eventimportCalendarMoveEventfromlangchain_google_community.calendar.search_eventsimportCalendarSearchEventsfromlangchain_google_community.calendar.update_eventimportCalendarUpdateEventfromlangchain_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:passSCOPES=["https://www.googleapis.com/auth/calendar"]
[docs]classCalendarToolkit(BaseToolkit):"""Toolkit for interacting with Google Calendar. *Security Note*: This toolkit contains tools that can read and modify the state of a service; e.g., by reading, creating, updating, deleting data associated with this service. For example, this toolkit can be used to create events on behalf of the associated account. See https://python.langchain.com/docs/security for more information. """api_resource:Resource=Field(default_factory=build_resource_service)model_config=ConfigDict(arbitrary_types_allowed=True,)
[docs]defget_tools(self)->List[BaseTool]:"""Get the tools in the toolkit."""return[CalendarCreateEvent(api_resource=self.api_resource),CalendarSearchEvents(api_resource=self.api_resource),CalendarUpdateEvent(api_resource=self.api_resource),GetCalendarsInfo(api_resource=self.api_resource),CalendarMoveEvent(api_resource=self.api_resource),CalendarDeleteEvent(api_resource=self.api_resource),GetCurrentDatetime(api_resource=self.api_resource),]