diff --git a/evoprompt/models.py b/evoprompt/models.py index 19eb363ed5f2cf70923505a4c15218392dec4aba..ce55258e370f037707129e255b61979739bbdabf 100644 --- a/evoprompt/models.py +++ b/evoprompt/models.py @@ -281,11 +281,8 @@ class ChatModel: # a history is prepended to the messages, and we assume that it also includes a system message, i.e., we never add a system message in this case # TODO is it better to check for a system message in the history? - if history is not None: - messages = history + messages - [messages.insert(index, entry) for index, entry in enumerate(history)] - elif system_message: - messages = [self._get_system_message(system_message)] + messages + if history is None and system_message: + history = [self._get_system_message(system_message)] reponse, usage = self._create_completion( messages=messages, @@ -296,7 +293,7 @@ class ChatModel: ) messages.append(self._get_assistant_message(reponse)) - return reponse, messages, usage + return reponse, history + messages, usage class LlamaChat(Llama, ChatModel):