Skip to content

Commit d7c9fc6

Browse files
committed
feat:添加MATMASTER_THINKING_UI以展示正在思考过程的UI更新
1 parent 3f07370 commit d7c9fc6

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

agents/matmaster_agent/flow_agents/agent.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
MATMASTER_FLOW_PLANS,
4444
MATMASTER_GENERATE_NPS,
4545
MATMASTER_INTENT_UI,
46+
MATMASTER_THINKING_UI,
4647
)
4748
from agents.matmaster_agent.flow_agents.execution_agent.agent import (
4849
MatMasterSupervisorAgent,
@@ -548,6 +549,23 @@ async def _run_plan_make_agent(
548549
thinking_text = ''
549550
if not skip_thinking:
550551
try:
552+
for _thinking_ui_event in context_function_event(
553+
ctx,
554+
self.name,
555+
MATMASTER_THINKING_UI,
556+
None,
557+
ModelRole,
558+
{
559+
'matmaster_thinking_ui_args': json.dumps(
560+
{
561+
'title': '正在思考',
562+
'status': 'start',
563+
}
564+
)
565+
},
566+
):
567+
yield _thinking_ui_event
568+
551569
self._thinking_agent.set_thinking_params(
552570
available_tools_with_info_str,
553571
session_file_summary,
@@ -580,6 +598,21 @@ async def _run_plan_make_agent(
580598
f'{ctx.session.id} reasoning_agent result length={len(thinking_text)}, '
581599
f'preview={repr(thinking_text[:300]) if thinking_text else "empty"}'
582600
)
601+
for _thinking_ui_event in context_function_event(
602+
ctx,
603+
self.name,
604+
MATMASTER_THINKING_UI,
605+
None,
606+
ModelRole,
607+
{
608+
'matmaster_thinking_ui_args': json.dumps(
609+
{
610+
'status': 'end',
611+
}
612+
)
613+
},
614+
):
615+
yield _thinking_ui_event
583616
except Exception as e:
584617
logger.warning(
585618
f'{ctx.session.id} reasoning_agent failed: {e}, proceed without thinking'

agents/matmaster_agent/flow_agents/constant.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
MATMASTER_FLOW_PLANS = 'matmaster_flow_plans'
1111
MATMASTER_GENERATE_NPS = 'matmaster_generate_nps'
1212
MATMASTER_INTENT_UI = 'matmaster_intent_ui'
13+
MATMASTER_THINKING_UI = 'matmaster_thinking_ui'
1314

1415
# matmaster_flow 展示文案,直接传给前端(正常执行无标签则传空字符串)
1516
EXECUTION_TYPE_LABEL_RETRY = '重试工具'

0 commit comments

Comments
 (0)