diff --git a/python_binding_and_cmdline/refact/chat_client.py b/python_binding_and_cmdline/refact/chat_client.py index b331a369b..1be3e4693 100644 --- a/python_binding_and_cmdline/refact/chat_client.py +++ b/python_binding_and_cmdline/refact/chat_client.py @@ -117,17 +117,14 @@ def join_messages_and_choices( if len(deterministic_messages) > 0 and deterministic_messages[-1].role == "user": while len(messages) > 0 and messages[-1].role == "user": messages.pop() + messages.extend(deterministic_messages) msg: Optional[Message] - for msg in deterministic_messages: - if msg.role == "system": - messages.insert(0, msg) - else: - messages.append(msg) - if verbose: + if verbose: + for msg in deterministic_messages: print("deterministic", - termcolor.colored(str(msg.role), "yellow"), - str(msg.content), - termcolor.colored(str(msg.finish_reason), "red")) + termcolor.colored(str(msg.role), "yellow"), + str(msg.content), + termcolor.colored(str(msg.finish_reason), "red")) output = [copy.deepcopy(messages) for _ in range(len(choices))] for i, msg in enumerate(choices): if msg is None: