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
bc65c827
authored
Jul 14, 2025
by
RedwindA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🎨
feat(channel-test): Enhance request conversion for Embedding models and update input type
parent
5c55da29
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
controller/channel-test.go
+17
-2
No files found.
controller/channel-test.go
View file @
bc65c827
...
@@ -17,6 +17,7 @@ import (
...
@@ -17,6 +17,7 @@ import (
"one-api/model"
"one-api/model"
"one-api/relay"
"one-api/relay"
relaycommon
"one-api/relay/common"
relaycommon
"one-api/relay/common"
relayconstant
"one-api/relay/constant"
"one-api/relay/helper"
"one-api/relay/helper"
"one-api/service"
"one-api/service"
"one-api/types"
"one-api/types"
...
@@ -165,7 +166,21 @@ func testChannel(channel *model.Channel, testModel string) testResult {
...
@@ -165,7 +166,21 @@ func testChannel(channel *model.Channel, testModel string) testResult {
adaptor
.
Init
(
info
)
adaptor
.
Init
(
info
)
convertedRequest
,
err
:=
adaptor
.
ConvertOpenAIRequest
(
c
,
info
,
request
)
var
convertedRequest
any
// 根据 RelayMode 选择正确的转换函数
if
info
.
RelayMode
==
relayconstant
.
RelayModeEmbeddings
{
// 创建一个 EmbeddingRequest
embeddingRequest
:=
dto
.
EmbeddingRequest
{
Input
:
request
.
Input
,
Model
:
request
.
Model
,
}
// 调用专门用于 Embedding 的转换函数
convertedRequest
,
err
=
adaptor
.
ConvertEmbeddingRequest
(
c
,
info
,
embeddingRequest
)
}
else
{
// 对其他所有请求类型(如 Chat),保持原有逻辑
convertedRequest
,
err
=
adaptor
.
ConvertOpenAIRequest
(
c
,
info
,
request
)
}
if
err
!=
nil
{
if
err
!=
nil
{
return
testResult
{
return
testResult
{
context
:
c
,
context
:
c
,
...
@@ -278,7 +293,7 @@ func buildTestRequest(model string) *dto.GeneralOpenAIRequest {
...
@@ -278,7 +293,7 @@ func buildTestRequest(model string) *dto.GeneralOpenAIRequest {
strings
.
Contains
(
model
,
"bge-"
)
{
strings
.
Contains
(
model
,
"bge-"
)
{
testRequest
.
Model
=
model
testRequest
.
Model
=
model
// Embedding 请求
// Embedding 请求
testRequest
.
Input
=
[]
string
{
"hello world"
}
testRequest
.
Input
=
[]
any
{
"hello world"
}
// 修改为any,因为dto/openai_request.go 的ParseInput方法无法处理[]string类型
return
testRequest
return
testRequest
}
}
// 并非Embedding 模型
// 并非Embedding 模型
...
...
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