Commit fd8ccaf0 authored by CoolCoolTomato's avatar CoolCoolTomato
Browse files

fix: 修复gpt-5.2以上模型映射到gpt-5.2以下时verbosity参数引发的报错

parent 8dd38f47
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 ""
......
......@@ -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),与上游允许值对齐。
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment