From 3e9462a693ebfd44ba3bdc8fc1be62c1ad56f95b Mon Sep 17 00:00:00 2001 From: root <953994191@qq.com> Date: Sat, 2 May 2026 10:32:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=89=8D=E7=AB=AF=EF=BC=8C?= =?UTF-8?q?=E6=94=AF=E6=8C=81=20react=5Freasoning=20=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E4=BA=8B=E4=BB=B6=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/chat_area.py | 34 +++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/chat_area.py b/frontend/src/components/chat_area.py index f3bb688..258b1f3 100644 --- a/frontend/src/components/chat_area.py +++ b/frontend/src/components/chat_area.py @@ -159,7 +159,39 @@ def _handle_ai_response(): thought_placeholder.info(f"**🤔 思考过程 (正在思考...)**\n\n{display_thought}▌") # 2. 处理各种控制事件,显示到思考过程 - if event_type == "intent_classified": + elif event_type == "react_reasoning": + # 处理我们自定义的推理事件(来自 react_reason_node, web_search, rag, 子图等) + step = event.get("step", 1) + action = event.get("action", "unknown") + confidence = event.get("confidence", 0) + reasoning = event.get("reasoning", "") + + # 根据 action 类型显示不同的图标 + action_icon = "🤔" + if "web_search" in action: + action_icon = "🌐" + elif "rag" in action or "retrieve" in action: + action_icon = "📚" + elif "subgraph" in action: + action_icon = "📦" + elif "DIRECT" in action: + action_icon = "💬" + elif "ROUTE" in action: + action_icon = "🔀" + elif "TOOL" in action: + action_icon = "🔧" + + api_thought += f"\n\n{action_icon} **第 {step} 次推理**" + api_thought += f"\n 📋 动作: {action}" + if confidence > 0: + api_thought += f"\n 📊 置信度: {confidence:.2f}" + if reasoning: + api_thought += f"\n 💭 {reasoning}" + + display_thought = api_thought + thought_placeholder.info(f"**🤔 思考过程 (正在思考...)**\n\n{display_thought}▌") + + elif event_type == "intent_classified": intent = event.get("intent", "unknown") confidence = event.get("confidence", 0) reasoning = event.get("reasoning", "")