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", "")