diff --git a/relay/controller/helper.go b/relay/controller/helper.go index 89fc69ce..5f452c16 100644 --- a/relay/controller/helper.go +++ b/relay/controller/helper.go @@ -172,6 +172,7 @@ func postConsumeQuota(ctx context.Context, usage *relaymodel.Usage, meta *util.R if err != nil { logger.Error(ctx, "error update user quota cache: "+err.Error()) } + logContent := fmt.Sprintf("模型倍率 %.2f,分组倍率 %.2f,补全倍率 %.2f", modelRatio, groupRatio, completionRatio) model.RecordConsumeLog(ctx, meta.UserId, meta.ChannelId, promptTokens, completionTokens, textRequest.Model, meta.TokenName, quota, logContent) model.UpdateUserUsedQuotaAndRequestCount(meta.UserId, quota) diff --git a/relay/util/common.go b/relay/util/common.go index 6d993378..2eef88a6 100644 --- a/relay/util/common.go +++ b/relay/util/common.go @@ -147,13 +147,14 @@ func PostConsumeQuota(ctx context.Context, tokenId int, quotaDelta int, totalQuo logger.SysError("error update user quota cache: " + err.Error()) } // totalQuota is total quota consumed - if totalQuota != 0 { + if totalQuota >= 0 { logContent := fmt.Sprintf("模型倍率 %.2f,分组倍率 %.2f", modelRatio, groupRatio) model.RecordConsumeLog(ctx, userId, channelId, totalQuota, 0, modelName, tokenName, totalQuota, logContent) model.UpdateUserUsedQuotaAndRequestCount(userId, totalQuota) model.UpdateChannelUsedQuota(channelId, totalQuota) } - if totalQuota <= 0 { + + if totalQuota < 0 { logger.Error(ctx, fmt.Sprintf("totalQuota consumed is %d, something is wrong", totalQuota)) } }