mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-17 09:34:48 +00:00
fix(ollama): address Greptile findings on image conversion
Catch all exceptions on Pillow import, not just ImportError, so the helpful install hint always appears. Break a line that exceeded 120 characters
This commit is contained in:
parent
d7898b0ea2
commit
ddd7ecc1ad
2 changed files with 5 additions and 2 deletions
|
|
@ -19,7 +19,7 @@ _JPEG_AND_PNG_SIGNATURES: Final = (b"\xff\xd8\xff", b"\x89PNG\r\n\x1a\n")
|
|||
def _reencode_as_jpeg(raw_image: bytes, original: str) -> str:
|
||||
try:
|
||||
from PIL import Image
|
||||
except ImportError:
|
||||
except Exception:
|
||||
raise Exception("ollama image conversion failed please run `pip install Pillow`")
|
||||
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -565,7 +565,10 @@ def _transform_image_request(image_base64: str, mime_subtype: str) -> dict:
|
|||
"role": "user",
|
||||
"content": [
|
||||
{"type": "text", "text": "What colour is this?"},
|
||||
{"type": "image_url", "image_url": {"url": f"data:image/{mime_subtype};base64,{image_base64}"}},
|
||||
{
|
||||
"type": "image_url",
|
||||
"image_url": {"url": f"data:image/{mime_subtype};base64,{image_base64}"},
|
||||
},
|
||||
],
|
||||
}
|
||||
],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue