@@ -83,7 +83,10 @@ def _build_input_parts(item: dict, task_type: str, image_field):
8383
8484
8585def 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 = [
0 commit comments