From fd8ccaf01aa80486fb61f536664b79bec773e948 Mon Sep 17 00:00:00 2001 From: CoolCoolTomato <2983315455@qq.com> Date: Wed, 11 Mar 2026 21:12:07 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dgpt-5.2=E4=BB=A5?= =?UTF-8?q?=E4=B8=8A=E6=A8=A1=E5=9E=8B=E6=98=A0=E5=B0=84=E5=88=B0gpt-5.2?= =?UTF-8?q?=E4=BB=A5=E4=B8=8B=E6=97=B6verbosity=E5=8F=82=E6=95=B0=E5=BC=95?= =?UTF-8?q?=E5=8F=91=E7=9A=84=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/openai_codex_transform.go | 24 +++++++++++++++++++ .../service/openai_gateway_service.go | 10 ++++++++ 2 files changed, 34 insertions(+) diff --git a/backend/internal/service/openai_codex_transform.go b/backend/internal/service/openai_codex_transform.go index d1920140b2..b0e4d44fb7 100644 --- a/backend/internal/service/openai_codex_transform.go +++ b/backend/internal/service/openai_codex_transform.go @@ -1,6 +1,7 @@ package service import ( + "fmt" "strings" ) @@ -226,6 +227,29 @@ func normalizeCodexModel(model string) string { return "gpt-5.1" } +func SupportsVerbosity(model string) bool { + if !strings.HasPrefix(model, "gpt-") { + return true + } + + var major, minor int + n, _ := fmt.Sscanf(model, "gpt-%d.%d", &major, &minor) + + if major > 5 { + return true + } + if major < 5 { + return false + } + + // gpt-5 + if n == 1 { + return true + } + + return minor >= 3 +} + func getNormalizedCodexModel(modelID string) string { if modelID == "" { return "" diff --git a/backend/internal/service/openai_gateway_service.go b/backend/internal/service/openai_gateway_service.go index 54068f2b2f..1d5622e635 100644 --- a/backend/internal/service/openai_gateway_service.go +++ b/backend/internal/service/openai_gateway_service.go @@ -1758,6 +1758,16 @@ func (s *OpenAIGatewayService) Forward(ctx context.Context, c *gin.Context, acco bodyModified = true markPatchSet("model", normalizedModel) } + + // 移除 gpt-5.2-codex 以下的版本 verbosity 参数 + // 确保高版本模型向低版本模型映射不报错 + if !SupportsVerbosity(reqBody["model"].(string)) { + if text, ok := reqBody["text"].(map[string]any); ok { + if _, ok := text["verbosity"].(string); ok { + delete(text, "verbosity") + } + } + } } // 规范化 reasoning.effort 参数(minimal -> none),与上游允许值对齐。 From eb0b77bf4d35209f782ccbf7acd9e6e374cb1220 Mon Sep 17 00:00:00 2001 From: CoolCoolTomato <2983315455@qq.com> Date: Wed, 11 Mar 2026 22:56:20 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=B5=81=E6=B0=B4?= =?UTF-8?q?=E7=BA=BFgolangci-lint=20=E7=9A=84=20errcheck?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/internal/service/openai_gateway_service.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/backend/internal/service/openai_gateway_service.go b/backend/internal/service/openai_gateway_service.go index 1d5622e635..e470745532 100644 --- a/backend/internal/service/openai_gateway_service.go +++ b/backend/internal/service/openai_gateway_service.go @@ -1761,11 +1761,9 @@ func (s *OpenAIGatewayService) Forward(ctx context.Context, c *gin.Context, acco // 移除 gpt-5.2-codex 以下的版本 verbosity 参数 // 确保高版本模型向低版本模型映射不报错 - if !SupportsVerbosity(reqBody["model"].(string)) { + if !SupportsVerbosity(normalizedModel) { if text, ok := reqBody["text"].(map[string]any); ok { - if _, ok := text["verbosity"].(string); ok { - delete(text, "verbosity") - } + delete(text, "verbosity") } } }