OoO 1da7564567
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
feat(p22+23): caller 整合 model_router (sales_copy) + cost_throttle (claude)
Operation Ollama-First v5.0 / Phase 22.1 + Phase 23 — 路由治理整合

Phase 22.1: services/ollama_service.py generate_sales_copy
- 短文 < 100 字(estimated_length = product_name × 5)→ 走 model_router
- model_router 推算 → 短文 gemma3:4b / 長文 llama3.1:8b
- MODEL_ROUTER_ENABLED=false 時 select_model 直接回 self.model(向下相容)
- router 失敗 swallow(fallback self.model 不影響主流程)

Phase 23: services/anthropic_service.py is_available()
- 新增 cost_throttle 整合:claude provider throttle 時 is_available=False
- caller 看到 False 自動走 Gemini fallback,不送 Claude 請求
- COST_THROTTLE_ENABLED=false 時不影響(戰役預設 OFF)
- cost_throttle 不可用時 try/except 不阻擋(向下相容)

行為對照:
  戰前:sales_copy 永遠用 self.model (llama3.1:8b)
  戰後(flag OFF):完全相同
  戰後(flag ON):商品名 < 20 字 → gemma3:4b 短文,提速 50%

  戰前:Claude 燒到月底超預算才告警,無自動節流
  戰後(throttle flag OFF):完全相同
  戰後(throttle flag ON):claude 月底推估 > 110% → is_available=False
                              → caller fallback Gemini 自動省錢

regression: 既有 retry_chain / anthropic / model_router test 全綠

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-04 11:00:04 +08:00
Description
EwoooC — 商品看板 + 業績報表 + AI KM (Flask + pgvector, Docker Compose on 188)
37 MiB
Languages
PostScript 59.7%
Python 30.9%
HTML 4.2%
CSS 2.1%
JavaScript 1.9%
Other 1.1%