aboutsummaryrefslogtreecommitdiff
path: root/tools/summarize.py
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2023-10-14 14:47:49 -0600
committerNavan Chauhan <navanchauhan@gmail.com>2023-10-14 14:47:49 -0600
commit42e54a2cb29943b793bf9a47dd7e0121e1c0c87d (patch)
treed5570585dc0bfccdab3ec3f9aaa79a9e4290470e /tools/summarize.py
parent704b6407b4e51800376e73fe934a762e94b30d9d (diff)
Diffstat (limited to 'tools/summarize.py')
-rw-r--r--tools/summarize.py20
1 files changed, 8 insertions, 12 deletions
diff --git a/tools/summarize.py b/tools/summarize.py
index d90c49d..fa0bf44 100644
--- a/tools/summarize.py
+++ b/tools/summarize.py
@@ -4,29 +4,25 @@ 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
+from langchain.prompts.prompt import PromptTemplate
-load_dotenv()
-toolkit = GmailToolkit()
-tools = toolkit.get_tools()
+load_dotenv()
@tool("summarize")
def summarize(input: str) -> bool:
"""
Summarize the response to the input prompt.
"""
- prompt = input
+ data = input
llm = OpenAI(temperature=0)
- agent = initialize_agent(
- prompt=prompt,
- llm=llm,
- agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION,
- )
- return agent.run(prompt)
+ template = "Human: Can you summarize this in a couple of sentences: {data}"
+ prompt = PromptTemplate(input_variables=["data"], template=template)
+ pred = llm.predict(prompt.format(data=data))
+ return pred
+ #preferred_forums[make] = [make_url]