perf: update test model ux (#4375)

* perf: update test model ux

* feat: oceanbase vector db doc
This commit is contained in:
Archer
2025-03-27 18:45:30 +08:00
committed by GitHub
parent 14895bbcfd
commit 4f86a0591c
2 changed files with 55 additions and 52 deletions

View File

@@ -97,53 +97,49 @@ const ModelTest = ({
const { runAsync: onStartTest, loading: isAnyModelLoading } = useRequest2(
async () => {
try {
let errorNum = 0;
const testModel = async (model: string) => {
let errorNum = 0;
setTestModelList((prev) => prev.map((item) => ({ ...item, loading: true })));
const testModel = async (model: string) => {
setTestModelList((prev) =>
prev.map((item) =>
item.model === model ? { ...item, status: 'running', message: '' } : item
)
);
const start = Date.now();
try {
await getTestModel({ model, channelId });
const duration = Date.now() - start;
setTestModelList((prev) =>
prev.map((item) =>
item.model === model
? { ...item, status: 'running', message: '', loading: true }
? { ...item, status: 'success', duration: duration / 1000, loading: false }
: item
)
);
const start = Date.now();
try {
await getTestModel({ model, channelId });
const duration = Date.now() - start;
setTestModelList((prev) =>
prev.map((item) =>
item.model === model
? { ...item, status: 'success', duration: duration / 1000, loading: false }
: item
)
);
} catch (error) {
setTestModelList((prev) =>
prev.map((item) =>
item.model === model
? { ...item, status: 'error', message: getErrText(error), loading: false }
: item
)
);
errorNum++;
}
};
await batchRun(
testModelList.map((item) => item.model),
testModel,
5
);
if (errorNum > 0) {
toast({
status: 'warning',
title: t('account_model:test_failed', { num: errorNum })
});
} catch (error) {
setTestModelList((prev) =>
prev.map((item) =>
item.model === model
? { ...item, status: 'error', message: getErrText(error), loading: false }
: item
)
);
errorNum++;
}
} catch (error) {
console.error('Error during model testing:', error);
};
await batchRun(
testModelList.map((item) => item.model),
testModel,
5
);
if (errorNum > 0) {
toast({
status: 'warning',
title: t('account_model:test_failed', { num: errorNum })
});
}
},
{
@@ -187,6 +183,8 @@ const ModelTest = ({
}
);
const isTesting = isAnyModelLoading || testingOneModel;
return (
<MyModal
iconSrc={'core/chat/sendLight'}
@@ -230,12 +228,14 @@ const ModelTest = ({
</Flex>
</Td>
<Td>
<MyIconButton
isLoading={item.loading}
icon={'core/chat/sendLight'}
tip={t('account:model.test_model')}
onClick={() => onTestOneModel(item.model)}
/>
{(!isAnyModelLoading || item.loading) && (
<MyIconButton
isLoading={item.loading}
icon={'core/chat/sendLight'}
tip={t('account:model.test_model')}
onClick={() => onTestOneModel(item.model)}
/>
)}
</Td>
</Tr>
);
@@ -248,11 +248,7 @@ const ModelTest = ({
<Button mr={4} variant={'whiteBase'} onClick={onClose}>
{t('common:common.Cancel')}
</Button>
<Button
isLoading={isAnyModelLoading || testingOneModel}
variant={'primary'}
onClick={onStartTest}
>
<Button isLoading={isTesting} variant={'primary'} onClick={onStartTest}>
{t('account_model:start_test', { num: testModelList.length })}
</Button>
</ModalFooter>