mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
fix(bfl): handle URL and file path inputs in image edit
_read_image_bytes was not handling string inputs (URLs or file paths), causing a TypeError when passing a URL as the image source.
This commit is contained in:
parent
d9d39d545a
commit
00cf9550af
1 changed files with 10 additions and 0 deletions
|
|
@ -184,6 +184,16 @@ class BlackForestLabsImageEditConfig(BaseImageEditConfig):
|
|||
elif isinstance(image, list):
|
||||
# If it's a list, take the first image
|
||||
return self._read_image_bytes(image[0])
|
||||
elif isinstance(image, str):
|
||||
if image.startswith(("http://", "https://")):
|
||||
# Download image from URL
|
||||
import httpx as _httpx
|
||||
response = _httpx.get(image)
|
||||
return response.content
|
||||
else:
|
||||
# Assume it's a file path
|
||||
with open(image, "rb") as f:
|
||||
return f.read()
|
||||
elif hasattr(image, "read"):
|
||||
# File-like object
|
||||
pos = getattr(image, "tell", lambda: 0)()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue