update: record consume logs of 0 quota
This commit is contained in:
parent
338363f0ee
commit
c1db6dc0f7
@ -113,12 +113,18 @@ func postConsumeQuota(ctx context.Context, usage *openai.Usage, meta *util.Relay
|
||||
if err != nil {
|
||||
logger.Error(ctx, "error update user quota cache: "+err.Error())
|
||||
}
|
||||
if quota != 0 {
|
||||
|
||||
// if model ratio is zero, quota can be zero too
|
||||
// without setting custom ratios, only "text-moderation-*" from OpenAI is currently 0
|
||||
if quota >= 0 {
|
||||
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)
|
||||
model.UpdateChannelUsedQuota(meta.ChannelId, quota)
|
||||
}
|
||||
if quota < 0 {
|
||||
logger.Error(ctx, fmt.Sprintf("quota consumed is %d, something is wrong", quota))
|
||||
}
|
||||
}
|
||||
|
||||
func doRequest(ctx context.Context, c *gin.Context, meta *util.RelayMeta, isStream bool, fullRequestURL string, requestBody io.Reader) (*http.Response, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user