From f07707c891b445e7ff7e09aed48b1c0ac50f167e Mon Sep 17 00:00:00 2001 From: OG T Date: Tue, 24 Mar 2026 10:07:18 +0800 Subject: [PATCH] =?UTF-8?q?feat(api):=20=E5=A2=9E=E5=BC=B7=E7=89=88?= =?UTF-8?q?=E4=B8=BB=E9=A1=8C=E8=90=83=E5=8F=96=20(12=20=E9=A0=98=E5=9F=9F?= =?UTF-8?q?=E5=88=86=E9=A1=9E)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 效能: timeout, latency, memory, cpu - 網路: network, connection - 儲存: disk, database - 容器: pod, scaling - 應用: error, config 支援中英文關鍵字匹配 TODO Phase 7: 整合 OpenClaw LLM 智能萃取 Co-Authored-By: Claude Opus 4.5 --- apps/api/src/api/v1/stats.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/apps/api/src/api/v1/stats.py b/apps/api/src/api/v1/stats.py index f48ddf926..57eff5869 100644 --- a/apps/api/src/api/v1/stats.py +++ b/apps/api/src/api/v1/stats.py @@ -538,12 +538,33 @@ async def get_feedback_summary( negative += 1 # 萃取主題 (從 learning_notes) + # TODO Phase 7: 整合 OpenClaw LLM 進行智能主題萃取 notes = o.get("learning_notes") or o.get("notes") or "" if notes: - # 簡單關鍵字萃取 (未來可用 NLP) - for keyword in ["timeout", "memory", "network", "disk", "cpu", "connection"]: - if keyword.lower() in notes.lower(): - themes[keyword] = themes.get(keyword, 0) + 1 + notes_lower = notes.lower() + # 增強版關鍵字萃取 (按領域分類) + theme_keywords = { + # 效能類 + "timeout": ["timeout", "超時", "timed out", "deadline"], + "latency": ["latency", "延遲", "slow", "慢", "p99", "p95"], + "memory": ["memory", "記憶體", "oom", "heap", "內存"], + "cpu": ["cpu", "處理器", "high load", "負載"], + # 網路類 + "network": ["network", "網路", "dns", "connection refused"], + "connection": ["connection", "連線", "socket", "tcp"], + # 儲存類 + "disk": ["disk", "磁碟", "storage", "io", "iops"], + "database": ["database", "資料庫", "db", "query", "deadlock"], + # 容器類 + "pod": ["pod", "container", "restart", "crashloop"], + "scaling": ["scale", "擴容", "replica", "hpa"], + # 應用類 + "error": ["error", "錯誤", "exception", "fail"], + "config": ["config", "配置", "env", "secret"], + } + for theme, keywords in theme_keywords.items(): + if any(kw in notes_lower for kw in keywords): + themes[theme] = themes.get(theme, 0) + 1 # 取前 5 個常見主題 sorted_themes = sorted(themes.items(), key=lambda x: x[1], reverse=True)[:5]