chore: 移除计费相关调试打印日志
This commit is contained in:
@@ -30,12 +30,9 @@ 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 {
|
func calculateInferenceTierBilling(config map[string]any, data map[string]any) map[string]any {
|
||||||
promptTokens := gconv.Int64(data["prompt_tokens"])
|
promptTokens := gconv.Int64(data["prompt_tokens"])
|
||||||
fmt.Printf("calculateInferenceTierBilling promptTokens=%v\n", promptTokens)
|
|
||||||
completionTokens := gconv.Int64(data["completion_tokens"])
|
completionTokens := gconv.Int64(data["completion_tokens"])
|
||||||
fmt.Printf("calculateInferenceTierBilling completionTokens=%v\n", completionTokens)
|
|
||||||
hasAudio := gconv.Bool(data["has_audio"])
|
hasAudio := gconv.Bool(data["has_audio"])
|
||||||
inputK := promptTokens / 1000
|
inputK := promptTokens / 1000
|
||||||
fmt.Printf("calculateInferenceTierBilling inputK=%v\n", inputK)
|
|
||||||
tiers := config["pricing"].(map[string]any)["tiers"].([]any)
|
tiers := config["pricing"].(map[string]any)["tiers"].([]any)
|
||||||
var matched map[string]any
|
var matched map[string]any
|
||||||
for _, t := range tiers {
|
for _, t := range tiers {
|
||||||
@@ -55,13 +52,10 @@ func calculateInferenceTierBilling(config map[string]any, data map[string]any) m
|
|||||||
} else {
|
} else {
|
||||||
inputPrice = gconv.Float64(matched["input_price"])
|
inputPrice = gconv.Float64(matched["input_price"])
|
||||||
}
|
}
|
||||||
fmt.Printf("calculateInferenceTierBilling inputPrice=%v\n", inputPrice)
|
|
||||||
outputPrice := gconv.Float64(matched["output_price"])
|
outputPrice := gconv.Float64(matched["output_price"])
|
||||||
fmt.Printf("calculateInferenceTierBilling outputPrice=%v\n", outputPrice)
|
|
||||||
inputCost := float64(promptTokens) * inputPrice / 1000000
|
inputCost := float64(promptTokens) * inputPrice / 1000000
|
||||||
outputCost := float64(completionTokens) * outputPrice / 1000000
|
outputCost := float64(completionTokens) * outputPrice / 1000000
|
||||||
|
|
||||||
fmt.Printf("calculateBilling inputCost=%v, outputCost=%v\n", inputCost, outputCost)
|
|
||||||
// 推理模型
|
// 推理模型
|
||||||
return map[string]any{
|
return map[string]any{
|
||||||
"model_name": data["model_name"],
|
"model_name": data["model_name"],
|
||||||
|
|||||||
@@ -125,9 +125,7 @@ func (w *asyncWorker) handleOne(ctx context.Context, task *entity.ModelGatewayTa
|
|||||||
if billingResult != nil {
|
if billingResult != nil {
|
||||||
task.BillingData[0] = billingResult
|
task.BillingData[0] = billingResult
|
||||||
totalFee := gconv.Float64(billingResult["total_fee"])
|
totalFee := gconv.Float64(billingResult["total_fee"])
|
||||||
fmt.Printf("[handleOne] 计费处理 totalFee1=%f", totalFee)
|
|
||||||
if totalFee > 0 {
|
if totalFee > 0 {
|
||||||
fmt.Printf("[handleOne] 计费处理 totalFee2=%f", totalFee)
|
|
||||||
_ = gateway.DeductBalance(util.AsyncCtx(ctx), model.TenantId, -totalFee)
|
_ = gateway.DeductBalance(util.AsyncCtx(ctx), model.TenantId, -totalFee)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -338,9 +336,7 @@ func (w *asyncWorker) parseAndRetry(ctx context.Context, body map[string]any, mo
|
|||||||
if billingResult != nil {
|
if billingResult != nil {
|
||||||
task.BillingData = append(task.BillingData, billingResult)
|
task.BillingData = append(task.BillingData, billingResult)
|
||||||
totalFee := gconv.Float64(billingResult["total_fee"])
|
totalFee := gconv.Float64(billingResult["total_fee"])
|
||||||
fmt.Println("totalFee==================", totalFee)
|
|
||||||
if totalFee > 0 {
|
if totalFee > 0 {
|
||||||
fmt.Println("deduct balance================", totalFee)
|
|
||||||
_ = gateway.DeductBalance(util.AsyncCtx(ctx), task.TenantId, -totalFee)
|
_ = gateway.DeductBalance(util.AsyncCtx(ctx), task.TenantId, -totalFee)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user