From 462da5a778decdb7c204b06b0b951f5bcc7ff59e Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 15 Apr 2024 18:18:55 -0700 Subject: [PATCH] fix - support base 64 image conversion for all gemini model --- litellm/__init__.py | 1 + litellm/llms/prompt_templates/factory.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/litellm/__init__.py b/litellm/__init__.py index 055dd74241..5ef78dce4d 100644 --- a/litellm/__init__.py +++ b/litellm/__init__.py @@ -583,6 +583,7 @@ from .utils import ( completion_cost, supports_function_calling, supports_parallel_function_calling, + supports_vision, get_litellm_params, Logging, acreate, diff --git a/litellm/llms/prompt_templates/factory.py b/litellm/llms/prompt_templates/factory.py index eba8e27ea3..2bb15552cb 100644 --- a/litellm/llms/prompt_templates/factory.py +++ b/litellm/llms/prompt_templates/factory.py @@ -1286,7 +1286,11 @@ def prompt_factory( messages=messages, prompt_format=prompt_format, chat_template=chat_template ) elif custom_llm_provider == "gemini": - if model == "gemini-pro-vision": + if ( + model == "gemini-pro-vision" + or litellm.supports_vision(model=model) + or litellm.supports_vision(model=custom_llm_provider + "/" + model) + ): return _gemini_vision_convert_messages(messages=messages) else: return gemini_text_image_pt(messages=messages)