OG T
|
f1b037bb0c
|
refactor(api): playbook_rag.py 模組化改造 (P1 違規修復)
修復 P1 違規:
- Line 29: Service 直接 import Redis → Repository Pattern
- Line 156: 自建 httpx.AsyncClient → DI 注入
變更:
- 新增 IEmbeddingCacheRepository Protocol (interfaces.py)
- 新增 EmbeddingCacheRepository 實作 (embedding_repository.py)
- PlaybookRAGService 改用 DI 注入 http_client + embedding_cache
- get_playbook_rag_service() 改為 async factory
- PlaybookService 改用 lazy initialization
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-03-27 10:07:30 +08:00 |
|
OG T
|
3c034526a5
|
feat(api): ADR-030 Phase 3 Playbook RAG 向量搜尋
實作 Playbook 語意搜尋能力:
1. playbook_rag.py - RAG 向量服務
- Ollama nomic-embed-text 生成 embedding
- Redis 儲存向量 (JSON 格式)
- 餘弦相似度搜尋
- 混合搜尋 (Vector 60% + Jaccard 40%)
2. playbook_service.py - 整合 RAG
- extract_from_incident 後自動建立向量索引
- get_recommendations 支援混合搜尋
- RAG 失敗時 fallback 到純 Jaccard
功能:
- embed_text(): 文字向量化
- embed_playbook(): Playbook 向量化
- search_similar(): 向量相似度搜尋
- hybrid_search(): 混合搜尋
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-03-26 22:08:15 +08:00 |
|
OG T
|
30153496d1
|
fix(api): 修復全部 lint 錯誤 (ruff --fix)
- Import sorting (I001)
- Unused imports (F401)
- f-string without placeholders (F541)
- Loop variable unused (B007)
- zip() strict parameter (B905)
- Exception chaining (B904)
- collections.abc imports (UP035)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-03-26 16:06:20 +08:00 |
|
OG T
|
2e75a20150
|
feat(api): Phase 7.5-7.6 Playbook 整合決策與自動萃取
Phase 7.5: DecisionManager 三軌決策
- 新增 Playbook 優先匹配 (similarity >= 85%)
- 三軌決策順序: Playbook > LLM > Expert System
- 整合 PlaybookService 推薦引擎
Phase 7.6: 自動萃取機制
- approval_execution.py 成功執行後觸發萃取
- 條件: RESOLVED/CLOSED + effectiveness >= 4
- 滿分 (5) 自動核准 Playbook
測試:
- 13 個 Playbook 單元測試全部通過
- 修復 Incident 模型欄位對應 (reasoning_steps)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-03-26 11:09:25 +08:00 |
|
OG T
|
698687f092
|
feat(api): #7 Playbook 萃取功能 (Phase 7.1-7.4)
實作內容:
- models/playbook.py: Playbook 資料模型 + Request/Response
- repositories/playbook_repository.py: Redis 雙層儲存
- repositories/interfaces.py: IPlaybookRepository Protocol
- services/playbook_service.py: 業務邏輯 (萃取/推薦/核准)
- api/v1/playbooks.py: REST API 端點
API 端點:
- POST /playbooks/extract/{incident_id} - 從成功案例萃取
- POST /playbooks/recommend - 症狀匹配推薦
- POST /playbooks/{id}/approve - 人工核准
- GET/PATCH/DELETE /playbooks/{id} - CRUD
遵循 leWOOOgo 積木化: Router → Service → Repository
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
2026-03-26 10:54:13 +08:00 |
|