chore: 添加计费处理调试日志

This commit is contained in:
2026-07-04 18:55:47 +08:00
parent dc6375707f
commit fe64d178ad
2 changed files with 10 additions and 9 deletions
+6 -2
View File
@@ -30,10 +30,12 @@ func CalculateBilling(config map[string]any, billingData map[string]any) map[str
func calculateInferenceTierBilling(config map[string]any, data map[string]any) map[string]any {
promptTokens := gconv.Int64(data["prompt_tokens"])
fmt.Printf("calculateInferenceTierBilling promptTokens=%v\n", promptTokens)
completionTokens := gconv.Int64(data["completion_tokens"])
fmt.Printf("calculateInferenceTierBilling completionTokens=%v\n", completionTokens)
hasAudio := gconv.Bool(data["has_audio"])
inputK := promptTokens / 1000
fmt.Printf("calculateInferenceTierBilling inputK=%v\n", inputK)
tiers := config["pricing"].(map[string]any)["tiers"].([]any)
var matched map[string]any
for _, t := range tiers {
@@ -53,11 +55,13 @@ func calculateInferenceTierBilling(config map[string]any, data map[string]any) m
} else {
inputPrice = gconv.Float64(matched["input_price"])
}
fmt.Printf("calculateInferenceTierBilling inputPrice=%v\n", inputPrice)
outputPrice := gconv.Float64(matched["output_price"])
fmt.Printf("calculateInferenceTierBilling outputPrice=%v\n", outputPrice)
inputCost := float64(promptTokens) * inputPrice / 1000000
outputCost := float64(completionTokens) * outputPrice / 1000000
fmt.Printf("calculateBilling inputCost=%v, outputCost=%v\n", inputCost, outputCost)
// 推理模型
return map[string]any{
"model_name": data["model_name"],