mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-27 17:35:07 +01:00
Use .get() to get text accompanying image url, instead of subindexing
This commit is contained in:
parent
1e89baca7b
commit
e3ca52b7cb
1 changed files with 3 additions and 1 deletions
|
@ -228,7 +228,9 @@ def format_messages_for_gemini(messages: list[ChatMessage], system_prompt: str =
|
|||
if isinstance(message.content, list):
|
||||
# Convert image_urls to PIL.Image and place them at beginning of list (better for Gemini)
|
||||
message.content = [
|
||||
get_image_from_url(item["image_url"]["url"]).content if item["type"] == "image_url" else item["text"]
|
||||
get_image_from_url(item["image_url"]["url"]).content
|
||||
if item["type"] == "image_url"
|
||||
else item.get("text", "")
|
||||
for item in sorted(message.content, key=lambda x: 0 if x["type"] == "image_url" else 1)
|
||||
]
|
||||
elif isinstance(message.content, str):
|
||||
|
|
Loading…
Reference in a new issue