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:
Pawan-Shahane 2026-09-19 23:39:56 +05:30
parent d7898b0ea2
commit ddd7ecc1ad
2 changed files with 5 additions and 2 deletions

View file

@ -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:

View file

@ -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}"},
},
],
}
],