66
77import litellm
88from google .adk .agents .callback_context import CallbackContext
9- from google .adk .models import LlmResponse , LlmRequest
9+ from google .adk .models import LlmResponse
1010from google .genai import types
1111from google .genai .types import FunctionCall , Part , FunctionResponse
1212
@@ -53,7 +53,8 @@ async def matmaster_set_lang(callback_context: CallbackContext) -> Optional[type
5353 callback_context .state ['target_language' ] = language
5454
5555
56- async def matmaster_check_job_status (callback_context : CallbackContext , llm_response : LlmRequest ) -> Optional [
56+ # after_model_callback
57+ async def matmaster_check_job_status (callback_context : CallbackContext , llm_response : LlmResponse ) -> Optional [
5758 LlmResponse ]:
5859 if (
5960 (jobs_dict := callback_context .state ['long_running_jobs' ]) and
@@ -76,15 +77,15 @@ async def matmaster_check_job_status(callback_context: CallbackContext, llm_resp
7677 llm_response .content .parts .insert (0 , Part (text = job_complete_intro .format (job_id = job_id ),
7778 function_call = FunctionCall (id = function_call_id ,
7879 name = 'transfer_to_agent' ,
79- args = {'agent_name' : agent_name }),
80- function_response = FunctionResponse (id = function_call_id ,
81- name = 'transfer_to_agent' ,
82- response = None )
80+ args = {'agent_name' : agent_name })
8381 )
8482 )
83+ llm_response .content .parts .insert (1 , Part (function_response = FunctionResponse (id = function_call_id ,
84+ name = 'transfer_to_agent' ,
85+ response = None )))
86+ return llm_response
8587
8688
87- # after_model_callback
8889async def matmaster_check_transfer (callback_context : CallbackContext , llm_response : LlmResponse ) -> Optional [
8990 LlmResponse ]:
9091 # 检查响应是否有效
0 commit comments