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
Unverified
Commit
7d09c695
authored
Aug 15, 2026
by
Seefs
Committed by
GitHub
Aug 15, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: prompt_cache_key openai chat -> openai responses (#6861)
parent
47ba9d2c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
0 deletions
+41
-0
relaykit/relayconvert/internal/oai_chat/to_oai_responses_req.go
+9
-0
relaykit/relayconvert/internal/oai_chat/to_oai_responses_req_test.go
+32
-0
No files found.
relaykit/relayconvert/internal/oai_chat/to_oai_responses_req.go
View file @
7d09c695
...
...
@@ -380,6 +380,14 @@ func ChatCompletionsRequestToResponsesRequest(req *dto.GeneralOpenAIRequest) (*d
presencePenaltyRaw
,
_
=
kitutil
.
Marshal
(
req
.
PresencePenalty
)
}
var
promptCacheKeyRaw
json
.
RawMessage
if
req
.
PromptCacheKey
!=
""
{
promptCacheKeyRaw
,
err
=
kitutil
.
Marshal
(
req
.
PromptCacheKey
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"marshal prompt_cache_key: %w"
,
err
)
}
}
out
:=
&
dto
.
OpenAIResponsesRequest
{
Model
:
req
.
Model
,
Input
:
inputRaw
,
...
...
@@ -396,6 +404,7 @@ func ChatCompletionsRequestToResponsesRequest(req *dto.GeneralOpenAIRequest) (*d
ParallelToolCalls
:
parallelToolCallsRaw
,
Store
:
req
.
Store
,
Metadata
:
req
.
Metadata
,
PromptCacheKey
:
promptCacheKeyRaw
,
EnableThinking
:
req
.
EnableThinking
,
ThinkingBudget
:
req
.
ThinkingBudget
,
}
...
...
relaykit/relayconvert/internal/oai_chat/to_oai_responses_req_test.go
View file @
7d09c695
...
...
@@ -39,6 +39,38 @@ func TestChatCompletionsRequestToResponsesRequestInstructionsAndTools(t *testing
assert
.
Equal
(
t
,
"function_call_output"
,
gjson
.
GetBytes
(
got
.
Input
,
"3.type"
)
.
String
())
}
func
TestChatCompletionsRequestToResponsesRequestPreservesPromptCacheKey
(
t
*
testing
.
T
)
{
t
.
Run
(
"present"
,
func
(
t
*
testing
.
T
)
{
key
:=
"session-
\"
quoted
\"\\
path
\n
世界"
got
,
err
:=
ChatCompletionsRequestToResponsesRequest
(
&
dto
.
GeneralOpenAIRequest
{
Model
:
"gpt-test"
,
Messages
:
[]
dto
.
Message
{{
Role
:
"user"
,
Content
:
"hello"
}},
PromptCacheKey
:
key
,
})
require
.
NoError
(
t
,
err
)
keyRaw
,
err
:=
kitutil
.
Marshal
(
key
)
require
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
keyRaw
,
[]
byte
(
got
.
PromptCacheKey
))
encoded
,
err
:=
kitutil
.
Marshal
(
got
)
require
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
key
,
gjson
.
GetBytes
(
encoded
,
"prompt_cache_key"
)
.
String
())
})
t
.
Run
(
"absent"
,
func
(
t
*
testing
.
T
)
{
got
,
err
:=
ChatCompletionsRequestToResponsesRequest
(
&
dto
.
GeneralOpenAIRequest
{
Model
:
"gpt-test"
,
Messages
:
[]
dto
.
Message
{{
Role
:
"user"
,
Content
:
"hello"
}},
})
require
.
NoError
(
t
,
err
)
encoded
,
err
:=
kitutil
.
Marshal
(
got
)
require
.
NoError
(
t
,
err
)
assert
.
False
(
t
,
gjson
.
GetBytes
(
encoded
,
"prompt_cache_key"
)
.
Exists
())
})
}
func
TestChatCompletionsRequestToResponsesRequestPreservesQwenThinkingBudget
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
name
string
...
...
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