fix(api): align kb extractor ollama model
This commit is contained in:
@@ -1,3 +1,45 @@
|
||||
## 2026-05-31|KB extractor Ollama 模型漂移修復
|
||||
|
||||
**背景**:
|
||||
|
||||
- `INC-20260531-D6A3C4` resolve path 已寫入 KM / Postmortem,但 API log 同時出現 `kb_ollama_all_endpoints_failed`。
|
||||
- 直接探測 110 proxy 後確認:
|
||||
- `11435` / `11436` 的 `/api/tags` 都是 `200`,GCP-A/B Ollama 服務不是整台掛掉。
|
||||
- `11435` / `11436` 對 `llama3.2:3b` 的 `/api/generate` 回 `404 model not found`。
|
||||
- `11436` 對 `hermes3:latest` 的 `/api/generate` 回 `200`。
|
||||
- `11437` local fallback 仍為 `502 Bad Gateway`,保留為獨立基礎設施紅燈。
|
||||
- 根因是 `KnowledgeExtractorService` 還硬打舊模型 `llama3.2:3b`,但目前 GCP-A/B 實際可用模型包含 `hermes3:latest` / `deepseek-r1:14b`。
|
||||
|
||||
**本次調整**:
|
||||
|
||||
- `apps/api/src/services/knowledge_extractor_service.py`:
|
||||
- KB extractor 改用既有 `settings.OLLAMA_TOOL_MODEL`,預設 fallback `hermes3:latest`。
|
||||
- endpoint workload 從 `deep_rca` 改成 `hermes`。
|
||||
- 接上 `resolve_ollama_order_with_cooldown()`,失敗 endpoint 短期 cooldown,成功後清除 cooldown,避免 GCP-A timeout 反覆拖慢背景 KB 萃取。
|
||||
- 新增 `apps/api/tests/test_knowledge_extractor_model.py`,鎖住 extractor 不再回退到已移除的 `llama3.2:3b`。
|
||||
|
||||
**驗證**:
|
||||
|
||||
```text
|
||||
live probe:
|
||||
11435 /api/tags -> 200
|
||||
11435 llama3.2:3b /api/generate -> 404 model not found
|
||||
11436 /api/tags -> 200
|
||||
11436 llama3.2:3b /api/generate -> 404 model not found
|
||||
11436 hermes3:latest /api/generate -> 200, response=OK
|
||||
11437 /api/tags and /api/generate -> 502 Bad Gateway
|
||||
|
||||
local:
|
||||
python3 -m py_compile knowledge_extractor_service.py test_knowledge_extractor_model.py -> pass
|
||||
ruff check knowledge_extractor_service.py test_knowledge_extractor_model.py --select E9,F401,F821,F841 -> pass
|
||||
pytest tests/test_knowledge_extractor_model.py -q -> 2 passed
|
||||
```
|
||||
|
||||
**判讀**:
|
||||
|
||||
- 這次修的是 KB extractor 的模型漂移,不是改 AI Router 主路由,也沒有新增付費 provider。
|
||||
- GCP-A/B Ollama proxy 可列模型;GCP-B `hermes3:latest` 可生成。11437 local fallback 仍需後續基礎設施修復,不能宣稱三層 Ollama 全綠。
|
||||
|
||||
## 2026-05-31|IwoooS 側欄單一資安入口收斂
|
||||
|
||||
**背景**:
|
||||
|
||||
@@ -2716,6 +2716,12 @@ Phase 6 完成後
|
||||
- Verification:production status-chain 回 `repair_state=auto_repaired_verified`、`operator_outcome.state=completed_verified`、`needs_human=false`、`execution_result.summary_zh=已完成:修復指令成功,且驗證通過`、`execution.ansible.latest_operation_type=ansible_apply_executed`、`latest_returncode=0`、`controlled_apply=true`。Resolve path 已寫 incident case KM `9207f7e1-ee6f-4a4d-981f-4676c04a5d61`、postmortem KM `c28c5f56-d4b3-4314-b961-31d0b69a9c05`,Telegram postmortem sent。
|
||||
- 判讀:T154g 是使用者批准後的 controlled apply + 人工驗證收斂,不是 24h 全自動修復宣稱;但此 incident 已不需人工介入,後續只需監控是否回歸。
|
||||
|
||||
**T154h KB extractor Ollama model drift repair(2026-05-31 台北)**:
|
||||
- 觸發:D6A3C4 resolve path 成功寫 KM / Postmortem 後,背景 `KnowledgeExtractorService` 仍記錄 `kb_ollama_all_endpoints_failed`。Live probe 證明 GCP-A/B proxy `/api/tags` 為 200,問題不是 GCP-A/B 整台掛掉,而是 extractor 還硬打不存在的 `llama3.2:3b`;GCP-B `hermes3:latest` `/api/generate` 可回 200。
|
||||
- 修正:`KnowledgeExtractorService` 改用 `settings.OLLAMA_TOOL_MODEL`,預設 `hermes3:latest`;endpoint workload 改為 `hermes`;接上 `resolve_ollama_order_with_cooldown()`,失敗 endpoint 短期 cooldown、成功後清除 cooldown,避免 GCP-A timeout 反覆拖慢背景 KB 萃取。新增 `test_knowledge_extractor_model.py` 鎖住空設定 fallback 也不再回到 `llama3.2:3b`。
|
||||
- Verification:live probe `11436 hermes3:latest /api/generate -> 200 response=OK`;`11435/11436 llama3.2:3b -> 404 model not found`;`11437 -> 502` 仍是 local fallback 紅燈。Local `py_compile` pass、ruff `E9/F401/F821/F841` pass、pytest `tests/test_knowledge_extractor_model.py` 2 passed。
|
||||
- 判讀:T154h 修的是背景 KB extractor 的模型漂移,不改 AI Router 主路由、不新增付費 provider;不能因此宣稱三層 Ollama 全綠,11437 local fallback 仍需後續基礎設施修復。
|
||||
|
||||
**T152 Ansible runtime readiness surfaced(2026-05-24 台北)**:
|
||||
- 觸發:T151 已讓首頁看到 execution backend / Ansible attribution,但 operator 仍看不到 runtime 端缺什麼,容易把「Ansible 有候選」誤解成「Ansible 已能自動修復」。
|
||||
- 修正:API image 複製 `infra/ansible/` 作 read-only catalog;`truth-chain/quality/summary` 新增 `ansible_runtime`,回報 playbook binary、catalog、inventory、playbook_count、can_run_check_mode、blockers。首頁 execution evidence 同步顯示 runtime 狀態;目前 production 顯示 `runtime 未就緒:ansible_playbook_binary_missing`。未安裝 `ansible-core`、未啟用 check-mode / apply。
|
||||
|
||||
Reference in New Issue
Block a user