Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions backend/internal/service/openai_codex_transform.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package service

import (
"fmt"
"strings"
)

Expand Down Expand Up @@ -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 ""
Expand Down
8 changes: 8 additions & 0 deletions backend/internal/service/openai_gateway_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1758,6 +1758,14 @@ func (s *OpenAIGatewayService) Forward(ctx context.Context, c *gin.Context, acco
bodyModified = true
markPatchSet("model", normalizedModel)
}

// 移除 gpt-5.2-codex 以下的版本 verbosity 参数
// 确保高版本模型向低版本模型映射不报错
if !SupportsVerbosity(normalizedModel) {
if text, ok := reqBody["text"].(map[string]any); ok {
delete(text, "verbosity")
}
}
}

// 规范化 reasoning.effort 参数(minimal -> none),与上游允许值对齐。
Expand Down
Loading