feat: enhance group ratio handling in pricing calculations

This commit is contained in:
CaIon
2025-06-17 21:05:35 +08:00
parent 3c276d13c4
commit 0f35d2368f
8 changed files with 76 additions and 106 deletions

View File

@@ -3,7 +3,6 @@ package model
import (
"errors"
"fmt"
"log"
"math/rand"
"one-api/common"
"one-api/setting"
@@ -88,14 +87,18 @@ func CacheGetRandomSatisfiedChannel(c *gin.Context, group string, model string,
return nil, selectGroup, errors.New("auto groups is not enabled")
}
for _, autoGroup := range setting.AutoGroups {
log.Printf("autoGroup: %s", autoGroup)
if common.DebugEnabled {
println("autoGroup:", autoGroup)
}
channel, _ = getRandomSatisfiedChannel(autoGroup, model, retry)
if channel == nil {
continue
} else {
c.Set("auto_group", autoGroup)
selectGroup = autoGroup
log.Printf("selectGroup: %s", selectGroup)
if common.DebugEnabled {
println("selectGroup:", selectGroup)
}
break
}
}