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
03675397
authored
Jun 01, 2025
by
Apple\Apple
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'main' into ui/refactor
parents
dec73f75
46f95fdd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
2 deletions
+23
-2
dto/openai_request.go
+10
-2
relay/channel/baidu_v2/adaptor.go
+13
-0
No files found.
dto/openai_request.go
View file @
03675397
...
@@ -2,6 +2,7 @@ package dto
...
@@ -2,6 +2,7 @@ package dto
import
(
import
(
"encoding/json"
"encoding/json"
"one-api/common"
"strings"
"strings"
)
)
...
@@ -57,6 +58,13 @@ type GeneralOpenAIRequest struct {
...
@@ -57,6 +58,13 @@ type GeneralOpenAIRequest struct {
WebSearchOptions
*
WebSearchOptions
`json:"web_search_options,omitempty"`
WebSearchOptions
*
WebSearchOptions
`json:"web_search_options,omitempty"`
}
}
func
(
r
*
GeneralOpenAIRequest
)
ToMap
()
map
[
string
]
any
{
result
:=
make
(
map
[
string
]
any
)
data
,
_
:=
common
.
EncodeJson
(
r
)
_
=
common
.
DecodeJson
(
data
,
&
result
)
return
result
}
type
ToolCallRequest
struct
{
type
ToolCallRequest
struct
{
ID
string
`json:"id,omitempty"`
ID
string
`json:"id,omitempty"`
Type
string
`json:"type"`
Type
string
`json:"type"`
...
@@ -74,11 +82,11 @@ type StreamOptions struct {
...
@@ -74,11 +82,11 @@ type StreamOptions struct {
IncludeUsage
bool
`json:"include_usage,omitempty"`
IncludeUsage
bool
`json:"include_usage,omitempty"`
}
}
func
(
r
GeneralOpenAIRequest
)
GetMaxTokens
()
int
{
func
(
r
*
GeneralOpenAIRequest
)
GetMaxTokens
()
int
{
return
int
(
r
.
MaxTokens
)
return
int
(
r
.
MaxTokens
)
}
}
func
(
r
GeneralOpenAIRequest
)
ParseInput
()
[]
string
{
func
(
r
*
GeneralOpenAIRequest
)
ParseInput
()
[]
string
{
if
r
.
Input
==
nil
{
if
r
.
Input
==
nil
{
return
nil
return
nil
}
}
...
...
relay/channel/baidu_v2/adaptor.go
View file @
03675397
...
@@ -9,6 +9,7 @@ import (
...
@@ -9,6 +9,7 @@ import (
"one-api/relay/channel"
"one-api/relay/channel"
"one-api/relay/channel/openai"
"one-api/relay/channel/openai"
relaycommon
"one-api/relay/common"
relaycommon
"one-api/relay/common"
"strings"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
)
)
...
@@ -49,6 +50,18 @@ func (a *Adaptor) ConvertOpenAIRequest(c *gin.Context, info *relaycommon.RelayIn
...
@@ -49,6 +50,18 @@ func (a *Adaptor) ConvertOpenAIRequest(c *gin.Context, info *relaycommon.RelayIn
if
request
==
nil
{
if
request
==
nil
{
return
nil
,
errors
.
New
(
"request is 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
[
"web_search"
]
=
map
[
string
]
any
{
"enable"
:
true
,
"enable_citation"
:
true
,
"enable_trace"
:
true
,
"enable_status"
:
false
,
}
return
toMap
,
nil
}
return
request
,
nil
return
request
,
nil
}
}
...
...
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