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
63bbd9e3
authored
Sep 30, 2025
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add endpoint type selection to channel testing functionality
parent
f92d7834
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
4 deletions
+40
-4
common/endpoint_defaults.go
+1
-0
constant/endpoint_type.go
+1
-0
controller/channel-test.go
+0
-0
web/src/components/table/channels/modals/ModelTestModal.jsx
+27
-1
web/src/hooks/channels/useChannelsData.jsx
+11
-3
No files found.
common/endpoint_defaults.go
View file @
63bbd9e3
...
...
@@ -23,6 +23,7 @@ var defaultEndpointInfoMap = map[constant.EndpointType]EndpointInfo{
constant
.
EndpointTypeGemini
:
{
Path
:
"/v1beta/models/{model}:generateContent"
,
Method
:
"POST"
},
constant
.
EndpointTypeJinaRerank
:
{
Path
:
"/rerank"
,
Method
:
"POST"
},
constant
.
EndpointTypeImageGeneration
:
{
Path
:
"/v1/images/generations"
,
Method
:
"POST"
},
constant
.
EndpointTypeEmbeddings
:
{
Path
:
"/v1/embeddings"
,
Method
:
"POST"
},
}
// GetDefaultEndpointInfo 返回指定端点类型的默认信息以及是否存在
...
...
constant/endpoint_type.go
View file @
63bbd9e3
...
...
@@ -9,6 +9,7 @@ const (
EndpointTypeGemini
EndpointType
=
"gemini"
EndpointTypeJinaRerank
EndpointType
=
"jina-rerank"
EndpointTypeImageGeneration
EndpointType
=
"image-generation"
EndpointTypeEmbeddings
EndpointType
=
"embeddings"
//EndpointTypeMidjourney EndpointType = "midjourney-proxy"
//EndpointTypeSuno EndpointType = "suno-proxy"
//EndpointTypeKling EndpointType = "kling"
...
...
controller/channel-test.go
View file @
63bbd9e3
This diff is collapsed.
Click to expand it.
web/src/components/table/channels/modals/ModelTestModal.jsx
View file @
63bbd9e3
...
...
@@ -25,6 +25,7 @@ import {
Table
,
Tag
,
Typography
,
Select
,
}
from
'@douyinfe/semi-ui'
;
import
{
IconSearch
}
from
'@douyinfe/semi-icons'
;
import
{
copy
,
showError
,
showInfo
,
showSuccess
}
from
'../../../../helpers'
;
...
...
@@ -45,6 +46,8 @@ const ModelTestModal = ({
testChannel
,
modelTablePage
,
setModelTablePage
,
selectedEndpointType
,
setSelectedEndpointType
,
allSelectingRef
,
isMobile
,
t
,
...
...
@@ -59,6 +62,17 @@ const ModelTestModal = ({
)
:
[];
const
endpointTypeOptions
=
[
{
value
:
''
,
label
:
t
(
'自动检测'
)
},
{
value
:
'openai'
,
label
:
'OpenAI (/v1/chat/completions)'
},
{
value
:
'openai-response'
,
label
:
'OpenAI Response (/v1/responses)'
},
{
value
:
'anthropic'
,
label
:
'Anthropic (/v1/messages)'
},
{
value
:
'gemini'
,
label
:
'Gemini (/v1beta/models/{model}:generateContent)'
},
{
value
:
'jina-rerank'
,
label
:
'Jina Rerank (/rerank)'
},
{
value
:
'image-generation'
,
label
:
t
(
'图像生成'
)
+
' (/v1/images/generations)'
},
{
value
:
'embeddings'
,
label
:
'Embeddings (/v1/embeddings)'
},
];
const
handleCopySelected
=
()
=>
{
if
(
selectedModelKeys
.
length
===
0
)
{
showError
(
t
(
'请先选择模型!'
));
...
...
@@ -152,7 +166,7 @@ const ModelTestModal = ({
return
(
<
Button
type=
'tertiary'
onClick=
{
()
=>
testChannel
(
currentTestChannel
,
record
.
model
)
}
onClick=
{
()
=>
testChannel
(
currentTestChannel
,
record
.
model
,
selectedEndpointType
)
}
loading=
{
isTesting
}
size=
'small'
>
...
...
@@ -228,6 +242,18 @@ const ModelTestModal = ({
>
{
hasChannel
&&
(
<
div
className=
'model-test-scroll'
>
{
/* 端点类型选择器 */
}
<
div
className=
'flex items-center gap-2 w-full mb-2'
>
<
Typography
.
Text
strong
>
{
t
(
'端点类型'
)
}
:
</
Typography
.
Text
>
<
Select
value=
{
selectedEndpointType
}
onChange=
{
setSelectedEndpointType
}
optionList=
{
endpointTypeOptions
}
className=
'!w-full'
placeholder=
{
t
(
'选择端点类型'
)
}
/>
</
div
>
{
/* 搜索与操作按钮 */
}
<
div
className=
'flex items-center justify-end gap-2 w-full mb-2'
>
<
Input
...
...
web/src/hooks/channels/useChannelsData.jsx
View file @
63bbd9e3
...
...
@@ -80,6 +80,7 @@ export const useChannelsData = () => {
const
[
selectedModelKeys
,
setSelectedModelKeys
]
=
useState
([]);
const
[
isBatchTesting
,
setIsBatchTesting
]
=
useState
(
false
);
const
[
modelTablePage
,
setModelTablePage
]
=
useState
(
1
);
const
[
selectedEndpointType
,
setSelectedEndpointType
]
=
useState
(
''
);
// 使用 ref 来避免闭包问题,类似旧版实现
const
shouldStopBatchTestingRef
=
useRef
(
false
);
...
...
@@ -691,7 +692,7 @@ export const useChannelsData = () => {
};
// Test channel - 单个模型测试,参考旧版实现
const
testChannel
=
async
(
record
,
model
)
=>
{
const
testChannel
=
async
(
record
,
model
,
endpointType
=
''
)
=>
{
const
testKey
=
`
${
record
.
id
}
-
${
model
}
`
;
// 检查是否应该停止批量测试
...
...
@@ -703,7 +704,11 @@ export const useChannelsData = () => {
setTestingModels
(
prev
=>
new
Set
([...
prev
,
model
]));
try
{
const
res
=
await
API
.
get
(
`/api/channel/test/
${
record
.
id
}
?model=
${
model
}
`
);
let
url
=
`/api/channel/test/
${
record
.
id
}
?model=
${
model
}
`
;
if
(
endpointType
)
{
url
+=
`&endpoint_type=
${
endpointType
}
`
;
}
const
res
=
await
API
.
get
(
url
);
// 检查是否在请求期间被停止
if
(
shouldStopBatchTestingRef
.
current
&&
isBatchTesting
)
{
...
...
@@ -820,7 +825,7 @@ export const useChannelsData = () => {
.
replace
(
'${total}'
,
models
.
length
)
);
const
batchPromises
=
batch
.
map
(
model
=>
testChannel
(
currentTestChannel
,
model
));
const
batchPromises
=
batch
.
map
(
model
=>
testChannel
(
currentTestChannel
,
model
,
selectedEndpointType
));
const
batchResults
=
await
Promise
.
allSettled
(
batchPromises
);
results
.
push
(...
batchResults
);
...
...
@@ -902,6 +907,7 @@ export const useChannelsData = () => {
setTestingModels
(
new
Set
());
setSelectedModelKeys
([]);
setModelTablePage
(
1
);
setSelectedEndpointType
(
''
);
// 可选择性保留测试结果,这里不清空以便用户查看
};
...
...
@@ -989,6 +995,8 @@ export const useChannelsData = () => {
isBatchTesting
,
modelTablePage
,
setModelTablePage
,
selectedEndpointType
,
setSelectedEndpointType
,
allSelectingRef
,
// Multi-key management states
...
...
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