From 704b6407b4e51800376e73fe934a762e94b30d9d Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Sat, 14 Oct 2023 04:39:41 -0600 Subject: rebased --- tools/summarize.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tools/summarize.py (limited to 'tools/summarize.py') 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) + -- cgit v1.2.3