This commit is contained in:
wood 2023-11-25 02:10:28 +08:00
parent c253a34537
commit aa808b0210

View File

@ -148,7 +148,6 @@ func relayImageHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode
var textResponse ImageResponse
defer func(ctx context.Context) {
if consumeQuota {
err := model.PostConsumeTokenQuota(tokenId, quota)
if err != nil {
common.SysError("error consuming token remain quota: " + err.Error())
@ -159,13 +158,13 @@ func relayImageHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode
}
if quota != 0 {
tokenName := c.GetString("token_name")
logContent := fmt.Sprintf("费用0.002* %.2f", modelRatio)
outputPrice := ratio * 0.002
logContent := fmt.Sprintf("单价: $%.6g", outputPrice)
model.RecordConsumeLog(ctx, userId, channelId, 0, 0, imageModel, tokenName, quota, logContent)
model.UpdateUserUsedQuotaAndRequestCount(userId, quota)
channelId := c.GetInt("channel_id")
model.UpdateChannelUsedQuota(channelId, quota)
}
}
}(c.Request.Context())
responseBody, err := io.ReadAll(resp.Body)