-
Notifications
You must be signed in to change notification settings - Fork 368
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
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scottmx81
requested review from
tomtobac,
abimacarmes,
knajjars,
BeatrixCohere,
tianjing-li,
EugeneLightsOn,
malexw and
a team
as code owners
November 11, 2024 21:51
tianjing-li
reviewed
Nov 13, 2024
tianjing-li
reviewed
Nov 13, 2024
tianjing-li
reviewed
Nov 13, 2024
tianjing-li
requested changes
Nov 13, 2024
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!
tianjing-li
approved these changes
Nov 26, 2024
scottmx81
temporarily deployed
to
development
November 27, 2024 19:20
— with
GitHub Actions
Inactive
scottmx81
temporarily deployed
to
development
November 27, 2024 19:33
— with
GitHub Actions
Inactive
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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