fix: stop system prompt being duplicated

This commit is contained in:
Peter De-Ath 2024-08-26 21:25:57 +01:00
parent f568389235
commit b2e682e263

View File

@ -82,7 +82,7 @@ def add_or_update_system_message(content: str, messages: list[dict]):
"""
if messages and messages[0].get("role") == "system":
messages[0]["content"] += f"{content}\n{messages[0]['content']}"
messages[0]["content"] = f"{content}\n{messages[0]['content']}"
else:
# Insert at the beginning
messages.insert(0, {"role": "system", "content": content})