diff options
author | Navan Chauhan <navanchauhan@gmail.com> | 2023-10-14 03:06:31 -0600 |
---|---|---|
committer | Navan Chauhan <navanchauhan@gmail.com> | 2023-10-14 03:06:31 -0600 |
commit | 1808d25fea07c51e251941ef414f396ef8c95c27 (patch) | |
tree | 74fb1d2b2dcd40f7f336eea0b536dfb3c31d5e40 /tools | |
parent | 9f914f8d479d58d7ccc045784fe614dfea9a1219 (diff) |
add email tool
Diffstat (limited to 'tools')
-rw-r--r-- | tools/email_tool.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tools/email_tool.py b/tools/email_tool.py new file mode 100644 index 0000000..932a7e5 --- /dev/null +++ b/tools/email_tool.py @@ -0,0 +1,40 @@ +import logging +import asyncio +import os +from langchain.agents import tool +from dotenv import load_dotenv + +from langchain.agents.agent_toolkits import GmailToolkit + +from langchain.llms import OpenAI +from langchain.agents import initialize_agent, AgentType + +load_dotenv() +toolkit = GmailToolkit() + +tools = toolkit.get_tools() + +@tool("email tasks") +def email_tasks(input: str) -> bool: + """draft/send/search/get email and return whatever you get. + the input to this tool is the prompt to the gmail toolkit. + + Re-order the tasks in the prompt to change the order in which they are executed. + + Re organise the the input to the tool to pass all information needed to complete the task. + + should use this tool as many times needed to complete the task. + + for example, `send an email to grsi2038@colorado.edu asking him if he is still looking for a job and that he should continue doing whatever he his doing because he will eventually find it` will email grsi2038@colorado.edu + """ + prompt = input + + llm = OpenAI(temperature=0) + agent = initialize_agent( + tools=toolkit.get_tools(), + llm=llm, + agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION, + ) + + return agent.run(prompt) + |