aboutsummaryrefslogtreecommitdiff
path: root/tools/summarize.py
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2023-10-14 04:39:41 -0600
committerNavan Chauhan <navanchauhan@gmail.com>2023-10-14 04:39:41 -0600
commit704b6407b4e51800376e73fe934a762e94b30d9d (patch)
treef51b5c0bd74abd7b836746f3f2222d282bbd541e /tools/summarize.py
parentd433b974d9f15f9a7ab57ba592a4858e7977726d (diff)
rebased
Diffstat (limited to 'tools/summarize.py')
-rw-r--r--tools/summarize.py32
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)
+