From 79b15e45945e03ea87cab1bde9be7fbd23c02af8 Mon Sep 17 00:00:00 2001 From: sabaimran Date: Sat, 9 Nov 2024 19:37:30 -0800 Subject: [PATCH] Only add images when they're present and vision enabled --- src/khoj/processor/conversation/utils.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/khoj/processor/conversation/utils.py b/src/khoj/processor/conversation/utils.py index 7187acdb..ec050c93 100644 --- a/src/khoj/processor/conversation/utils.py +++ b/src/khoj/processor/conversation/utils.py @@ -277,9 +277,6 @@ def construct_structured_message( """ Format messages into appropriate multimedia format for supported chat model types """ - if not images or not vision_enabled: - return message - constructed_messages = [ {"type": "text", "text": message}, ] @@ -292,8 +289,9 @@ def construct_structured_message( ChatModelOptions.ModelType.GOOGLE, ChatModelOptions.ModelType.ANTHROPIC, ]: - for image in images: - constructed_messages.append({"type": "image_url", "image_url": {"url": image}}) + if vision_enabled and images: + for image in images: + constructed_messages.append({"type": "image_url", "image_url": {"url": image}}) return constructed_messages