Skip to content
Snippets Groups Projects
Commit 331a4901 authored by Grießhaber Daniel's avatar Grießhaber Daniel :squid:
Browse files

simplify history handling in `ChatModel.create_completion`

parent a78c704c
No related branches found
No related tags found
2 merge requests!2remove is_chat argument,!1Refactor models
......@@ -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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment