feat: model file chunk

This commit is contained in:
jialin
2024-09-06 19:27:59 +08:00
parent 58e9a4c742
commit 7b999e6692
4 changed files with 17 additions and 10 deletions
@@ -44,6 +44,7 @@ const HFModelFile: React.FC<HFModelFileProps> = (props) => {
const axiosTokenRef = useRef<any>(null);
const handleSelectModelFile = (item: any) => {
console.log('handleSelectModelFile', item);
props.onSelectFile?.(item);
setCurrent(item.path);
};
@@ -70,9 +71,14 @@ const HFModelFile: React.FC<HFModelFileProps> = (props) => {
// general file
if (!data) {
return list;
return _.map(list, (item: any) => {
item.fakeName = item.path;
return item;
});
}
// shard file
const newList = _.map(list, (item: any) => {
const parsed = parseFilename(item.path);
return {
@@ -83,9 +89,10 @@ const HFModelFile: React.FC<HFModelFileProps> = (props) => {
const group = _.groupBy(newList, 'filename');
return _.map(group, (value: any[], key: string) => {
return _.map(group, (value: any[], filename: string) => {
return {
path: key,
path: filename,
fakeName: `${filename}*.gguf`,
size: _.sumBy(value, 'size'),
parts: value
};
@@ -117,9 +124,9 @@ const HFModelFile: React.FC<HFModelFileProps> = (props) => {
return _.endsWith(file.path, '.gguf') || _.includes(file.path, '.gguf');
});
// const newList = generateGroupByFilename(list);
const newList = generateGroupByFilename(list);
const sortList = _.sortBy(list, (item: any) => {
const sortList = _.sortBy(newList, (item: any) => {
return sortType === 'size' ? item.size : item.path;
});
handleSelectModelFile(sortList[0]);