返回提交历史
Modified
g4f/Provider/needs_auth/Azure.py
+5
-3
Modified
g4f/image/__init__.py
+2
-2
XFEstudio/gpt4free
Fix Azure image
fe79b110
代码差异
2 个文件
+7
-5
@@ -87,7 +87,8 @@ class Azure(OpenaiTemplate):
87
87
if media:
88
88
form = FormData()
89
89
form.add_field("prompt", prompt)
90
form.add_field("size", f"{width}x{height}")
90
form.add_field("width", width)
91
form.add_field("height", height)
91
92
output_format = "png"
92
93
for i in range(len(media)):
93
94
if media[i][1] is None and isinstance(media[i][0], str):
@@ -96,10 +97,12 @@ class Azure(OpenaiTemplate):
96
97
for image, image_name in media:
97
98
form.add_field(f"image", image, filename=image_name)
98
99
else:
100
api_endpoint = api_endpoint.replace("/edits", "/generations")
99
101
data = {
100
102
"prompt": prompt,
101
103
"n": 1,
102
"size": f"{width}x{height}",
104
"width": width,
105
"height": height,
103
106
"output_format": output_format,
104
107
}
105
108
async with StreamSession(proxy=kwargs.get("proxy"), headers={
@@ -108,7 +111,6 @@ class Azure(OpenaiTemplate):
108
111
}) as session:
109
112
async with session.post(api_endpoint, data=form, json=data) as response:
110
113
data = await response.json()
111
cls.raise_error(data, response.status)
112
114
await raise_for_status(response, data)
113
115
async for chunk in save_response_media(data["data"][0]["b64_json"], prompt, content_type=f"image/{output_format}"):
114
116
yield chunk
@@ -324,9 +324,9 @@ def get_width_height(
324
324
if aspect_ratio == "1:1":
325
325
return width or 1024, height or 1024
326
326
elif aspect_ratio == "16:9":
327
return width or 1792, height or 1024
327
return width or 832, height or 480
328
328
elif aspect_ratio == "9:16":
329
return width or 1024, height or 1792
329
return width or 480, height or 832,
330
330
return width, height
331
331
332
332
class ImageRequest: