Skip to content
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 12 commits into from
Nov 27, 2024
Merged

Tools: Add Gmail support #838

merged 12 commits into from
Nov 27, 2024

Conversation

scottmx81
Copy link
Collaborator

@scottmx81 scottmx81 commented Nov 11, 2024

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 the BaseTool class. The GmailTool 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 the client_id and client_secret are set in the gmail_settings object. If both are set, the method returns True, indicating that the tool is available.

The GmailTool class also includes a method, get_tool_definition, which returns a ToolDefinition 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 a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService 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 a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService 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 a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService 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 a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, get_gmail_service, which returns a GmailService object. This method takes a user ID and a search limit as input and returns a GmailService object.

The GmailTool class also includes a method, `get_gmail_service

@scottmx81 scottmx81 changed the title ***Tools***: Add Gmail support Tools: Add Gmail support Nov 11, 2024
Copy link
Collaborator

@tianjing-li tianjing-li left a 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!

@scottmx81 scottmx81 merged commit 81a6f32 into cohere-ai:main Nov 27, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants