feat: 添加 Token 费用估算与自定义忽略规则
- 在 LLM 客户端中捕获流式响应的 Token 使用量 - 内置多模型官方定价表,支持自定义输入/输出单价覆盖 - 新增 `--price-input` 和 `--price-output` 配置项 - 支持通过 `.airignore` 文件自定义排除评审文件 - 更新中英日文文档,补充费用估算与忽略规则说明
This commit is contained in:
1 parent
02e2e4edd3
commit
28c29e69df
13 files changed
+691
-82
No files matched your search
@@ -30,6 +30,28 @@ func PrintFooter() {
|
||||
fmt.Println(colorGray + strings.Repeat("─", 65) + colorReset)
|
||||
}
|
||||
|
||||
// PrintUsage 打印 Token 消耗与费用估算
|
||||
func PrintUsage(inputTokens, outputTokens int, costUSD float64) {
|
||||
if inputTokens == 0 && outputTokens == 0 {
|
||||
return
|
||||
}
|
||||
costStr := ""
|
||||
if costUSD < 0 {
|
||||
costStr = "费用未知"
|
||||
} else if costUSD == 0 {
|
||||
costStr = "本地免费"
|
||||
} else {
|
||||
costStr = fmt.Sprintf("≈ $%.4f", costUSD)
|
||||
}
|
||||
|
||||
fmt.Printf("\n- %sToken: 输入 %s%d%s / 输出 %s%d%s | %s%s%s\n",
|
||||
colorBold,
|
||||
colorCyan, inputTokens, colorGray,
|
||||
colorCyan, outputTokens, colorGray,
|
||||
colorCyan, costStr, colorReset,
|
||||
)
|
||||
}
|
||||
|
||||
// PrintError 打印错误信息
|
||||
func PrintError(format string, a ...interface{}) {
|
||||
msg := fmt.Sprintf(format, a...)
|
||||
|
||||
Reference in new issue
Block a user