From 42e54a2cb29943b793bf9a47dd7e0121e1c0c87d Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Sat, 14 Oct 2023 14:47:49 -0600 Subject: final --- tools/summarize.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'tools/summarize.py') 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] -- cgit v1.2.3