mirror of
https://github.com/xtekky/gpt4free.git
synced 2025-12-06 02:30:41 -08:00
Fix Azure image
This commit is contained in:
parent
05784da883
commit
fe79b11070
2 changed files with 7 additions and 5 deletions
|
|
@ -87,7 +87,8 @@ class Azure(OpenaiTemplate):
|
|||
if media:
|
||||
form = FormData()
|
||||
form.add_field("prompt", prompt)
|
||||
form.add_field("size", f"{width}x{height}")
|
||||
form.add_field("width", width)
|
||||
form.add_field("height", height)
|
||||
output_format = "png"
|
||||
for i in range(len(media)):
|
||||
if media[i][1] is None and isinstance(media[i][0], str):
|
||||
|
|
@ -96,10 +97,12 @@ class Azure(OpenaiTemplate):
|
|||
for image, image_name in media:
|
||||
form.add_field(f"image", image, filename=image_name)
|
||||
else:
|
||||
api_endpoint = api_endpoint.replace("/edits", "/generations")
|
||||
data = {
|
||||
"prompt": prompt,
|
||||
"n": 1,
|
||||
"size": f"{width}x{height}",
|
||||
"width": width,
|
||||
"height": height,
|
||||
"output_format": output_format,
|
||||
}
|
||||
async with StreamSession(proxy=kwargs.get("proxy"), headers={
|
||||
|
|
@ -108,7 +111,6 @@ class Azure(OpenaiTemplate):
|
|||
}) as session:
|
||||
async with session.post(api_endpoint, data=form, json=data) as response:
|
||||
data = await response.json()
|
||||
cls.raise_error(data, response.status)
|
||||
await raise_for_status(response, data)
|
||||
async for chunk in save_response_media(data["data"][0]["b64_json"], prompt, content_type=f"image/{output_format}"):
|
||||
yield chunk
|
||||
|
|
|
|||
|
|
@ -324,9 +324,9 @@ def get_width_height(
|
|||
if aspect_ratio == "1:1":
|
||||
return width or 1024, height or 1024
|
||||
elif aspect_ratio == "16:9":
|
||||
return width or 1792, height or 1024
|
||||
return width or 832, height or 480
|
||||
elif aspect_ratio == "9:16":
|
||||
return width or 1024, height or 1792
|
||||
return width or 480, height or 832,
|
||||
return width, height
|
||||
|
||||
class ImageRequest:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue