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
fb76abb3
authored
Mar 06, 2026
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: update OpenAI request fields to use json.RawMessage for dynamic data handling
parent
9905599d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
25 deletions
+34
-25
dto/openai_request.go
+8
-8
relay/channel/baidu/dto.go
+11
-10
relay/channel/coze/dto.go
+1
-1
relay/channel/coze/relay-coze.go
+2
-2
relay/channel/dify/dto.go
+3
-1
relay/channel/dify/relay-dify.go
+9
-3
No files found.
dto/openai_request.go
View file @
fb76abb3
...
...
@@ -56,10 +56,10 @@ type GeneralOpenAIRequest struct {
Tools
[]
ToolCallRequest
`json:"tools,omitempty"`
ToolChoice
any
`json:"tool_choice,omitempty"`
FunctionCall
json
.
RawMessage
`json:"function_call,omitempty"`
User
string
`json:"user,omitempty"`
User
json
.
RawMessage
`json:"user,omitempty"`
// ServiceTier specifies upstream service level and may affect billing.
// This field is filtered by default and can be enabled via channel setting allow_service_tier.
ServiceTier
string
`json:"service_tier,omitempty"`
ServiceTier
json
.
RawMessage
`json:"service_tier,omitempty"`
LogProbs
*
bool
`json:"logprobs,omitempty"`
TopLogProbs
*
int
`json:"top_logprobs,omitempty"`
Dimensions
*
int
`json:"dimensions,omitempty"`
...
...
@@ -67,7 +67,7 @@ type GeneralOpenAIRequest struct {
Audio
json
.
RawMessage
`json:"audio,omitempty"`
// 安全标识符,用于帮助 OpenAI 检测可能违反使用政策的应用程序用户
// 注意:此字段会向 OpenAI 发送用户标识信息,默认过滤,可通过 allow_safety_identifier 开启
SafetyIdentifier
string
`json:"safety_identifier,omitempty"`
SafetyIdentifier
json
.
RawMessage
`json:"safety_identifier,omitempty"`
// Whether or not to store the output of this chat completion request for use in our model distillation or evals products.
// 是否存储此次请求数据供 OpenAI 用于评估和优化产品
// 注意:默认允许透传,可通过 disable_store 禁用;禁用后可能导致 Codex 无法正常使用
...
...
@@ -100,10 +100,10 @@ type GeneralOpenAIRequest struct {
THINKING
json
.
RawMessage
`json:"thinking,omitempty"`
// pplx Params
SearchDomainFilter
json
.
RawMessage
`json:"search_domain_filter,omitempty"`
SearchRecencyFilter
string
`json:"search_recency_filter,omitempty"`
SearchRecencyFilter
json
.
RawMessage
`json:"search_recency_filter,omitempty"`
ReturnImages
*
bool
`json:"return_images,omitempty"`
ReturnRelatedQuestions
*
bool
`json:"return_related_questions,omitempty"`
SearchMode
string
`json:"search_mode,omitempty"`
SearchMode
json
.
RawMessage
`json:"search_mode,omitempty"`
// Minimax
ReasoningSplit
json
.
RawMessage
`json:"reasoning_split,omitempty"`
}
...
...
@@ -836,7 +836,7 @@ type OpenAIResponsesRequest struct {
PromptCacheRetention
json
.
RawMessage
`json:"prompt_cache_retention,omitempty"`
// SafetyIdentifier carries client identity for policy abuse detection.
// This field is filtered by default and can be enabled via channel setting allow_safety_identifier.
SafetyIdentifier
string
`json:"safety_identifier,omitempty"`
SafetyIdentifier
json
.
RawMessage
`json:"safety_identifier,omitempty"`
Stream
*
bool
`json:"stream,omitempty"`
StreamOptions
*
StreamOptions
`json:"stream_options,omitempty"`
Temperature
*
float64
`json:"temperature,omitempty"`
...
...
@@ -844,8 +844,8 @@ type OpenAIResponsesRequest struct {
ToolChoice
json
.
RawMessage
`json:"tool_choice,omitempty"`
Tools
json
.
RawMessage
`json:"tools,omitempty"`
// 需要处理的参数很少,MCP 参数太多不确定,所以用 map
TopP
*
float64
`json:"top_p,omitempty"`
Truncation
string
`json:"truncation,omitempty"`
User
string
`json:"user,omitempty"`
Truncation
json
.
RawMessage
`json:"truncation,omitempty"`
User
json
.
RawMessage
`json:"user,omitempty"`
MaxToolCalls
*
uint
`json:"max_tool_calls,omitempty"`
Prompt
json
.
RawMessage
`json:"prompt,omitempty"`
// qwen
...
...
relay/channel/baidu/dto.go
View file @
fb76abb3
package
baidu
import
(
"encoding/json"
"time"
"github.com/QuantumNous/new-api/dto"
...
...
@@ -12,16 +13,16 @@ type BaiduMessage struct {
}
type
BaiduChatRequest
struct
{
Messages
[]
BaiduMessage
`json:"messages"`
Temperature
*
float64
`json:"temperature,omitempty"`
TopP
float64
`json:"top_p,omitempty"`
PenaltyScore
float64
`json:"penalty_score,omitempty"`
Stream
bool
`json:"stream,omitempty"`
System
string
`json:"system,omitempty"`
DisableSearch
bool
`json:"disable_search,omitempty"`
EnableCitation
bool
`json:"enable_citation,omitempty"`
MaxOutputTokens
*
int
`json:"max_output_tokens,omitempty"`
UserId
string
`json:"user_id,omitempty"`
Messages
[]
BaiduMessage
`json:"messages"`
Temperature
*
float64
`json:"temperature,omitempty"`
TopP
float64
`json:"top_p,omitempty"`
PenaltyScore
float64
`json:"penalty_score,omitempty"`
Stream
bool
`json:"stream,omitempty"`
System
string
`json:"system,omitempty"`
DisableSearch
bool
`json:"disable_search,omitempty"`
EnableCitation
bool
`json:"enable_citation,omitempty"`
MaxOutputTokens
*
int
`json:"max_output_tokens,omitempty"`
UserId
json
.
RawMessage
`json:"user_id,omitempty"`
}
type
Error
struct
{
...
...
relay/channel/coze/dto.go
View file @
fb76abb3
...
...
@@ -17,7 +17,7 @@ type CozeEnterMessage struct {
type
CozeChatRequest
struct
{
BotId
string
`json:"bot_id"`
UserId
string
`json:"user_id"`
UserId
json
.
RawMessage
`json:"user_id"`
AdditionalMessages
[]
CozeEnterMessage
`json:"additional_messages,omitempty"`
Stream
bool
`json:"stream,omitempty"`
CustomVariables
json
.
RawMessage
`json:"custom_variables,omitempty"`
...
...
relay/channel/coze/relay-coze.go
View file @
fb76abb3
...
...
@@ -34,8 +34,8 @@ func convertCozeChatRequest(c *gin.Context, request dto.GeneralOpenAIRequest) *C
}
}
user
:=
request
.
User
if
user
==
""
{
user
=
helper
.
GetResponseID
(
c
)
if
len
(
user
)
==
0
{
user
=
json
.
RawMessage
(
helper
.
GetResponseID
(
c
)
)
}
cozeRequest
:=
&
CozeChatRequest
{
BotId
:
c
.
GetString
(
"bot_id"
),
...
...
relay/channel/dify/dto.go
View file @
fb76abb3
package
dify
import
"github.com/QuantumNous/new-api/dto"
import
(
"github.com/QuantumNous/new-api/dto"
)
type
DifyChatRequest
struct
{
Inputs
map
[
string
]
interface
{}
`json:"inputs"`
...
...
relay/channel/dify/relay-dify.go
View file @
fb76abb3
...
...
@@ -131,10 +131,16 @@ func requestOpenAI2Dify(c *gin.Context, info *relaycommon.RelayInfo, request dto
}
user
:=
request
.
User
if
user
==
""
{
user
=
helper
.
GetResponseID
(
c
)
if
len
(
user
)
==
0
{
user
=
json
.
RawMessage
(
helper
.
GetResponseID
(
c
)
)
}
difyReq
.
User
=
user
var
stringUser
string
err
:=
json
.
Unmarshal
(
user
,
&
stringUser
)
if
err
!=
nil
{
common
.
SysLog
(
"failed to unmarshal user: "
+
err
.
Error
())
stringUser
=
helper
.
GetResponseID
(
c
)
}
difyReq
.
User
=
stringUser
files
:=
make
([]
DifyFile
,
0
)
var
content
strings
.
Builder
...
...
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