diff --git a/apps/hal9/tools/generic.py b/apps/hal9/tools/generic.py index 8eb67df3..b3d966cc 100644 --- a/apps/hal9/tools/generic.py +++ b/apps/hal9/tools/generic.py @@ -1,14 +1,19 @@ from groq import Groq -from utils import stream_print +from utils import stream_print, load_messages, insert_message, save_messages def answer_generic_question(user_input): + # load messages + messages = load_messages(file_path="./.storage/.generic_agent_messages.json") + messages = insert_message(messages, "user", user_input) response = Groq().chat.completions.create( - model = "llama3-70b-8192", - messages = [{"role": "user", "content": user_input}], - temperature = 0, - seed = 1) + model = "llama3-70b-8192", + messages = messages, + temperature = 0, + seed = 1) text_response = response.choices[0].message.content + messages = insert_message(messages, "assistant", text_response) + save_messages(messages, file_path="./.storage/.generic_agent_messages.json") stream_print(text_response) return text_response