feat: model file chunk
This commit is contained in:
@@ -43,7 +43,7 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
|||||||
const [loadingModel, setLoadingModel] = useState<boolean>(false);
|
const [loadingModel, setLoadingModel] = useState<boolean>(false);
|
||||||
|
|
||||||
const handleSelectModelFile = useCallback((item: any) => {
|
const handleSelectModelFile = useCallback((item: any) => {
|
||||||
form.current?.setFieldValue?.('huggingface_filename', item.path);
|
form.current?.setFieldValue?.('huggingface_filename', item.fakeName);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleOnSelectModel = (item: any) => {
|
const handleOnSelectModel = (item: any) => {
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ const HFModelFile: React.FC<HFModelFileProps> = (props) => {
|
|||||||
const axiosTokenRef = useRef<any>(null);
|
const axiosTokenRef = useRef<any>(null);
|
||||||
|
|
||||||
const handleSelectModelFile = (item: any) => {
|
const handleSelectModelFile = (item: any) => {
|
||||||
|
console.log('handleSelectModelFile', item);
|
||||||
props.onSelectFile?.(item);
|
props.onSelectFile?.(item);
|
||||||
setCurrent(item.path);
|
setCurrent(item.path);
|
||||||
};
|
};
|
||||||
@@ -70,9 +71,14 @@ const HFModelFile: React.FC<HFModelFileProps> = (props) => {
|
|||||||
|
|
||||||
// general file
|
// general file
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return list;
|
return _.map(list, (item: any) => {
|
||||||
|
item.fakeName = item.path;
|
||||||
|
return item;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// shard file
|
||||||
|
|
||||||
const newList = _.map(list, (item: any) => {
|
const newList = _.map(list, (item: any) => {
|
||||||
const parsed = parseFilename(item.path);
|
const parsed = parseFilename(item.path);
|
||||||
return {
|
return {
|
||||||
@@ -83,9 +89,10 @@ const HFModelFile: React.FC<HFModelFileProps> = (props) => {
|
|||||||
|
|
||||||
const group = _.groupBy(newList, 'filename');
|
const group = _.groupBy(newList, 'filename');
|
||||||
|
|
||||||
return _.map(group, (value: any[], key: string) => {
|
return _.map(group, (value: any[], filename: string) => {
|
||||||
return {
|
return {
|
||||||
path: key,
|
path: filename,
|
||||||
|
fakeName: `${filename}*.gguf`,
|
||||||
size: _.sumBy(value, 'size'),
|
size: _.sumBy(value, 'size'),
|
||||||
parts: value
|
parts: value
|
||||||
};
|
};
|
||||||
@@ -117,9 +124,9 @@ const HFModelFile: React.FC<HFModelFileProps> = (props) => {
|
|||||||
return _.endsWith(file.path, '.gguf') || _.includes(file.path, '.gguf');
|
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;
|
return sortType === 'size' ? item.size : item.path;
|
||||||
});
|
});
|
||||||
handleSelectModelFile(sortList[0]);
|
handleSelectModelFile(sortList[0]);
|
||||||
|
|||||||
@@ -62,6 +62,9 @@ const SearchModel: React.FC<SearchInputProps> = (props) => {
|
|||||||
|
|
||||||
const handleOnSearchRepo = useCallback(
|
const handleOnSearchRepo = useCallback(
|
||||||
async (sortType?: string) => {
|
async (sortType?: string) => {
|
||||||
|
if (modelSource === modelSourceMap.ollama_library_value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
axiosTokenRef.current?.abort?.();
|
axiosTokenRef.current?.abort?.();
|
||||||
axiosTokenRef.current = new AbortController();
|
axiosTokenRef.current = new AbortController();
|
||||||
if (dataSource.loading) return;
|
if (dataSource.loading) return;
|
||||||
|
|||||||
@@ -64,11 +64,8 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (action === PageAction.EDIT && open) {
|
if (action === PageAction.EDIT && open) {
|
||||||
const list = _.split(props.data?.ollama_library_model_name, ':');
|
|
||||||
form.setFieldsValue({
|
form.setFieldsValue({
|
||||||
...props.data,
|
...props.data
|
||||||
ollama_library_model_name: _.get(list, '0'),
|
|
||||||
tag: _.get(list, '1')
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user