Fix issue in anthropic chat when khoj message becomes top message

This is because Anthropic requires the first message in the chat history to be from the user.
This commit is contained in:
sabaimran
2024-06-26 12:59:34 +05:30
parent 4f89319b40
commit 8c12a69570

View File

@@ -180,6 +180,10 @@ def converse_anthropic(
tokenizer_name=tokenizer_name,
)
if len(messages) > 1:
if messages[0].role == "assistant":
messages = messages[1:]
for message in messages.copy():
if message.role == "system":
system_prompt += message.content