Skip to content

Commit

Permalink
fix: system prompt goes to the front when it is streamed (like chat-j…
Browse files Browse the repository at this point in the history
…s does)
  • Loading branch information
humbertoyusta committed Dec 18, 2024
1 parent 115754c commit dafdc41
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions python_binding_and_cmdline/refact/chat_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,17 @@ 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]
if verbose:
for msg in deterministic_messages:
for msg in deterministic_messages:
if msg.role == "system":
messages.insert(0, msg)
else:
messages.append(msg)
if verbose:
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:
Expand Down

0 comments on commit dafdc41

Please sign in to comment.