feat: openrouter format for claude request
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"one-api/common"
|
"one-api/common"
|
||||||
"one-api/dto"
|
"one-api/dto"
|
||||||
|
"one-api/relay/channel/openrouter"
|
||||||
relaycommon "one-api/relay/common"
|
relaycommon "one-api/relay/common"
|
||||||
"one-api/relay/helper"
|
"one-api/relay/helper"
|
||||||
"one-api/service"
|
"one-api/service"
|
||||||
@@ -122,6 +123,21 @@ func RequestOpenAI2ClaudeMessage(textRequest dto.GeneralOpenAIRequest) (*dto.Cla
|
|||||||
claudeRequest.Model = strings.TrimSuffix(textRequest.Model, "-thinking")
|
claudeRequest.Model = strings.TrimSuffix(textRequest.Model, "-thinking")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if textRequest.Reasoning != nil {
|
||||||
|
var reasoning openrouter.RequestReasoning
|
||||||
|
if err := json.Unmarshal(textRequest.Reasoning, &reasoning); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
budgetTokens := reasoning.MaxTokens
|
||||||
|
if budgetTokens > 0 {
|
||||||
|
claudeRequest.Thinking = &dto.Thinking{
|
||||||
|
Type: "enabled",
|
||||||
|
BudgetTokens: budgetTokens,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if textRequest.Stop != nil {
|
if textRequest.Stop != nil {
|
||||||
// stop maybe string/array string, convert to array string
|
// stop maybe string/array string, convert to array string
|
||||||
switch textRequest.Stop.(type) {
|
switch textRequest.Stop.(type) {
|
||||||
|
|||||||
Reference in New Issue
Block a user