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,19 +433,20 @@ def generate_chatml_messages_with_context(
|
||||||
reconstructed_context_message = ChatMessage(content=message_context, role="user")
|
reconstructed_context_message = ChatMessage(content=message_context, role="user")
|
||||||
chatml_messages.insert(0, reconstructed_context_message)
|
chatml_messages.insert(0, reconstructed_context_message)
|
||||||
|
|
||||||
if chat.get("images") and role == "assistant":
|
if chat.get("images"):
|
||||||
# Issue: the assistant role cannot accept an image as a message content, so send it in a separate user message.
|
if role == "assistant":
|
||||||
file_attachment_message = construct_structured_message(
|
# Issue: the assistant role cannot accept an image as a message content, so send it in a separate user message.
|
||||||
message=prompts.generated_image_attachment.format(),
|
file_attachment_message = construct_structured_message(
|
||||||
images=chat.get("images"),
|
message=prompts.generated_image_attachment.format(),
|
||||||
model_type=model_type,
|
images=chat.get("images"),
|
||||||
vision_enabled=vision_enabled,
|
model_type=model_type,
|
||||||
)
|
vision_enabled=vision_enabled,
|
||||||
chatml_messages.append(ChatMessage(content=file_attachment_message, role="user"))
|
)
|
||||||
|
chatml_messages.append(ChatMessage(content=file_attachment_message, role="user"))
|
||||||
message_content = construct_structured_message(
|
else:
|
||||||
chat_message, chat.get("images") if role == "user" else [], model_type, vision_enabled
|
message_content = construct_structured_message(
|
||||||
)
|
chat_message, chat.get("images"), model_type, vision_enabled
|
||||||
|
)
|
||||||
|
|
||||||
reconstructed_message = ChatMessage(content=message_content, role=role)
|
reconstructed_message = ChatMessage(content=message_content, role=role)
|
||||||
chatml_messages.insert(0, reconstructed_message)
|
chatml_messages.insert(0, reconstructed_message)
|
||||||
|
|
Loading…
Reference in a new issue