mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-18 09:45:23 +00:00
Merge c1d02c6866 into e16d79d635
This commit is contained in:
commit
ed2e84de7c
2 changed files with 21 additions and 2 deletions
|
|
@ -987,7 +987,7 @@ def image_edit(
|
|||
|
||||
@client
|
||||
async def aimage_edit(
|
||||
image: FileTypes | list[FileTypes],
|
||||
image: FileTypes | list[FileTypes] | None,
|
||||
model: str,
|
||||
prompt: str,
|
||||
mask: str | None = None,
|
||||
|
|
@ -1027,7 +1027,7 @@ async def aimage_edit(
|
|||
model=model, api_base=local_vars.get("base_url", None)
|
||||
)
|
||||
|
||||
images: Final = image if isinstance(image, list) else [image]
|
||||
images: Final = image if isinstance(image, list) else ([image] if image is not None else [])
|
||||
|
||||
func: Final = partial(
|
||||
image_edit,
|
||||
|
|
|
|||
|
|
@ -375,3 +375,22 @@ async def test_async_transform_image_edit_request_downloads_only_the_first_url_o
|
|||
|
||||
assert fetched == ["https://cdn.example/a.png"]
|
||||
assert base64.b64decode(data["input_image"]) == b"first-bytes"
|
||||
|
||||
|
||||
async def test_aimage_edit_none_image_raises_bad_request(monkeypatch):
|
||||
"""aimage_edit with image=None must surface a clean 400, not an APIConnectionError.
|
||||
|
||||
Regression test: the sync `image_edit` normalizes ``image=None`` to ``[]`` while
|
||||
`aimage_edit` used to build ``[None]``, which crashed the BFL handler with
|
||||
"Unsupported image type: <class 'NoneType'>".
|
||||
"""
|
||||
import litellm
|
||||
|
||||
monkeypatch.setenv("BFL_API_KEY", "test-key")
|
||||
|
||||
with pytest.raises(litellm.BadRequestError, match="No image provided"):
|
||||
await litellm.aimage_edit(
|
||||
model="black_forest_labs/flux-kontext-pro",
|
||||
prompt="make it blue",
|
||||
image=None,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue