From 2b7eb832eddb1bae1503261d34aa4daa5ac42414 Mon Sep 17 00:00:00 2001 From: jialin Date: Mon, 12 May 2025 10:43:08 +0800 Subject: [PATCH] fix: remove evaluating for files --- .../llmodels/components/hf-model-file.tsx | 79 ++++--------------- 1 file changed, 16 insertions(+), 63 deletions(-) diff --git a/src/pages/llmodels/components/hf-model-file.tsx b/src/pages/llmodels/components/hf-model-file.tsx index 13abcc0c..cb977934 100644 --- a/src/pages/llmodels/components/hf-model-file.tsx +++ b/src/pages/llmodels/components/hf-model-file.tsx @@ -1,4 +1,3 @@ -import MoreButton from '@/components/buttons/more'; import SimpleOverlay from '@/components/simple-overlay'; import { createAxiosToken } from '@/hooks/use-chunk-request'; import { useIntl } from '@umijs/max'; @@ -10,7 +9,6 @@ import React, { useCallback, useEffect, useImperativeHandle, - useMemo, useRef, useState } from 'react'; @@ -56,7 +54,13 @@ const includeReg = /\.(safetensors|gguf)$/i; const filterRegGGUF = /\.(gguf)$/i; const HFModelFile: React.FC = forwardRef((props, ref) => { - const { collapsed, modelSource, isDownload, displayEvaluateStatus } = props; + const { + collapsed, + modelSource, + isDownload, + gpuOptions, + displayEvaluateStatus + } = props; const intl = useIntl(); const [isEvaluating, setIsEvaluating] = useState(false); const [dataSource, setDataSource] = useState({ @@ -79,7 +83,6 @@ const HFModelFile: React.FC = forwardRef((props, ref) => { const axiosTokenRef = useRef(null); const checkTokenRef = useRef(null); const timer = useRef(null); - const cacheSortListRef = useRef([]); const handleSelectModelFile = (item: any, evaluate?: boolean) => { props.onSelectFile?.(item, evaluate); @@ -229,7 +232,7 @@ const HFModelFile: React.FC = forwardRef((props, ref) => { } }, []); - const handleEvaluate = async (list: any[], first?: boolean) => { + const handleEvaluate = async (list: any[]) => { if (isDownload) { return; } @@ -256,8 +259,7 @@ const HFModelFile: React.FC = forwardRef((props, ref) => { const resultList = _.map(list, (item: any, index: number) => { return { ...item, - evaluateResult: evaluationList[index], - done: true + evaluateResult: evaluationList[index] }; }); const currentItem = _.find( @@ -273,10 +275,7 @@ const HFModelFile: React.FC = forwardRef((props, ref) => { if (currentItem) { handleSelectModelFile(currentItem, true); } - setDataSource({ - fileList: first ? resultList : [...dataSource.fileList, ...resultList], - loading: false - }); + setDataSource({ fileList: resultList, loading: false }); setIsEvaluating(false); } catch (error) { setIsEvaluating(false); @@ -299,12 +298,7 @@ const HFModelFile: React.FC = forwardRef((props, ref) => { axiosTokenRef.current?.abort?.(); axiosTokenRef.current = new AbortController(); setDataSource({ ...dataSource, loading: true }); - displayEvaluateStatus?.({ - show: true, - flag: { - file: true - } - }); + setCurrent(''); try { let list = []; @@ -319,23 +313,11 @@ const HFModelFile: React.FC = forwardRef((props, ref) => { return sortType === 'size' ? item.size : item.path; }); - cacheSortListRef.current = sortList; - - const headList = cacheSortListRef.current.splice(0, 10); - - handleSelectModelFile(headList[0]); - setDataSource({ fileList: headList, loading: false }); - - handleEvaluate(headList, true); + handleSelectModelFile(sortList[0]); + setDataSource({ fileList: sortList, loading: false }); } catch (error) { setDataSource({ fileList: [], loading: false }); handleSelectModelFile({}); - displayEvaluateStatus?.({ - show: false, - flag: { - file: false - } - }); } }; @@ -353,28 +335,12 @@ const HFModelFile: React.FC = forwardRef((props, ref) => { handleSelectModelFile(item); } }; - - const handleOnScrollEnd = () => { - const headList = cacheSortListRef.current.splice(0, 10); - if (headList.length) { - setDataSource({ - ...dataSource, - fileList: [...dataSource.fileList, ...headList] - }); - handleEvaluate(headList); - } - }; - useImperativeHandle(ref, () => ({ fetchModelFiles: handleFetchModelFiles })); - const maxHeight = useMemo(() => { - return collapsed ? 'max-content' : 'calc(100vh - 300px)'; - }, [collapsed]); - useEffect(() => { - if (!props.selectedModel?.name) { + if (!props.selectedModel.name) { setDataSource({ fileList: [], loading: false }); handleSelectModelFile({}); } @@ -420,11 +386,7 @@ const HFModelFile: React.FC = forwardRef((props, ref) => { > )} - +
{dataSource.fileList.length ? ( @@ -433,7 +395,7 @@ const HFModelFile: React.FC = forwardRef((props, ref) => { = forwardRef((props, ref) => { /> ) )} - 0 && - !dataSource.loading && - !isEvaluating - } - loading={dataSource.loading || isEvaluating} - loadMore={handleOnScrollEnd} - >