fix(phase22): 修復 Telegram 對話三個 Bug (ADR-044)
All checks were successful
E2E Health Check / e2e-health (push) Successful in 18s

P0: security_interceptor.py 新增 intercept_telegram() 方法
- 修復 _handle_chat_message 的 AttributeError (致命 Bug)
- 白名單驗證,不需要 Nonce (對話訊息 vs 按鈕回調)

P1: nvidia_provider.py chat() 新增 use_json_mode 參數
- 對話場景預設 False (自然語言回應)
- RCA/分析場景傳入 True (結構化 JSON 輸出)
- openclaw.py RCA 呼叫加上 use_json_mode=True

P2: K8s ConfigMap 啟用 TELEGRAM_ENABLE_POLLING=true
- K8s AWOOOI API 接管 @tsenyangbot Long Polling
- OpenClaw (188) 停止 Telegram,改為純 REST 服務

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-03-31 21:53:09 +08:00
parent 589f2fc4c7
commit cc6b18e3bc
4 changed files with 29 additions and 5 deletions

View File

@@ -660,12 +660,15 @@ class NvidiaProvider:
model: str | None = None,
temperature: float = 0.1,
max_tokens: int = 2048,
use_json_mode: bool = False,
) -> tuple[str, bool, int, float]:
"""
一般對話 (非 Tool Calling) - 用於 RCA 分析
一般對話 (非 Tool Calling) - 用於 RCA 分析或自由對話
2026-03-29 ogt: 新增,符合模組化規範
從 openclaw.py 遷移,統一由 NvidiaProvider 處理所有 NVIDIA API 呼叫
2026-03-31 ogt: 新增 use_json_mode 參數 (Phase 22 修復)
- RCA/分析場景: use_json_mode=True (結構化輸出)
- 對話場景: use_json_mode=False (預設,自然語言回應)
Args:
prompt: 對話內容
@@ -726,7 +729,7 @@ class NvidiaProvider:
"messages": [{"role": "user", "content": prompt}],
"temperature": temperature,
"max_tokens": max_tokens,
"response_format": {"type": "json_object"},
**({"response_format": {"type": "json_object"}} if use_json_mode else {}),
},
)
response.raise_for_status()