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})