模型请求速率限制,增加对请求次数最大值的限制
This commit is contained in:
@@ -3,6 +3,7 @@ package setting
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"one-api/common"
|
"one-api/common"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
@@ -58,7 +59,7 @@ func CheckModelRequestRateLimitGroup(jsonStr string) error {
|
|||||||
if limits[0] < 0 || limits[1] < 1 {
|
if limits[0] < 0 || limits[1] < 1 {
|
||||||
return fmt.Errorf("group %s has negative rate limit values: [%d, %d]", group, limits[0], limits[1])
|
return fmt.Errorf("group %s has negative rate limit values: [%d, %d]", group, limits[0], limits[1])
|
||||||
}
|
}
|
||||||
if limits[0] > 2147483647 || limits[1] > 2147483647 {
|
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 fmt.Errorf("group %s [%d, %d] has max rate limits value 2147483647", group, limits[0], limits[1])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ export default function RequestRateLimit(props) {
|
|||||||
label={t('用户每周期最多请求次数')}
|
label={t('用户每周期最多请求次数')}
|
||||||
step={1}
|
step={1}
|
||||||
min={0}
|
min={0}
|
||||||
max={2147483647}
|
max={100000}
|
||||||
suffix={t('次')}
|
suffix={t('次')}
|
||||||
extraText={t('包括失败请求的次数,0代表不限制')}
|
extraText={t('包括失败请求的次数,0代表不限制')}
|
||||||
field={'ModelRequestRateLimitCount'}
|
field={'ModelRequestRateLimitCount'}
|
||||||
@@ -145,7 +145,7 @@ export default function RequestRateLimit(props) {
|
|||||||
label={t('用户每周期最多请求完成次数')}
|
label={t('用户每周期最多请求完成次数')}
|
||||||
step={1}
|
step={1}
|
||||||
min={1}
|
min={1}
|
||||||
max={2147483647}
|
max={100000}
|
||||||
suffix={t('次')}
|
suffix={t('次')}
|
||||||
extraText={t('只包括请求成功的次数')}
|
extraText={t('只包括请求成功的次数')}
|
||||||
field={'ModelRequestRateLimitSuccessCount'}
|
field={'ModelRequestRateLimitSuccessCount'}
|
||||||
|
|||||||
Reference in New Issue
Block a user