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
7384b092
authored
Sep 20, 2025
by
Seefs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: claude system prompt overwrite
parent
d6f1b862
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
relay/claude_handler.go
+26
-0
No files found.
relay/claude_handler.go
View file @
7384b092
...
@@ -6,6 +6,7 @@ import (
...
@@ -6,6 +6,7 @@ import (
"io"
"io"
"net/http"
"net/http"
"one-api/common"
"one-api/common"
"one-api/constant"
"one-api/dto"
"one-api/dto"
relaycommon
"one-api/relay/common"
relaycommon
"one-api/relay/common"
"one-api/relay/helper"
"one-api/relay/helper"
...
@@ -69,6 +70,31 @@ func ClaudeHelper(c *gin.Context, info *relaycommon.RelayInfo) (newAPIError *typ
...
@@ -69,6 +70,31 @@ func ClaudeHelper(c *gin.Context, info *relaycommon.RelayInfo) (newAPIError *typ
info
.
UpstreamModelName
=
request
.
Model
info
.
UpstreamModelName
=
request
.
Model
}
}
if
info
.
ChannelSetting
.
SystemPrompt
!=
""
&&
info
.
ChannelSetting
.
SystemPromptOverride
{
if
request
.
System
==
nil
{
request
.
SetStringSystem
(
info
.
ChannelSetting
.
SystemPrompt
)
}
else
if
info
.
ChannelSetting
.
SystemPromptOverride
{
common
.
SetContextKey
(
c
,
constant
.
ContextKeySystemPromptOverride
,
true
)
if
request
.
IsStringSystem
()
{
existing
:=
strings
.
TrimSpace
(
request
.
GetStringSystem
())
if
existing
==
""
{
request
.
SetStringSystem
(
info
.
ChannelSetting
.
SystemPrompt
)
}
else
{
request
.
SetStringSystem
(
info
.
ChannelSetting
.
SystemPrompt
+
"
\n
"
+
existing
)
}
}
else
{
systemContents
:=
request
.
ParseSystem
()
newSystem
:=
dto
.
ClaudeMediaMessage
{
Type
:
dto
.
ContentTypeText
}
newSystem
.
SetText
(
info
.
ChannelSetting
.
SystemPrompt
)
if
len
(
systemContents
)
==
0
{
request
.
System
=
[]
dto
.
ClaudeMediaMessage
{
newSystem
}
}
else
{
request
.
System
=
append
([]
dto
.
ClaudeMediaMessage
{
newSystem
},
systemContents
...
)
}
}
}
}
var
requestBody
io
.
Reader
var
requestBody
io
.
Reader
if
model_setting
.
GetGlobalSettings
()
.
PassThroughRequestEnabled
||
info
.
ChannelSetting
.
PassThroughBodyEnabled
{
if
model_setting
.
GetGlobalSettings
()
.
PassThroughRequestEnabled
||
info
.
ChannelSetting
.
PassThroughBodyEnabled
{
body
,
err
:=
common
.
GetRequestBody
(
c
)
body
,
err
:=
common
.
GetRequestBody
(
c
)
...
...
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