feat: able to configure ratio for different models (close #26)

This commit is contained in:
JustSong
2023-04-28 19:16:37 +08:00
parent b08cd7e104
commit d93cb8f645
4 changed files with 70 additions and 19 deletions

View File

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