From 5c372bbaa3defbe33aab2c724e139ea8417b2111 Mon Sep 17 00:00:00 2001 From: jialin Date: Fri, 6 Sep 2024 19:56:31 +0800 Subject: [PATCH] fix: mixture files display error --- .../llmodels/components/hf-model-file.tsx | 50 ++++++++++++------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/src/pages/llmodels/components/hf-model-file.tsx b/src/pages/llmodels/components/hf-model-file.tsx index 42e39369..2b06910c 100644 --- a/src/pages/llmodels/components/hf-model-file.tsx +++ b/src/pages/llmodels/components/hf-model-file.tsx @@ -69,17 +69,26 @@ const HFModelFile: React.FC = (props) => { return !!parsed; }); - // general file - if (!data) { - return _.map(list, (item: any) => { - item.fakeName = item.path; - return item; - }); - } + const generalFileList = _.filter(list, (item: any) => { + const parsed = parseFilename(item.path); + return !parsed; + }); + + const newGeneralFileList = _.map(generalFileList, (item: any) => { + return { + ...item, + fakeName: item.path + }; + }); // shard file - const newList = _.map(list, (item: any) => { + const shardFileList = _.filter(list, (item: any) => { + const parsed = parseFilename(item.path); + return !!parsed; + }); + + const newShardFileList = _.map(shardFileList, (item: any) => { const parsed = parseFilename(item.path); return { ...item, @@ -87,16 +96,21 @@ const HFModelFile: React.FC = (props) => { }; }); - const group = _.groupBy(newList, 'filename'); + const group = _.groupBy(newShardFileList, 'filename'); - return _.map(group, (value: any[], filename: string) => { - return { - path: filename, - fakeName: `${filename}*.gguf`, - size: _.sumBy(value, 'size'), - parts: value - }; - }); + const shardFileListResult = _.map( + group, + (value: any[], filename: string) => { + return { + path: filename, + fakeName: `${filename}*.gguf`, + size: _.sumBy(value, 'size'), + parts: value + }; + } + ); + + return [...shardFileListResult, ...newGeneralFileList]; }, []); const handleFetchModelFiles = async () => { @@ -126,6 +140,8 @@ const HFModelFile: React.FC = (props) => { const newList = generateGroupByFilename(list); + console.log('newList==========', newList); + const sortList = _.sortBy(newList, (item: any) => { return sortType === 'size' ? item.size : item.path; });