Additional Toolkits
Google Sheets
GoogleSheetsTools enable an Agent to interact with Google Sheets API for reading, creating, updating, and duplicating spreadsheets.
Prerequisites
You need to install the required Google API client libraries:
Set up the following environment variables:
How to Get Credentials
-
Go to Google Cloud Console (https://console.cloud.google.com)
-
Create a new project or select an existing one
-
Enable the Google Sheets API:
- Go to “APIs & Services” > “Enable APIs and Services”
- Search for “Google Sheets API”
- Click “Enable”
-
Create OAuth 2.0 credentials:
- Go to “APIs & Services” > “Credentials”
- Click “Create Credentials” > “OAuth client ID”
- Go through the OAuth consent screen setup
- Give it a name and click “Create”
- You’ll receive:
- Client ID (GOOGLE_CLIENT_ID)
- Client Secret (GOOGLE_CLIENT_SECRET)
- The Project ID (GOOGLE_PROJECT_ID) is visible in the project dropdown at the top of the page
Example
The following agent will use Google Sheets to read and update spreadsheet data.
cookbook/tools/googlesheets_tools.py
Toolkit Params
Parameter | Type | Default | Description |
---|---|---|---|
scopes | List[str] | None | Custom OAuth scopes. If None, determined by operations. |
spreadsheet_id | str | None | ID of the target spreadsheet. |
spreadsheet_range | str | None | Range within the spreadsheet. |
creds | Credentials | None | Pre-existing credentials. |
creds_path | str | None | Path to credentials file. |
token_path | str | None | Path to token file. |
read | bool | True | Enable read operations. |
create | bool | False | Enable create operations. |
update | bool | False | Enable update operations. |
duplicate | bool | False | Enable duplicate operations. |
Toolkit Functions
Function | Description |
---|---|
read_sheet | Read values from a Google Sheet |
create_sheet | Create a new Google Sheet |
update_sheet | Update data in a Google Sheet |
create_duplicate_sheet | Create a duplicate of an existing Google Sheet |