diff options
author | Navan Chauhan <navanchauhan@gmail.com> | 2023-10-14 04:39:41 -0600 |
---|---|---|
committer | Navan Chauhan <navanchauhan@gmail.com> | 2023-10-14 04:39:41 -0600 |
commit | 704b6407b4e51800376e73fe934a762e94b30d9d (patch) | |
tree | f51b5c0bd74abd7b836746f3f2222d282bbd541e /tools/summarize.py | |
parent | d433b974d9f15f9a7ab57ba592a4858e7977726d (diff) |
rebased
Diffstat (limited to 'tools/summarize.py')
-rw-r--r-- | tools/summarize.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tools/summarize.py b/tools/summarize.py new file mode 100644 index 0000000..d90c49d --- /dev/null +++ b/tools/summarize.py @@ -0,0 +1,32 @@ +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("summarize") +def summarize(input: str) -> bool: + """ + Summarize the response to the input prompt. + """ + prompt = input + + llm = OpenAI(temperature=0) + agent = initialize_agent( + prompt=prompt, + llm=llm, + agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION, + ) + + return agent.run(prompt) + |