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.
Metadata
Release files for gsuite-langchain-tools 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gsuite_langchain_tools-0.1.0.tar.gz | 2.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gsuite_langchain_tools-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 5.3 kB
Release files / gsuite_langchain_tools-0.1.0.tar.gz
| Download URL | gsuite_langchain_tools-0.1.0.tar.gz |
|---|---|
| Size | 2.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6275d2387219c817af9e6d98fb22b6f7b0e9ff969220ffbdac81d2c221d8f6ea
|
|
BLAKE2b-256 checksum How to use checksums |
17b1182295116411e25f40c33bdb8e2c5b3ae887c851867f5e71c5b535d046c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Release files / gsuite_langchain_tools-0.1.0-py3-none-any.whl
| Download URL | gsuite_langchain_tools-0.1.0-py3-none-any.whl |
|---|---|
| Size | 2.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3f897b5e7a3da052fbd8bb794d31bfdcfbee5e4fc06e2bbc02093d0538ec9064
|
|
BLAKE2b-256 checksum How to use checksums |
e7321090260de7b12f6f284767dd772caa1d73b5c7baac7ec88e017ca828607a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|