feat(api): 增強版主題萃取 (12 領域分類)

- 效能: timeout, latency, memory, cpu
- 網路: network, connection
- 儲存: disk, database
- 容器: pod, scaling
- 應用: error, config

支援中英文關鍵字匹配
TODO Phase 7: 整合 OpenClaw LLM 智能萃取

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-03-24 10:07:18 +08:00
parent 2c934e13b6
commit f07707c891

View File

@@ -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]