-
Notifications
You must be signed in to change notification settings - Fork 366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tools: Add Gmail support #838
base: main
Are you sure you want to change the base?
Conversation
## 5. Run the Backend and Frontend | ||
|
||
run next command to start the backend and frontend: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great docs
src/backend/tools/gmail/auth.py
Outdated
def __init__(self): | ||
super().__init__() | ||
|
||
settings = Settings() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Settings() usage can be updated now to use .get()
src/backend/tools/gmail/tool.py
Outdated
|
||
@classmethod | ||
def is_available(cls) -> bool: | ||
settings = Settings() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here, let's update Settings() to use .get()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also move the attribute setting out of is_available
and directly onto the class attribute, then only check that they're not None in is_available
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some v minor changes then good to go!
Description: This PR adds a Gmail tool that allows users to access emails from their Gmail account.
Dependencies: This features requires the user to have a Gmail account, and for the Google Cloud Console to have Gmail API access enabled. This PR does not add any new Python dependencies to
pyproject.toml
because it uses the same Python SDK that is already in the Toolkit for accessing Google Drive.AI Description
This PR introduces a new Gmail tool to the application, enabling users to search for messages and files in their Gmail accounts. The tool is implemented as a new class,
GmailTool
, which extends theBaseTool
class. TheGmailTool
class provides a method,call
, which performs the search and returns a list of relevant email snippets.The
GmailTool
class also includes a method,is_available
, which checks if the tool is available for use. This method checks if theclient_id
andclient_secret
are set in thegmail_settings
object. If both are set, the method returnsTrue
, indicating that the tool is available.The
GmailTool
class also includes a method,get_tool_definition
, which returns aToolDefinition
object. This object contains information about the tool, such as its name, display name, implementation, parameter definitions, visibility, availability, authentication implementation, error message, category, and description.The
GmailTool
class also includes a method,_handle_tool_specific_errors
, which handles tool-specific errors. This method takes an error object and a dictionary of keyword arguments as input. If an error occurs, the method deletes the tool authentication from the database and raises an exception with an error message.The
GmailTool
class also includes a method,search_all
, which performs a search in the user's Gmail account. This method takes a query string as input and returns a list of messages that match the query.The
GmailTool
class also includes a method,retrieve_messages
, which retrieves messages from the user's Gmail account. This method takes a list of message IDs as input and returns a list of messages.The
GmailTool
class also includes a method,serialize_results
, which serializes the results of a search. This method takes a list of messages as input and returns a list of dictionaries, where each dictionary represents a message.The
GmailTool
class also includes a method,serialize_result
, which serializes a single message. This method takes a message object as input and returns a dictionary representing the message.The
GmailTool
class also includes a method,get_header_value
, which retrieves the value of a header from a list of headers. This method takes a list of headers and a header name as input and returns the value of the header.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailService
class is a new class that provides methods for searching and retrieving messages from a user's Gmail account. The class includes a method,search_all
, which performs a search in the user's Gmail account. This method takes a query string as input and returns a list of messages that match the query.The
GmailService
class also includes a method,retrieve_messages
, which retrieves messages from the user's Gmail account. This method takes a list of message IDs as input and returns a list of messages.The
GmailService
class also includes a method,serialize_results
, which serializes the results of a search. This method takes a list of messages as input and returns a list of dictionaries, where each dictionary represents a message.The
GmailService
class also includes a method,serialize_result
, which serializes a single message. This method takes a message object as input and returns a dictionary representing the message.The
GmailService
class also includes a method,get_header_value
, which retrieves the value of a header from a list of headers. This method takes a list of headers and a header name as input and returns the value of the header.The
GmailService
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailAuth
class is a new class that provides methods for authenticating a user with Gmail. The class includes a method,get_auth_url
, which returns the URL for the authentication endpoint. This method takes a user ID as input and returns a URL.The
GmailAuth
class also includes a method,retrieve_auth_token
, which retrieves an authentication token from the authentication endpoint. This method takes a request object, a session object, and a user ID as input and returns an authentication token.The
GmailAuth
class also includes a method,try_refresh_token
, which refreshes an authentication token. This method takes a session object, a user ID, and a tool authentication object as input and returns a boolean indicating whether the token was successfully refreshed.The
GmailClient
class is a new class that provides methods for interacting with the Gmail API. The class includes a method,search_all
, which performs a search in the user's Gmail account. This method takes a query string as input and returns a list of messages that match the query.The
GmailClient
class also includes a method,retrieve_messages
, which retrieves messages from the user's Gmail account. This method takes a list of message IDs as input and returns a list of messages.The
GmailClient
class also includes a method,serialize_results
, which serializes the results of a search. This method takes a list of messages as input and returns a list of dictionaries, where each dictionary represents a message.The
GmailClient
class also includes a method,serialize_result
, which serializes a single message. This method takes a message object as input and returns a dictionary representing the message.The
GmailClient
class also includes a method,get_header_value
, which retrieves the value of a header from a list of headers. This method takes a list of headers and a header name as input and returns the value of the header.The
GmailClient
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,decode_base64_raw
, which decodes a base64-encoded string. This method takes a base64-encoded string as input and returns a decoded string.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method,get_gmail_service
, which returns aGmailService
object. This method takes a user ID and a search limit as input and returns aGmailService
object.The
GmailTool
class also includes a method, `get_gmail_service