From 30ccc4a66caa5913234f0f76dfcac3a5a0ebe9f1 Mon Sep 17 00:00:00 2001 From: Yongteng Lei Date: Tue, 5 Aug 2025 09:26:42 +0800 Subject: [PATCH] Fix: correct single base64 image handling in image prompt (#9220) ### What problem does this PR solve? Correct single base64 image handling in image prompt. ![img_v3_02or_ec4757c2-a9d4-4774-9a76-f7c6be633ebg](https://github.com/user-attachments/assets/872a86bf-e2a8-48d1-9b71-2a0c7a35ba9e) ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- rag/llm/cv_model.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rag/llm/cv_model.py b/rag/llm/cv_model.py index 0f1aa386d..5f487576e 100644 --- a/rag/llm/cv_model.py +++ b/rag/llm/cv_model.py @@ -59,6 +59,10 @@ class Base(ABC): def _image_prompt(self, text, images): if not images: return text + + if isinstance(images, str): + images = [images] + pmpt = [{"type": "text", "text": text}] for img in images: pmpt.append({ @@ -795,4 +799,4 @@ class GoogleCV(AnthropicCV, GeminiCV): yield ans else: for ans in GeminiCV.chat_streamly(self, system, history, gen_conf, images): - yield ans \ No newline at end of file + yield ans