mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-04 02:31:27 +00:00
fix(factory.py): fix linting error
This commit is contained in:
parent
8dec87425e
commit
e8df9c4041
1 changed files with 7 additions and 3 deletions
|
|
@ -126,7 +126,7 @@ def convert_to_ollama_image(openai_image_url: str):
|
|||
else:
|
||||
base64_data = openai_image_url
|
||||
|
||||
return base64_data;
|
||||
return base64_data
|
||||
except Exception as e:
|
||||
if "Error: Unable to fetch image from URL" in str(e):
|
||||
raise e
|
||||
|
|
@ -134,6 +134,7 @@ def convert_to_ollama_image(openai_image_url: str):
|
|||
"""Image url not in expected format. Example Expected input - "image_url": "data:image/jpeg;base64,{base64_image}". """
|
||||
)
|
||||
|
||||
|
||||
def ollama_pt(
|
||||
model, messages
|
||||
): # https://github.com/ollama/ollama/blob/af4cf55884ac54b9e637cd71dadfe9b7a5685877/docs/modelfile.md#template
|
||||
|
|
@ -166,7 +167,9 @@ def ollama_pt(
|
|||
if element["type"] == "text":
|
||||
prompt += element["text"]
|
||||
elif element["type"] == "image_url":
|
||||
base64_image = convert_to_ollama_image(element["image_url"]["url"])
|
||||
base64_image = convert_to_ollama_image(
|
||||
element["image_url"]["url"]
|
||||
)
|
||||
images.append(base64_image)
|
||||
return {"prompt": prompt, "images": images}
|
||||
else:
|
||||
|
|
@ -1528,11 +1531,12 @@ def _gemini_vision_convert_messages(messages: list):
|
|||
raise Exception(
|
||||
"gemini image conversion failed please run `pip install Pillow`"
|
||||
)
|
||||
|
||||
|
||||
if "base64" in img:
|
||||
# Case 2: Base64 image data
|
||||
import base64
|
||||
import io
|
||||
|
||||
# Extract the base64 image data
|
||||
base64_data = img.split("base64,")[1]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue