From 96e71a3be47d3522f0b820840a1756d71ad56496 Mon Sep 17 00:00:00 2001 From: fengsilin Date: Thu, 26 Mar 2026 15:54:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=94=AF=E6=8C=81=E5=B8=A6=E4=BE=9B?= =?UTF-8?q?=E5=BA=94=E5=95=86=E5=89=8D=E7=BC=80=E7=9A=84=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E5=80=8D=E7=8E=87=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 当模型名称包含供应商前缀(如 "openai/o3-mini")时,自动尝试去掉前缀重新查找倍率配置。 - 在 GetModelPrice 和 GetModelRatio 函数中添加前缀剥离逻辑 - 在前端倍率配置页面添加提示说明 Co-Authored-By: Claude Opus 4.6 --- setting/ratio_setting/model_ratio.go | 22 +++++++++++++++++++ .../Setting/Ratio/ModelRatioSettings.jsx | 1 + 2 files changed, 23 insertions(+) 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) {