fix: 所有 Telegram 告警內容統一繁體中文

新增 _TRIGGER_ZH / _AGENT_ZH / _ACTION_ZH 翻譯表:
- trigger_type 英文代碼 → 繁中標籤(價格下滑警報、市場機會偵測等)
- agent 名稱 → 繁中(Hermes 分析師、NemoTron 監控、OpenClaw 策略師)
- action 代碼 → 繁中(競品價格分析、派送告警通知等)
- 升級審核觸發類型、參與模組、執行步驟全面繁中化

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ogt
2026-04-20 20:07:36 +08:00
parent c8da68125d
commit 65de5d7893

View File

@@ -49,6 +49,42 @@ _TRIGGER_TO_DECISION_TYPE = {
"resource_optimization": DecisionType.RESOURCE_ALLOCATION,
}
# 告警繁中翻譯表(所有 Telegram 告警內容統一使用繁體中文)
_TRIGGER_ZH: Dict[str, str] = {
"price_drop_alert": "價格下滑警報",
"market_opportunity": "市場機會偵測",
"threat_escalation": "威脅升級通報",
"resource_optimization": "資源調配優化",
"sales_anomaly": "銷售異常偵測",
"ea_escalation": "EA 升級審核",
}
_AGENT_ZH: Dict[str, str] = {
"hermes": "Hermes 分析師",
"nemotron": "NemoTron 監控",
"openclaw": "OpenClaw 策略師",
"scheduler": "排程器",
"?": "未知模組",
}
_ACTION_ZH: Dict[str, str] = {
"analyze_price_competition": "競品價格分析",
"dispatch_alert": "派送告警通知",
"generate_strategic_analysis": "產出策略分析報告",
"adjust_price": "調整定價",
"send_alert": "發送告警",
}
def _zh_trigger(trigger_type: str) -> str:
return _TRIGGER_ZH.get(trigger_type, trigger_type)
def _zh_step(step: dict) -> str:
agent = _AGENT_ZH.get(step.get("agent", "?"), step.get("agent", "?"))
action = _ACTION_ZH.get(step.get("action", ""), step.get("action", "?"))
return f"[{agent}] {action}"
@dataclass
class DecisionOutcome:
@@ -551,14 +587,14 @@ class ElephantAlphaAutonomousEngine:
msg, keyboard = triaged_alert(
base_event={
"event_type": trigger.trigger_type,
"title": f"🐘 EA 自主執行完畢 · {trigger.trigger_type}",
"title": f"🐘 EA 自主執行完畢 · {_zh_trigger(trigger.trigger_type)}",
"summary": decision.expected_outcome or "EA 完成自主決策",
"id": f"ea_{trigger.trigger_type}_{int(datetime.now().timestamp())}",
},
tier_label="🐘 Elephant Alpha · 自主執行",
ai_summary=(decision.reasoning or "")[:300],
ai_executed=[
f"[{s.get('agent', '?')}] {s.get('action', '?')}"
_zh_step(s)
for s in decision.execution_plan[:5]
] or ["(無具體執行計畫)"],
)
@@ -632,7 +668,7 @@ class ElephantAlphaAutonomousEngine:
msg, keyboard = triaged_alert(
base_event={
"event_type": "ea_escalation",
"title": f"🐘 EA 升級審核 · {trigger.trigger_type}",
"title": f"🐘 EA 升級審核 · {_zh_trigger(trigger.trigger_type)}",
"summary": (
f"自主決策信心度 {decision.confidence:.2f} 低於門檻,需人工批准"
),
@@ -641,12 +677,12 @@ class ElephantAlphaAutonomousEngine:
tier_label="🐘 Elephant Alpha · L3 HITL",
ai_summary=(decision.reasoning or "")[:300],
ai_cause=(
f"觸發{trigger.trigger_type} | "
f"觸發類型{_zh_trigger(trigger.trigger_type)} | "
f"信心度:{decision.confidence:.2f} | "
f"需求 Agent{', '.join(decision.agents_required)}"
f"參與模組{', '.join(_AGENT_ZH.get(a, a) for a in decision.agents_required)}"
),
ai_actions=[
f"Step {s.get('step', i+1)}: [{s.get('agent', '?')}] {s.get('action', '?')}"
f"步驟 {s.get('step', i+1)}{_zh_step(s)}"
for i, s in enumerate(decision.execution_plan[:3])
] or ["無具體執行計畫"],
)