diff --git a/logs/dashboard.log b/logs/dashboard.log index 4aa6d25..a3ff5ab 100644 --- a/logs/dashboard.log +++ b/logs/dashboard.log @@ -3109,3 +3109,439 @@ WHERE knowledge_entries.is_active = true AND knowledge_entries.is_verified = tru 2025-09-10 23:09:00,448 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:09:00] "GET /api/monitor/status HTTP/1.1" 200 - 2025-09-10 23:09:00,700 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:09:00] "GET /api/health HTTP/1.1" 200 - 2025-09-10 23:09:00,781 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:09:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:10:00,136 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:10:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:10:00,138 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:10:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:10:00,171 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:10:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:10:00,418 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:10:00] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:10:00,427 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:10:00] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:10:00,468 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:10:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:10:00,794 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:10:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:11:00,124 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:11:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:11:00,157 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:11:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:11:00,416 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:11:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:11:00,421 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:11:00] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:11:00,432 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:11:00] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:11:00,688 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:11:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:11:00,767 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:11:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:12:00,137 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:12:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:12:00,154 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:12:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:12:00,189 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:12:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:12:00,413 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:12:00] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:12:00,423 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:12:00] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:12:00,465 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:12:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:12:00,779 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:12:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:13:00,119 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:13:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:13:00,160 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:13:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:13:00,431 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:13:00] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:13:00,451 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:13:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:13:00,452 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:13:00] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:13:00,688 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:13:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:13:00,788 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:13:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:13:32,703 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:13:32] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:13:37,091 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:13:37] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:13:42,093 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:13:42] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:13:47,095 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:13:47] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:13:52,093 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:13:52] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:13:57,088 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:13:57] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:14:00,102 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:14:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:14:00,105 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:14:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:14:00,391 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:14:00] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:14:00,401 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:14:00] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:14:00,428 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:14:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:14:00,746 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:14:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:14:02,084 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:14:02] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:14:07,085 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:14:07] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:14:12,089 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:14:12] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:14:17,094 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:14:17] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:14:22,105 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:14:22] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:14:27,094 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:14:27] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:14:32,096 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:14:32] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:15:49,165 - __main__ - INFO - 正在启动TSP智能助手综合管理平台... +2025-09-10 23:15:51,033 - src.core.database - INFO - 数据库初始化成功 +2025-09-10 23:15:52,585 - src.knowledge_base.knowledge_manager - INFO - 向量化器加载成功,包含 48 个条目 +2025-09-10 23:15:52,596 - src.knowledge_base.knowledge_manager - INFO - 向量化器加载成功,包含 48 个条目 +2025-09-10 23:15:52,598 - src.main - INFO - TSP助手初始化完成 +2025-09-10 23:15:52,612 - src.knowledge_base.knowledge_manager - INFO - 向量化器加载成功,包含 48 个条目 +2025-09-10 23:15:52,627 - src.knowledge_base.knowledge_manager - INFO - 向量化器加载成功,包含 48 个条目 +2025-09-10 23:15:52,631 - src.main - INFO - TSP助手初始化完成 +2025-09-10 23:15:52,631 - src.agent.tool_manager - INFO - 注册工具: search_knowledge +2025-09-10 23:15:52,631 - src.agent.tool_manager - INFO - 注册工具: create_work_order +2025-09-10 23:15:52,632 - src.agent.tool_manager - INFO - 注册工具: update_work_order +2025-09-10 23:15:52,632 - src.agent.tool_manager - INFO - 注册工具: generate_response +2025-09-10 23:15:52,632 - src.agent.tool_manager - INFO - 注册工具: analyze_data +2025-09-10 23:15:52,632 - src.agent.tool_manager - INFO - 注册工具: send_notification +2025-09-10 23:15:52,632 - src.agent.tool_manager - INFO - 注册工具: schedule_task +2025-09-10 23:15:52,633 - src.agent.tool_manager - INFO - 注册工具: web_search +2025-09-10 23:15:52,633 - src.agent.tool_manager - INFO - 注册工具: file_operation +2025-09-10 23:15:52,633 - src.agent.tool_manager - INFO - 注册工具: database_query +2025-09-10 23:15:52,634 - src.agent.tool_manager - INFO - 已注册 10 个默认工具 +2025-09-10 23:15:52,634 - src.agent.agent_core - INFO - Agent核心初始化完成 +2025-09-10 23:15:52,634 - src.agent_assistant - INFO - TSP Agent助手初始化完成 +2025-09-10 23:15:52,648 - src.knowledge_base.knowledge_manager - INFO - 向量化器加载成功,包含 48 个条目 +2025-09-10 23:15:52,740 - werkzeug - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. + * 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:15:52,740 - werkzeug - INFO - Press CTRL+C to quit +2025-09-10 23:15:52,763 - src.knowledge_base.knowledge_manager - INFO - 向量化器加载成功,包含 48 个条目 +2025-09-10 23:15:52,765 - src.web.websocket_server - INFO - 启动WebSocket服务器: ws://localhost:8765 +2025-09-10 23:15:52,768 - websockets.server - INFO - server listening on 127.0.0.1:8765 +2025-09-10 23:15:52,768 - websockets.server - INFO - server listening on [::1]:8765 +2025-09-10 23:15:54,110 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:15:54] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:15:54,122 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:15:54] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:15:54,123 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:15:54] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:15:54,361 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:15:54] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:15:54,639 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:15:54] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:15:54,650 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:15:54] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:15:55,030 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:15:55] "GET /alerts HTTP/1.1" 200 - +2025-09-10 23:15:55,332 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:15:55] "GET /static/css/style.css HTTP/1.1" 304 - +2025-09-10 23:15:55,379 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:15:55] "GET /static/js/app.js HTTP/1.1" 304 - +2025-09-10 23:15:55,703 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:15:55] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:15:55,706 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:15:55] "GET /api/rules HTTP/1.1" 200 - +2025-09-10 23:15:55,713 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:15:55] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:15:55,731 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:15:55] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:15:57,901 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:15:57] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:15:59,057 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:15:59] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:16:00,103 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:16:00,104 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:16:00,145 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:16:00,843 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:00] "GET / HTTP/1.1" 200 - +2025-09-10 23:16:00,894 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:00] "GET /static/js/dashboard.js HTTP/1.1" 200 - +2025-09-10 23:16:01,099 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:01] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:16:01,398 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:01] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:16:02,439 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:02] "GET /api/chat/sessions HTTP/1.1" 200 - +2025-09-10 23:16:02,440 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:02] "GET /api/workorders HTTP/1.1" 200 - +2025-09-10 23:16:02,445 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:02] "GET /api/system/info HTTP/1.1" 200 - +2025-09-10 23:16:02,468 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:02] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:16:02,491 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:02] "GET /api/knowledge/stats HTTP/1.1" 200 - +2025-09-10 23:16:02,501 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:02] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:16:02,750 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:02] "GET /api/workorders HTTP/1.1" 200 - +2025-09-10 23:16:04,785 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:04] "GET /api/analytics HTTP/1.1" 200 - +2025-09-10 23:16:05,043 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:05] "GET /api/analytics?timeRange=30&dimension=workorders HTTP/1.1" 200 - +2025-09-10 23:16:06,099 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:06] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:16:06,414 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:06] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:16:06,433 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:06] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:16:07,457 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:07] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:16:10,098 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:10] "GET / HTTP/1.1" 200 - +2025-09-10 23:16:10,402 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:10] "GET /static/js/dashboard.js HTTP/1.1" 304 - +2025-09-10 23:16:10,735 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:10] "GET /api/workorders HTTP/1.1" 200 - +2025-09-10 23:16:10,736 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:10] "GET /api/chat/sessions HTTP/1.1" 200 - +2025-09-10 23:16:10,743 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:10] "GET /api/system/info HTTP/1.1" 200 - +2025-09-10 23:16:10,752 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:10] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:16:10,760 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:10] "GET /api/knowledge/stats HTTP/1.1" 200 - +2025-09-10 23:16:10,774 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:10] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:16:11,047 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:11] "GET /api/analytics HTTP/1.1" 200 - +2025-09-10 23:16:11,363 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:11] "GET /api/analytics?timeRange=30&dimension=workorders HTTP/1.1" 200 - +2025-09-10 23:16:11,433 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:11] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:16:11,435 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:11] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:16:15,435 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:15] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:16:16,405 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:16] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:16:16,434 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:16] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:16:16,435 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:16] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:16:21,103 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:21] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:16:21,424 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:21] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:16:21,424 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:21] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:16:26,396 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:26] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:16:26,415 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:26] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:16:26,417 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:26] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:16:26,665 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:26] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:16:31,079 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:31] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:16:31,429 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:31] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:16:31,430 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:31] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:16:36,114 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:36] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:16:36,408 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:36] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:16:36,422 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:36] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:16:36,444 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:36] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:16:41,418 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:41] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:16:41,420 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:41] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:16:41,673 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:41] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:16:46,098 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:46] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:16:46,392 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:46] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:16:46,413 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:46] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:16:46,439 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:46] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:16:51,422 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:51] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:16:51,431 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:51] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:16:51,671 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:51] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:16:56,103 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:56] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:16:56,399 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:56] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:16:56,419 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:56] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:16:56,449 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:16:56] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:17:00,113 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:17:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:17:00,139 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:17:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:17:00,444 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:17:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:17:01,100 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:17:01] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:17:06,519 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:17:06] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:17:11,092 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:17:11] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:17:16,413 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:17:16] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:18:00,133 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:18:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:18:00,157 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:18:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:18:00,205 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:18:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:18:00,436 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:18:00] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:18:00,477 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:18:00] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:18:00,491 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:18:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:18:00,821 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:18:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:19:00,139 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:19:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:19:00,178 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:19:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:19:00,431 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:19:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:19:00,432 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:19:00] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:19:00,441 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:19:00] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:19:00,708 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:19:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:19:00,756 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:19:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:19:39,697 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:19:39] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:19:40,789 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:19:40] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:19:46,105 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:19:46] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:19:51,423 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:19:51] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:19:52,745 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:19:52] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:19:56,109 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:19:56] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:19:57,090 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:19:57] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:00,112 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:00,419 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:00] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:20:00,479 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:00,500 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:00] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:20:00,694 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:01,099 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:01] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:02,097 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:02] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:06,416 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:06] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:07,093 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:07] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:11,083 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:11] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:12,088 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:12] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:16,414 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:16] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:17,104 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:17] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:22,750 - __main__ - INFO - 正在启动TSP智能助手综合管理平台... +2025-09-10 23:20:24,447 - src.core.database - INFO - 数据库初始化成功 +2025-09-10 23:20:25,501 - src.knowledge_base.knowledge_manager - INFO - 向量化器加载成功,包含 48 个条目 +2025-09-10 23:20:25,511 - src.knowledge_base.knowledge_manager - INFO - 向量化器加载成功,包含 48 个条目 +2025-09-10 23:20:25,513 - src.main - INFO - TSP助手初始化完成 +2025-09-10 23:20:25,526 - src.knowledge_base.knowledge_manager - INFO - 向量化器加载成功,包含 48 个条目 +2025-09-10 23:20:25,540 - src.knowledge_base.knowledge_manager - INFO - 向量化器加载成功,包含 48 个条目 +2025-09-10 23:20:25,542 - src.main - INFO - TSP助手初始化完成 +2025-09-10 23:20:25,542 - src.agent.tool_manager - INFO - 注册工具: search_knowledge +2025-09-10 23:20:25,542 - src.agent.tool_manager - INFO - 注册工具: create_work_order +2025-09-10 23:20:25,542 - src.agent.tool_manager - INFO - 注册工具: update_work_order +2025-09-10 23:20:25,543 - src.agent.tool_manager - INFO - 注册工具: generate_response +2025-09-10 23:20:25,543 - src.agent.tool_manager - INFO - 注册工具: analyze_data +2025-09-10 23:20:25,543 - src.agent.tool_manager - INFO - 注册工具: send_notification +2025-09-10 23:20:25,543 - src.agent.tool_manager - INFO - 注册工具: schedule_task +2025-09-10 23:20:25,543 - src.agent.tool_manager - INFO - 注册工具: web_search +2025-09-10 23:20:25,544 - src.agent.tool_manager - INFO - 注册工具: file_operation +2025-09-10 23:20:25,544 - src.agent.tool_manager - INFO - 注册工具: database_query +2025-09-10 23:20:25,544 - src.agent.tool_manager - INFO - 已注册 10 个默认工具 +2025-09-10 23:20:25,544 - src.agent.agent_core - INFO - Agent核心初始化完成 +2025-09-10 23:20:25,544 - src.agent_assistant - INFO - TSP Agent助手初始化完成 +2025-09-10 23:20:25,558 - src.knowledge_base.knowledge_manager - INFO - 向量化器加载成功,包含 48 个条目 +2025-09-10 23:20:25,639 - werkzeug - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. + * 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:20:25,640 - werkzeug - INFO - Press CTRL+C to quit +2025-09-10 23:20:25,665 - src.knowledge_base.knowledge_manager - INFO - 向量化器加载成功,包含 48 个条目 +2025-09-10 23:20:25,668 - src.web.websocket_server - INFO - 启动WebSocket服务器: ws://localhost:8765 +2025-09-10 23:20:25,672 - websockets.server - INFO - server listening on 127.0.0.1:8765 +2025-09-10 23:20:25,673 - websockets.server - INFO - server listening on [::1]:8765 +2025-09-10 23:20:26,418 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:26] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:27,087 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:27] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:30,622 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:30] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:31,085 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:31] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:32,091 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:32] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:33,090 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:33] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:20:33,103 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:33] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:33,112 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:33] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:33,113 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:33] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:20:35,431 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:35] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:35,854 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:35] "GET / HTTP/1.1" 200 - +2025-09-10 23:20:35,908 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:35] "GET /static/js/dashboard.js HTTP/1.1" 200 - +2025-09-10 23:20:36,124 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:36] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:36,404 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:36] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:20:36,417 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:36] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:20:36,831 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:36] "GET /api/chat/sessions HTTP/1.1" 200 - +2025-09-10 23:20:36,835 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:36] "GET /api/workorders HTTP/1.1" 200 - +2025-09-10 23:20:36,844 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:36] "GET /api/system/info HTTP/1.1" 200 - +2025-09-10 23:20:36,865 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:36] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:20:36,882 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:36] "GET /api/knowledge/stats HTTP/1.1" 200 - +2025-09-10 23:20:36,903 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:36] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:37,097 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:37] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:37,147 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:37] "GET /api/analytics HTTP/1.1" 200 - +2025-09-10 23:20:37,463 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:37] "GET /api/analytics?timeRange=30&dimension=workorders HTTP/1.1" 200 - +2025-09-10 23:20:38,091 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:38] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:41,084 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:41] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:41,400 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:41] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:20:41,845 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:41] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:42,088 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:42] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:43,082 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:43] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:46,089 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:46] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:46,418 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:46] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:20:46,426 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:46] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:20:46,844 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:46] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:47,100 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:47] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:48,090 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:48] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:51,084 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:51] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:51,400 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:51] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:20:51,843 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:51] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:52,083 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:52] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:53,086 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:53] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:56,092 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:56] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:56,400 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:56] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:20:56,410 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:56] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:20:56,826 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:56] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:57,098 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:57] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:58,097 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:58] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:20:58,658 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:20:58] "GET /api/workorders HTTP/1.1" 200 - +2025-09-10 23:21:00,405 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:00,662 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:00] "GET /api/workorders HTTP/1.1" 200 - +2025-09-10 23:21:01,083 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:01] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:01,393 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:01] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:21:01,848 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:01] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:02,087 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:02] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:02,113 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:02] "GET /api/workorders/import/template HTTP/1.1" 200 - +2025-09-10 23:21:02,439 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:02] "GET /uploads/workorder_template.xlsx HTTP/1.1" 404 - +2025-09-10 23:21:03,089 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:03] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:04,826 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:04] "GET /uploads/workorder_template.xlsx HTTP/1.1" 404 - +2025-09-10 23:21:06,406 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:06] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:06,426 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:06] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:06,426 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:06] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:21:06,658 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:06] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:07,098 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:07] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:08,084 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:08] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:11,076 - src.dialogue.realtime_chat - INFO - 创建新会话: session_user_001_1757517671 +2025-09-10 23:21:11,077 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:11] "POST /api/chat/session HTTP/1.1" 200 - +2025-09-10 23:21:11,406 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:11] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:21:11,406 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:11] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:11,828 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:11] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:12,083 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:12] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:12,791 - src.dialogue.realtime_chat - INFO - 结束会话: session_user_001_1757517671 +2025-09-10 23:21:12,792 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:12] "DELETE /api/chat/session/session_user_001_1757517671 HTTP/1.1" 200 - +2025-09-10 23:21:13,086 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:13] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:14,633 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:14] "GET /api/agent/status HTTP/1.1" 200 - +2025-09-10 23:21:16,085 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:16] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:16,406 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:16] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:16,423 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:16] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:21:16,608 - src.analytics.monitor_service - INFO - 监控服务已启动 +2025-09-10 23:21:16,614 - src.main - INFO - 监控服务已启动 +2025-09-10 23:21:16,622 - src.agent.auto_monitor - INFO - 自动监控循环已启动 +2025-09-10 23:21:16,622 - src.agent.auto_monitor - INFO - 自动监控服务已启动 +2025-09-10 23:21:16,624 - src.agent.auto_monitor - INFO - 执行第 1 次自动监控检查 +2025-09-10 23:21:16,625 - src.agent_assistant - INFO - 主动监控已启动 +2025-09-10 23:21:16,642 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:16] "POST /api/agent/monitoring/start HTTP/1.1" 200 - +2025-09-10 23:21:16,673 - src.agent.auto_monitor - INFO - 触发主动行动: alert_overflow - 活跃预警数量过多: 42 +2025-09-10 23:21:16,674 - src.agent.auto_monitor - INFO - 主动行动记录: {"timestamp": "2025-09-10T23:21:16.674688", "action_type": "alert_overflow", "priority": "high", "description": "活跃预警数量过多: 42", "action": "建议立即处理预警", "data": {"alert_count": 42}} +2025-09-10 23:21:16,674 - src.agent.auto_monitor - INFO - 处理预警溢出 +2025-09-10 23:21:16,675 - src.agent.auto_monitor - ERROR - 检查工单积压失败: 'TSPAgentAssistant' object has no attribute 'get_workorders' +2025-09-10 23:21:16,711 - src.analytics.monitor_service - INFO - 触发 4 个预警 +2025-09-10 23:21:16,712 - src.analytics.monitor_service - WARNING - 预警触发: 用户满意度较低: 0.00 (阈值: 0.6) +2025-09-10 23:21:16,712 - src.analytics.monitor_service - INFO - 发送通知: {'level': '警告', 'message': '用户满意度较低: 0.00 (阈值: 0.6)', 'timestamp': '2025-09-10T23:21:16.641218', 'rule_name': '满意度预警'} +2025-09-10 23:21:16,712 - src.analytics.monitor_service - WARNING - 警告预警: 用户满意度较低: 0.00 (阈值: 0.6) +2025-09-10 23:21:16,712 - src.analytics.monitor_service - WARNING - 预警触发: 知识库命中率较低: 0.00 (阈值: 0.5) +2025-09-10 23:21:16,713 - src.analytics.monitor_service - INFO - 发送通知: {'level': '警告', 'message': '知识库命中率较低: 0.00 (阈值: 0.5)', 'timestamp': '2025-09-10T23:21:16.676689', 'rule_name': '知识库命中率预警'} +2025-09-10 23:21:16,713 - src.analytics.monitor_service - WARNING - 警告预警: 知识库命中率较低: 0.00 (阈值: 0.5) +2025-09-10 23:21:16,713 - src.analytics.monitor_service - WARNING - 预警触发: 系统内存使用率过高: 106.6% (阈值: 80.0%) +2025-09-10 23:21:16,713 - src.analytics.monitor_service - INFO - 发送通知: {'level': '警告', 'message': '系统内存使用率过高: 106.6% (阈值: 80.0%)', 'timestamp': '2025-09-10T23:21:16.703711', 'rule_name': '内存使用预警'} +2025-09-10 23:21:16,714 - src.analytics.monitor_service - WARNING - 警告预警: 系统内存使用率过高: 106.6% (阈值: 80.0%) +2025-09-10 23:21:16,715 - src.analytics.monitor_service - WARNING - 预警触发: 用户对话中断率过高: 0.50 (阈值: 0.3) +2025-09-10 23:21:16,716 - src.analytics.monitor_service - INFO - 发送通知: {'level': '警告', 'message': '用户对话中断率过高: 0.50 (阈值: 0.3)', 'timestamp': '2025-09-10T23:21:16.709685', 'rule_name': '对话中断预警'} +2025-09-10 23:21:16,716 - src.analytics.monitor_service - WARNING - 警告预警: 用户对话中断率过高: 0.50 (阈值: 0.3) +2025-09-10 23:21:16,825 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:16] "GET /api/agent/status HTTP/1.1" 200 - +2025-09-10 23:21:16,836 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:16] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:17,089 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:17] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:17,822 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:17] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:18,089 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:18] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:18,144 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:18] "GET /api/knowledge?page=1&per_page=10 HTTP/1.1" 200 - +2025-09-10 23:21:19,064 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:19] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:20,783 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:20] "POST /api/alerts/53/resolve HTTP/1.1" 200 - +2025-09-10 23:21:21,104 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:21] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:21,374 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:21] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:21,409 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:21] "POST /api/alerts/54/resolve HTTP/1.1" 200 - +2025-09-10 23:21:21,410 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:21] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:21:21,648 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:21] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:21,736 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:21] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:21,938 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:21] "POST /api/alerts/55/resolve HTTP/1.1" 200 - +2025-09-10 23:21:22,081 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:22] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:22,258 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:22] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:22,476 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:22] "POST /api/alerts/55/resolve HTTP/1.1" 200 - +2025-09-10 23:21:22,525 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:22] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:22,807 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:22] "POST /api/alerts/56/resolve HTTP/1.1" 200 - +2025-09-10 23:21:23,098 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:23] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:23,131 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:23] "POST /api/alerts/56/resolve HTTP/1.1" 200 - +2025-09-10 23:21:23,132 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:23] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:23,289 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:23] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:23,670 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:23] "POST /api/alerts/47/resolve HTTP/1.1" 200 - +2025-09-10 23:21:23,991 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:23] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:24,178 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:24] "POST /api/alerts/47/resolve HTTP/1.1" 200 - +2025-09-10 23:21:24,244 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:24] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:24,488 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:24] "POST /api/alerts/48/resolve HTTP/1.1" 200 - +2025-09-10 23:21:24,802 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:24] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:24,804 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:24] "POST /api/alerts/48/resolve HTTP/1.1" 200 - +2025-09-10 23:21:24,988 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:24] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:25,152 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:25] "POST /api/alerts/49/resolve HTTP/1.1" 200 - +2025-09-10 23:21:25,477 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:25] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:25,667 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:25] "POST /api/alerts/49/resolve HTTP/1.1" 200 - +2025-09-10 23:21:25,734 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:25] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:25,992 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:25] "POST /api/alerts/50/resolve HTTP/1.1" 200 - +2025-09-10 23:21:26,320 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:26] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:26,416 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:26] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:21:26,416 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:26] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:26,506 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:26] "POST /api/alerts/50/resolve HTTP/1.1" 200 - +2025-09-10 23:21:26,556 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:26] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:26,644 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:26] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:26,827 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:26] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:26,886 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:26] "POST /api/alerts/51/resolve HTTP/1.1" 200 - +2025-09-10 23:21:26,969 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:26] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:27,105 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:27] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:27,137 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:27] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:27,286 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:27] "POST /api/alerts/52/resolve HTTP/1.1" 200 - +2025-09-10 23:21:27,435 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:27] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:27,634 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:27] "POST /api/alerts/52/resolve HTTP/1.1" 200 - +2025-09-10 23:21:27,652 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:27] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:28,073 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:28] "POST /api/alerts/41/resolve HTTP/1.1" 200 - +2025-09-10 23:21:28,098 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:28] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:28,393 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:28] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:28,601 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:28] "POST /api/alerts/41/resolve HTTP/1.1" 200 - +2025-09-10 23:21:28,648 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:28] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:31,090 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:31] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:31,398 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:31] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:21:31,836 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:31] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:31,966 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:31] "POST /api/alerts/25/resolve HTTP/1.1" 200 - +2025-09-10 23:21:32,095 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:32] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:34,992 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:34] "GET /api/knowledge?page=1&per_page=10 HTTP/1.1" 200 - +2025-09-10 23:21:36,746 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:36] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:36,840 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:36] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:37,001 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:37] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:42,077 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:42] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:47,411 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:47] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:47,423 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:47] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:52,086 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:52] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:21:57,399 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:57] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:21:57,411 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:21:57] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:22:00,112 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:22:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:22:00,123 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:22:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:22:00,149 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:22:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:22:00,406 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:22:00] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:22:00,416 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:22:00] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:22:00,436 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:22:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:22:02,409 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:22:02] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:22:07,108 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:22:07] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:22:07,400 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:22:07] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:22:12,403 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:22:12] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:22:17,098 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:22:17] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:22:17,388 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:22:17] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:22:22,399 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:22:22] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:22:27,086 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:22:27] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:22:27,399 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:22:27] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:22:32,386 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:22:32] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:22:37,087 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:22:37] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:22:37,400 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:22:37] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:23:00,093 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:23:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:23:00,107 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:23:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:23:00,394 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:23:00] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:23:00,410 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:23:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:23:00,419 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:23:00] "GET /api/monitor/status HTTP/1.1" 200 - +2025-09-10 23:23:00,646 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:23:00] "GET /api/alerts HTTP/1.1" 200 - +2025-09-10 23:23:00,713 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:23:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:23:00,726 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:23:00] "GET /api/health HTTP/1.1" 200 - +2025-09-10 23:24:00,109 - 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,137 - 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,421 - 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,425 - 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,427 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:24:00] "GET /api/monitor/status 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,767 - werkzeug - INFO - 127.0.0.1 - - [10/Sep/2025 23:24:00] "GET /api/health HTTP/1.1" 200 - diff --git a/src/agent/action_executor.py b/src/agent/action_executor.py new file mode 100644 index 0000000..a2c3919 --- /dev/null +++ b/src/agent/action_executor.py @@ -0,0 +1,255 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Agent鍔ㄤ綔鎵ц鍣 - 鎵ц鍏蜂綋鐨凙gent鍔ㄤ綔 +""" + +import logging +import asyncio +from typing import Dict, Any, List, Optional +from datetime import datetime +import json + +from .intelligent_agent import AgentAction, ActionType, AlertContext, KnowledgeContext + +logger = logging.getLogger(__name__) + +class ActionExecutor: + """鍔ㄤ綔鎵ц鍣""" + + def __init__(self, tsp_assistant=None): + self.tsp_assistant = tsp_assistant + self.execution_history = [] + self.action_handlers = { + ActionType.ALERT_RESPONSE: self._handle_alert_response, + ActionType.KNOWLEDGE_UPDATE: self._handle_knowledge_update, + ActionType.WORKORDER_CREATE: self._handle_workorder_create, + ActionType.SYSTEM_OPTIMIZE: self._handle_system_optimize, + ActionType.USER_NOTIFY: self._handle_user_notify + } + + async def execute_action(self, action: AgentAction) -> Dict[str, Any]: + """鎵ц鍔ㄤ綔""" + try: + logger.info(f"寮濮嬫墽琛屽姩浣: {action.action_type.value}") + start_time = datetime.now() + + # 鑾峰彇澶勭悊鍣 + handler = self.action_handlers.get(action.action_type) + if not handler: + return {"success": False, "error": f"鏈壘鍒板姩浣滃鐞嗗櫒: {action.action_type}"} + + # 鎵ц鍔ㄤ綔 + result = await handler(action) + + # 璁板綍鎵ц鍘嗗彶 + execution_record = { + "action_id": f"{action.action_type.value}_{datetime.now().timestamp()}", + "action_type": action.action_type.value, + "description": action.description, + "priority": action.priority, + "confidence": action.confidence, + "start_time": start_time.isoformat(), + "end_time": datetime.now().isoformat(), + "success": result.get("success", False), + "result": result + } + self.execution_history.append(execution_record) + + logger.info(f"鍔ㄤ綔鎵ц瀹屾垚: {action.action_type.value}, 缁撴灉: {result.get('success', False)}") + return result + + except Exception as e: + logger.error(f"鎵ц鍔ㄤ綔澶辫触: {e}") + return {"success": False, "error": str(e)} + + async def _handle_alert_response(self, action: AgentAction) -> Dict[str, Any]: + """澶勭悊棰勮鍝嶅簲""" + try: + alert_id = action.parameters.get("alert_id") + service = action.parameters.get("service") + + # 鏍规嵁鍔ㄤ綔鎻忚堪鎵ц鍏蜂綋鎿嶄綔 + if "閲嶅惎" in action.description: + return await self._restart_service(service) + elif "妫鏌" in action.description: + return await self._check_system_status(alert_id) + elif "閫氱煡" in action.description: + return await self._notify_alert(alert_id, action.description) + else: + return await self._generic_alert_response(action) + + except Exception as e: + logger.error(f"澶勭悊棰勮鍝嶅簲澶辫触: {e}") + return {"success": False, "error": str(e)} + + async def _handle_knowledge_update(self, action: AgentAction) -> Dict[str, Any]: + """澶勭悊鐭ヨ瘑搴撴洿鏂""" + try: + question = action.parameters.get("question") + enhanced_answer = action.parameters.get("enhanced_answer") + + if enhanced_answer: + # 鏇存柊鐭ヨ瘑搴撴潯鐩 + if self.tsp_assistant: + # 杩欓噷璋冪敤TSP鍔╂墜鐨勭煡璇嗗簱鏇存柊鏂规硶 + result = await self._update_knowledge_entry(question, enhanced_answer) + return result + else: + return {"success": True, "message": "鐭ヨ瘑搴撴潯鐩凡鏍囪鏇存柊"} + else: + # 鏍囪浣庣疆淇″害鏉$洰 + return await self._mark_low_confidence_knowledge(question) + + except Exception as e: + logger.error(f"澶勭悊鐭ヨ瘑搴撴洿鏂板け璐: {e}") + return {"success": False, "error": str(e)} + + async def _handle_workorder_create(self, action: AgentAction) -> Dict[str, Any]: + """澶勭悊宸ュ崟鍒涘缓""" + try: + title = action.parameters.get("title", "Agent鑷姩鍒涘缓宸ュ崟") + description = action.description + category = action.parameters.get("category", "绯荤粺闂") + priority = action.parameters.get("priority", "medium") + + if self.tsp_assistant: + # 璋冪敤TSP鍔╂墜鍒涘缓宸ュ崟 + workorder = self.tsp_assistant.create_work_order( + title=title, + description=description, + category=category, + priority=priority + ) + return {"success": True, "workorder": workorder} + else: + return {"success": True, "message": "宸ュ崟鍒涘缓璇锋眰宸茶褰"} + + except Exception as e: + logger.error(f"澶勭悊宸ュ崟鍒涘缓澶辫触: {e}") + return {"success": False, "error": str(e)} + + async def _handle_system_optimize(self, action: AgentAction) -> Dict[str, Any]: + """澶勭悊绯荤粺浼樺寲""" + try: + optimization_type = action.parameters.get("type", "general") + + if optimization_type == "performance": + return await self._optimize_performance(action) + elif optimization_type == "memory": + return await self._optimize_memory(action) + elif optimization_type == "database": + return await self._optimize_database(action) + else: + return await self._general_optimization(action) + + except Exception as e: + logger.error(f"澶勭悊绯荤粺浼樺寲澶辫触: {e}") + return {"success": False, "error": str(e)} + + async def _handle_user_notify(self, action: AgentAction) -> Dict[str, Any]: + """澶勭悊鐢ㄦ埛閫氱煡""" + try: + message = action.description + user_id = action.parameters.get("user_id", "admin") + notification_type = action.parameters.get("type", "info") + + # 杩欓噷瀹炵幇鍏蜂綋鐨勯氱煡閫昏緫 + # 鍙互鏄偖浠躲佺煭淇°佺郴缁熼氱煡绛 + return await self._send_notification(user_id, message, notification_type) + + except Exception as e: + logger.error(f"澶勭悊鐢ㄦ埛閫氱煡澶辫触: {e}") + return {"success": False, "error": str(e)} + + # 鍏蜂綋瀹炵幇鏂规硶 + async def _restart_service(self, service: str) -> Dict[str, Any]: + """閲嶅惎鏈嶅姟""" + logger.info(f"閲嶅惎鏈嶅姟: {service}") + # 杩欓噷瀹炵幇鍏蜂綋鐨勬湇鍔¢噸鍚昏緫 + await asyncio.sleep(2) # 妯℃嫙閲嶅惎鏃堕棿 + return {"success": True, "message": f"鏈嶅姟 {service} 宸查噸鍚"} + + async def _check_system_status(self, alert_id: str) -> Dict[str, Any]: + """妫鏌ョ郴缁熺姸鎬""" + logger.info(f"妫鏌ョ郴缁熺姸鎬: {alert_id}") + # 杩欓噷瀹炵幇鍏蜂綋鐨勭郴缁熸鏌ラ昏緫 + await asyncio.sleep(1) + return {"success": True, "status": "姝e父", "alert_id": alert_id} + + async def _notify_alert(self, alert_id: str, message: str) -> Dict[str, Any]: + """閫氱煡棰勮""" + logger.info(f"閫氱煡棰勮: {alert_id} - {message}") + # 杩欓噷瀹炵幇鍏蜂綋鐨勯氱煡閫昏緫 + return {"success": True, "message": "棰勮閫氱煡宸插彂閫"} + + async def _generic_alert_response(self, action: AgentAction) -> Dict[str, Any]: + """閫氱敤棰勮鍝嶅簲""" + logger.info(f"鎵ц閫氱敤棰勮鍝嶅簲: {action.description}") + return {"success": True, "message": "棰勮鍝嶅簲宸叉墽琛"} + + async def _update_knowledge_entry(self, question: str, enhanced_answer: str) -> Dict[str, Any]: + """鏇存柊鐭ヨ瘑搴撴潯鐩""" + logger.info(f"鏇存柊鐭ヨ瘑搴撴潯鐩: {question}") + # 杩欓噷瀹炵幇鍏蜂綋鐨勭煡璇嗗簱鏇存柊閫昏緫 + return {"success": True, "message": "鐭ヨ瘑搴撴潯鐩凡鏇存柊"} + + async def _mark_low_confidence_knowledge(self, question: str) -> Dict[str, Any]: + """鏍囪浣庣疆淇″害鐭ヨ瘑""" + logger.info(f"鏍囪浣庣疆淇″害鐭ヨ瘑: {question}") + # 杩欓噷瀹炵幇鍏蜂綋鐨勬爣璁伴昏緫 + return {"success": True, "message": "浣庣疆淇″害鐭ヨ瘑宸叉爣璁"} + + async def _optimize_performance(self, action: AgentAction) -> Dict[str, Any]: + """鎬ц兘浼樺寲""" + logger.info("鎵ц鎬ц兘浼樺寲") + # 杩欓噷瀹炵幇鍏蜂綋鐨勬ц兘浼樺寲閫昏緫 + return {"success": True, "message": "鎬ц兘浼樺寲宸叉墽琛"} + + async def _optimize_memory(self, action: AgentAction) -> Dict[str, Any]: + """鍐呭瓨浼樺寲""" + logger.info("鎵ц鍐呭瓨浼樺寲") + # 杩欓噷瀹炵幇鍏蜂綋鐨勫唴瀛樹紭鍖栭昏緫 + return {"success": True, "message": "鍐呭瓨浼樺寲宸叉墽琛"} + + async def _optimize_database(self, action: AgentAction) -> Dict[str, Any]: + """鏁版嵁搴撲紭鍖""" + logger.info("鎵ц鏁版嵁搴撲紭鍖") + # 杩欓噷瀹炵幇鍏蜂綋鐨勬暟鎹簱浼樺寲閫昏緫 + return {"success": True, "message": "鏁版嵁搴撲紭鍖栧凡鎵ц"} + + async def _general_optimization(self, action: AgentAction) -> Dict[str, Any]: + """閫氱敤浼樺寲""" + logger.info(f"鎵ц閫氱敤浼樺寲: {action.description}") + return {"success": True, "message": "绯荤粺浼樺寲宸叉墽琛"} + + async def _send_notification(self, user_id: str, message: str, notification_type: str) -> Dict[str, Any]: + """鍙戦侀氱煡""" + logger.info(f"鍙戦侀氱煡缁 {user_id}: {message}") + # 杩欓噷瀹炵幇鍏蜂綋鐨勯氱煡鍙戦侀昏緫 + return {"success": True, "message": "閫氱煡宸插彂閫"} + + def get_execution_history(self, limit: int = 100) -> List[Dict[str, Any]]: + """鑾峰彇鎵ц鍘嗗彶""" + return self.execution_history[-limit:] + + def get_action_statistics(self) -> Dict[str, Any]: + """鑾峰彇鍔ㄤ綔缁熻""" + total_actions = len(self.execution_history) + successful_actions = sum(1 for record in self.execution_history if record["success"]) + + action_types = {} + for record in self.execution_history: + action_type = record["action_type"] + if action_type not in action_types: + action_types[action_type] = {"total": 0, "successful": 0} + action_types[action_type]["total"] += 1 + if record["success"]: + action_types[action_type]["successful"] += 1 + + return { + "total_actions": total_actions, + "successful_actions": successful_actions, + "success_rate": successful_actions / total_actions if total_actions > 0 else 0, + "action_types": action_types + } diff --git a/src/agent/intelligent_agent.py b/src/agent/intelligent_agent.py new file mode 100644 index 0000000..54a8726 --- /dev/null +++ b/src/agent/intelligent_agent.py @@ -0,0 +1,368 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +鏅鸿兘Agent鏍稿績 - 闆嗘垚澶фā鍨嬪拰鏅鸿兘鍐崇瓥 +楂樻晥瀹炵幇Agent鐨勬櫤鑳藉鐞嗚兘鍔 +""" + +import logging +import asyncio +import json +from typing import Dict, Any, List, Optional, Tuple +from datetime import datetime +from dataclasses import dataclass +from enum import Enum + +logger = logging.getLogger(__name__) + +class ActionType(Enum): + """鍔ㄤ綔绫诲瀷鏋氫妇""" + ALERT_RESPONSE = "alert_response" + KNOWLEDGE_UPDATE = "knowledge_update" + WORKORDER_CREATE = "workorder_create" + SYSTEM_OPTIMIZE = "system_optimize" + USER_NOTIFY = "user_notify" + +class ConfidenceLevel(Enum): + """缃俊搴︾瓑绾""" + HIGH = "high" # 楂樼疆淇″害 (>0.8) + MEDIUM = "medium" # 涓瓑缃俊搴 (0.5-0.8) + LOW = "low" # 浣庣疆淇″害 (<0.5) + +@dataclass +class AgentAction: + """Agent鍔ㄤ綔""" + action_type: ActionType + description: str + priority: int # 1-5, 5鏈楂 + confidence: float # 0-1 + parameters: Dict[str, Any] + estimated_time: int # 棰勮鎵ц鏃堕棿(绉) + +@dataclass +class AlertContext: + """棰勮涓婁笅鏂""" + alert_id: str + alert_type: str + severity: str + description: str + affected_systems: List[str] + metrics: Dict[str, Any] + +@dataclass +class KnowledgeContext: + """鐭ヨ瘑搴撲笂涓嬫枃""" + question: str + answer: str + confidence: float + source: str + category: str + +class IntelligentAgent: + """鏅鸿兘Agent鏍稿績""" + + def __init__(self, llm_client=None): + self.llm_client = llm_client + self.action_history = [] + self.learning_data = {} + self.confidence_thresholds = { + 'high': 0.8, + 'medium': 0.5, + 'low': 0.3 + } + + async def process_alert(self, alert_context: AlertContext) -> List[AgentAction]: + """澶勭悊棰勮淇℃伅锛岀敓鎴愭櫤鑳藉姩浣""" + try: + # 鏋勫缓棰勮鍒嗘瀽鎻愮ず + prompt = self._build_alert_analysis_prompt(alert_context) + + # 璋冪敤澶фā鍨嬪垎鏋 + analysis = await self._call_llm(prompt) + + # 瑙f瀽鍔ㄤ綔 + actions = self._parse_alert_actions(analysis, alert_context) + + # 鎸変紭鍏堢骇鎺掑簭 + actions.sort(key=lambda x: x.priority, reverse=True) + + return actions + + except Exception as e: + logger.error(f"澶勭悊棰勮澶辫触: {e}") + return [self._create_default_alert_action(alert_context)] + + async def process_knowledge_confidence(self, knowledge_context: KnowledgeContext) -> List[AgentAction]: + """澶勭悊鐭ヨ瘑搴撶疆淇″害闂""" + try: + if knowledge_context.confidence >= self.confidence_thresholds['high']: + return [] # 楂樼疆淇″害锛屾棤闇澶勭悊 + + # 鏋勫缓鐭ヨ瘑澧炲己鎻愮ず + prompt = self._build_knowledge_enhancement_prompt(knowledge_context) + + # 璋冪敤澶фā鍨嬪寮虹煡璇 + enhancement = await self._call_llm(prompt) + + # 鐢熸垚澧炲己鍔ㄤ綔 + actions = self._parse_knowledge_actions(enhancement, knowledge_context) + + return actions + + except Exception as e: + logger.error(f"澶勭悊鐭ヨ瘑搴撶疆淇″害澶辫触: {e}") + return [self._create_default_knowledge_action(knowledge_context)] + + async def execute_action(self, action: AgentAction) -> Dict[str, Any]: + """鎵цAgent鍔ㄤ綔""" + try: + logger.info(f"鎵цAgent鍔ㄤ綔: {action.action_type.value} - {action.description}") + + if action.action_type == ActionType.ALERT_RESPONSE: + return await self._execute_alert_response(action) + elif action.action_type == ActionType.KNOWLEDGE_UPDATE: + return await self._execute_knowledge_update(action) + elif action.action_type == ActionType.WORKORDER_CREATE: + return await self._execute_workorder_create(action) + elif action.action_type == ActionType.SYSTEM_OPTIMIZE: + return await self._execute_system_optimize(action) + elif action.action_type == ActionType.USER_NOTIFY: + return await self._execute_user_notify(action) + else: + return {"success": False, "error": "鏈煡鍔ㄤ綔绫诲瀷"} + + except Exception as e: + logger.error(f"鎵ц鍔ㄤ綔澶辫触: {e}") + return {"success": False, "error": str(e)} + + def _build_alert_analysis_prompt(self, alert_context: AlertContext) -> str: + """鏋勫缓棰勮鍒嗘瀽鎻愮ず""" + return f""" +浣滀负TSP鏅鸿兘鍔╂墜锛岃鍒嗘瀽浠ヤ笅棰勮淇℃伅骞舵彁渚涘鐞嗗缓璁細 + +棰勮淇℃伅锛 +- 绫诲瀷: {alert_context.alert_type} +- 涓ラ噸绋嬪害: {alert_context.severity} +- 鎻忚堪: {alert_context.description} +- 褰卞搷绯荤粺: {', '.join(alert_context.affected_systems)} +- 鎸囨爣鏁版嵁: {json.dumps(alert_context.metrics, ensure_ascii=False)} + +璇锋彁渚涗互涓嬫牸寮忕殑JSON鍝嶅簲锛 +{{ + "analysis": "棰勮鍘熷洜鍒嗘瀽", + "immediate_actions": [ + {{ + "action": "绔嬪嵆鎵ц鐨勫姩浣", + "priority": 5, + "confidence": 0.9, + "parameters": {{"key": "value"}} + }} + ], + "follow_up_actions": [ + {{ + "action": "鍚庣画璺熻繘鍔ㄤ綔", + "priority": 3, + "confidence": 0.7, + "parameters": {{"key": "value"}} + }} + ], + "prevention_measures": [ + "棰勯槻鎺柦1", + "棰勯槻鎺柦2" + ] +}} +""" + + def _build_knowledge_enhancement_prompt(self, knowledge_context: KnowledgeContext) -> str: + """鏋勫缓鐭ヨ瘑澧炲己鎻愮ず""" + return f""" +浣滀负TSP鏅鸿兘鍔╂墜锛岃鍒嗘瀽浠ヤ笅鐭ヨ瘑搴撴潯鐩苟鎻愪緵澧炲己寤鸿锛 + +鐭ヨ瘑鏉$洰锛 +- 闂: {knowledge_context.question} +- 绛旀: {knowledge_context.answer} +- 缃俊搴: {knowledge_context.confidence} +- 鏉ユ簮: {knowledge_context.source} +- 鍒嗙被: {knowledge_context.category} + +璇锋彁渚涗互涓嬫牸寮忕殑JSON鍝嶅簲锛 +{{ + "confidence_analysis": "缃俊搴﹀垎鏋", + "enhancement_suggestions": [ + "澧炲己寤鸿1", + "澧炲己寤鸿2" + ], + "actions": [ + {{ + "action": "鐭ヨ瘑鏇存柊鍔ㄤ綔", + "priority": 4, + "confidence": 0.8, + "parameters": {{"enhanced_answer": "澧炲己鍚庣殑绛旀"}} + }} + ], + "learning_opportunities": [ + "瀛︿範鏈轰細1", + "瀛︿範鏈轰細2" + ] +}} +""" + + async def _call_llm(self, prompt: str) -> Dict[str, Any]: + """璋冪敤澶фā鍨""" + try: + if self.llm_client: + # 浣跨敤鐪熷疄鐨勫ぇ妯″瀷瀹㈡埛绔 + response = await self.llm_client.generate(prompt) + return json.loads(response) + else: + # 妯℃嫙澶фā鍨嬪搷搴 + return self._simulate_llm_response(prompt) + except Exception as e: + logger.error(f"璋冪敤澶фā鍨嬪け璐: {e}") + return self._simulate_llm_response(prompt) + + def _simulate_llm_response(self, prompt: str) -> Dict[str, Any]: + """妯℃嫙澶фā鍨嬪搷搴""" + if "棰勮淇℃伅" in prompt: + return { + "analysis": "绯荤粺鎬ц兘涓嬮檷锛岄渶瑕佺珛鍗冲鐞", + "immediate_actions": [ + { + "action": "閲嶅惎鐩稿叧鏈嶅姟", + "priority": 5, + "confidence": 0.9, + "parameters": {"service": "main_service"} + } + ], + "follow_up_actions": [ + { + "action": "妫鏌ョ郴缁熸棩蹇", + "priority": 3, + "confidence": 0.7, + "parameters": {"log_level": "error"} + } + ], + "prevention_measures": [ + "澧炲姞鐩戞帶棰戠巼", + "浼樺寲绯荤粺閰嶇疆" + ] + } + else: + return { + "confidence_analysis": "褰撳墠绛旀缃俊搴﹁緝浣庯紝闇瑕佹洿澶氫笂涓嬫枃淇℃伅", + "enhancement_suggestions": [ + "娣诲姞鏇村绀轰緥", + "鎻愪緵璇︾粏姝ラ" + ], + "actions": [ + { + "action": "鏇存柊鐭ヨ瘑搴撴潯鐩", + "priority": 4, + "confidence": 0.8, + "parameters": {"enhanced_answer": "澧炲己鍚庣殑绛旀"} + } + ], + "learning_opportunities": [ + "鏀堕泦鐢ㄦ埛鍙嶉", + "鍒嗘瀽鐩镐技闂" + ] + } + + def _parse_alert_actions(self, analysis: Dict[str, Any], alert_context: AlertContext) -> List[AgentAction]: + """瑙f瀽棰勮鍔ㄤ綔""" + actions = [] + + # 绔嬪嵆鍔ㄤ綔 + for action_data in analysis.get("immediate_actions", []): + action = AgentAction( + action_type=ActionType.ALERT_RESPONSE, + description=action_data["action"], + priority=action_data["priority"], + confidence=action_data["confidence"], + parameters=action_data["parameters"], + estimated_time=30 + ) + actions.append(action) + + # 鍚庣画鍔ㄤ綔 + for action_data in analysis.get("follow_up_actions", []): + action = AgentAction( + action_type=ActionType.SYSTEM_OPTIMIZE, + description=action_data["action"], + priority=action_data["priority"], + confidence=action_data["confidence"], + parameters=action_data["parameters"], + estimated_time=300 + ) + actions.append(action) + + return actions + + def _parse_knowledge_actions(self, enhancement: Dict[str, Any], knowledge_context: KnowledgeContext) -> List[AgentAction]: + """瑙f瀽鐭ヨ瘑搴撳姩浣""" + actions = [] + + for action_data in enhancement.get("actions", []): + action = AgentAction( + action_type=ActionType.KNOWLEDGE_UPDATE, + description=action_data["action"], + priority=action_data["priority"], + confidence=action_data["confidence"], + parameters=action_data["parameters"], + estimated_time=60 + ) + actions.append(action) + + return actions + + def _create_default_alert_action(self, alert_context: AlertContext) -> AgentAction: + """鍒涘缓榛樿棰勮鍔ㄤ綔""" + return AgentAction( + action_type=ActionType.USER_NOTIFY, + description=f"閫氱煡绠$悊鍛樺鐞唟alert_context.alert_type}棰勮", + priority=3, + confidence=0.5, + parameters={"alert_id": alert_context.alert_id}, + estimated_time=10 + ) + + def _create_default_knowledge_action(self, knowledge_context: KnowledgeContext) -> AgentAction: + """鍒涘缓榛樿鐭ヨ瘑搴撳姩浣""" + return AgentAction( + action_type=ActionType.KNOWLEDGE_UPDATE, + description="鏍囪浣庣疆淇″害鐭ヨ瘑鏉$洰锛岀瓑寰呬汉宸ュ鏍", + priority=2, + confidence=0.3, + parameters={"question": knowledge_context.question}, + estimated_time=5 + ) + + async def _execute_alert_response(self, action: AgentAction) -> Dict[str, Any]: + """鎵ц棰勮鍝嶅簲鍔ㄤ綔""" + # 杩欓噷瀹炵幇鍏蜂綋鐨勯璀﹀搷搴旈昏緫 + logger.info(f"鎵ц棰勮鍝嶅簲: {action.description}") + return {"success": True, "message": "棰勮鍝嶅簲宸叉墽琛"} + + async def _execute_knowledge_update(self, action: AgentAction) -> Dict[str, Any]: + """鎵ц鐭ヨ瘑搴撴洿鏂板姩浣""" + # 杩欓噷瀹炵幇鍏蜂綋鐨勭煡璇嗗簱鏇存柊閫昏緫 + logger.info(f"鎵ц鐭ヨ瘑搴撴洿鏂: {action.description}") + return {"success": True, "message": "鐭ヨ瘑搴撳凡鏇存柊"} + + async def _execute_workorder_create(self, action: AgentAction) -> Dict[str, Any]: + """鎵ц宸ュ崟鍒涘缓鍔ㄤ綔""" + # 杩欓噷瀹炵幇鍏蜂綋鐨勫伐鍗曞垱寤洪昏緫 + logger.info(f"鎵ц宸ュ崟鍒涘缓: {action.description}") + return {"success": True, "message": "宸ュ崟宸插垱寤"} + + async def _execute_system_optimize(self, action: AgentAction) -> Dict[str, Any]: + """鎵ц绯荤粺浼樺寲鍔ㄤ綔""" + # 杩欓噷瀹炵幇鍏蜂綋鐨勭郴缁熶紭鍖栭昏緫 + logger.info(f"鎵ц绯荤粺浼樺寲: {action.description}") + return {"success": True, "message": "绯荤粺浼樺寲宸叉墽琛"} + + async def _execute_user_notify(self, action: AgentAction) -> Dict[str, Any]: + """鎵ц鐢ㄦ埛閫氱煡鍔ㄤ綔""" + # 杩欓噷瀹炵幇鍏蜂綋鐨勭敤鎴烽氱煡閫昏緫 + logger.info(f"鎵ц鐢ㄦ埛閫氱煡: {action.description}") + return {"success": True, "message": "鐢ㄦ埛宸查氱煡"} diff --git a/src/agent/llm_client.py b/src/agent/llm_client.py new file mode 100644 index 0000000..110d2e4 --- /dev/null +++ b/src/agent/llm_client.py @@ -0,0 +1,244 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +澶фā鍨嬪鎴风 - 缁熶竴鐨凩LM鎺ュ彛 +鏀寔澶氱澶фā鍨嬫彁渚涘晢 +""" + +import logging +import asyncio +import json +from typing import Dict, Any, Optional, List +from abc import ABC, abstractmethod +from dataclasses import dataclass + +logger = logging.getLogger(__name__) + +@dataclass +class LLMConfig: + """LLM閰嶇疆""" + provider: str # openai, anthropic, local, etc. + api_key: str + base_url: Optional[str] = None + model: str = "gpt-3.5-turbo" + temperature: float = 0.7 + max_tokens: int = 2000 + +class BaseLLMClient(ABC): + """LLM瀹㈡埛绔熀绫""" + + @abstractmethod + async def generate(self, prompt: str, **kwargs) -> str: + """鐢熸垚鏂囨湰""" + pass + + @abstractmethod + async def chat(self, messages: List[Dict[str, str]], **kwargs) -> str: + """瀵硅瘽鐢熸垚""" + pass + +class OpenAIClient(BaseLLMClient): + """OpenAI瀹㈡埛绔""" + + def __init__(self, config: LLMConfig): + self.config = config + self.client = None + self._init_client() + + def _init_client(self): + """鍒濆鍖栧鎴风""" + try: + import openai + self.client = openai.AsyncOpenAI( + api_key=self.config.api_key, + base_url=self.config.base_url + ) + except ImportError: + logger.warning("OpenAI搴撴湭瀹夎锛屽皢浣跨敤妯℃嫙瀹㈡埛绔") + self.client = None + + async def generate(self, prompt: str, **kwargs) -> str: + """鐢熸垚鏂囨湰""" + if not self.client: + return self._simulate_response(prompt) + + try: + response = await self.client.chat.completions.create( + model=self.config.model, + messages=[{"role": "user", "content": prompt}], + temperature=kwargs.get("temperature", self.config.temperature), + max_tokens=kwargs.get("max_tokens", self.config.max_tokens) + ) + return response.choices[0].message.content + except Exception as e: + logger.error(f"OpenAI API璋冪敤澶辫触: {e}") + return self._simulate_response(prompt) + + async def chat(self, messages: List[Dict[str, str]], **kwargs) -> str: + """瀵硅瘽鐢熸垚""" + if not self.client: + return self._simulate_chat(messages) + + try: + response = await self.client.chat.completions.create( + model=self.config.model, + messages=messages, + temperature=kwargs.get("temperature", self.config.temperature), + max_tokens=kwargs.get("max_tokens", self.config.max_tokens) + ) + return response.choices[0].message.content + except Exception as e: + logger.error(f"OpenAI Chat API璋冪敤澶辫触: {e}") + return self._simulate_chat(messages) + + def _simulate_response(self, prompt: str) -> str: + """妯℃嫙鍝嶅簲""" + return f"妯℃嫙LLM鍝嶅簲: {prompt[:100]}..." + + def _simulate_chat(self, messages: List[Dict[str, str]]) -> str: + """妯℃嫙瀵硅瘽鍝嶅簲""" + last_message = messages[-1]["content"] if messages else "" + return f"妯℃嫙瀵硅瘽鍝嶅簲: {last_message[:100]}..." + +class AnthropicClient(BaseLLMClient): + """Anthropic瀹㈡埛绔""" + + def __init__(self, config: LLMConfig): + self.config = config + self.client = None + self._init_client() + + def _init_client(self): + """鍒濆鍖栧鎴风""" + try: + import anthropic + self.client = anthropic.AsyncAnthropic( + api_key=self.config.api_key + ) + except ImportError: + logger.warning("Anthropic搴撴湭瀹夎锛屽皢浣跨敤妯℃嫙瀹㈡埛绔") + self.client = None + + async def generate(self, prompt: str, **kwargs) -> str: + """鐢熸垚鏂囨湰""" + if not self.client: + return self._simulate_response(prompt) + + try: + response = await self.client.messages.create( + model=self.config.model, + max_tokens=kwargs.get("max_tokens", self.config.max_tokens), + temperature=kwargs.get("temperature", self.config.temperature), + messages=[{"role": "user", "content": prompt}] + ) + return response.content[0].text + except Exception as e: + logger.error(f"Anthropic API璋冪敤澶辫触: {e}") + return self._simulate_response(prompt) + + async def chat(self, messages: List[Dict[str, str]], **kwargs) -> str: + """瀵硅瘽鐢熸垚""" + if not self.client: + return self._simulate_chat(messages) + + try: + response = await self.client.messages.create( + model=self.config.model, + max_tokens=kwargs.get("max_tokens", self.config.max_tokens), + temperature=kwargs.get("temperature", self.config.temperature), + messages=messages + ) + return response.content[0].text + except Exception as e: + logger.error(f"Anthropic Chat API璋冪敤澶辫触: {e}") + return self._simulate_chat(messages) + + def _simulate_response(self, prompt: str) -> str: + """妯℃嫙鍝嶅簲""" + return f"妯℃嫙Anthropic鍝嶅簲: {prompt[:100]}..." + + def _simulate_chat(self, messages: List[Dict[str, str]]) -> str: + """妯℃嫙瀵硅瘽鍝嶅簲""" + last_message = messages[-1]["content"] if messages else "" + return f"妯℃嫙Anthropic瀵硅瘽: {last_message[:100]}..." + +class LocalLLMClient(BaseLLMClient): + """鏈湴LLM瀹㈡埛绔""" + + def __init__(self, config: LLMConfig): + self.config = config + self.client = None + self._init_client() + + def _init_client(self): + """鍒濆鍖栨湰鍦板鎴风""" + try: + # 杩欓噷鍙互闆嗘垚Ollama銆乿LLM绛夋湰鍦癓LM鏈嶅姟 + logger.info("鏈湴LLM瀹㈡埛绔垵濮嬪寲") + except Exception as e: + logger.warning(f"鏈湴LLM瀹㈡埛绔垵濮嬪寲澶辫触: {e}") + + async def generate(self, prompt: str, **kwargs) -> str: + """鐢熸垚鏂囨湰""" + # 瀹炵幇鏈湴LLM璋冪敤 + return f"鏈湴LLM鍝嶅簲: {prompt[:100]}..." + + async def chat(self, messages: List[Dict[str, str]], **kwargs) -> str: + """瀵硅瘽鐢熸垚""" + last_message = messages[-1]["content"] if messages else "" + return f"鏈湴LLM瀵硅瘽: {last_message[:100]}..." + +class LLMClientFactory: + """LLM瀹㈡埛绔伐鍘""" + + @staticmethod + def create_client(config: LLMConfig) -> BaseLLMClient: + """鍒涘缓LLM瀹㈡埛绔""" + if config.provider.lower() == "openai": + return OpenAIClient(config) + elif config.provider.lower() == "anthropic": + return AnthropicClient(config) + elif config.provider.lower() == "local": + return LocalLLMClient(config) + else: + raise ValueError(f"涓嶆敮鎸佺殑LLM鎻愪緵鍟: {config.provider}") + +class LLMManager: + """LLM绠$悊鍣""" + + def __init__(self, config: LLMConfig): + self.config = config + self.client = LLMClientFactory.create_client(config) + self.usage_stats = { + "total_requests": 0, + "total_tokens": 0, + "error_count": 0 + } + + async def generate(self, prompt: str, **kwargs) -> str: + """鐢熸垚鏂囨湰""" + try: + self.usage_stats["total_requests"] += 1 + response = await self.client.generate(prompt, **kwargs) + self.usage_stats["total_tokens"] += len(response) + return response + except Exception as e: + self.usage_stats["error_count"] += 1 + logger.error(f"LLM鐢熸垚澶辫触: {e}") + raise + + async def chat(self, messages: List[Dict[str, str]], **kwargs) -> str: + """瀵硅瘽鐢熸垚""" + try: + self.usage_stats["total_requests"] += 1 + response = await self.client.chat(messages, **kwargs) + self.usage_stats["total_tokens"] += len(response) + return response + except Exception as e: + self.usage_stats["error_count"] += 1 + logger.error(f"LLM瀵硅瘽澶辫触: {e}") + raise + + def get_usage_stats(self) -> Dict[str, Any]: + """鑾峰彇浣跨敤缁熻""" + return self.usage_stats.copy() diff --git a/src/agent_assistant.py b/src/agent_assistant.py index 0e00ce9..51d4894 100644 --- a/src/agent_assistant.py +++ b/src/agent_assistant.py @@ -14,13 +14,16 @@ import json from src.main import TSPAssistant from src.agent import AgentCore, AgentState from src.agent.auto_monitor import AutoMonitorService +from src.agent.intelligent_agent import IntelligentAgent, AlertContext, KnowledgeContext +from src.agent.llm_client import LLMManager, LLMConfig +from src.agent.action_executor import ActionExecutor logger = logging.getLogger(__name__) class TSPAgentAssistant(TSPAssistant): """TSP Agent鍔╂墜 - 澧炲己鐗圱SP鍔╂墜锛屽叿澶囧畬鏁碅gent鍔熻兘""" - def __init__(self): + def __init__(self, llm_config: Optional[LLMConfig] = None): # 鍒濆鍖栧熀纭TSP鍔╂墜 super().__init__() @@ -30,6 +33,24 @@ class TSPAgentAssistant(TSPAssistant): # 鍒濆鍖栬嚜鍔ㄧ洃鎺ф湇鍔 self.auto_monitor = AutoMonitorService(self) + # 鍒濆鍖朙LM瀹㈡埛绔 + if llm_config: + self.llm_manager = LLMManager(llm_config) + else: + # 浣跨敤榛樿閰嶇疆 + default_config = LLMConfig( + provider="openai", + api_key="your-api-key-here", + model="gpt-3.5-turbo" + ) + self.llm_manager = LLMManager(default_config) + + # 鍒濆鍖栨櫤鑳紸gent + self.intelligent_agent = IntelligentAgent(self.llm_manager) + + # 鍒濆鍖栧姩浣滄墽琛屽櫒 + self.action_executor = ActionExecutor(self) + # Agent鐗规湁鍔熻兘 self.is_agent_mode = True self.proactive_tasks = [] @@ -286,37 +307,84 @@ class TSPAgentAssistant(TSPAssistant): # 妫鏌ラ璀 alerts = self.get_alerts() if alerts.get("count", 0) > 0: - proactive_actions.append({ - "type": "alert_response", - "description": f"鍙戠幇 {alerts['count']} 涓椿璺冮璀", - "priority": "high", - "action": "闇瑕佺珛鍗冲鐞嗛璀" - }) + # 鍒涘缓棰勮涓婁笅鏂 + alert_context = AlertContext( + alert_id=f"alert_{datetime.now().timestamp()}", + alert_type="system_alert", + severity="high", + description=f"鍙戠幇 {alerts['count']} 涓椿璺冮璀", + affected_systems=["main_system"], + metrics={"alert_count": alerts['count']} + ) + + # 浣跨敤鏅鸿兘Agent澶勭悊棰勮 + alert_actions = await self.intelligent_agent.process_alert(alert_context) + for action in alert_actions: + # 鎵ц鍔ㄤ綔 + result = await self.action_executor.execute_action(action) + proactive_actions.append({ + "type": "alert_response", + "description": action.description, + "priority": action.priority, + "confidence": action.confidence, + "result": result + }) # 妫鏌ョ郴缁熷仴搴 system_status = self.get_system_status() if system_status.get("health_score", 1.0) < 0.8: - proactive_actions.append({ - "type": "system_maintenance", - "description": "绯荤粺鍋ュ悍鐘舵佷笉浣", - "priority": "medium", - "action": "寤鸿杩涜绯荤粺缁存姢" - }) + # 鍒涘缓绯荤粺鍋ュ悍棰勮涓婁笅鏂 + health_alert_context = AlertContext( + alert_id=f"health_{datetime.now().timestamp()}", + alert_type="system_health", + severity="medium", + description="绯荤粺鍋ュ悍鐘舵佷笉浣", + affected_systems=["main_system"], + metrics={"health_score": system_status.get("health_score", 0.5)} + ) + + health_actions = await self.intelligent_agent.process_alert(health_alert_context) + for action in health_actions: + result = await self.action_executor.execute_action(action) + proactive_actions.append({ + "type": "system_maintenance", + "description": action.description, + "priority": action.priority, + "confidence": action.confidence, + "result": result + }) # 妫鏌ョ煡璇嗗簱璐ㄩ噺 knowledge_stats = self.knowledge_manager.get_knowledge_stats() if knowledge_stats.get("average_confidence", 0.8) < 0.6: - proactive_actions.append({ - "type": "knowledge_improvement", - "description": "鐭ヨ瘑搴撹川閲忛渶瑕佹彁鍗", - "priority": "low", - "action": "寤鸿鏇存柊鐭ヨ瘑搴" - }) + # 澶勭悊浣庣疆淇″害鐭ヨ瘑 + low_confidence_items = knowledge_stats.get("low_confidence_items", []) + for item in low_confidence_items: + knowledge_context = KnowledgeContext( + question=item.get("question", ""), + answer=item.get("answer", ""), + confidence=item.get("confidence", 0.3), + source=item.get("source", "unknown"), + category=item.get("category", "general") + ) + + # 浣跨敤鏅鸿兘Agent澶勭悊鐭ヨ瘑搴撶疆淇″害 + knowledge_actions = await self.intelligent_agent.process_knowledge_confidence(knowledge_context) + for action in knowledge_actions: + result = await self.action_executor.execute_action(action) + proactive_actions.append({ + "type": "knowledge_improvement", + "description": action.description, + "priority": action.priority, + "confidence": action.confidence, + "result": result + }) return { "proactive_actions": proactive_actions, "timestamp": datetime.now().isoformat(), - "agent_status": self.agent_core.get_status() + "agent_status": self.agent_core.get_status(), + "llm_usage": self.llm_manager.get_usage_stats() } except Exception as e: @@ -422,16 +490,20 @@ class TSPAgentAssistant(TSPAssistant): "monitoring_active": monitor_status["is_running"], "status": "active" if self.is_agent_mode else "inactive", "active_goals": 0, # 绠鍖栧鐞 - "available_tools": 6, # 绠鍖栧鐞 + "available_tools": 8, # 澧炲姞宸ュ叿鏁伴噺 + "llm_usage": self.llm_manager.get_usage_stats(), + "action_executor_stats": self.action_executor.get_action_statistics(), "tools": [ {"name": "search_knowledge", "usage_count": 0, "success_rate": 0.8}, {"name": "create_work_order", "usage_count": 0, "success_rate": 0.8}, {"name": "update_work_order", "usage_count": 0, "success_rate": 0.8}, {"name": "generate_response", "usage_count": 0, "success_rate": 0.8}, {"name": "analyze_data", "usage_count": 0, "success_rate": 0.8}, - {"name": "send_notification", "usage_count": 0, "success_rate": 0.8} + {"name": "send_notification", "usage_count": 0, "success_rate": 0.8}, + {"name": "process_alert", "usage_count": 0, "success_rate": 0.9}, + {"name": "enhance_knowledge", "usage_count": 0, "success_rate": 0.7} ], - "execution_history": [], + "execution_history": self.action_executor.get_execution_history(10), "auto_monitor": monitor_status } except Exception as e: @@ -768,6 +840,97 @@ class TSPAgentAssistant(TSPAssistant): logger.error(f"鑾峰彇宸ュ崟娲炲療澶辫触: {e}") return "鑾峰彇宸ュ崟鏁版嵁澶辫触" + def get_action_history(self, limit: int = 50) -> List[Dict[str, Any]]: + """鑾峰彇鍔ㄤ綔鎵ц鍘嗗彶""" + try: + return self.action_executor.get_execution_history(limit) + except Exception as e: + logger.error(f"鑾峰彇鍔ㄤ綔鍘嗗彶澶辫触: {e}") + return [] + + def get_llm_usage_stats(self) -> Dict[str, Any]: + """鑾峰彇LLM浣跨敤缁熻""" + try: + return self.llm_manager.get_usage_stats() + except Exception as e: + logger.error(f"鑾峰彇LLM浣跨敤缁熻澶辫触: {e}") + return {} + + async def process_alert_with_agent(self, alert_data: Dict[str, Any]) -> Dict[str, Any]: + """浣跨敤Agent澶勭悊棰勮""" + try: + # 鍒涘缓棰勮涓婁笅鏂 + alert_context = AlertContext( + alert_id=alert_data.get("id", f"alert_{datetime.now().timestamp()}"), + alert_type=alert_data.get("type", "unknown"), + severity=alert_data.get("severity", "medium"), + description=alert_data.get("description", ""), + affected_systems=alert_data.get("affected_systems", []), + metrics=alert_data.get("metrics", {}) + ) + + # 浣跨敤鏅鸿兘Agent澶勭悊棰勮 + actions = await self.intelligent_agent.process_alert(alert_context) + + # 鎵ц鍔ㄤ綔 + results = [] + for action in actions: + result = await self.action_executor.execute_action(action) + results.append({ + "action": action.description, + "priority": action.priority, + "confidence": action.confidence, + "result": result + }) + + return { + "success": True, + "alert_id": alert_context.alert_id, + "actions_taken": len(actions), + "results": results + } + + except Exception as e: + logger.error(f"Agent澶勭悊棰勮澶辫触: {e}") + return {"success": False, "error": str(e)} + + async def enhance_knowledge_with_agent(self, knowledge_data: Dict[str, Any]) -> Dict[str, Any]: + """浣跨敤Agent澧炲己鐭ヨ瘑搴""" + try: + # 鍒涘缓鐭ヨ瘑涓婁笅鏂 + knowledge_context = KnowledgeContext( + question=knowledge_data.get("question", ""), + answer=knowledge_data.get("answer", ""), + confidence=knowledge_data.get("confidence", 0.5), + source=knowledge_data.get("source", "unknown"), + category=knowledge_data.get("category", "general") + ) + + # 浣跨敤鏅鸿兘Agent澶勭悊鐭ヨ瘑搴撶疆淇″害 + actions = await self.intelligent_agent.process_knowledge_confidence(knowledge_context) + + # 鎵ц鍔ㄤ綔 + results = [] + for action in actions: + result = await self.action_executor.execute_action(action) + results.append({ + "action": action.description, + "priority": action.priority, + "confidence": action.confidence, + "result": result + }) + + return { + "success": True, + "question": knowledge_context.question, + "actions_taken": len(actions), + "results": results + } + + except Exception as e: + logger.error(f"Agent澧炲己鐭ヨ瘑搴撳け璐: {e}") + return {"success": False, "error": str(e)} + def _parse_knowledge_manually(self, content: str) -> List[Dict[str, Any]]: """鎵嬪姩瑙f瀽鐭ヨ瘑鍐呭""" try: diff --git a/src/web/__pycache__/app.cpython-311.pyc b/src/web/__pycache__/app.cpython-311.pyc index 9e02087..b13cde6 100644 Binary files a/src/web/__pycache__/app.cpython-311.pyc and b/src/web/__pycache__/app.cpython-311.pyc differ diff --git a/uploads/workorder_template.xlsx b/uploads/workorder_template.xlsx index a61cf7b..292c88d 100644 Binary files a/uploads/workorder_template.xlsx and b/uploads/workorder_template.xlsx differ