fix: form data merge with raw data
This commit is contained in:
@@ -116,13 +116,11 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getModelSpec = (data: {
|
const getModelSpec = (data: {
|
||||||
source: string;
|
|
||||||
backend: string;
|
backend: string;
|
||||||
size: number;
|
size: number;
|
||||||
quantization: string;
|
quantization: string;
|
||||||
}) => {
|
}) => {
|
||||||
const groupList = sourceGroupMap.current[data.source];
|
const spec = _.find(specListRef.current, (item: CatalogSpec) => {
|
||||||
const spec = _.find(groupList, (item: CatalogSpec) => {
|
|
||||||
if (data.size && data.quantization) {
|
if (data.size && data.quantization) {
|
||||||
return (
|
return (
|
||||||
item.size === data.size &&
|
item.size === data.size &&
|
||||||
@@ -156,11 +154,9 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSetSizeOptions = (data: { source: string; backend: string }) => {
|
const handleSetSizeOptions = (data: { backend: string }) => {
|
||||||
const groupList = sourceGroupMap.current[source];
|
|
||||||
const list = _.filter(groupList, (item: CatalogSpec) => item.size);
|
|
||||||
const sizeGroup = _.groupBy(
|
const sizeGroup = _.groupBy(
|
||||||
_.filter(list, (item: CatalogSpec) => {
|
_.filter(specListRef.current, (item: CatalogSpec) => {
|
||||||
return item.backend === data.backend;
|
return item.backend === data.backend;
|
||||||
}),
|
}),
|
||||||
'size'
|
'size'
|
||||||
@@ -180,13 +176,10 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSetQuantizationOptions = (data: {
|
const handleSetQuantizationOptions = (data: {
|
||||||
source: string;
|
|
||||||
size: number;
|
size: number;
|
||||||
backend: string;
|
backend: string;
|
||||||
}) => {
|
}) => {
|
||||||
const groupList = sourceGroupMap.current[data.source];
|
const sizeGroup = _.filter(specListRef.current, (item: CatalogSpec) => {
|
||||||
console.log('groupList====', data, groupList);
|
|
||||||
const sizeGroup = _.filter(groupList, (item: CatalogSpec) => {
|
|
||||||
return item.size === data.size && item.backend === data.backend;
|
return item.size === data.size && item.backend === data.backend;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -200,10 +193,8 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
|||||||
return quantizationList;
|
return quantizationList;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSetBackendOptions = (source: string) => {
|
const handleSetBackendOptions = () => {
|
||||||
const groupList = sourceGroupMap.current[source];
|
const backendGroup = _.groupBy(specListRef.current, 'backend');
|
||||||
const backendGroup = _.groupBy(groupList, 'backend');
|
|
||||||
console.log('backendGroup====', backendGroup, source);
|
|
||||||
|
|
||||||
const backendList = _.filter(backendOptions, (item: any) => {
|
const backendList = _.filter(backendOptions, (item: any) => {
|
||||||
return backendGroup[item.value];
|
return backendGroup[item.value];
|
||||||
@@ -214,14 +205,11 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
|||||||
|
|
||||||
const handleSourceChange = (source: string) => {
|
const handleSourceChange = (source: string) => {
|
||||||
const defaultSpec = _.get(sourceGroupMap.current, `${source}.0`, {});
|
const defaultSpec = _.get(sourceGroupMap.current, `${source}.0`, {});
|
||||||
console.log('source====', source, defaultSpec);
|
|
||||||
initFormDataBySource(defaultSpec);
|
initFormDataBySource(defaultSpec);
|
||||||
handleSetSizeOptions({
|
handleSetSizeOptions({
|
||||||
source: source,
|
|
||||||
backend: defaultSpec.backend
|
backend: defaultSpec.backend
|
||||||
});
|
});
|
||||||
handleSetQuantizationOptions({
|
handleSetQuantizationOptions({
|
||||||
source: source,
|
|
||||||
size: defaultSpec.size,
|
size: defaultSpec.size,
|
||||||
backend: defaultSpec.backend
|
backend: defaultSpec.backend
|
||||||
});
|
});
|
||||||
@@ -265,14 +253,12 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
|||||||
setIsGGUF(true);
|
setIsGGUF(true);
|
||||||
}
|
}
|
||||||
const sizeList = handleSetSizeOptions({
|
const sizeList = handleSetSizeOptions({
|
||||||
source: form.current.getFieldValue('source'),
|
|
||||||
backend: backend
|
backend: backend
|
||||||
});
|
});
|
||||||
|
|
||||||
const size = checkSize(sizeList);
|
const size = checkSize(sizeList);
|
||||||
|
|
||||||
const quantizaList = handleSetQuantizationOptions({
|
const quantizaList = handleSetQuantizationOptions({
|
||||||
source: form.current.getFieldValue('source'),
|
|
||||||
size: size,
|
size: size,
|
||||||
backend: backend
|
backend: backend
|
||||||
});
|
});
|
||||||
@@ -280,7 +266,6 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
|||||||
const quantization = checkQuantization(quantizaList);
|
const quantization = checkQuantization(quantizaList);
|
||||||
|
|
||||||
const data = getModelSpec({
|
const data = getModelSpec({
|
||||||
source: form.current.getFieldValue('source'),
|
|
||||||
backend: backend,
|
backend: backend,
|
||||||
size: size,
|
size: size,
|
||||||
quantization: quantization
|
quantization: quantization
|
||||||
@@ -304,29 +289,30 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
const groupList = _.groupBy(res.items, 'source');
|
const groupList = _.groupBy(res.items, 'source');
|
||||||
|
|
||||||
sourceGroupMap.current = groupList;
|
sourceGroupMap.current = groupList;
|
||||||
|
|
||||||
|
specListRef.current = res.items;
|
||||||
|
|
||||||
const sources = _.filter(sourceOptions, (item: any) => {
|
const sources = _.filter(sourceOptions, (item: any) => {
|
||||||
return groupList[item.value];
|
return groupList[item.value];
|
||||||
});
|
});
|
||||||
const source = _.get(sources, '0.value', '');
|
|
||||||
const defaultSpec =
|
const defaultSpec =
|
||||||
_.find(groupList[source], (item: CatalogSpec) => {
|
_.find(res.items, (item: CatalogSpec) => {
|
||||||
return getDefaultQuant({
|
return getDefaultQuant({
|
||||||
category: _.get(current, 'categories.0', ''),
|
category: _.get(current, 'categories.0', ''),
|
||||||
quantOption: item.quantization
|
quantOption: item.quantization
|
||||||
});
|
});
|
||||||
}) || _.get(groupList, `${source}.0`, {});
|
}) || _.get(res.items, `0`, {});
|
||||||
|
|
||||||
selectSpecRef.current = defaultSpec;
|
selectSpecRef.current = defaultSpec;
|
||||||
setSourceList(sources);
|
setSourceList(sources);
|
||||||
handleSetBackendOptions(source);
|
handleSetBackendOptions();
|
||||||
handleSetSizeOptions({
|
handleSetSizeOptions({
|
||||||
source: source,
|
|
||||||
backend: defaultSpec.backend
|
backend: defaultSpec.backend
|
||||||
});
|
});
|
||||||
handleSetQuantizationOptions({
|
handleSetQuantizationOptions({
|
||||||
source: source,
|
|
||||||
size: defaultSpec.size,
|
size: defaultSpec.size,
|
||||||
backend: defaultSpec.backend
|
backend: defaultSpec.backend
|
||||||
});
|
});
|
||||||
@@ -349,7 +335,6 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
|||||||
|
|
||||||
const handleOnQuantizationChange = (val: string) => {
|
const handleOnQuantizationChange = (val: string) => {
|
||||||
const data = getModelSpec({
|
const data = getModelSpec({
|
||||||
source: form.current.getFieldValue('source'),
|
|
||||||
backend: form.current.getFieldValue('backend'),
|
backend: form.current.getFieldValue('backend'),
|
||||||
size: form.current.getFieldValue('size'),
|
size: form.current.getFieldValue('size'),
|
||||||
quantization: val
|
quantization: val
|
||||||
@@ -361,7 +346,6 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
|||||||
|
|
||||||
const handleOnSizeChange = (val: number) => {
|
const handleOnSizeChange = (val: number) => {
|
||||||
const list = handleSetQuantizationOptions({
|
const list = handleSetQuantizationOptions({
|
||||||
source: form.current.getFieldValue('source'),
|
|
||||||
backend: form.current.getFieldValue('backend'),
|
backend: form.current.getFieldValue('backend'),
|
||||||
size: val
|
size: val
|
||||||
});
|
});
|
||||||
@@ -369,7 +353,6 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
|||||||
const quantization = checkQuantization(list);
|
const quantization = checkQuantization(list);
|
||||||
|
|
||||||
const data = getModelSpec({
|
const data = getModelSpec({
|
||||||
source: form.current.getFieldValue('source'),
|
|
||||||
backend: form.current.getFieldValue('backend'),
|
backend: form.current.getFieldValue('backend'),
|
||||||
size: val,
|
size: val,
|
||||||
quantization: quantization
|
quantization: quantization
|
||||||
@@ -383,9 +366,8 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
|||||||
|
|
||||||
const handleOk = (values: FormData) => {
|
const handleOk = (values: FormData) => {
|
||||||
onOk({
|
onOk({
|
||||||
...values,
|
..._.omit(selectSpecRef.current, ['name']),
|
||||||
...getModelFile(selectSpecRef.current),
|
...values
|
||||||
..._.omit(selectSpecRef.current, ['name'])
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user