Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1b179862
authored
Mar 05, 2026
by
Nekohy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete some if
parent
a4629f26
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
26 deletions
+24
-26
service/convert.go
+24
-26
No files found.
service/convert.go
View file @
1b179862
...
...
@@ -34,36 +34,34 @@ func ClaudeToOpenAIRequest(claudeRequest dto.ClaudeRequest, info *relaycommon.Re
isOpenRouter
:=
info
.
ChannelType
==
constant
.
ChannelTypeOpenRouter
if
claudeRequest
.
Thinking
!=
nil
&&
(
claudeRequest
.
Thinking
.
Type
==
"enabled"
||
claudeRequest
.
Thinking
.
Type
==
"adaptive"
)
{
if
isOpenRouter
{
if
effort
:=
claudeRequest
.
GetEfforts
();
effort
!=
""
{
effortBytes
,
_
:=
json
.
Marshal
(
effort
)
openAIRequest
.
Verbosity
=
effortBytes
}
if
claudeRequest
.
Thinking
!=
nil
{
var
reasoning
openrouter
.
RequestReasoning
if
claudeRequest
.
Thinking
.
Type
==
"enabled"
{
reasoning
=
openrouter
.
RequestReasoning
{
Enabled
:
true
,
MaxTokens
:
claudeRequest
.
Thinking
.
GetBudgetTokens
(),
}
}
else
if
claudeRequest
.
Thinking
.
Type
==
"adaptive"
{
reasoning
=
openrouter
.
RequestReasoning
{
Enabled
:
true
,
}
if
isOpenRouter
{
if
effort
:=
claudeRequest
.
GetEfforts
();
effort
!=
""
{
effortBytes
,
_
:=
json
.
Marshal
(
effort
)
openAIRequest
.
Verbosity
=
effortBytes
}
if
claudeRequest
.
Thinking
!=
nil
{
var
reasoning
openrouter
.
RequestReasoning
if
claudeRequest
.
Thinking
.
Type
==
"enabled"
{
reasoning
=
openrouter
.
RequestReasoning
{
Enabled
:
true
,
MaxTokens
:
claudeRequest
.
Thinking
.
GetBudgetTokens
(),
}
reasoningJSON
,
err
:=
json
.
Marshal
(
reasoning
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to marshal reasoning: %w"
,
err
)
}
else
if
claudeRequest
.
Thinking
.
Type
==
"adaptive"
{
reasoning
=
openrouter
.
RequestReasoning
{
Enabled
:
true
,
}
openAIRequest
.
Reasoning
=
reasoningJSON
}
}
else
{
thinkingSuffix
:=
"-thinking"
if
strings
.
HasSuffix
(
info
.
OriginModelName
,
thinkingSuffix
)
&&
!
strings
.
HasSuffix
(
openAIRequest
.
Model
,
thinkingSuffix
)
{
openAIRequest
.
Model
=
openAIRequest
.
Model
+
thinkingSuffix
reasoningJSON
,
err
:=
json
.
Marshal
(
reasoning
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to marshal reasoning: %w"
,
err
)
}
openAIRequest
.
Reasoning
=
reasoningJSON
}
}
else
{
thinkingSuffix
:=
"-thinking"
if
strings
.
HasSuffix
(
info
.
OriginModelName
,
thinkingSuffix
)
&&
!
strings
.
HasSuffix
(
openAIRequest
.
Model
,
thinkingSuffix
)
{
openAIRequest
.
Model
=
openAIRequest
.
Model
+
thinkingSuffix
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment