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
67719dc0
authored
Aug 26, 2025
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: update web search handling and request structure in adaptor and openai_request
parent
1b8bcfb0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
dto/openai_request.go
+9
-3
relay/channel/baidu_v2/adaptor.go
+4
-1
No files found.
dto/openai_request.go
View file @
67719dc0
...
@@ -57,18 +57,24 @@ type GeneralOpenAIRequest struct {
...
@@ -57,18 +57,24 @@ type GeneralOpenAIRequest struct {
Dimensions
int
`json:"dimensions,omitempty"`
Dimensions
int
`json:"dimensions,omitempty"`
Modalities
json
.
RawMessage
`json:"modalities,omitempty"`
Modalities
json
.
RawMessage
`json:"modalities,omitempty"`
Audio
json
.
RawMessage
`json:"audio,omitempty"`
Audio
json
.
RawMessage
`json:"audio,omitempty"`
EnableThinking
any
`json:"enable_thinking,omitempty"`
// ali
// gemini
THINKING
json
.
RawMessage
`json:"thinking,omitempty"`
// doubao,zhipu_v4
ExtraBody
json
.
RawMessage
`json:"extra_body,omitempty"`
ExtraBody
json
.
RawMessage
`json:"extra_body,omitempty"`
SearchParameters
any
`json:"search_parameters,omitempty"`
//xai
//xai
SearchParameters
json
.
RawMessage
`json:"search_parameters,omitempty"`
// claude
WebSearchOptions
*
WebSearchOptions
`json:"web_search_options,omitempty"`
WebSearchOptions
*
WebSearchOptions
`json:"web_search_options,omitempty"`
// OpenRouter Params
// OpenRouter Params
Usage
json
.
RawMessage
`json:"usage,omitempty"`
Usage
json
.
RawMessage
`json:"usage,omitempty"`
Reasoning
json
.
RawMessage
`json:"reasoning,omitempty"`
Reasoning
json
.
RawMessage
`json:"reasoning,omitempty"`
// Ali Qwen Params
// Ali Qwen Params
VlHighResolutionImages
json
.
RawMessage
`json:"vl_high_resolution_images,omitempty"`
VlHighResolutionImages
json
.
RawMessage
`json:"vl_high_resolution_images,omitempty"`
EnableThinking
any
`json:"enable_thinking,omitempty"`
// ollama Params
// ollama Params
Think
json
.
RawMessage
`json:"think,omitempty"`
Think
json
.
RawMessage
`json:"think,omitempty"`
// baidu v2
WebSearch
json
.
RawMessage
`json:"web_search,omitempty"`
// doubao,zhipu_v4
THINKING
json
.
RawMessage
`json:"thinking,omitempty"`
}
}
func
(
r
*
GeneralOpenAIRequest
)
GetTokenCountMeta
()
*
types
.
TokenCountMeta
{
func
(
r
*
GeneralOpenAIRequest
)
GetTokenCountMeta
()
*
types
.
TokenCountMeta
{
...
...
relay/channel/baidu_v2/adaptor.go
View file @
67719dc0
...
@@ -81,6 +81,7 @@ func (a *Adaptor) ConvertOpenAIRequest(c *gin.Context, info *relaycommon.RelayIn
...
@@ -81,6 +81,7 @@ func (a *Adaptor) ConvertOpenAIRequest(c *gin.Context, info *relaycommon.RelayIn
if
strings
.
HasSuffix
(
info
.
UpstreamModelName
,
"-search"
)
{
if
strings
.
HasSuffix
(
info
.
UpstreamModelName
,
"-search"
)
{
info
.
UpstreamModelName
=
strings
.
TrimSuffix
(
info
.
UpstreamModelName
,
"-search"
)
info
.
UpstreamModelName
=
strings
.
TrimSuffix
(
info
.
UpstreamModelName
,
"-search"
)
request
.
Model
=
info
.
UpstreamModelName
request
.
Model
=
info
.
UpstreamModelName
if
len
(
request
.
WebSearch
)
==
0
{
toMap
:=
request
.
ToMap
()
toMap
:=
request
.
ToMap
()
toMap
[
"web_search"
]
=
map
[
string
]
any
{
toMap
[
"web_search"
]
=
map
[
string
]
any
{
"enable"
:
true
,
"enable"
:
true
,
...
@@ -91,10 +92,12 @@ func (a *Adaptor) ConvertOpenAIRequest(c *gin.Context, info *relaycommon.RelayIn
...
@@ -91,10 +92,12 @@ func (a *Adaptor) ConvertOpenAIRequest(c *gin.Context, info *relaycommon.RelayIn
return
toMap
,
nil
return
toMap
,
nil
}
}
return
request
,
nil
return
request
,
nil
}
return
request
,
nil
}
}
func
(
a
*
Adaptor
)
ConvertRerankRequest
(
c
*
gin
.
Context
,
relayMode
int
,
request
dto
.
RerankRequest
)
(
any
,
error
)
{
func
(
a
*
Adaptor
)
ConvertRerankRequest
(
c
*
gin
.
Context
,
relayMode
int
,
request
dto
.
RerankRequest
)
(
any
,
error
)
{
return
nil
,
nil
return
nil
,
errors
.
New
(
"not implemented"
)
}
}
func
(
a
*
Adaptor
)
ConvertEmbeddingRequest
(
c
*
gin
.
Context
,
info
*
relaycommon
.
RelayInfo
,
request
dto
.
EmbeddingRequest
)
(
any
,
error
)
{
func
(
a
*
Adaptor
)
ConvertEmbeddingRequest
(
c
*
gin
.
Context
,
info
*
relaycommon
.
RelayInfo
,
request
dto
.
EmbeddingRequest
)
(
any
,
error
)
{
...
...
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