fix(gemini): Correct MIME type for jpg images

pull/1176/head
Eric-Terminal 2025-08-12 20:21:25 +08:00
parent 04bd05c1fe
commit c59f8de306
1 changed files with 4 additions and 1 deletions

View File

@ -82,8 +82,11 @@ def _convert_messages(
content: List[Part] = []
for item in message.content:
if isinstance(item, tuple):
image_format = item[0].lower()
if image_format == "jpg":
image_format = "jpeg"
content.append(
Part.from_bytes(data=base64.b64decode(item[1]), mime_type=f"image/{item[0].lower()}")
Part.from_bytes(data=base64.b64decode(item[1]), mime_type=f"image/{image_format}")
)
elif isinstance(item, str):
content.append(Part.from_text(text=item))