fix(price): 未设置价格,错误返回模型价格匹配的名字
This commit is contained in:
@@ -116,7 +116,7 @@ func updatePricing() {
|
|||||||
pricing.ModelPrice = modelPrice
|
pricing.ModelPrice = modelPrice
|
||||||
pricing.QuotaType = 1
|
pricing.QuotaType = 1
|
||||||
} else {
|
} else {
|
||||||
modelRatio, _ := ratio_setting.GetModelRatio(model)
|
modelRatio, _, _ := ratio_setting.GetModelRatio(model)
|
||||||
pricing.ModelRatio = modelRatio
|
pricing.ModelRatio = modelRatio
|
||||||
pricing.CompletionRatio = ratio_setting.GetCompletionRatio(model)
|
pricing.CompletionRatio = ratio_setting.GetCompletionRatio(model)
|
||||||
pricing.QuotaType = 0
|
pricing.QuotaType = 0
|
||||||
|
|||||||
@@ -79,14 +79,15 @@ func ModelPriceHelper(c *gin.Context, info *relaycommon.RelayInfo, promptTokens
|
|||||||
preConsumedTokens = promptTokens + maxTokens
|
preConsumedTokens = promptTokens + maxTokens
|
||||||
}
|
}
|
||||||
var success bool
|
var success bool
|
||||||
modelRatio, success = ratio_setting.GetModelRatio(info.OriginModelName)
|
var matchName string
|
||||||
|
modelRatio, success, matchName = ratio_setting.GetModelRatio(info.OriginModelName)
|
||||||
if !success {
|
if !success {
|
||||||
acceptUnsetRatio := false
|
acceptUnsetRatio := false
|
||||||
if info.UserSetting.AcceptUnsetRatioModel {
|
if info.UserSetting.AcceptUnsetRatioModel {
|
||||||
acceptUnsetRatio = true
|
acceptUnsetRatio = true
|
||||||
}
|
}
|
||||||
if !acceptUnsetRatio {
|
if !acceptUnsetRatio {
|
||||||
return PriceData{}, fmt.Errorf("模型 %s 倍率或价格未配置,请联系管理员设置或开始自用模式;Model %s ratio or price not set, please set or start self-use mode", info.OriginModelName, info.OriginModelName)
|
return PriceData{}, fmt.Errorf("模型 %s 倍率或价格未配置,请联系管理员设置或开始自用模式;Model %s ratio or price not set, please set or start self-use mode", matchName, matchName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
completionRatio = ratio_setting.GetCompletionRatio(info.OriginModelName)
|
completionRatio = ratio_setting.GetCompletionRatio(info.OriginModelName)
|
||||||
@@ -152,7 +153,7 @@ func ContainPriceOrRatio(modelName string) bool {
|
|||||||
if ok {
|
if ok {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
_, ok = ratio_setting.GetModelRatio(modelName)
|
_, ok, _ = ratio_setting.GetModelRatio(modelName)
|
||||||
if ok {
|
if ok {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ func PreWssConsumeQuota(ctx *gin.Context, relayInfo *relaycommon.RelayInfo, usag
|
|||||||
audioInputTokens := usage.InputTokenDetails.AudioTokens
|
audioInputTokens := usage.InputTokenDetails.AudioTokens
|
||||||
audioOutTokens := usage.OutputTokenDetails.AudioTokens
|
audioOutTokens := usage.OutputTokenDetails.AudioTokens
|
||||||
groupRatio := ratio_setting.GetGroupRatio(relayInfo.UsingGroup)
|
groupRatio := ratio_setting.GetGroupRatio(relayInfo.UsingGroup)
|
||||||
modelRatio, _ := ratio_setting.GetModelRatio(modelName)
|
modelRatio, _, _ := ratio_setting.GetModelRatio(modelName)
|
||||||
|
|
||||||
autoGroup, exists := ctx.Get("auto_group")
|
autoGroup, exists := ctx.Get("auto_group")
|
||||||
if exists {
|
if exists {
|
||||||
|
|||||||
@@ -369,7 +369,7 @@ func handleThinkingBudgetModel(name, prefix, wildcard string) string {
|
|||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetModelRatio(name string) (float64, bool) {
|
func GetModelRatio(name string) (float64, bool, string) {
|
||||||
modelRatioMapMutex.RLock()
|
modelRatioMapMutex.RLock()
|
||||||
defer modelRatioMapMutex.RUnlock()
|
defer modelRatioMapMutex.RUnlock()
|
||||||
|
|
||||||
@@ -380,9 +380,9 @@ func GetModelRatio(name string) (float64, bool) {
|
|||||||
}
|
}
|
||||||
ratio, ok := modelRatioMap[name]
|
ratio, ok := modelRatioMap[name]
|
||||||
if !ok {
|
if !ok {
|
||||||
return 37.5, operation_setting.SelfUseModeEnabled
|
return 37.5, operation_setting.SelfUseModeEnabled, name
|
||||||
}
|
}
|
||||||
return ratio, true
|
return ratio, true, name
|
||||||
}
|
}
|
||||||
|
|
||||||
func DefaultModelRatio2JSONString() string {
|
func DefaultModelRatio2JSONString() string {
|
||||||
|
|||||||
Reference in New Issue
Block a user