feat(api): Phase 15.1 Langfuse LLMOps 整合 + 模型升級

## 新功能
- Langfuse 自建部署 (192.168.0.110:3100)
- langfuse_client.py - LLM 呼叫追蹤包裝
- OpenClaw 整合 Langfuse trace

## 模型升級 (統帥批准)
- 生產預設: llama3.2:3b → qwen2.5:7b-instruct
- 摘要任務: llama3.2:3b (速度優先)

## 配置更新
- requirements.txt: +langfuse>=2.0.0
- config.py: +LANGFUSE_* 設定
- models.json: 更新 Ollama 模型配置
- K8s: Secret + ConfigMap 更新

## 審查通過
- 模組化檢查 
- 核心測試 31/31 

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-03-26 00:32:19 +08:00
parent 31fabe8d61
commit 1ac8965a7a
11 changed files with 727 additions and 31 deletions

View File

@@ -157,6 +157,28 @@ class Settings(BaseSettings):
description="Trace sampling rate (1.0 = 100%)",
)
# ==========================================================================
# Langfuse LLMOps (Phase 15.1)
# LLM 呼叫追蹤、成本監控、Prompt 版本管理
# 端點: http://192.168.0.110:3100 (DevOps 金庫)
# ==========================================================================
LANGFUSE_ENABLED: bool = Field(
default=True,
description="Enable Langfuse LLM observability",
)
LANGFUSE_URL: str = Field(
default="http://192.168.0.110:3100",
description="Langfuse self-hosted URL",
)
LANGFUSE_PUBLIC_KEY: str = Field(
default="",
description="Langfuse public key (from K8s Secret)",
)
LANGFUSE_SECRET_KEY: str = Field(
default="",
description="Langfuse secret key (from K8s Secret)",
)
# ==========================================================================
# AI Fallback Strategy (ADR-006)
# Order: Ollama (local) -> Gemini (cloud) -> Claude (cloud)
@@ -224,8 +246,8 @@ class Settings(BaseSettings):
description="OpenClaw AI Agent service URL",
)
OPENCLAW_DEFAULT_MODEL: str = Field(
default="llama3.2:3b",
description="Default Ollama model for RCA analysis",
default="qwen2.5:7b-instruct",
description="Default Ollama model for RCA analysis (7B params, better Chinese)",
)
OPENCLAW_TIMEOUT: int = Field(
default=90,