fix(ai): 修復 generate_incident_proposal tuple unpacking 錯誤

- _call_with_cache 返回 6 值 (含 ai_tokens/ai_cost)
- generate_incident_proposal 解包只取 4 值導致 ValueError
- 修復: 完整解包 6 值並傳遞 ai_tokens/ai_cost 到 proposal_dict

2026-03-29 ogt: Token/Cost 追蹤補遺

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-03-29 00:03:22 +08:00
parent b77e151387
commit 7c905c4bf3

View File

@@ -1261,7 +1261,8 @@ Focus on:
"severity": severity,
}
raw_response, provider, success, from_cache = await self._call_with_cache(
# 2026-03-29 ogt: 修復 tuple unpacking (Token/Cost 追蹤)
raw_response, provider, success, from_cache, ai_tokens, ai_cost = await self._call_with_cache(
proposal_prompt,
alert_context,
signoz_metrics,
@@ -1290,6 +1291,7 @@ Focus on:
)
# 轉換為 proposal dict (optimization_suggestions 是 list[dict])
# 2026-03-29 ogt: 加入 ai_tokens/ai_cost 追蹤
proposal_dict = {
"action": result.action_title,
"description": result.description,
@@ -1311,6 +1313,8 @@ Focus on:
"signoz_correlation": result.signoz_correlation,
"from_cache": from_cache,
"provider": provider,
"ai_tokens": ai_tokens,
"ai_cost": ai_cost,
}
return proposal_dict, provider, True