From c351f59fd02bb11ce7fe1c30f25c82441b6fb60a Mon Sep 17 00:00:00 2001 From: jegranado Date: Thu, 27 Nov 2025 17:16:22 +0100 Subject: [PATCH] check for images in all messages of the chat - not only the last one It was checking only the last image of the chat, meaning that if the user continued the conversation, it would break because the original model may not accept images/multi-modal inputs. With this change, it checks the entire history for images before deciding to route - or not - the request, ensuring that follow-up questions are still analyzed by the vison-enabled model. --- functions/filters/dynamic_vision_router/main.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/functions/filters/dynamic_vision_router/main.py b/functions/filters/dynamic_vision_router/main.py index c4bc4ca..3b7786b 100644 --- a/functions/filters/dynamic_vision_router/main.py +++ b/functions/filters/dynamic_vision_router/main.py @@ -4,7 +4,7 @@ credits to @iamg30 for v0.1.5-v0.1.7 updates author_url: https://github.com/open-webui funding_url: https://github.com/open-webui -version: 0.1.7 +version: 0.1.8 required_open_webui_version: 0.3.8 """ @@ -84,6 +84,17 @@ async def inlet( item.get("type") == "image_url" for item in user_message_content ) + # check for all history + if not has_images: + for m in messages: + user_message_content = m.get("content") + if user_message_content is not None and isinstance( + user_message_content, list + ): + has_images = any( + item.get("type") == "image_url" for item in user_message_content + ) + if has_images: if self.valves.vision_model_id: body["model"] = self.valves.vision_model_id