@@ -62,27 +62,27 @@ async def matmaster_check_job_status(callback_context: CallbackContext, llm_resp
6262 ):
6363 running_job_ids = get_running_jobs_detail (jobs_dict )
6464 access_key = _get_ak (callback_context )
65- if callback_context .state ['target_language' ] in ['Chinese' ]:
65+ if callback_context .state ['target_language' ] in ['Chinese' , 'zh-CN' , '简体中文' , 'Chinese (Simplified)' ]:
6666 job_complete_intro = '检测到任务 <{job_id}> 已完成,我将立刻转移至对应的 Agent 去获取任务结果,请稍等...'
6767 else :
6868 job_complete_intro = ('Job <{job_id}> has been detected as completed. '
6969 'I will immediately transfer to the corresponding agent to retrieve the job results. Please wait...' )
7070
71+ reset = False
7172 for origin_job_id , job_id , job_query_url , agent_name in running_job_ids :
7273 job_status = get_job_status (job_query_url , access_key = access_key )
7374 if job_status in ['Failed' , 'Finished' ]:
75+ if not reset :
76+ llm_response .content .parts = []
77+ reset = True
7478 logger .info (f"[matmaster_check_job_status] job_id = { job_id } , job_status = { job_status } " )
7579 function_call_id = f"call_{ str (uuid .uuid4 ()).replace ('-' , '' )[:24 ]} "
7680 callback_context .state ['origin_job_id' ] = origin_job_id
77- llm_response .content .parts .insert (0 , Part (text = job_complete_intro .format (job_id = job_id ),
78- function_call = FunctionCall (id = function_call_id ,
79- name = 'transfer_to_agent' ,
80- args = {'agent_name' : agent_name })
81- )
82- )
83- llm_response .content .parts .insert (1 , Part (function_response = FunctionResponse (id = function_call_id ,
84- name = 'transfer_to_agent' ,
85- response = None )))
81+ llm_response .content .parts .append (Part (text = job_complete_intro .format (job_id = job_id )))
82+ llm_response .content .parts .append (Part (function_call = FunctionCall (id = function_call_id ,
83+ name = 'transfer_to_agent' ,
84+ args = {'agent_name' : agent_name })))
85+
8686 return llm_response
8787
8888
0 commit comments