Принимать входное изображение edits под именем поля image[] (совместимость с LiteLLM)
This commit is contained in:
@@ -152,6 +152,14 @@ def _parse_json_body(raw: bytes, model_cls):
|
|||||||
async def _parse_multipart(request: Request):
|
async def _parse_multipart(request: Request):
|
||||||
form = await request.form()
|
form = await request.form()
|
||||||
upload = form.get("image")
|
upload = form.get("image")
|
||||||
|
if upload is None or not hasattr(upload, "read"):
|
||||||
|
# Clients following OpenAI's newer image API (e.g. LiteLLM) send the file
|
||||||
|
# under "image[]"; also accept other common field names.
|
||||||
|
for _key in ("image[]", "image[0]", "file", "input_file"):
|
||||||
|
_alt = form.get(_key)
|
||||||
|
if _alt is not None and hasattr(_alt, "read"):
|
||||||
|
upload = _alt
|
||||||
|
break
|
||||||
# duck-typing: FastAPI 0.142+ ships its own UploadFile class, forms yield starlette's
|
# duck-typing: FastAPI 0.142+ ships its own UploadFile class, forms yield starlette's
|
||||||
if upload is None or not hasattr(upload, "read"):
|
if upload is None or not hasattr(upload, "read"):
|
||||||
raise InvalidRequest("field 'image' (file) is required")
|
raise InvalidRequest("field 'image' (file) is required")
|
||||||
|
|||||||
Reference in New Issue
Block a user