chore: check configuration on initial and change values
This commit is contained in:
@@ -83,6 +83,8 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
setWarningStatus,
|
||||
handleEvaluate,
|
||||
generateGPUIds,
|
||||
cancelEvaluate,
|
||||
submitAnyway,
|
||||
handleOnValuesChange,
|
||||
warningStatus
|
||||
} = useCheckCompatibility();
|
||||
@@ -99,7 +101,6 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
const axiosToken = useRef<any>(null);
|
||||
const selectSpecRef = useRef<CatalogSpec>({} as CatalogSpec);
|
||||
const specListRef = useRef<any[]>([]);
|
||||
const submitAnyway = useRef<any>(null);
|
||||
|
||||
const handleSumit = () => {
|
||||
form.current?.submit?.();
|
||||
@@ -111,9 +112,11 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
};
|
||||
|
||||
const generateSubmitData = (formData: FormData) => {
|
||||
const gpuSelector = generateGPUIds(formData);
|
||||
const data = {
|
||||
..._.omit(selectSpecRef.current, ['name']),
|
||||
...formData
|
||||
...formData,
|
||||
...gpuSelector
|
||||
};
|
||||
|
||||
return data;
|
||||
@@ -233,6 +236,12 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
return evalutionData;
|
||||
};
|
||||
|
||||
const handleCheckFormData = () => {
|
||||
const values = form.current?.getFieldsValue();
|
||||
const allValues = generateSubmitData(values);
|
||||
handleCheckCompatibility(allValues);
|
||||
};
|
||||
|
||||
const handleSourceChange = (source: string) => {
|
||||
const defaultSpec = _.get(sourceGroupMap.current, `${source}.0`, {});
|
||||
initFormDataBySource(defaultSpec);
|
||||
@@ -245,8 +254,7 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
});
|
||||
// set form value
|
||||
initFormDataBySource(defaultSpec);
|
||||
const data = generateSubmitData(form.current.getFieldsValue());
|
||||
handleCheckCompatibility(data);
|
||||
handleCheckFormData();
|
||||
};
|
||||
|
||||
const checkSize = (list: any[]) => {
|
||||
@@ -314,7 +322,7 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
form.current.setFieldsValue({
|
||||
...data
|
||||
});
|
||||
handleCheckCompatibility(data);
|
||||
handleCheckFormData();
|
||||
};
|
||||
|
||||
const fetchSpecData = async () => {
|
||||
@@ -364,12 +372,14 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
'name',
|
||||
_.toLower(current.name).replace(/\s/g, '-') || ''
|
||||
);
|
||||
if (defaultSpec.backend === backendOptionsMap.vllm) {
|
||||
setIsGGUF(false);
|
||||
}
|
||||
|
||||
const allValues = generateSubmitData(defaultSpec);
|
||||
handleCheckCompatibility(allValues);
|
||||
|
||||
if (defaultSpec.backend === backendOptionsMap.llamaBox) {
|
||||
setIsGGUF(true);
|
||||
} else {
|
||||
setIsGGUF(false);
|
||||
}
|
||||
console.log('values====', form.current.form.getFieldsValue());
|
||||
} catch (error) {
|
||||
@@ -386,8 +396,7 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
form.current.setFieldsValue({
|
||||
...data
|
||||
});
|
||||
const allValues = generateSubmitData(data);
|
||||
handleCheckCompatibility(allValues);
|
||||
handleCheckFormData();
|
||||
};
|
||||
|
||||
const handleOnSizeChange = (val: number) => {
|
||||
@@ -408,21 +417,12 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
form.current.setFieldsValue({
|
||||
...data
|
||||
});
|
||||
const allValues = generateSubmitData(data);
|
||||
handleCheckCompatibility(allValues);
|
||||
handleCheckFormData();
|
||||
};
|
||||
|
||||
const handleOk = async (values: FormData) => {
|
||||
const data = generateSubmitData(values);
|
||||
|
||||
if (submitAnyway.current) {
|
||||
onOk(data);
|
||||
return;
|
||||
}
|
||||
const evaluateResult = await handleCheckCompatibility(data);
|
||||
if (evaluateResult?.compatible) {
|
||||
onOk(data);
|
||||
}
|
||||
onOk(data);
|
||||
};
|
||||
|
||||
const handleCancel = useCallback(() => {
|
||||
@@ -436,6 +436,7 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
}
|
||||
return () => {
|
||||
axiosToken.current?.cancel?.();
|
||||
cancelEvaluate();
|
||||
setWarningStatus({
|
||||
show: false,
|
||||
title: '',
|
||||
|
||||
@@ -117,16 +117,7 @@ const AddModal: FC<AddModalProps> = (props) => {
|
||||
|
||||
const handleOnOk = async (allValues: FormData) => {
|
||||
const result = getSourceRepoConfigValue(props.source, allValues).values;
|
||||
if (submitAnyway.current) {
|
||||
onOk(result);
|
||||
return;
|
||||
}
|
||||
|
||||
const evalutionData = await handleEvaluate(result);
|
||||
handleShowCompatibleAlert?.(evalutionData);
|
||||
if (evalutionData?.compatible) {
|
||||
onOk(result);
|
||||
}
|
||||
onOk(result);
|
||||
};
|
||||
|
||||
const handleSubmitAnyway = async () => {
|
||||
@@ -198,22 +189,25 @@ const AddModal: FC<AddModalProps> = (props) => {
|
||||
onCancel?.();
|
||||
}, [onCancel]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) {
|
||||
return;
|
||||
}
|
||||
const handleOnOpen = useCallback(() => {
|
||||
if (props.deploymentType === 'modelFiles') {
|
||||
form.current?.form?.setFieldsValue({
|
||||
...props.initialValues
|
||||
});
|
||||
setIsGGUF(props.isGGUF || false);
|
||||
} else {
|
||||
const backend =
|
||||
source === modelSourceMap.ollama_library_value
|
||||
? backendOptionsMap.llamaBox
|
||||
: backendOptionsMap.vllm;
|
||||
form.current?.setFieldValue?.('backend', backend);
|
||||
setIsGGUF(backend === backendOptionsMap.llamaBox);
|
||||
}
|
||||
}, [source, props.initialValues, props.deploymentType]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) {
|
||||
return;
|
||||
} else {
|
||||
handleOnOpen();
|
||||
}
|
||||
|
||||
return () => {
|
||||
@@ -225,7 +219,7 @@ const AddModal: FC<AddModalProps> = (props) => {
|
||||
});
|
||||
checkTokenRef.current?.cancel();
|
||||
};
|
||||
}, [open, props.isGGUF, source, props.initialValues, props.deploymentType]);
|
||||
}, [open, handleOnOpen]);
|
||||
|
||||
return (
|
||||
<Drawer
|
||||
|
||||
@@ -597,7 +597,7 @@ const InstanceItem: React.FC<InstanceItemProps> = ({
|
||||
</span>
|
||||
</Col>
|
||||
<Col span={4}>
|
||||
<span style={{ paddingLeft: 45 }} className="flex">
|
||||
<span style={{ paddingLeft: 43 }} className="flex">
|
||||
<AutoTooltip ghost>
|
||||
{dayjs(instanceData.created_at).format('YYYY-MM-DD HH:mm:ss')}
|
||||
</AutoTooltip>
|
||||
|
||||
@@ -123,7 +123,7 @@ const SearchModel: React.FC<SearchInputProps> = (props) => {
|
||||
value: item.name,
|
||||
label: item.name,
|
||||
isGGUF: checkIsGGUF(item),
|
||||
source: modelSourceMap.modelscope_value
|
||||
source: modelSource
|
||||
};
|
||||
});
|
||||
return list;
|
||||
@@ -161,7 +161,7 @@ const SearchModel: React.FC<SearchInputProps> = (props) => {
|
||||
tags: item.Tags,
|
||||
libraries: item.Libraries,
|
||||
isGGUF: checkIsGGUF({ tags: item.Tags, libraries: item.Libraries }),
|
||||
source: modelSourceMap.modelscope_value
|
||||
source: modelSource
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -182,11 +182,13 @@ const Models: React.FC<ModelsProps> = ({
|
||||
hasLinuxWorker?: boolean;
|
||||
source: SourceType;
|
||||
gpuOptions: any[];
|
||||
isGGUF?: boolean;
|
||||
modelFileOptions?: any[];
|
||||
}>({
|
||||
show: false,
|
||||
hasLinuxWorker: false,
|
||||
width: 600,
|
||||
isGGUF: false,
|
||||
source: modelSourceMap.huggingface_value as SourceType,
|
||||
gpuOptions: [],
|
||||
modelFileOptions: []
|
||||
@@ -830,6 +832,7 @@ const Models: React.FC<ModelsProps> = ({
|
||||
title={intl.formatMessage({ id: 'models.button.deploy' })}
|
||||
source={openDeployModal.source}
|
||||
width={openDeployModal.width}
|
||||
isGGUF={openDeployModal.isGGUF}
|
||||
hasLinuxWorker={openDeployModal.hasLinuxWorker}
|
||||
gpuOptions={openDeployModal.gpuOptions}
|
||||
modelFileOptions={openDeployModal.modelFileOptions || []}
|
||||
|
||||
@@ -311,23 +311,12 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
|
||||
submitData = {
|
||||
..._.omit(formdata, ['scheduleType']),
|
||||
categories: formdata.categories ? [formdata.categories] : [],
|
||||
worker_selector: null,
|
||||
worker_selector:
|
||||
formdata.scheduleType === 'manual' ? null : formdata.worker_selector,
|
||||
...obj,
|
||||
...(formdata.scheduleType === 'manual'
|
||||
? generateGPUIds(formdata)
|
||||
: { gpu_selector: null })
|
||||
...generateGPUIds(formdata)
|
||||
};
|
||||
|
||||
if (submitAnyway.current) {
|
||||
onOk(submitData);
|
||||
return;
|
||||
}
|
||||
|
||||
const evalutionData = await handleEvaluate(submitData);
|
||||
handleShowCompatibleAlert?.(evalutionData);
|
||||
if (evalutionData?.compatible) {
|
||||
onOk(submitData);
|
||||
}
|
||||
onOk(submitData);
|
||||
};
|
||||
|
||||
const onValuesChange = (changedValues: any, allValues: any) => {
|
||||
|
||||
Reference in New Issue
Block a user