feat: channel test stream

This commit is contained in:
Seefs
2026-02-06 21:57:38 +08:00
parent cb34e23918
commit 0c0b69a31a
9 changed files with 214 additions and 40 deletions

View File

@@ -87,6 +87,7 @@ export const useChannelsData = () => {
const [isBatchTesting, setIsBatchTesting] = useState(false);
const [modelTablePage, setModelTablePage] = useState(1);
const [selectedEndpointType, setSelectedEndpointType] = useState('');
const [isStreamTest, setIsStreamTest] = useState(false);
const [globalPassThroughEnabled, setGlobalPassThroughEnabled] =
useState(false);
@@ -851,7 +852,12 @@ export const useChannelsData = () => {
};
// Test channel - 单个模型测试,参考旧版实现
const testChannel = async (record, model, endpointType = '') => {
const testChannel = async (
record,
model,
endpointType = '',
stream = false,
) => {
const testKey = `${record.id}-${model}`;
// 检查是否应该停止批量测试
@@ -867,6 +873,9 @@ export const useChannelsData = () => {
if (endpointType) {
url += `&endpoint_type=${endpointType}`;
}
if (stream) {
url += `&stream=true`;
}
const res = await API.get(url);
// 检查是否在请求期间被停止
@@ -995,7 +1004,12 @@ export const useChannelsData = () => {
);
const batchPromises = batch.map((model) =>
testChannel(currentTestChannel, model, selectedEndpointType),
testChannel(
currentTestChannel,
model,
selectedEndpointType,
isStreamTest,
),
);
const batchResults = await Promise.allSettled(batchPromises);
results.push(...batchResults);
@@ -1080,6 +1094,7 @@ export const useChannelsData = () => {
setSelectedModelKeys([]);
setModelTablePage(1);
setSelectedEndpointType('');
setIsStreamTest(false);
// 可选择性保留测试结果,这里不清空以便用户查看
};
@@ -1170,6 +1185,8 @@ export const useChannelsData = () => {
setModelTablePage,
selectedEndpointType,
setSelectedEndpointType,
isStreamTest,
setIsStreamTest,
allSelectingRef,
// Multi-key management states