Merge pull request #1446 from Raymondxox/fix

模型请求速率限制,增加对请求次数最大值的限制
This commit is contained in:
Calcium-Ion
2025-07-27 16:33:49 +08:00
committed by GitHub
2 changed files with 7 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ package setting
import (
"encoding/json"
"fmt"
"math"
"one-api/common"
"sync"
)
@@ -58,6 +59,9 @@ func CheckModelRequestRateLimitGroup(jsonStr string) error {
if limits[0] < 0 || limits[1] < 1 {
return fmt.Errorf("group %s has negative rate limit values: [%d, %d]", group, limits[0], limits[1])
}
if limits[0] > math.MaxInt32 || limits[1] > math.MaxInt32 {
return fmt.Errorf("group %s [%d, %d] has max rate limits value 2147483647", group, limits[0], limits[1])
}
}
return nil