feat: model file chunk

main
jialin 2 years ago
parent 58e9a4c742
commit 7b999e6692

@ -43,7 +43,7 @@ const AddModal: React.FC<AddModalProps> = (props) => {
const [loadingModel, setLoadingModel] = useState<boolean>(false);
const handleSelectModelFile = useCallback((item: any) => {
form.current?.setFieldValue?.('huggingface_filename', item.path);
form.current?.setFieldValue?.('huggingface_filename', item.fakeName);
}, []);
const handleOnSelectModel = (item: any) => {

@ -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]);

@ -62,6 +62,9 @@ const SearchModel: React.FC<SearchInputProps> = (props) => {
const handleOnSearchRepo = useCallback(
async (sortType?: string) => {
if (modelSource === modelSourceMap.ollama_library_value) {
return;
}
axiosTokenRef.current?.abort?.();
axiosTokenRef.current = new AbortController();
if (dataSource.loading) return;

@ -64,11 +64,8 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
});
}
if (action === PageAction.EDIT && open) {
const list = _.split(props.data?.ollama_library_model_name, ':');
form.setFieldsValue({
...props.data,
ollama_library_model_name: _.get(list, '0'),
tag: _.get(list, '1')
...props.data
});
}
};

Loading…
Cancel
Save