Przeglądaj źródła

record all the consume log even if quota is 0

CaIon 2 lat temu
rodzic
commit
36b0db2a3e
1 zmienionych plików z 8 dodań i 6 usunięć
  1. 8 6
      controller/relay-text.go

+ 8 - 6
controller/relay-text.go

@@ -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())