Integrate Google Services with LlamaIndex
Search Google, and read or create Gmail and Calendar events, from a LlamaIndex agent.
Why it matters
Seamlessly connect your LlamaIndex applications to Google's powerful suite of services, including Search, Gmail, and Calendar, for enhanced data retrieval and automation.
Outcomes
What it gets done
Perform Google searches and retrieve results.
Read and create calendar events.
Read and create Gmail messages.
Enable custom search engines for targeted queries.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/li-tool-tools-google | bash Overview
LlamaIndex Tools Integration: Google
A LlamaIndex tool set for Google Search, Gmail, and Calendar, each requiring per-service Cloud Console setup and OAuth credentials. Use for Google search or Gmail/Calendar read-create access; calendar event creation can fail when timezone can't be inferred.
What it does
The Google Tools Integration provides a set of tools to interact with Google services from a LlamaIndex agent: GmailToolSpec, GoogleCalendarToolSpec, and GoogleSearchToolSpec. Each corresponding Google service must be enabled individually in Google Cloud Console under the same API key before its tool can be used.
GoogleSearchToolSpec is configured with a key collected from the Google Cloud service console and an engine identifying which custom search engine to query, created through Google's Programmable Search Engine console. The calendar (read, create) and Gmail (read, create) tools both require OAuth 2.0 credentials created in the Google Cloud console, with the resulting credentials.json stored in the same directory as the running agent; both also require manually approving the OAuth prompt every time the tool is invoked, rather than authenticating once and staying authenticated.
The source documents one known defect: the calendar tool's create function cannot generate an event if the agent is unable to infer the timezone from the request.
When to use - and when NOT to
Use GoogleSearchToolSpec when an agent needs web search results through a custom Google search engine. Use the Gmail and Calendar tools when an agent needs to read or create emails and calendar events on behalf of the user, accepting that each invocation requires a manual OAuth approval rather than a one-time login. Do not rely on the calendar create function for events where the timezone cannot be clearly inferred from the request - this is a documented, unresolved limitation, not an edge case to assume away.
Capabilities
GoogleSearchToolSpec runs searches through a configured custom search engine. GoogleCalendarToolSpec reads and creates calendar events. GmailToolSpec reads and creates emails. Calendar and Gmail both require per-invocation manual OAuth approval.
How to install
### pip install llama-index-tools-google
from llama_index.tools.google import GmailToolSpec
from llama_index.tools.google import GoogleCalendarToolSpec
from llama_index.tools.google import GoogleSearchToolSpec
Requires enabling each Google service in Google Cloud Console under a shared API key, plus OAuth 2.0 credentials (credentials.json) for Calendar and Gmail.
Who it's for
Developers building LlamaIndex agents that need to search the web via Google or read/create Gmail messages and Calendar events, and can accommodate manual OAuth approval on each tool invocation.
Source README
LlamaIndex Tools Integration: Google
Provides a set of tools to interact with Google services.
- you need to enable each of the below services in your google cloud console, under a same API key for a service, in
order to use them.
Quick Start:
### pip install llama-index-tools-google
from llama_index.tools.google import GmailToolSpec
from llama_index.tools.google import GoogleCalendarToolSpec
from llama_index.tools.google import GoogleSearchToolSpec
custom search service
google_spec = GoogleSearchToolSpec(key="your-key", engine="your-engine")
keycollected from your service consoleenginewhich represents the search engine to use, you can create a custom search
engine here
calendar read, create
- requires OAuth 2.0 credentials, you can create them here
- store oAuth
credentials.jsonin the same directory as the runnable agent. - you will need to manually approve the Oath every time this tool is invoked
gmail read, create
- same as calendar
known defects
- the calendar tool create is not able to generate an event if the agent is not able to infer the timezome
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.