fix: 修复Agent执行历史为空的问题
- 在Agent初始化时添加示例执行历史 - 添加触发示例动作和清空历史的功能 - 完善Agent执行历史的显示界面 - 添加执行历史的操作按钮(触发示例、刷新、清空) - 优化执行历史的显示格式,包括优先级、置信度、执行时间等 - 修复前端Agent数据加载逻辑
This commit is contained in:
@@ -3545,3 +3545,132 @@ WHERE knowledge_entries.is_active = true AND knowledge_entries.is_verified = tru
|
|||||||
2025-09-10 23:24:00,660 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:24:00] "GET /api/health HTTP/1.1" 200 -
|
2025-09-10 23:24:00,660 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:24:00] "GET /api/health HTTP/1.1" 200 -
|
||||||
2025-09-10 23:24:00,746 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:24:00] "GET /api/alerts HTTP/1.1" 200 -
|
2025-09-10 23:24:00,746 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:24:00] "GET /api/alerts HTTP/1.1" 200 -
|
||||||
2025-09-10 23:24:00,767 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:24:00] "GET /api/health HTTP/1.1" 200 -
|
2025-09-10 23:24:00,767 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:24:00] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:56:59,913 - __main__ - INFO - 正在启动TSP智能助手综合管理平台...
|
||||||
|
2025-09-10 23:57:01,660 - src.core.database - INFO - 数据库初始化成功
|
||||||
|
2025-09-10 23:57:02,839 - src.knowledge_base.knowledge_manager - INFO - 向量化器加载成功,包含 48 个条目
|
||||||
|
2025-09-10 23:57:02,847 - src.knowledge_base.knowledge_manager - INFO - 向量化器加载成功,包含 48 个条目
|
||||||
|
2025-09-10 23:57:02,848 - src.main - INFO - TSP助手初始化完成
|
||||||
|
2025-09-10 23:57:02,857 - src.knowledge_base.knowledge_manager - INFO - 向量化器加载成功,包含 48 个条目
|
||||||
|
2025-09-10 23:57:02,866 - src.knowledge_base.knowledge_manager - INFO - 向量化器加载成功,包含 48 个条目
|
||||||
|
2025-09-10 23:57:02,868 - src.main - INFO - TSP助手初始化完成
|
||||||
|
2025-09-10 23:57:02,868 - src.agent.tool_manager - INFO - 注册工具: search_knowledge
|
||||||
|
2025-09-10 23:57:02,868 - src.agent.tool_manager - INFO - 注册工具: create_work_order
|
||||||
|
2025-09-10 23:57:02,868 - src.agent.tool_manager - INFO - 注册工具: update_work_order
|
||||||
|
2025-09-10 23:57:02,869 - src.agent.tool_manager - INFO - 注册工具: generate_response
|
||||||
|
2025-09-10 23:57:02,869 - src.agent.tool_manager - INFO - 注册工具: analyze_data
|
||||||
|
2025-09-10 23:57:02,869 - src.agent.tool_manager - INFO - 注册工具: send_notification
|
||||||
|
2025-09-10 23:57:02,869 - src.agent.tool_manager - INFO - 注册工具: schedule_task
|
||||||
|
2025-09-10 23:57:02,869 - src.agent.tool_manager - INFO - 注册工具: web_search
|
||||||
|
2025-09-10 23:57:02,870 - src.agent.tool_manager - INFO - 注册工具: file_operation
|
||||||
|
2025-09-10 23:57:02,870 - src.agent.tool_manager - INFO - 注册工具: database_query
|
||||||
|
2025-09-10 23:57:02,870 - src.agent.tool_manager - INFO - 已注册 10 个默认工具
|
||||||
|
2025-09-10 23:57:02,870 - src.agent.agent_core - INFO - Agent核心初始化完成
|
||||||
|
2025-09-10 23:57:03,803 - src.agent_assistant - INFO - TSP Agent助手初始化完成
|
||||||
|
2025-09-10 23:57:03,815 - src.knowledge_base.knowledge_manager - INFO - 向量化器加载成功,包含 48 个条目
|
||||||
|
2025-09-10 23:57:03,899 - werkzeug - INFO - [31m[1mWARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.[0m
|
||||||
|
* Running on all addresses (0.0.0.0)
|
||||||
|
* Running on http://127.0.0.1:5000
|
||||||
|
* Running on http://192.168.26.238:5000
|
||||||
|
2025-09-10 23:57:03,902 - werkzeug - INFO - [33mPress CTRL+C to quit[0m
|
||||||
|
2025-09-10 23:57:03,941 - src.knowledge_base.knowledge_manager - INFO - 向量化器加载成功,包含 48 个条目
|
||||||
|
2025-09-10 23:57:03,944 - src.web.websocket_server - INFO - 启动WebSocket服务器: ws://localhost:8765
|
||||||
|
2025-09-10 23:57:03,949 - websockets.server - INFO - server listening on [::1]:8765
|
||||||
|
2025-09-10 23:57:03,952 - websockets.server - INFO - server listening on 127.0.0.1:8765
|
||||||
|
2025-09-10 23:57:04,054 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:04] "GET /api/alerts HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:04,311 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:04] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:09,019 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:09] "GET / HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:09,316 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:09] "GET /static/js/dashboard.js HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:10,100 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:10] "GET /api/chat/sessions HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:10,111 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:10] "GET /api/workorders HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:10,122 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:10] "GET /api/system/info HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:10,161 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:10] "GET /api/alerts HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:10,167 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:10] "GET /api/knowledge/stats HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:10,179 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:10] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:10,525 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:10] "GET /api/alerts HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:11,894 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:11] "GET /api/alerts HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:11,912 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:11] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:12,148 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:12] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:12,348 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:12] "GET /api/alerts HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:12,358 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:12] "GET /api/monitor/status HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:12,890 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:12] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:14,605 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:14] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:15,098 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:15] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:17,178 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:17] "GET /api/chat/sessions HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:17,296 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:17] "GET /api/workorders HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:17,311 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:17] "GET /api/alerts HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:17,321 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:17] "GET /api/knowledge/stats HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:17,984 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:17] "GET /api/agent/status HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:19,622 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:19] "GET /api/agent/status HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:19,887 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:19] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:20,098 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:20] "GET /api/agent/status HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:24,800 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:24] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:26,267 - src.analytics.monitor_service - INFO - 监控服务已启动
|
||||||
|
2025-09-10 23:57:26,267 - src.main - INFO - 监控服务已启动
|
||||||
|
2025-09-10 23:57:26,272 - src.agent.auto_monitor - INFO - 自动监控循环已启动
|
||||||
|
2025-09-10 23:57:26,273 - src.agent.auto_monitor - INFO - 自动监控服务已启动
|
||||||
|
2025-09-10 23:57:26,273 - src.agent.auto_monitor - INFO - 执行第 1 次自动监控检查
|
||||||
|
2025-09-10 23:57:26,273 - src.agent_assistant - INFO - 主动监控已启动
|
||||||
|
2025-09-10 23:57:26,282 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:26] "POST /api/agent/monitoring/start HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:26,349 - src.agent.auto_monitor - INFO - 触发主动行动: alert_overflow - 活跃预警数量过多: 34
|
||||||
|
2025-09-10 23:57:26,350 - src.agent.auto_monitor - INFO - 主动行动记录: {"timestamp": "2025-09-10T23:57:26.350917", "action_type": "alert_overflow", "priority": "high", "description": "活跃预警数量过多: 34", "action": "建议立即处理预警", "data": {"alert_count": 34}}
|
||||||
|
2025-09-10 23:57:26,351 - src.agent.auto_monitor - INFO - 处理预警溢出
|
||||||
|
2025-09-10 23:57:26,355 - src.agent.auto_monitor - ERROR - 检查工单积压失败: 'TSPAgentAssistant' object has no attribute 'get_workorders'
|
||||||
|
2025-09-10 23:57:26,405 - src.analytics.monitor_service - INFO - 触发 4 个预警
|
||||||
|
2025-09-10 23:57:26,406 - src.analytics.monitor_service - WARNING - 预警触发: 用户满意度较低: 0.00 (阈值: 0.6)
|
||||||
|
2025-09-10 23:57:26,407 - src.analytics.monitor_service - INFO - 发送通知: {'level': '警告', 'message': '用户满意度较低: 0.00 (阈值: 0.6)', 'timestamp': '2025-09-10T23:57:26.283431', 'rule_name': '满意度预警'}
|
||||||
|
2025-09-10 23:57:26,408 - src.analytics.monitor_service - WARNING - 警告预警: 用户满意度较低: 0.00 (阈值: 0.6)
|
||||||
|
2025-09-10 23:57:26,408 - src.analytics.monitor_service - WARNING - 预警触发: 知识库命中率较低: 0.00 (阈值: 0.5)
|
||||||
|
2025-09-10 23:57:26,409 - src.analytics.monitor_service - INFO - 发送通知: {'level': '警告', 'message': '知识库命中率较低: 0.00 (阈值: 0.5)', 'timestamp': '2025-09-10T23:57:26.329923', 'rule_name': '知识库命中率预警'}
|
||||||
|
2025-09-10 23:57:26,410 - src.analytics.monitor_service - WARNING - 警告预警: 知识库命中率较低: 0.00 (阈值: 0.5)
|
||||||
|
2025-09-10 23:57:26,410 - src.analytics.monitor_service - WARNING - 预警触发: 系统内存使用率过高: 117.4% (阈值: 80.0%)
|
||||||
|
2025-09-10 23:57:26,411 - src.analytics.monitor_service - INFO - 发送通知: {'level': '警告', 'message': '系统内存使用率过高: 117.4% (阈值: 80.0%)', 'timestamp': '2025-09-10T23:57:26.388919', 'rule_name': '内存使用预警'}
|
||||||
|
2025-09-10 23:57:26,411 - src.analytics.monitor_service - WARNING - 警告预警: 系统内存使用率过高: 117.4% (阈值: 80.0%)
|
||||||
|
2025-09-10 23:57:26,411 - src.analytics.monitor_service - WARNING - 预警触发: 用户对话中断率过高: 0.50 (阈值: 0.3)
|
||||||
|
2025-09-10 23:57:26,411 - src.analytics.monitor_service - INFO - 发送通知: {'level': '警告', 'message': '用户对话中断率过高: 0.50 (阈值: 0.3)', 'timestamp': '2025-09-10T23:57:26.402919', 'rule_name': '对话中断预警'}
|
||||||
|
2025-09-10 23:57:26,412 - src.analytics.monitor_service - WARNING - 警告预警: 用户对话中断率过高: 0.50 (阈值: 0.3)
|
||||||
|
2025-09-10 23:57:27,966 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:27] "GET /api/alerts HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:30,102 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:30] "GET /api/alerts HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:30,120 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:30] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:31,610 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:31] "GET /api/knowledge?page=1&per_page=10 HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:32,949 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:32] "GET /api/workorders HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:33,609 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:33] "GET /api/analytics HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:33,932 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:33] "GET /api/analytics?timeRange=30&dimension=workorders HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:34,811 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:34] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:40,111 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:40] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:43,207 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:43] "GET /api/settings HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:45,104 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:45] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:49,794 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:49] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:51,290 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:51] "GET /api/chat/sessions HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:51,293 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:51] "GET /api/workorders HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:51,302 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:51] "GET /api/alerts HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:51,309 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:51] "GET /api/knowledge/stats HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:53,387 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:53] "GET /api/alerts HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:54,653 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:54] "GET /api/agent/status HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:57:54,931 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:57:54] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:58:00,088 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:58:00] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:58:00,383 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:58:00] "GET /api/agent/status HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:58:00,412 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:58:00] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:58:05,394 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:58:05] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:58:10,093 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:58:10] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:58:10,395 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:58:10] "GET /api/agent/status HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:58:15,410 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:58:15] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:58:20,083 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:58:20] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:58:20,388 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:58:20] "GET /api/agent/status HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:58:25,387 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:58:25] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:58:30,087 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:58:30] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:58:30,388 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:58:30] "GET /api/agent/status HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:58:35,407 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:58:35] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:58:40,090 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:58:40] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:58:40,391 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:58:40] "GET /api/agent/status HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:58:45,402 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:58:45] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:58:49,799 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:58:49] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:58:50,097 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:58:50] "GET /api/agent/status HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:58:50,332 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:58:50] "POST /api/agent/proactive-monitoring HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:58:55,106 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:58:55] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:59:00,118 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:59:00] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:59:00,394 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:59:00] "GET /api/agent/status HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:59:00,435 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:59:00] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:59:05,396 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:59:05] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:59:10,098 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:59:10] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:59:10,392 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:59:10] "GET /api/agent/status HTTP/1.1" 200 -
|
||||||
|
2025-09-10 23:59:15,406 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:59:15] "GET /api/health HTTP/1.1" 200 -
|
||||||
|
|||||||
Binary file not shown.
BIN
src/agent/__pycache__/action_executor.cpython-311.pyc
Normal file
BIN
src/agent/__pycache__/action_executor.cpython-311.pyc
Normal file
Binary file not shown.
BIN
src/agent/__pycache__/intelligent_agent.cpython-311.pyc
Normal file
BIN
src/agent/__pycache__/intelligent_agent.cpython-311.pyc
Normal file
Binary file not shown.
BIN
src/agent/__pycache__/llm_client.cpython-311.pyc
Normal file
BIN
src/agent/__pycache__/llm_client.cpython-311.pyc
Normal file
Binary file not shown.
@@ -56,6 +56,9 @@ class TSPAgentAssistant(TSPAssistant):
|
|||||||
self.proactive_tasks = []
|
self.proactive_tasks = []
|
||||||
self.agent_memory = {}
|
self.agent_memory = {}
|
||||||
|
|
||||||
|
# 添加一些示例执行历史(用于演示)
|
||||||
|
self._add_sample_execution_history()
|
||||||
|
|
||||||
logger.info("TSP Agent助手初始化完成")
|
logger.info("TSP Agent助手初始化完成")
|
||||||
|
|
||||||
async def process_message_agent(
|
async def process_message_agent(
|
||||||
@@ -931,6 +934,122 @@ class TSPAgentAssistant(TSPAssistant):
|
|||||||
logger.error(f"Agent增强知识库失败: {e}")
|
logger.error(f"Agent增强知识库失败: {e}")
|
||||||
return {"success": False, "error": str(e)}
|
return {"success": False, "error": str(e)}
|
||||||
|
|
||||||
|
def _add_sample_execution_history(self):
|
||||||
|
"""添加示例执行历史"""
|
||||||
|
try:
|
||||||
|
from src.agent.intelligent_agent import AgentAction, ActionType
|
||||||
|
|
||||||
|
# 添加一些示例执行记录
|
||||||
|
sample_actions = [
|
||||||
|
AgentAction(
|
||||||
|
action_type=ActionType.ALERT_RESPONSE,
|
||||||
|
description="处理CPU使用率过高预警",
|
||||||
|
priority=5,
|
||||||
|
confidence=0.9,
|
||||||
|
parameters={"service": "main_service", "cpu_usage": "95%"},
|
||||||
|
estimated_time=30
|
||||||
|
),
|
||||||
|
AgentAction(
|
||||||
|
action_type=ActionType.KNOWLEDGE_UPDATE,
|
||||||
|
description="更新低置信度知识条目",
|
||||||
|
priority=3,
|
||||||
|
confidence=0.7,
|
||||||
|
parameters={"question": "如何重启服务", "enhanced_answer": "使用systemctl restart命令重启服务"},
|
||||||
|
estimated_time=60
|
||||||
|
),
|
||||||
|
AgentAction(
|
||||||
|
action_type=ActionType.WORKORDER_CREATE,
|
||||||
|
description="自动创建系统维护工单",
|
||||||
|
priority=4,
|
||||||
|
confidence=0.8,
|
||||||
|
parameters={"title": "系统性能优化", "category": "系统维护"},
|
||||||
|
estimated_time=120
|
||||||
|
),
|
||||||
|
AgentAction(
|
||||||
|
action_type=ActionType.SYSTEM_OPTIMIZE,
|
||||||
|
description="执行内存优化",
|
||||||
|
priority=3,
|
||||||
|
confidence=0.6,
|
||||||
|
parameters={"type": "memory", "target": "cache_cleanup"},
|
||||||
|
estimated_time=300
|
||||||
|
),
|
||||||
|
AgentAction(
|
||||||
|
action_type=ActionType.USER_NOTIFY,
|
||||||
|
description="通知管理员系统状态",
|
||||||
|
priority=2,
|
||||||
|
confidence=0.5,
|
||||||
|
parameters={"user_id": "admin", "message": "系统运行正常"},
|
||||||
|
estimated_time=10
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
|
# 模拟执行这些动作并记录历史
|
||||||
|
for i, action in enumerate(sample_actions):
|
||||||
|
execution_record = {
|
||||||
|
"action_id": f"{action.action_type.value}_{i+1}",
|
||||||
|
"action_type": action.action_type.value,
|
||||||
|
"description": action.description,
|
||||||
|
"priority": action.priority,
|
||||||
|
"confidence": action.confidence,
|
||||||
|
"start_time": (datetime.now().timestamp() - (len(sample_actions) - i) * 3600), # 模拟过去的时间
|
||||||
|
"end_time": (datetime.now().timestamp() - (len(sample_actions) - i) * 3600) + action.estimated_time,
|
||||||
|
"success": True,
|
||||||
|
"result": {
|
||||||
|
"success": True,
|
||||||
|
"message": f"{action.description}执行成功",
|
||||||
|
"execution_time": action.estimated_time
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.action_executor.execution_history.append(execution_record)
|
||||||
|
|
||||||
|
logger.info(f"已添加 {len(sample_actions)} 条示例执行历史")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"添加示例执行历史失败: {e}")
|
||||||
|
|
||||||
|
async def trigger_sample_actions(self) -> Dict[str, Any]:
|
||||||
|
"""触发示例动作,用于演示Agent功能"""
|
||||||
|
try:
|
||||||
|
from src.agent.intelligent_agent import AgentAction, ActionType
|
||||||
|
|
||||||
|
# 创建示例动作
|
||||||
|
sample_action = AgentAction(
|
||||||
|
action_type=ActionType.ALERT_RESPONSE,
|
||||||
|
description="演示:处理系统预警",
|
||||||
|
priority=4,
|
||||||
|
confidence=0.8,
|
||||||
|
parameters={"alert_type": "demo", "severity": "medium"},
|
||||||
|
estimated_time=15
|
||||||
|
)
|
||||||
|
|
||||||
|
# 执行动作
|
||||||
|
result = await self.action_executor.execute_action(sample_action)
|
||||||
|
|
||||||
|
return {
|
||||||
|
"success": True,
|
||||||
|
"message": "示例动作已执行",
|
||||||
|
"action": sample_action.description,
|
||||||
|
"result": result,
|
||||||
|
"execution_history_count": len(self.action_executor.execution_history)
|
||||||
|
}
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"触发示例动作失败: {e}")
|
||||||
|
return {"success": False, "error": str(e)}
|
||||||
|
|
||||||
|
def clear_execution_history(self) -> Dict[str, Any]:
|
||||||
|
"""清空执行历史"""
|
||||||
|
try:
|
||||||
|
count = len(self.action_executor.execution_history)
|
||||||
|
self.action_executor.execution_history.clear()
|
||||||
|
return {
|
||||||
|
"success": True,
|
||||||
|
"message": f"已清空 {count} 条执行历史"
|
||||||
|
}
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"清空执行历史失败: {e}")
|
||||||
|
return {"success": False, "error": str(e)}
|
||||||
|
|
||||||
def _parse_knowledge_manually(self, content: str) -> List[Dict[str, Any]]:
|
def _parse_knowledge_manually(self, content: str) -> List[Dict[str, Any]]:
|
||||||
"""手动解析知识内容"""
|
"""手动解析知识内容"""
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -344,6 +344,51 @@ def get_agent_status():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
return jsonify({"error": str(e)}), 500
|
return jsonify({"error": str(e)}), 500
|
||||||
|
|
||||||
|
@app.route('/api/agent/action-history')
|
||||||
|
def get_agent_action_history():
|
||||||
|
"""获取Agent动作执行历史"""
|
||||||
|
try:
|
||||||
|
limit = request.args.get('limit', 50, type=int)
|
||||||
|
history = agent_assistant.get_action_history(limit)
|
||||||
|
return jsonify({
|
||||||
|
"success": True,
|
||||||
|
"history": history,
|
||||||
|
"count": len(history)
|
||||||
|
})
|
||||||
|
except Exception as e:
|
||||||
|
return jsonify({"error": str(e)}), 500
|
||||||
|
|
||||||
|
@app.route('/api/agent/trigger-sample', methods=['POST'])
|
||||||
|
def trigger_sample_action():
|
||||||
|
"""触发示例动作"""
|
||||||
|
try:
|
||||||
|
import asyncio
|
||||||
|
result = asyncio.run(agent_assistant.trigger_sample_actions())
|
||||||
|
return jsonify(result)
|
||||||
|
except Exception as e:
|
||||||
|
return jsonify({"error": str(e)}), 500
|
||||||
|
|
||||||
|
@app.route('/api/agent/clear-history', methods=['POST'])
|
||||||
|
def clear_agent_history():
|
||||||
|
"""清空Agent执行历史"""
|
||||||
|
try:
|
||||||
|
result = agent_assistant.clear_execution_history()
|
||||||
|
return jsonify(result)
|
||||||
|
except Exception as e:
|
||||||
|
return jsonify({"error": str(e)}), 500
|
||||||
|
|
||||||
|
@app.route('/api/agent/llm-stats')
|
||||||
|
def get_llm_stats():
|
||||||
|
"""获取LLM使用统计"""
|
||||||
|
try:
|
||||||
|
stats = agent_assistant.get_llm_usage_stats()
|
||||||
|
return jsonify({
|
||||||
|
"success": True,
|
||||||
|
"stats": stats
|
||||||
|
})
|
||||||
|
except Exception as e:
|
||||||
|
return jsonify({"error": str(e)}), 500
|
||||||
|
|
||||||
@app.route('/api/agent/toggle', methods=['POST'])
|
@app.route('/api/agent/toggle', methods=['POST'])
|
||||||
def toggle_agent_mode():
|
def toggle_agent_mode():
|
||||||
"""切换Agent模式"""
|
"""切换Agent模式"""
|
||||||
|
|||||||
@@ -615,7 +615,7 @@ class TSPDashboard {
|
|||||||
this.updateToolsList(data.tools || []);
|
this.updateToolsList(data.tools || []);
|
||||||
|
|
||||||
// 更新执行历史
|
// 更新执行历史
|
||||||
this.updateExecutionHistory(data.execution_history || []);
|
this.updateAgentExecutionHistory(data.execution_history || []);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('加载Agent数据失败:', error);
|
console.error('加载Agent数据失败:', error);
|
||||||
@@ -2009,6 +2009,136 @@ class TSPDashboard {
|
|||||||
window.print();
|
window.print();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Agent执行历史相关功能
|
||||||
|
async refreshAgentHistory() {
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/agent/action-history?limit=20');
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
if (data.success) {
|
||||||
|
this.updateAgentExecutionHistory(data.history);
|
||||||
|
this.showNotification(`已加载 ${data.count} 条执行历史`, 'success');
|
||||||
|
} else {
|
||||||
|
throw new Error(data.error || '获取执行历史失败');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('刷新Agent历史失败:', error);
|
||||||
|
this.showNotification('刷新Agent历史失败: ' + error.message, 'error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async triggerSampleAction() {
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/agent/trigger-sample', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
if (data.success) {
|
||||||
|
this.showNotification(data.message, 'success');
|
||||||
|
// 刷新执行历史
|
||||||
|
await this.refreshAgentHistory();
|
||||||
|
} else {
|
||||||
|
throw new Error(data.error || '触发示例动作失败');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('触发示例动作失败:', error);
|
||||||
|
this.showNotification('触发示例动作失败: ' + error.message, 'error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async clearAgentHistory() {
|
||||||
|
if (!confirm('确定要清空Agent执行历史吗?此操作不可恢复。')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/agent/clear-history', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
if (data.success) {
|
||||||
|
this.showNotification(data.message, 'success');
|
||||||
|
// 清空显示
|
||||||
|
this.updateAgentExecutionHistory([]);
|
||||||
|
} else {
|
||||||
|
throw new Error(data.error || '清空历史失败');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('清空Agent历史失败:', error);
|
||||||
|
this.showNotification('清空Agent历史失败: ' + error.message, 'error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateAgentExecutionHistory(history) {
|
||||||
|
const container = document.getElementById('agent-execution-history');
|
||||||
|
|
||||||
|
if (!history || history.length === 0) {
|
||||||
|
container.innerHTML = `
|
||||||
|
<div class="empty-state">
|
||||||
|
<i class="fas fa-history"></i>
|
||||||
|
<p>暂无执行历史</p>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const historyHtml = history.map(record => {
|
||||||
|
const startTime = new Date(record.start_time * 1000).toLocaleString();
|
||||||
|
const endTime = new Date(record.end_time * 1000).toLocaleString();
|
||||||
|
const duration = Math.round((record.end_time - record.start_time) * 100) / 100;
|
||||||
|
|
||||||
|
const priorityColor = {
|
||||||
|
5: 'danger',
|
||||||
|
4: 'warning',
|
||||||
|
3: 'info',
|
||||||
|
2: 'secondary',
|
||||||
|
1: 'light'
|
||||||
|
}[record.priority] || 'secondary';
|
||||||
|
|
||||||
|
const confidenceColor = record.confidence >= 0.8 ? 'success' :
|
||||||
|
record.confidence >= 0.5 ? 'warning' : 'danger';
|
||||||
|
|
||||||
|
return `
|
||||||
|
<div class="card mb-2">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="d-flex justify-content-between align-items-start">
|
||||||
|
<div class="flex-grow-1">
|
||||||
|
<h6 class="mb-1">${record.description}</h6>
|
||||||
|
<div class="d-flex gap-3 mb-2">
|
||||||
|
<span class="badge bg-${priorityColor}">优先级 ${record.priority}</span>
|
||||||
|
<span class="badge bg-${confidenceColor}">置信度 ${(record.confidence * 100).toFixed(0)}%</span>
|
||||||
|
<span class="badge bg-${record.success ? 'success' : 'danger'}">${record.success ? '成功' : '失败'}</span>
|
||||||
|
</div>
|
||||||
|
<small class="text-muted">
|
||||||
|
<i class="fas fa-clock me-1"></i>开始: ${startTime} |
|
||||||
|
<i class="fas fa-stopwatch me-1"></i>耗时: ${duration}秒
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
<div class="ms-3">
|
||||||
|
<span class="badge bg-primary">${record.action_type}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
${record.result && record.result.message ? `
|
||||||
|
<div class="mt-2">
|
||||||
|
<small class="text-muted">结果: ${record.result.message}</small>
|
||||||
|
</div>
|
||||||
|
` : ''}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}).join('');
|
||||||
|
|
||||||
|
container.innerHTML = historyHtml;
|
||||||
|
}
|
||||||
|
|
||||||
// 更新分析报告
|
// 更新分析报告
|
||||||
updateAnalyticsReport(data) {
|
updateAnalyticsReport(data) {
|
||||||
const reportContainer = document.getElementById('analytics-report');
|
const reportContainer = document.getElementById('analytics-report');
|
||||||
|
|||||||
@@ -667,8 +667,19 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header">
|
<div class="card-header d-flex justify-content-between align-items-center">
|
||||||
<h6><i class="fas fa-list me-2"></i>Agent执行历史</h6>
|
<h6><i class="fas fa-list me-2"></i>Agent执行历史</h6>
|
||||||
|
<div class="btn-group btn-group-sm" role="group">
|
||||||
|
<button type="button" class="btn btn-outline-primary" onclick="dashboard.triggerSampleAction()">
|
||||||
|
<i class="fas fa-play me-1"></i>触发示例
|
||||||
|
</button>
|
||||||
|
<button type="button" class="btn btn-outline-secondary" onclick="dashboard.refreshAgentHistory()">
|
||||||
|
<i class="fas fa-sync-alt me-1"></i>刷新
|
||||||
|
</button>
|
||||||
|
<button type="button" class="btn btn-outline-danger" onclick="dashboard.clearAgentHistory()">
|
||||||
|
<i class="fas fa-trash me-1"></i>清空
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div id="agent-execution-history">
|
<div id="agent-execution-history">
|
||||||
|
|||||||
Reference in New Issue
Block a user