from llama_index.agent import OpenAIAgent
from llama_hub.tools.gmail.base import GmailToolSpec
from llama_hub.tools.google_calendar.base import GoogleCalendarToolSpec
from llama_hub.tools.google_search.base import GoogleSearchToolSpec
from llama_index.tools.tool_spec.load_and_search.base import LoadAndSearchToolSpec
import openai
openai.api_key = 'api key'
gmail_tools = GmailToolSpec().to_tool_list()
gcal_tools = GoogleCalendarToolSpec().to_tool_list()
gsearch_tools = GoogleSearchToolSpec(key="api key", engine="engine").to_tool_list()
print('Wrapping ' + gsearch_tools[0].metadata.name)
gsearch_load_and_search_tools = LoadAndSearchToolSpec.from_defaults(
gsearch_tools[0],
).to_tool_list()
print('Wrapping gmail ' + gmail_tools[0].metadata.name)
gmail_load_and_search_tools = LoadAndSearchToolSpec.from_defaults(
gmail_tools[0],
).to_tool_list()
print('Wrapping google calendar ' + gcal_tools[0].metadata.name)
gcal_load_and_search_tools = LoadAndSearchToolSpec.from_defaults(
gcal_tools[0],
).to_tool_list()
all_tools = [gsearch_load_and_search_tools,gmail_load_and_search_tools, gcal_load_and_search_tools,gcal_tools[1::], gmail_tools[1::],gsearch_tools[1::]]
agent = OpenAIAgent.from_tools(all_tools, verbose=True)
agent.chat('Is there any events on my calendar next week at 4pm?')
output:
Wrapping google_search
Wrapping gmail load_data
Wrapping google calendar load_data
=== Calling Function ===
Calling function: load_data with args: {
"number_of_results": 10
}
Got output: Content loaded! You can now search the information using read_load_data
========================
=== Calling Function ===
Calling function: read_load_data with args: {
"query": "events next week at 4pm"
}
Got output: There is not enough information in the given context to determine the events happening next week at 4pm.
whats the problem here