feat: able to configure ratio for more models now (close #53)

This commit is contained in:
JustSong
2023-05-11 20:59:35 +08:00
parent 241ade2fae
commit d9db16e999
6 changed files with 95 additions and 74 deletions

View File

@@ -47,9 +47,7 @@ func InitOptionMap() {
common.OptionMap["TurnstileSiteKey"] = ""
common.OptionMap["TurnstileSecretKey"] = ""
common.OptionMap["QuotaForNewUser"] = strconv.Itoa(common.QuotaForNewUser)
common.OptionMap["RatioGPT3dot5"] = strconv.FormatFloat(common.RatioGPT3dot5, 'f', -1, 64)
common.OptionMap["RatioGPT4"] = strconv.FormatFloat(common.RatioGPT4, 'f', -1, 64)
common.OptionMap["RatioGPT4_32k"] = strconv.FormatFloat(common.RatioGPT4_32k, 'f', -1, 64)
common.OptionMap["ModelRatio"] = common.ModelRatio2JSONString()
common.OptionMap["TopUpLink"] = common.TopUpLink
common.OptionMapRWMutex.Unlock()
options, _ := AllOption()
@@ -75,7 +73,7 @@ func UpdateOption(key string, value string) error {
return nil
}
func updateOptionMap(key string, value string) {
func updateOptionMap(key string, value string) (err error) {
common.OptionMapRWMutex.Lock()
defer common.OptionMapRWMutex.Unlock()
common.OptionMap[key] = value
@@ -138,13 +136,10 @@ func updateOptionMap(key string, value string) {
common.TurnstileSecretKey = value
case "QuotaForNewUser":
common.QuotaForNewUser, _ = strconv.Atoi(value)
case "RatioGPT3dot5":
common.RatioGPT3dot5, _ = strconv.ParseFloat(value, 64)
case "RatioGPT4":
common.RatioGPT4, _ = strconv.ParseFloat(value, 64)
case "RatioGPT4_32k":
common.RatioGPT4_32k, _ = strconv.ParseFloat(value, 64)
case "ModelRatio":
err = common.UpdateModelRatioByJSONString(value)
case "TopUpLink":
common.TopUpLink = value
}
return err
}