返回提交历史
Modified
g4f/gui/server/api.py
+1
-3
XFEstudio/gpt4free
Fix code review issues: remove redundant else clause and improve initialization
Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>
b3131a3f
代码差异
1 个文件
+1
-3
@@ -223,6 +223,7 @@ class Api:
223
223
yield self._format_json("preview", chunk.to_string(), urls=chunk.urls, alt=chunk.alt)
224
224
elif isinstance(chunk, MediaResponse):
225
225
media = chunk
226
image_metadata = None
226
227
if download_media or chunk.get("cookies"):
227
228
chunk.alt = format_media_prompt(kwargs.get("messages"), chunk.alt)
228
229
width, height = get_width_height(chunk.get("width"), chunk.get("height"))
@@ -240,7 +241,6 @@ class Api:
240
241
))
241
242
options = {}
242
243
target_paths, urls = get_target_paths_and_urls(media)
243
image_metadata = None
244
244
if target_paths:
245
245
if has_pillow:
246
246
try:
@@ -268,8 +268,6 @@ class Api:
268
268
if total_size > 0:
269
269
image_metadata["file_size"] = total_size
270
270
media = ImageResponse(urls, chunk.alt, options) if isinstance(chunk, ImageResponse) else VideoResponse(media, chunk.alt)
271
else:
272
image_metadata = None
273
271
yield self._format_json("content", str(media), urls=media.urls, alt=media.alt)
274
272
# Yield usage statistics with image metadata for image responses
275
273
if image_metadata: