|
|
|
@ -220,11 +220,11 @@ func consumption(key string, model string, prompt_tokens int, completion_tokens
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return "", errors.New("模型信息解析失败")
|
|
|
|
return "", errors.New("模型信息解析失败")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
balance, err := Redis.IncrByFloat(context.Background(), "user:"+userInfo.UID+":balance", float64(modelInfo.ModelPrepayment)*modelInfo.ModelPrice-(float64(total_tokens)*modelInfo.ModelPrice)).Result()
|
|
|
|
balance, err := Redis.IncrByFloat(context.Background(), "user:"+userInfo.UID+":balance", float64(modelInfo.ModelPrepayment)*modelInfo.ModelPrice-(float64(prompt_tokens)*modelInfo.ModelPrice+float64(completion_tokens)*modelInfo.ModelPrice2)).Result()
|
|
|
|
|
|
|
|
|
|
|
|
// 余额消费日志请求
|
|
|
|
// 余额消费日志请求
|
|
|
|
result, err := balanceConsumption(key, model, prompt_tokens, completion_tokens, total_tokens, msg_id)
|
|
|
|
result, err := balanceConsumption(key, model, prompt_tokens, completion_tokens, total_tokens, msg_id)
|
|
|
|
log.Printf("用户余额:%f 扣费KEY: %s 扣费token数: %d 扣费:%f 扣费日志发送结果 %s", balance, key, total_tokens, float64(modelInfo.ModelPrepayment)*modelInfo.ModelPrice-(float64(total_tokens)*modelInfo.ModelPrice), result)
|
|
|
|
log.Printf("用户余额:%f 扣费KEY: %s 扣费token数: %d 扣费:%f 扣费日志发送结果 %s", balance, key, total_tokens, float64(modelInfo.ModelPrepayment)*modelInfo.ModelPrice-(float64(prompt_tokens)*modelInfo.ModelPrice+float64(completion_tokens)*modelInfo.ModelPrice2), result)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Printf("%s 余额消费日志请求失败 %v", key, err)
|
|
|
|
log.Printf("%s 余额消费日志请求失败 %v", key, err)
|
|
|
|
return "", err
|
|
|
|
return "", err
|
|
|
|
|