Skip to content

Commit c8dc22f

Browse files
committed
feat:添加用户意图识别时的UI通知事件
1 parent 360c486 commit c8dc22f

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

agents/matmaster_agent/flow_agents/agent.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
MATMASTER_FLOW,
4343
MATMASTER_FLOW_PLANS,
4444
MATMASTER_GENERATE_NPS,
45+
MATMASTER_INTENT_UI,
4546
)
4647
from agents.matmaster_agent.flow_agents.execution_agent.agent import (
4748
MatMasterSupervisorAgent,
@@ -961,9 +962,42 @@ async def _run_async_impl(
961962

962963
# 用户意图识别(一旦进入 research 模式,暂时无法退出)
963964
if ctx.session.state['intent'].get('type', None) != IntentEnum.RESEARCH:
965+
for _intent_ui_event in context_function_event(
966+
ctx,
967+
self.name,
968+
MATMASTER_INTENT_UI,
969+
None,
970+
ModelRole,
971+
{
972+
'matmaster_intent_ui_args': json.dumps(
973+
{
974+
'title': '正在进行意图识别...',
975+
'status': 'start',
976+
}
977+
)
978+
},
979+
):
980+
yield _intent_ui_event
981+
964982
async for intent_event in self.intent_agent.run_async(ctx):
965983
yield intent_event
966984

985+
for _intent_ui_event in context_function_event(
986+
ctx,
987+
self.name,
988+
MATMASTER_INTENT_UI,
989+
None,
990+
ModelRole,
991+
{
992+
'matmaster_intent_ui_args': json.dumps(
993+
{
994+
'status': 'end',
995+
}
996+
)
997+
},
998+
):
999+
yield _intent_ui_event
1000+
9671001
# 如果用户上传文件,强制为 research 模式
9681002
if (
9691003
ctx.session.state[UPLOAD_FILE]

agents/matmaster_agent/flow_agents/constant.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
MATMASTER_FLOW = 'matmaster_flow'
1010
MATMASTER_FLOW_PLANS = 'matmaster_flow_plans'
1111
MATMASTER_GENERATE_NPS = 'matmaster_generate_nps'
12+
MATMASTER_INTENT_UI = 'matmaster_intent_ui'
1213

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

0 commit comments

Comments
 (0)