mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-03-29 23:28:36 +00:00
delete some if
This commit is contained in:
@@ -34,36 +34,34 @@ func ClaudeToOpenAIRequest(claudeRequest dto.ClaudeRequest, info *relaycommon.Re
|
|||||||
|
|
||||||
isOpenRouter := info.ChannelType == constant.ChannelTypeOpenRouter
|
isOpenRouter := info.ChannelType == constant.ChannelTypeOpenRouter
|
||||||
|
|
||||||
if claudeRequest.Thinking != nil && (claudeRequest.Thinking.Type == "enabled" || claudeRequest.Thinking.Type == "adaptive") {
|
if isOpenRouter {
|
||||||
if isOpenRouter {
|
if effort := claudeRequest.GetEfforts(); effort != "" {
|
||||||
if effort := claudeRequest.GetEfforts(); effort != "" {
|
effortBytes, _ := json.Marshal(effort)
|
||||||
effortBytes, _ := json.Marshal(effort)
|
openAIRequest.Verbosity = effortBytes
|
||||||
openAIRequest.Verbosity = effortBytes
|
}
|
||||||
}
|
if claudeRequest.Thinking != nil {
|
||||||
if claudeRequest.Thinking != nil {
|
var reasoning openrouter.RequestReasoning
|
||||||
var reasoning openrouter.RequestReasoning
|
if claudeRequest.Thinking.Type == "enabled" {
|
||||||
if claudeRequest.Thinking.Type == "enabled" {
|
reasoning = openrouter.RequestReasoning{
|
||||||
reasoning = openrouter.RequestReasoning{
|
Enabled: true,
|
||||||
Enabled: true,
|
MaxTokens: claudeRequest.Thinking.GetBudgetTokens(),
|
||||||
MaxTokens: claudeRequest.Thinking.GetBudgetTokens(),
|
|
||||||
}
|
|
||||||
} else if claudeRequest.Thinking.Type == "adaptive" {
|
|
||||||
reasoning = openrouter.RequestReasoning{
|
|
||||||
Enabled: true,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
reasoningJSON, err := json.Marshal(reasoning)
|
} else if claudeRequest.Thinking.Type == "adaptive" {
|
||||||
if err != nil {
|
reasoning = openrouter.RequestReasoning{
|
||||||
return nil, fmt.Errorf("failed to marshal reasoning: %w", err)
|
Enabled: true,
|
||||||
}
|
}
|
||||||
openAIRequest.Reasoning = reasoningJSON
|
|
||||||
}
|
}
|
||||||
} else {
|
reasoningJSON, err := json.Marshal(reasoning)
|
||||||
thinkingSuffix := "-thinking"
|
if err != nil {
|
||||||
if strings.HasSuffix(info.OriginModelName, thinkingSuffix) &&
|
return nil, fmt.Errorf("failed to marshal reasoning: %w", err)
|
||||||
!strings.HasSuffix(openAIRequest.Model, thinkingSuffix) {
|
|
||||||
openAIRequest.Model = openAIRequest.Model + thinkingSuffix
|
|
||||||
}
|
}
|
||||||
|
openAIRequest.Reasoning = reasoningJSON
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
thinkingSuffix := "-thinking"
|
||||||
|
if strings.HasSuffix(info.OriginModelName, thinkingSuffix) &&
|
||||||
|
!strings.HasSuffix(openAIRequest.Model, thinkingSuffix) {
|
||||||
|
openAIRequest.Model = openAIRequest.Model + thinkingSuffix
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user