Skip to content

Commit

Permalink
record all the consume log even if quota is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Calcium-Ion committed Nov 22, 2023
1 parent 560753c commit 36b0db2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions controller/relay-text.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,12 +446,14 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
if err != nil {
common.LogError(ctx, "error update user quota cache: "+err.Error())
}
if quota != 0 {
logContent := fmt.Sprintf("模型倍率 %.2f,分组倍率 %.2f", modelRatio, groupRatio)
model.RecordConsumeLog(ctx, userId, channelId, promptTokens, completionTokens, textRequest.Model, tokenName, quota, logContent, tokenId)
model.UpdateUserUsedQuotaAndRequestCount(userId, quota)
model.UpdateChannelUsedQuota(channelId, quota)
}
// record all the consume log even if quota is 0
logContent := fmt.Sprintf("模型倍率 %.2f,分组倍率 %.2f", modelRatio, groupRatio)
model.RecordConsumeLog(ctx, userId, channelId, promptTokens, completionTokens, textRequest.Model, tokenName, quota, logContent, tokenId)
model.UpdateUserUsedQuotaAndRequestCount(userId, quota)
model.UpdateChannelUsedQuota(channelId, quota)
//if quota != 0 {
//
//}
}
}()
}(c.Request.Context())
Expand Down

0 comments on commit 36b0db2

Please sign in to comment.