Skip to content

Commit 3d6a2ef

Browse files
letherkevinlin09
authored andcommitted
generation_wan26_bug_fix
1 parent 611a4a4 commit 3d6a2ef

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/agentscope_bricks/components/generations/image_generation_wan26.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class ImageGenerationWan26(
7979

8080
name: str = "modelstudio_wanx26_image_generation"
8181
description: str = (
82-
"[版本: wan2.6] 通义万相文生图模型(wanx2.6-t2i)。AI绘画服务,根据文本描述生成高质量图像,并返回图片URL。\n"
82+
"[版本: wan2.6] 通义万相文生图模型(wan2.6-t2i)。AI绘画服务,根据文本描述生成高质量图像,并返回图片URL。\n"
8383
"新功能包括图像编辑和图文混合输出,满足更多样化的生成与集成需求。\n"
8484
"支持自定义分辨率:图像面积介于 768×768 至 1440×1440 像素之间,"
8585
"允许在该范围内自由调整宽高比(例如 768×2700)。\n"
@@ -140,18 +140,18 @@ async def arun(
140140
)
141141
except Exception as e:
142142
raise RuntimeError(
143-
f"Failed to call Wanx 2.6 image generation API: {str(e)}",
143+
f"Failed to call Wan 2.6 image generation API: {str(e)}",
144144
) from e
145145

146146
if response.status_code != 200 or not response.output:
147-
raise RuntimeError(f"Wanx 2.6 image generation failed: {response}")
147+
raise RuntimeError(f"Wan 2.6 image generation failed: {response}")
148148

149149
results = []
150150
try:
151151
if hasattr(response, "output") and response.output:
152152
choices = getattr(response.output, "choices", [])
153-
if choices:
154-
message = getattr(choices[0], "message", {})
153+
for choice in choices: # ← 遍历所有 choices,而不是只取 [0]
154+
message = getattr(choice, "message", {})
155155
content = getattr(message, "content", [])
156156
if isinstance(content, list):
157157
for item in content:
@@ -163,7 +163,7 @@ async def arun(
163163
results.append(content["image"])
164164
except Exception as e:
165165
raise RuntimeError(
166-
f"Failed to parse Wanx 2.6 API response: {str(e)}",
166+
f"Failed to parse Wan 2.6 API response: {str(e)}",
167167
) from e
168168

169169
if not results:

0 commit comments

Comments
 (0)