mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-25 01:02:15 +00:00
refactor(fal_ai): drop redundant hasattr guards in the image edit byte reader
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
62c215be19
commit
cf581bf327
1 changed files with 4 additions and 6 deletions
|
|
@ -58,15 +58,13 @@ def _read_image_bytes(image: object) -> bytes:
|
|||
return _read_image_bytes(image[1])
|
||||
if isinstance(image, os.PathLike):
|
||||
return Path(image).read_bytes()
|
||||
if isinstance(image, str):
|
||||
if isinstance(image, str) or not isinstance(image, _Readable):
|
||||
raise ValueError(f"Unsupported image type for Fal AI image edit: {type(image).__name__}")
|
||||
if not hasattr(image, "read") or not isinstance(image, _Readable):
|
||||
raise ValueError(f"Unsupported image type for Fal AI image edit: {type(image).__name__}")
|
||||
position: Final = image.tell() if hasattr(image, "tell") and isinstance(image, _Tellable) else 0
|
||||
if hasattr(image, "seek") and isinstance(image, _Seekable):
|
||||
position: Final = image.tell() if isinstance(image, _Tellable) else 0
|
||||
if isinstance(image, _Seekable):
|
||||
image.seek(0)
|
||||
data: Final = image.read()
|
||||
if hasattr(image, "seek") and isinstance(image, _Seekable):
|
||||
if isinstance(image, _Seekable):
|
||||
image.seek(position)
|
||||
return data
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue