# Created by Leandro Carneiro at 19/01/2024 # Description: # ------------------------------------------------ from langchain_openai import ChatOpenAI import os def invoke_llm(context, task): prompt = f"""You are an assistant of a newspaper. Do not make up any information, execute the task just based on the given context. The task is delimited by ### and the context is delimited by $$$ Write in a formal language and in portuguese language. Execute the task just based on the given context. Your task is: ###{task}### The context is: $$${context}$$$ """ llm=ChatOpenAI(model_name="gpt-3.5-turbo", temperature=0, openai_api_key=os.environ['OPENAI_KEY'], max_tokens=1000) result = llm.invoke(prompt) return result.content # def generate_topics(text): # prompt = f"""You are an assistant of a newspaper. # Your task is to extract relevant topics of a news and build a concise road map. # Do not make up any information, create the road map just based on the given information. # The road map should be written in a formal language and in portuguese language. # Answer just the information, do not put any title. # The road map should be about the following context: {text} # """ # # llm=ChatOpenAI(model_name="gpt-3.5-turbo", # temperature=0, # openai_api_key=api_key.OPENAI_KEY, # max_tokens=1000) # result = llm.invoke(prompt) # return result.content