diff --git a/setting/ratio_setting/model_ratio.go b/setting/ratio_setting/model_ratio.go index dd77c18..62a0010 100644 --- a/setting/ratio_setting/model_ratio.go +++ b/setting/ratio_setting/model_ratio.go @@ -370,6 +370,17 @@ func GetModelPrice(name string, printErr bool) (float64, bool) { price, ok := modelPriceMap.Get(name) if !ok { + // 新增:如果模型名称包含 "/",尝试去掉供应商前缀后重新查找 + // 例如: "openai/gpt-4o" -> "gpt-4o" + if strings.Contains(name, "/") { + parts := strings.SplitN(name, "/", 2) + if len(parts) == 2 { + baseName := FormatMatchingModelName(parts[1]) + if basePrice, ok := modelPriceMap.Get(baseName); ok { + return basePrice, true + } + } + } if printErr { common.SysError("model price not found: " + name) } @@ -401,6 +412,17 @@ func GetModelRatio(name string) (float64, bool, string) { } //return 0, true, name } + // 新增:如果模型名称包含 "/",尝试去掉供应商前缀后重新查找 + // 例如: "openai/o3-mini" -> "o3-mini" + if strings.Contains(name, "/") { + parts := strings.SplitN(name, "/", 2) + if len(parts) == 2 { + baseName := FormatMatchingModelName(parts[1]) + if baseRatio, ok := modelRatioMap.Get(baseName); ok { + return baseRatio, true, name + } + } + } return 37.5, operation_setting.SelfUseModeEnabled, name } return ratio, true, name diff --git a/web/src/pages/Setting/Ratio/ModelRatioSettings.jsx b/web/src/pages/Setting/Ratio/ModelRatioSettings.jsx index e9be197..01b1bfa 100644 --- a/web/src/pages/Setting/Ratio/ModelRatioSettings.jsx +++ b/web/src/pages/Setting/Ratio/ModelRatioSettings.jsx @@ -167,6 +167,7 @@ export default function ModelRatioSettings(props) {