Source code for

from __future__ import annotations

from typing import TYPE_CHECKING, List

from langchain_core.pydantic_v1 import Field
from import BaseToolkit

from import BaseTool
from import GmailCreateDraft
from import GmailGetMessage
from import GmailGetThread
from import GmailSearch
from import GmailSendMessage
from import build_resource_service

    # This is for linting and IDE typehints
    from googleapiclient.discovery import Resource
        # We do this so pydantic can resolve the types when instantiating
        from googleapiclient.discovery import Resource
    except ImportError:

SCOPES = [""]

[docs]class GmailToolkit(BaseToolkit): """Toolkit for interacting with Gmail. *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 send emails on behalf of the associated account. See for more information. """ api_resource: Resource = Field(default_factory=build_resource_service) class Config: """Pydantic config.""" arbitrary_types_allowed = True
[docs] def get_tools(self) -> List[BaseTool]: """Get the tools in the toolkit.""" return [ GmailCreateDraft(api_resource=self.api_resource), GmailSendMessage(api_resource=self.api_resource), GmailSearch(api_resource=self.api_resource), GmailGetMessage(api_resource=self.api_resource), GmailGetThread(api_resource=self.api_resource), ]