From 5e62754bd1529fe6df1cb028f3361abf1008e4bd Mon Sep 17 00:00:00 2001 From: Zvonimir Sabljic Date: Mon, 14 Aug 2023 18:09:54 +0200 Subject: [PATCH] Separated part of the code into a new function --- euclid/helpers/AgentConvo.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/euclid/helpers/AgentConvo.py b/euclid/helpers/AgentConvo.py index ee2609f..e9640a7 100644 --- a/euclid/helpers/AgentConvo.py +++ b/euclid/helpers/AgentConvo.py @@ -23,9 +23,7 @@ class AgentConvo: def send_message(self, prompt_path=None, prompt_data=None, function_calls=None): # craft message - if prompt_path is not None and prompt_data is not None: - prompt = get_prompt(prompt_path, prompt_data) - self.messages.append({"role": "user", "content": prompt}) + self.construct_and_add_message_from_prompt(prompt_path, prompt_data) if function_calls is not None and 'function_calls' in function_calls: self.messages[-1]['content'] += '\nMAKE SURE THAT YOU RESPOND WITH A CORRECT JSON FORMAT!!!' @@ -134,4 +132,9 @@ class AgentConvo: process.communicate(content.replace('{{messages}}', str(self.messages)).encode('utf-8')) def remove_last_x_messages(self, x): - self.messages = self.messages[:-x] \ No newline at end of file + self.messages = self.messages[:-x] + + def construct_and_add_message_from_prompt(self, prompt_path, prompt_data): + if prompt_path is not None and prompt_data is not None: + prompt = get_prompt(prompt_path, prompt_data) + self.messages.append({"role": "user", "content": prompt})