From 7d50e432b5c0528dae0ba003b04606dc9c4087b4 Mon Sep 17 00:00:00 2001 From: ZhangYichi Date: Sun, 20 Jul 2025 18:25:43 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E6=A0=B9=E6=8D=AEOpenAI=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E7=9A=84=E8=AE=A1=E8=B4=B9=E8=A7=84=E5=88=99=EF=BC=8C?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=85=B6Web=20Search=20Tools=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setting/operation_setting/tools.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/setting/operation_setting/tools.go b/setting/operation_setting/tools.go index a59090ce..f87fcace 100644 --- a/setting/operation_setting/tools.go +++ b/setting/operation_setting/tools.go @@ -4,12 +4,12 @@ import "strings" const ( // Web search - WebSearchHighTierModelPriceLow = 30.00 - WebSearchHighTierModelPriceMedium = 35.00 - WebSearchHighTierModelPriceHigh = 50.00 + WebSearchHighTierModelPriceLow = 10.00 + WebSearchHighTierModelPriceMedium = 10.00 + WebSearchHighTierModelPriceHigh = 10.00 WebSearchPriceLow = 25.00 - WebSearchPriceMedium = 27.50 - WebSearchPriceHigh = 30.00 + WebSearchPriceMedium = 25.00 + WebSearchPriceHigh = 25.00 // File search FileSearchPrice = 2.5 ) @@ -35,9 +35,12 @@ func GetClaudeWebSearchPricePerThousand() float64 { func GetWebSearchPricePerThousand(modelName string, contextSize string) float64 { // 确定模型类型 // https://platform.openai.com/docs/pricing Web search 价格按模型类型和 search context size 收费 - // gpt-4.1, gpt-4o, or gpt-4o-search-preview 更贵,gpt-4.1-mini, gpt-4o-mini, gpt-4o-mini-search-preview 更便宜 - isHighTierModel := (strings.HasPrefix(modelName, "gpt-4.1") || strings.HasPrefix(modelName, "gpt-4o")) && - !strings.Contains(modelName, "mini") + // 新版计费规则不再关联 search context size,故在const区域将各size的价格设为一致。 + // gpt-4o and gpt-4.1 models (including mini models) 等普通模型更贵,o3, o4-mini, o3-pro, and deep research models 等高级模型更便宜 + isHighTierModel := + strings.HasPrefix(modelName, "o3") || + strings.HasPrefix(modelName, "o4") || + strings.Contains(modelName, "deep-research") // 确定 search context size 对应的价格 var priceWebSearchPerThousandCalls float64 switch contextSize { From 136a029bb418fbf27a767e8ba93f101249df2fc1 Mon Sep 17 00:00:00 2001 From: creamlike1024 Date: Tue, 22 Jul 2025 13:22:47 +0800 Subject: [PATCH 2/2] refactor: simplify WebSearchPrice const --- setting/operation_setting/tools.go | 49 +++++++----------------------- 1 file changed, 11 insertions(+), 38 deletions(-) diff --git a/setting/operation_setting/tools.go b/setting/operation_setting/tools.go index f87fcace..9f19ee84 100644 --- a/setting/operation_setting/tools.go +++ b/setting/operation_setting/tools.go @@ -4,12 +4,8 @@ import "strings" const ( // Web search - WebSearchHighTierModelPriceLow = 10.00 - WebSearchHighTierModelPriceMedium = 10.00 - WebSearchHighTierModelPriceHigh = 10.00 - WebSearchPriceLow = 25.00 - WebSearchPriceMedium = 25.00 - WebSearchPriceHigh = 25.00 + WebSearchPriceHigh = 25.00 + WebSearchPrice = 10.00 // File search FileSearchPrice = 2.5 ) @@ -34,41 +30,18 @@ func GetClaudeWebSearchPricePerThousand() float64 { func GetWebSearchPricePerThousand(modelName string, contextSize string) float64 { // 确定模型类型 - // https://platform.openai.com/docs/pricing Web search 价格按模型类型和 search context size 收费 + // https://platform.openai.com/docs/pricing Web search 价格按模型类型收费 // 新版计费规则不再关联 search context size,故在const区域将各size的价格设为一致。 - // gpt-4o and gpt-4.1 models (including mini models) 等普通模型更贵,o3, o4-mini, o3-pro, and deep research models 等高级模型更便宜 - isHighTierModel := + // gpt-4o and gpt-4.1 models (including mini models) 等模型更贵,o3, o4-mini, o3-pro, and deep research models 等模型更便宜 + isNormalPriceModel := strings.HasPrefix(modelName, "o3") || - strings.HasPrefix(modelName, "o4") || - strings.Contains(modelName, "deep-research") - // 确定 search context size 对应的价格 + strings.HasPrefix(modelName, "o4") || + strings.Contains(modelName, "deep-research") var priceWebSearchPerThousandCalls float64 - switch contextSize { - case "low": - if isHighTierModel { - priceWebSearchPerThousandCalls = WebSearchHighTierModelPriceLow - } else { - priceWebSearchPerThousandCalls = WebSearchPriceLow - } - case "medium": - if isHighTierModel { - priceWebSearchPerThousandCalls = WebSearchHighTierModelPriceMedium - } else { - priceWebSearchPerThousandCalls = WebSearchPriceMedium - } - case "high": - if isHighTierModel { - priceWebSearchPerThousandCalls = WebSearchHighTierModelPriceHigh - } else { - priceWebSearchPerThousandCalls = WebSearchPriceHigh - } - default: - // search context size 默认为 medium - if isHighTierModel { - priceWebSearchPerThousandCalls = WebSearchHighTierModelPriceMedium - } else { - priceWebSearchPerThousandCalls = WebSearchPriceMedium - } + if isNormalPriceModel { + priceWebSearchPerThousandCalls = WebSearchPrice + } else { + priceWebSearchPerThousandCalls = WebSearchPriceHigh } return priceWebSearchPerThousandCalls }