mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-10-14 23:00:27 +00:00
feat: able to configure ratio for different models (close #26)
This commit is contained in:
@@ -129,6 +129,15 @@ func relayHelper(c *gin.Context) error {
|
||||
} else {
|
||||
quota = textResponse.Usage.TotalTokens
|
||||
}
|
||||
ratio := common.RatioGPT3dot5
|
||||
if strings.HasPrefix(textRequest.Model, "gpt-4-32k") {
|
||||
ratio = common.RatioGPT4_32k
|
||||
} else if strings.HasPrefix(textRequest.Model, "gpt-4") {
|
||||
ratio = common.RatioGPT4
|
||||
} else {
|
||||
ratio = common.RatioGPT3dot5
|
||||
}
|
||||
quota = int(float64(quota) * ratio)
|
||||
err := model.ConsumeTokenQuota(tokenId, quota)
|
||||
if err != nil {
|
||||
common.SysError("Error consuming token remain quota: " + err.Error())
|
||||
|
Reference in New Issue
Block a user