mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 21:19:12 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user