blob: fa0bf447d15915f0bd132d6197a4cbcdeba076ee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
import logging
import asyncio
import os
from langchain.agents import tool
from dotenv import load_dotenv
from langchain.llms import OpenAI
from langchain.agents import initialize_agent, AgentType
from langchain.prompts.prompt import PromptTemplate
load_dotenv()
@tool("summarize")
def summarize(input: str) -> bool:
"""
Summarize the response to the input prompt.
"""
data = input
llm = OpenAI(temperature=0)
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]
|