Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
d7fa47d7
Commit
d7fa47d7
authored
Jan 12, 2026
by
ianshaw
Browse files
refactor(openai): 移除不必要的 seedOpenAISessionHeaders 函数
parent
3d6e01a5
Changes
1
Show whitespace changes
Inline
Side-by-side
backend/internal/handler/openai_gateway_handler.go
View file @
d7fa47d7
...
...
@@ -96,8 +96,6 @@ func (h *OpenAIGatewayHandler) Responses(c *gin.Context) {
return
}
seedOpenAISessionHeaders
(
c
,
reqBody
)
userAgent
:=
c
.
GetHeader
(
"User-Agent"
)
if
!
openai
.
IsCodexCLIRequest
(
userAgent
)
{
existingInstructions
,
_
:=
reqBody
[
"instructions"
]
.
(
string
)
...
...
@@ -301,37 +299,6 @@ func (h *OpenAIGatewayHandler) handleFailoverExhausted(c *gin.Context, statusCod
h
.
handleStreamingAwareError
(
c
,
status
,
errType
,
errMsg
,
streamStarted
)
}
func
seedOpenAISessionHeaders
(
c
*
gin
.
Context
,
reqBody
map
[
string
]
any
)
{
if
c
.
GetHeader
(
"session_id"
)
==
""
{
if
v
:=
firstNonEmptyString
(
reqBody
[
"prompt_cache_key"
],
reqBody
[
"session_id"
],
reqBody
[
"conversation_id"
],
reqBody
[
"previous_response_id"
],
);
v
!=
""
{
c
.
Request
.
Header
.
Set
(
"session_id"
,
v
)
}
}
if
c
.
GetHeader
(
"conversation_id"
)
==
""
{
if
v
:=
firstNonEmptyString
(
reqBody
[
"prompt_cache_key"
],
reqBody
[
"conversation_id"
]);
v
!=
""
{
c
.
Request
.
Header
.
Set
(
"conversation_id"
,
v
)
}
}
}
func
firstNonEmptyString
(
values
...
any
)
string
{
for
_
,
value
:=
range
values
{
s
,
ok
:=
value
.
(
string
)
if
ok
{
s
=
strings
.
TrimSpace
(
s
)
if
s
!=
""
{
return
s
}
}
}
return
""
}
func
(
h
*
OpenAIGatewayHandler
)
mapUpstreamError
(
statusCode
int
)
(
int
,
string
,
string
)
{
switch
statusCode
{
case
401
:
...
...
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