Skip to content

Commit

Permalink
Fix: langgenius#8190 (Update Model nam… (langgenius#8426)
Browse files Browse the repository at this point in the history
Co-authored-by: Yuanbo Li <[email protected]>
  • Loading branch information
2 people authored and LLmoskk committed Sep 16, 2024
1 parent 4744e9e commit 3dd9dfd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions api/core/model_runtime/model_providers/bedrock/llm/llm.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# standard import
import base64
import io
import json
import logging
import mimetypes
from collections.abc import Generator
from typing import Optional, Union, cast

Expand All @@ -17,7 +17,6 @@
ServiceNotInRegionError,
UnknownServiceError,
)
from PIL.Image import Image

# local import
from core.model_runtime.callbacks.base_callback import Callback
Expand Down Expand Up @@ -443,8 +442,9 @@ def _convert_prompt_message_to_dict(self, message: PromptMessage) -> dict:
try:
url = message_content.data
image_content = requests.get(url).content
with Image.open(io.BytesIO(image_content)) as img:
mime_type = f"image/{img.format.lower()}"
if "?" in url:
url = url.split("?")[0]
mime_type, _ = mimetypes.guess_type(url)
base64_data = base64.b64encode(image_content).decode("utf-8")
except Exception as ex:
raise ValueError(f"Failed to fetch image data from url {message_content.data}, {ex}")
Expand Down

0 comments on commit 3dd9dfd

Please sign in to comment.