Separated part of the code into a new function

This commit is contained in:
Zvonimir Sabljic
2023-08-14 18:09:54 +02:00
parent da2a95887f
commit 5e62754bd1

View File

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