|
17 | 17 | from agents.matmaster_agent.callback import matmaster_prepare_state, matmaster_check_transfer, matmaster_set_lang, \ |
18 | 18 | matmaster_check_job_status |
19 | 19 | from agents.matmaster_agent.chembrain_agent.agent import init_chembrain_agent |
20 | | -from agents.matmaster_agent.constant import MATMASTER_AGENT_NAME |
| 20 | +from agents.matmaster_agent.constant import MATMASTER_AGENT_NAME, ModelRole |
21 | 21 | from agents.matmaster_agent.llm_config import MatMasterLlmConfig |
22 | 22 | from agents.matmaster_agent.organic_reaction_agent.agent import init_organic_reaction_agent |
23 | 23 | from agents.matmaster_agent.perovskite_agent.agent import init_perovskite_agent |
|
28 | 28 | from agents.matmaster_agent.superconductor_agent.agent import init_superconductor_agent |
29 | 29 | from agents.matmaster_agent.thermoelectric_agent.agent import init_thermoelectric_agent |
30 | 30 | from agents.matmaster_agent.traj_analysis_agent.agent import init_traj_analysis_agent |
31 | | -from agents.matmaster_agent.utils.event_utils import send_error_event |
| 31 | +from agents.matmaster_agent.utils.event_utils import send_error_event, frontend_text_event |
| 32 | +from agents.matmaster_agent.utils.helper_func import update_session_state |
32 | 33 |
|
33 | 34 | logging.getLogger('google_adk.google.adk.tools.base_authenticated_tool').setLevel(logging.ERROR) |
34 | 35 |
|
@@ -86,6 +87,12 @@ async def _run_async_impl(self, ctx: InvocationContext) -> AsyncGenerator[Event, |
86 | 87 | try: |
87 | 88 | # Delegate to parent implementation for the actual processing |
88 | 89 | async for event in super()._run_async_impl(ctx): |
| 90 | + # 对于 [matmaster_check_job_status] 生成的消息, 手动拼一个流式消息 |
| 91 | + if ctx.session.state['special_llm_response']: |
| 92 | + yield frontend_text_event(ctx, self.name, event.content.parts[0].text, ModelRole) |
| 93 | + |
| 94 | + ctx.session.state['special_llm_response'] = False |
| 95 | + await update_session_state(ctx, self.name) |
89 | 96 | yield event |
90 | 97 | except BaseException as err: |
91 | 98 | async for error_event in send_error_event(err, ctx, self.name): |
|
0 commit comments