mirror of
https://github.com/langchain-ai/langchain.git
synced 2026-10-06 18:05:25 +03:00
2.3 KiB
2.3 KiB
In [ ]:
from langchain.llms import OpenAI
from langchain.agents.agent_toolkits.gmail.base import create_gmail_agent
import json
llm = OpenAI(verbose=True)
gmail_agent = create_gmail_agent(llm=llm, sender_name="Alice", verbose=True)In [ ]:
command = "search for all messages during november 2022"
output = gmail_agent.run(command)
messages = json.loads(output)
print("Messages:")
for message in messages:
print(f"{message['id']}: {message['snippet']}")
id = messages[0]["id"]
command = f"get the body for message id {id}"
output = gmail_agent.run(command)
print(f"Message body: {output}")
In [ ]:
command = "create a draft email to bob@example.com explaining why I can't make the meeting next week."
output = gmail_agent.run(command)
print(output)