fix: use thinking.adaptive for Opus 4.7 in ReasoningEffort and Reasoning paths
Opus 4.7 rejects thinking.type="enabled". The effort-suffix and -thinking suffix paths already handled this, but the ReasoningEffort and Reasoning parameter paths still sent "enabled". Now all paths use "adaptive" + output_config.effort for Opus 4.7. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -204,7 +204,16 @@ func RequestOpenAI2ClaudeMessage(c *gin.Context, textRequest dto.GeneralOpenAIRe
|
||||
}
|
||||
}
|
||||
|
||||
isOpus47 := strings.HasPrefix(claudeRequest.Model, "claude-opus-4-7")
|
||||
|
||||
if textRequest.ReasoningEffort != "" {
|
||||
if isOpus47 {
|
||||
claudeRequest.Thinking = &dto.Thinking{Type: "adaptive", Display: "summarized"}
|
||||
claudeRequest.OutputConfig = json.RawMessage(fmt.Sprintf(`{"effort":"%s"}`, textRequest.ReasoningEffort))
|
||||
claudeRequest.Temperature = nil
|
||||
claudeRequest.TopP = nil
|
||||
claudeRequest.TopK = nil
|
||||
} else {
|
||||
switch textRequest.ReasoningEffort {
|
||||
case "low":
|
||||
claudeRequest.Thinking = &dto.Thinking{
|
||||
@@ -223,6 +232,7 @@ func RequestOpenAI2ClaudeMessage(c *gin.Context, textRequest dto.GeneralOpenAIRe
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 指定了 reasoning 参数,覆盖 budgetTokens
|
||||
if textRequest.Reasoning != nil {
|
||||
@@ -233,12 +243,20 @@ func RequestOpenAI2ClaudeMessage(c *gin.Context, textRequest dto.GeneralOpenAIRe
|
||||
|
||||
budgetTokens := reasoning.MaxTokens
|
||||
if budgetTokens > 0 {
|
||||
if isOpus47 {
|
||||
claudeRequest.Thinking = &dto.Thinking{Type: "adaptive", Display: "summarized"}
|
||||
claudeRequest.OutputConfig = json.RawMessage(`{"effort":"high"}`)
|
||||
claudeRequest.Temperature = nil
|
||||
claudeRequest.TopP = nil
|
||||
claudeRequest.TopK = nil
|
||||
} else {
|
||||
claudeRequest.Thinking = &dto.Thinking{
|
||||
Type: "enabled",
|
||||
BudgetTokens: &budgetTokens,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if textRequest.Stop != nil {
|
||||
// stop maybe string/array string, convert to array string
|
||||
|
||||
Reference in New Issue
Block a user