Skip to content

Commit a01b2b9

Browse files
committed
fix: timeout of image generate
1 parent 685589f commit a01b2b9

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

veadk/tools/builtin_tools/image_generate.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ def _build_input_parts(item: dict, task_type: str, image_field):
8383

8484

8585
def handle_single_task_sync(
86-
idx: int, item: dict, tool_context
86+
idx: int,
87+
item: dict,
88+
timeout: int,
89+
tool_context,
8790
) -> tuple[list[dict], list[str]]:
8891
logger.debug(f"handle_single_task_sync item {idx}: {item}")
8992
success_list: list[dict] = []
@@ -139,6 +142,7 @@ def handle_single_task_sync(
139142
"MODEL_AGENT_CLIENT_REQ_ID", f"veadk/{VERSION}"
140143
),
141144
},
145+
timeout=timeout,
142146
)
143147
else:
144148
response = client.images.generate(
@@ -152,6 +156,7 @@ def handle_single_task_sync(
152156
"MODEL_AGENT_CLIENT_REQ_ID", f"veadk/{VERSION}"
153157
),
154158
},
159+
timeout=timeout,
155160
)
156161

157162
if not response.error:
@@ -228,14 +233,16 @@ def handle_single_task_sync(
228233
return success_list, error_list
229234

230235

231-
async def image_generate(tasks: list[dict], tool_context) -> Dict:
236+
async def image_generate(tasks: list[dict], tool_context, timeout: int = 600) -> Dict:
232237
"""Generate images with Seedream 4.0 / 4.5
233238
234239
Commit batch image generation requests via tasks.
235240
236241
Args:
237242
tasks (list[dict]):
238243
A list of image-generation tasks. Each task is a dict.
244+
timeout (int)
245+
The timeout limit for the image generation task request, in seconds, with a default value of 600 seconds.
239246
Per-task schema
240247
---------------
241248
Required:
@@ -336,7 +343,9 @@ async def image_generate(tasks: list[dict], tool_context) -> Dict:
336343

337344
def make_task(idx, item):
338345
ctx = base_ctx.copy()
339-
return lambda: ctx.run(handle_single_task_sync, idx, item, tool_context)
346+
return lambda: ctx.run(
347+
handle_single_task_sync, idx, item, timeout, tool_context
348+
)
340349

341350
loop = asyncio.get_event_loop()
342351
futures = [

veadk/tools/builtin_tools/video_generate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async def generate(
5252
if model_name.startswith("doubao-seedance-1-0") and generate_audio:
5353
logger.warning(
5454
"The `doubao-seedance-1-0` series models do not support enabling the audio field. "
55-
"Please upgrade to the `doubao-seedance-1-5` series."
55+
"Please upgrade to the doubao-seedance-1-5 series of you want to generate video with audio."
5656
)
5757
generate_audio = None
5858
if first_frame_image is None:

0 commit comments

Comments
 (0)