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
83191981
authored
Sep 07, 2025
by
IcedTangerine
Committed by
GitHub
Sep 07, 2025
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1761 from QuantumNous/openaitoclaude-improve
feat: 改进Claude响应转OpenAI响应
parents
80cfa0d0
de73bfff
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
2 deletions
+5
-2
relay/channel/claude/relay-claude.go
+5
-2
No files found.
relay/channel/claude/relay-claude.go
View file @
83191981
...
@@ -32,7 +32,7 @@ func stopReasonClaude2OpenAI(reason string) string {
...
@@ -32,7 +32,7 @@ func stopReasonClaude2OpenAI(reason string) string {
case
"end_turn"
:
case
"end_turn"
:
return
"stop"
return
"stop"
case
"max_tokens"
:
case
"max_tokens"
:
return
"
max_tokens
"
return
"
length
"
case
"tool_use"
:
case
"tool_use"
:
return
"tool_calls"
return
"tool_calls"
default
:
default
:
...
@@ -426,7 +426,10 @@ func StreamResponseClaude2OpenAI(reqMode int, claudeResponse *dto.ClaudeResponse
...
@@ -426,7 +426,10 @@ func StreamResponseClaude2OpenAI(reqMode int, claudeResponse *dto.ClaudeResponse
choice
.
Delta
.
Role
=
"assistant"
choice
.
Delta
.
Role
=
"assistant"
}
else
if
claudeResponse
.
Type
==
"content_block_start"
{
}
else
if
claudeResponse
.
Type
==
"content_block_start"
{
if
claudeResponse
.
ContentBlock
!=
nil
{
if
claudeResponse
.
ContentBlock
!=
nil
{
//choice.Delta.SetContentString(claudeResponse.ContentBlock.Text)
// 如果是文本块,尽可能发送首段文本(若存在)
if
claudeResponse
.
ContentBlock
.
Type
==
"text"
&&
claudeResponse
.
ContentBlock
.
Text
!=
nil
{
choice
.
Delta
.
SetContentString
(
*
claudeResponse
.
ContentBlock
.
Text
)
}
if
claudeResponse
.
ContentBlock
.
Type
==
"tool_use"
{
if
claudeResponse
.
ContentBlock
.
Type
==
"tool_use"
{
tools
=
append
(
tools
,
dto
.
ToolCallResponse
{
tools
=
append
(
tools
,
dto
.
ToolCallResponse
{
Index
:
common
.
GetPointer
(
fcIdx
),
Index
:
common
.
GetPointer
(
fcIdx
),
...
...
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