fix(gemini): Correct MIME type for jpg images
This commit is contained in:
@@ -82,8 +82,11 @@ def _convert_messages(
|
|||||||
content: List[Part] = []
|
content: List[Part] = []
|
||||||
for item in message.content:
|
for item in message.content:
|
||||||
if isinstance(item, tuple):
|
if isinstance(item, tuple):
|
||||||
|
image_format = item[0].lower()
|
||||||
|
if image_format == "jpg":
|
||||||
|
image_format = "jpeg"
|
||||||
content.append(
|
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):
|
elif isinstance(item, str):
|
||||||
content.append(Part.from_text(text=item))
|
content.append(Part.from_text(text=item))
|
||||||
|
|||||||
Reference in New Issue
Block a user