From 21f2778ee8423fbe3f4af3d2f15cbd2b7258bda6 Mon Sep 17 00:00:00 2001 From: Colby Rome Date: Fri, 23 Feb 2024 22:03:40 -0500 Subject: [PATCH] fix: send empty list when no image is specified. See #33. Recent versions of ollama-server return `unsupported image format` when called with the empty string in the list of images. --- bot/run.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bot/run.py b/bot/run.py index 6a2ac2c..0bcc375 100644 --- a/bot/run.py +++ b/bot/run.py @@ -176,12 +176,12 @@ async def ollama_request(message: types.Message): if ACTIVE_CHATS.get(message.from_user.id) is None: ACTIVE_CHATS[message.from_user.id] = { "model": modelname, - "messages": [{"role": "user", "content": prompt, "images": [image_base64]}], + "messages": [{"role": "user", "content": prompt, "images": ([image_base64] if image_base64 else [])}], "stream": True, } else: ACTIVE_CHATS[message.from_user.id]["messages"].append( - {"role": "user", "content": prompt, "images": [image_base64]} + {"role": "user", "content": prompt, "images": ([image_base64] if image_base64 else [])} ) logging.info( f"[Request]: Processing '{prompt}' for {message.from_user.first_name} {message.from_user.last_name}"