fix: do not close loading when evaluating

This commit is contained in:
jialin
2025-04-24 20:36:34 +08:00
parent 9a6b907c11
commit d4ffd8e8e4
3 changed files with 15 additions and 4 deletions
+11 -3
View File
@@ -102,6 +102,11 @@ const AddModal: FC<AddModalProps> = (props) => {
const [collapsed, setCollapsed] = useState<boolean>(false); const [collapsed, setCollapsed] = useState<boolean>(false);
const [isGGUF, setIsGGUF] = useState<boolean>(false); const [isGGUF, setIsGGUF] = useState<boolean>(false);
const modelFileRef = useRef<any>(null); const modelFileRef = useRef<any>(null);
const isHolderRef = useRef<boolean>(false);
const setIsHolderRef = (flag?: boolean) => {
isHolderRef.current = flag || false;
};
const getDefaultSpec = (item: any) => { const getDefaultSpec = (item: any) => {
const defaultSpec = item.evaluateResult?.default_spec || {}; const defaultSpec = item.evaluateResult?.default_spec || {};
@@ -139,7 +144,9 @@ const AddModal: FC<AddModalProps> = (props) => {
setIsGGUF(false); setIsGGUF(false);
form.current?.form?.resetFields(resetFields); form.current?.form?.resetFields(resetFields);
const modelInfo = onSelectModel(item, props.source); const modelInfo = onSelectModel(item, props.source);
handleShowCompatibleAlert(item.evaluateResult); if (!isHolderRef.current) {
handleShowCompatibleAlert(item.evaluateResult);
}
form.current?.setFieldsValue?.({ form.current?.setFieldsValue?.({
...getDefaultSpec(item), ...getDefaultSpec(item),
...modelInfo, ...modelInfo,
@@ -239,9 +246,10 @@ const AddModal: FC<AddModalProps> = (props) => {
return warningStatus.show && warningStatus.type !== 'success'; return warningStatus.show && warningStatus.type !== 'success';
}, [warningStatus.show, warningStatus.type]); }, [warningStatus.show, warningStatus.type]);
const displayEvaluateStatus = () => { const displayEvaluateStatus = (show?: boolean) => {
setIsHolderRef(show);
setWarningStatus({ setWarningStatus({
show: true, show: show || false,
title: '', title: '',
type: 'transition', type: 'transition',
message: intl.formatMessage({ id: 'models.form.evaluating' }) message: intl.formatMessage({ id: 'models.form.evaluating' })
@@ -264,6 +264,7 @@ const HFModelFile: React.FC<HFModelFileProps> = forwardRef((props, ref) => {
resultList, resultList,
(item: any) => item.path === currentPathRef.current (item: any) => item.path === currentPathRef.current
); );
displayEvaluateStatus?.(false);
if (currentItem) { if (currentItem) {
handleSelectModelFile(currentItem, true); handleSelectModelFile(currentItem, true);
} }
@@ -239,7 +239,6 @@ const SearchModel: React.FC<SearchInputProps> = (props) => {
}; };
}); });
setIsEvaluating(true); setIsEvaluating(true);
displayEvaluateStatus?.(true);
const evaluations = await getEvaluateResults(repoList); const evaluations = await getEvaluateResults(repoList);
const resultList = list.map((item, index) => { const resultList = list.map((item, index) => {
return { return {
@@ -248,6 +247,7 @@ const SearchModel: React.FC<SearchInputProps> = (props) => {
}; };
}); });
setIsEvaluating(false); setIsEvaluating(false);
setDataSource((pre) => { setDataSource((pre) => {
return { return {
...pre, ...pre,
@@ -258,6 +258,7 @@ const SearchModel: React.FC<SearchInputProps> = (props) => {
const currentItem = resultList.find( const currentItem = resultList.find(
(item) => item.id === currentRef.current (item) => item.id === currentRef.current
); );
displayEvaluateStatus?.(false);
if (currentItem) { if (currentItem) {
handleOnSelectModel(currentItem, true); handleOnSelectModel(currentItem, true);
} }
@@ -283,6 +284,7 @@ const SearchModel: React.FC<SearchInputProps> = (props) => {
return { ...pre }; return { ...pre };
}); });
setLoadingModel?.(true); setLoadingModel?.(true);
displayEvaluateStatus?.(true);
cacheRepoOptions.current = []; cacheRepoOptions.current = [];
let list: any[] = []; let list: any[] = [];
if (modelSource === modelSourceMap.huggingface_value) { if (modelSource === modelSourceMap.huggingface_value) {