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
515cd983
authored
Jul 12, 2025
by
Calcium-Ion
Committed by
GitHub
Jul 12, 2025
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1357 from RedwindA/feat/xAI-search
feat: support xAI-search
parents
23744465
98d1da6f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
2 deletions
+14
-2
dto/openai_request.go
+1
-0
main.go
+2
-2
relay/channel/xai/adaptor.go
+9
-0
relay/channel/xai/constants.go
+2
-0
No files found.
dto/openai_request.go
View file @
515cd983
...
...
@@ -55,6 +55,7 @@ type GeneralOpenAIRequest struct {
EnableThinking
any
`json:"enable_thinking,omitempty"`
// ali
THINKING
json
.
RawMessage
`json:"thinking,omitempty"`
// doubao
ExtraBody
json
.
RawMessage
`json:"extra_body,omitempty"`
SearchParameters
any
`json:"search_parameters,omitempty"`
//xai
WebSearchOptions
*
WebSearchOptions
`json:"web_search_options,omitempty"`
// OpenRouter Params
Usage
json
.
RawMessage
`json:"usage,omitempty"`
...
...
main.go
View file @
515cd983
...
...
@@ -168,11 +168,11 @@ func InitResources() error {
common
.
SysLog
(
"No .env file found, using default environment variables. If needed, please create a .env file and set the relevant variables."
)
}
common
.
SetupLogger
()
// 加载环境变量
common
.
InitEnv
()
common
.
SetupLogger
()
// Initialize model settings
ratio_setting
.
InitRatioSettings
()
...
...
relay/channel/xai/adaptor.go
View file @
515cd983
...
...
@@ -56,6 +56,15 @@ func (a *Adaptor) ConvertOpenAIRequest(c *gin.Context, info *relaycommon.RelayIn
if
request
==
nil
{
return
nil
,
errors
.
New
(
"request is nil"
)
}
if
strings
.
HasSuffix
(
info
.
UpstreamModelName
,
"-search"
)
{
info
.
UpstreamModelName
=
strings
.
TrimSuffix
(
info
.
UpstreamModelName
,
"-search"
)
request
.
Model
=
info
.
UpstreamModelName
toMap
:=
request
.
ToMap
()
toMap
[
"search_parameters"
]
=
map
[
string
]
any
{
"mode"
:
"on"
,
}
return
toMap
,
nil
}
if
strings
.
HasPrefix
(
request
.
Model
,
"grok-3-mini"
)
{
if
request
.
MaxCompletionTokens
==
0
&&
request
.
MaxTokens
!=
0
{
request
.
MaxCompletionTokens
=
request
.
MaxTokens
...
...
relay/channel/xai/constants.go
View file @
515cd983
package
xai
var
ModelList
=
[]
string
{
// grok-4
"grok-4"
,
"grok-4-0709"
,
"grok-4-0709-search"
,
// grok-3
"grok-3-beta"
,
"grok-3-mini-beta"
,
// grok-3 mini
...
...
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