fix: use default model price for radio price model

This commit is contained in:
feitianbubu
2026-03-03 10:56:57 +08:00
parent e71f5a45f2
commit d12cc3a8da

View File

@@ -147,24 +147,22 @@ func ModelPriceHelperPerCall(c *gin.Context, info *relaycommon.RelayInfo) (types
// 如果没有配置价格,检查模型倍率配置 // 如果没有配置价格,检查模型倍率配置
if !success { if !success {
// 没有配置费用,返回错误 // 没有配置费用,也要使用默认费用,否则按费率计费模型无法使用
defaultPrice, ok := ratio_setting.GetDefaultModelPriceMap()[info.OriginModelName] defaultPrice, ok := ratio_setting.GetDefaultModelPriceMap()[info.OriginModelName]
if !ok { if ok {
// 不再使用默认价格,而是返回错误
return types.PriceData{}, fmt.Errorf("模型 %s 价格未配置,请联系管理员设置", info.OriginModelName)
} else {
modelPrice = defaultPrice modelPrice = defaultPrice
} } else {
// 没有配置倍率也不接受没配置,那就返回错误 // 没有配置倍率也不接受没配置,那就返回错误
_, ratioSuccess, matchName := ratio_setting.GetModelRatio(info.OriginModelName) _, ratioSuccess, matchName := ratio_setting.GetModelRatio(info.OriginModelName)
if !ratioSuccess {
acceptUnsetRatio := false acceptUnsetRatio := false
if info.UserSetting.AcceptUnsetRatioModel { if info.UserSetting.AcceptUnsetRatioModel {
acceptUnsetRatio = true acceptUnsetRatio = true
} }
if !acceptUnsetRatio { if !ratioSuccess && !acceptUnsetRatio {
return types.PriceData{}, fmt.Errorf("模型 %s 倍率或价格未配置请联系管理员设置或开始自用模式Model %s ratio or price not set, please set or start self-use mode", matchName, matchName) return types.PriceData{}, fmt.Errorf("模型 %s 倍率或价格未配置请联系管理员设置或开始自用模式Model %s ratio or price not set, please set or start self-use mode", matchName, matchName)
} }
// 未配置价格但配置了倍率,使用默认预扣价格
modelPrice = float64(common.PreConsumedQuota) / common.QuotaPerUnit
} }
} }