Untitled
unknown
python
a year ago
1.2 kB
7
Indexable
from langchain_core.prompts import PromptTemplate
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(model="gpt-4-turbo", temperature=0)
class LLMInterface:
def __init__(self, memory):
self.memory = memory
self.prompt_template = self.create_prompt_template()
def create_prompt_template(self):
template = """You are a report system chat bot that summarizes news based on the memory provided
which has the description, the date and the title of some brazilian news. The input will be provided next
containing some question about the data. You need to answer in brazilian portuguese. You HAVE to use Telegram compatible basic HTML language
Insert links as hyperlink to the topics if needed. Also, remember to refer to the source of the information
Memory:
{memory}
New request for report: {input}
Response:"""
return PromptTemplate.from_template(template)
def get_llm_response(self,input):
prompt = self.prompt_template.format(
input=input, memory=str(self.memory[-50:])
)
return llm.invoke(prompt).contentEditor is loading...
Leave a Comment