mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-12-18 18:47:11 +00:00
Fix processing of images field when construct chat messages
This commit is contained in:
parent
3552032827
commit
df5e34615a
1 changed files with 14 additions and 13 deletions
|
@ -433,7 +433,8 @@ def generate_chatml_messages_with_context(
|
|||
reconstructed_context_message = ChatMessage(content=message_context, role="user")
|
||||
chatml_messages.insert(0, reconstructed_context_message)
|
||||
|
||||
if chat.get("images") and role == "assistant":
|
||||
if chat.get("images"):
|
||||
if role == "assistant":
|
||||
# Issue: the assistant role cannot accept an image as a message content, so send it in a separate user message.
|
||||
file_attachment_message = construct_structured_message(
|
||||
message=prompts.generated_image_attachment.format(),
|
||||
|
@ -442,9 +443,9 @@ def generate_chatml_messages_with_context(
|
|||
vision_enabled=vision_enabled,
|
||||
)
|
||||
chatml_messages.append(ChatMessage(content=file_attachment_message, role="user"))
|
||||
|
||||
else:
|
||||
message_content = construct_structured_message(
|
||||
chat_message, chat.get("images") if role == "user" else [], model_type, vision_enabled
|
||||
chat_message, chat.get("images"), model_type, vision_enabled
|
||||
)
|
||||
|
||||
reconstructed_message = ChatMessage(content=message_content, role=role)
|
||||
|
|
Loading…
Reference in a new issue