A LangChain toolkit for integrating Google Workspace (Gmail, Calendar, Tasks, Sheets, Drive)
Project description
GoogleSuiteToolkit for LangChain
A unified toolkit for integrating Google Workspace (Gmail, Calendar, Tasks, Sheets) with LangChain agents.
Features
- Access Gmail, Google Calendar, Google Tasks, and Google Sheets via LangChain tools
- Easy authentication using OAuth2 credentials
- Simple API for tool retrieval and usage
Installation
- Clone this repository or copy the toolkit files into your project.
- Install dependencies:
pip install -r requirements.txt
- Set up your Google Cloud project and download
credentials.jsonfor OAuth2.
Usage
from langchain_gsuite import GoogleSuiteToolkit, build_gsuite_service, DEFAULT_SCOPES
# Basic usage
toolkit = GoogleSuiteToolkit()
print(toolkit.get_tools())
print(toolkit.get_tools_dict())
# Advanced: Customizing Google API resource
from google.oauth2.credentials import Credentials
# Example: Use custom scopes and credentials
custom_scopes = [
"https://www.googleapis.com/auth/gmail.readonly",
"https://www.googleapis.com/auth/calendar",
]
creds = Credentials.from_authorized_user_file("path/to/credentials.json", custom_scopes)
api_resource = build_gsuite_service(
credentials=creds,
service_name="gmail", # or 'calendar', 'sheets', 'tasks'
service_version="v1",
scopes=custom_scopes
)
Required OAuth Scopes
Depending on the Google Workspace services you want to access, you must provide the appropriate OAuth scopes. Here are some common scopes:
- Gmail:
https://mail.google.com/orhttps://www.googleapis.com/auth/gmail.readonly - Calendar:
https://www.googleapis.com/auth/calendar - Sheets:
https://www.googleapis.com/auth/spreadsheets - Drive (readonly):
https://www.googleapis.com/auth/drive.readonly - Tasks:
https://www.googleapis.com/auth/tasks
The toolkit provides two lists for convenience:
DEFAULT_SCOPES: Full access for all supported servicesDEFAULT_SERVICE_SCOPES: Read-only access for all supported services
You can pass your own list of scopes to build_gsuite_service if you want to restrict or expand permissions.
Customizing build_gsuite_service
The build_gsuite_service function supports the following parameters:
credentials: (Optional) Agoogle.oauth2.credentials.Credentialsobject. If not provided, credentials will be loaded automatically.service_name: (str) The Google API service name (e.g., 'gmail', 'calendar', 'sheets', 'tasks').service_version: (str) The API version (default: 'v1').use_domain_wide: (bool) Use domain-wide delegation (for service accounts).delegated_user: (Optional[str]) User to delegate domain-wide authority to.service_account_file: (Optional[str]) Path to service account file.scopes: (Optional[List[str]]) List of OAuth2 scopes. If not provided, defaults toDEFAULT_SCOPESorDEFAULT_SERVICE_SCOPES.
See the docstring in utils.py for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gsuite_langchain_tools-0.1.0.tar.gz.
File metadata
- Download URL: gsuite_langchain_tools-0.1.0.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6275d2387219c817af9e6d98fb22b6f7b0e9ff969220ffbdac81d2c221d8f6ea
|
|
| MD5 |
46087d90b7678f9c025b894ecb19fcfb
|
|
| BLAKE2b-256 |
17b1182295116411e25f40c33bdb8e2c5b3ae887c851867f5e71c5b535d046c8
|
File details
Details for the file gsuite_langchain_tools-0.1.0-py3-none-any.whl.
File metadata
- Download URL: gsuite_langchain_tools-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f897b5e7a3da052fbd8bb794d31bfdcfbee5e4fc06e2bbc02093d0538ec9064
|
|
| MD5 |
81a4919d309cb5e510b3b945d496bd9d
|
|
| BLAKE2b-256 |
e7321090260de7b12f6f284767dd772caa1d73b5c7baac7ec88e017ca828607a
|