fix: reset form after switch model
This commit is contained in:
@@ -186,14 +186,7 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleBeforeGpuSelectorChange = (gpuIds: any[]) => {
|
||||
// if (backend !== backendOptionsMap.ascendMindie || !gpuIds?.length) {
|
||||
// return;
|
||||
// }
|
||||
// const lastGroupName = gpuIds[gpuIds.length - 1][0];
|
||||
// const lastGroupItems = gpuIds.filter((item) => item[0] === lastGroupName);
|
||||
// form.setFieldValue(['gpu_selector', 'gpu_ids'], lastGroupItems);
|
||||
};
|
||||
const handleBeforeGpuSelectorChange = (gpuIds: any[]) => {};
|
||||
|
||||
const handleGpuSelectorChange = (value: any[]) => {
|
||||
handleBeforeGpuSelectorChange(value);
|
||||
@@ -548,4 +541,4 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
export default React.memo(AdvanceConfig);
|
||||
export default AdvanceConfig;
|
||||
|
||||
@@ -37,6 +37,7 @@ import TitleWrapper from './title-wrapper';
|
||||
const resetFieldsByModel = ['backend_version', 'backend_parameters', 'env'];
|
||||
const pickFieldsFromSpec = ['backend_version', 'backend_parameters', 'env'];
|
||||
const dropFieldsFromForm = ['name', 'file_name', 'repo_id', 'backend'];
|
||||
const resetFields = ['worker_selector', 'env'];
|
||||
|
||||
const resetFieldsByFile = [
|
||||
'cpu_offloading',
|
||||
@@ -309,14 +310,11 @@ const AddModal: FC<AddModalProps> = (props) => {
|
||||
updateSelectedModel(item);
|
||||
|
||||
// TODO
|
||||
form.current?.form?.setFieldsValue(defaultFormValues);
|
||||
form.current?.resetFields(resetFields);
|
||||
const modelInfo = onSelectModel(item, props.source);
|
||||
form.current?.setFieldsValue?.({
|
||||
...defaultFormValues,
|
||||
...modelInfo,
|
||||
..._.omit(form.current?.form?.getFieldsValue?.(), [
|
||||
...dropFieldsFromForm,
|
||||
...pickFieldsFromSpec
|
||||
]),
|
||||
categories: getCategory(item)
|
||||
});
|
||||
|
||||
@@ -343,7 +341,7 @@ const AddModal: FC<AddModalProps> = (props) => {
|
||||
}
|
||||
|
||||
if (manual) {
|
||||
form.current?.form?.setFieldsValue(defaultFormValues);
|
||||
form.current?.resetFields(resetFields);
|
||||
}
|
||||
// If the item is empty
|
||||
setIsGGUF(item.isGGUF);
|
||||
@@ -360,20 +358,22 @@ const AddModal: FC<AddModalProps> = (props) => {
|
||||
item.evaluated
|
||||
) {
|
||||
handleShowCompatibleAlert(item.evaluateResult);
|
||||
|
||||
const newFormValues = {
|
||||
...(manual
|
||||
? { ...defaultFormValues }
|
||||
: _.omit(form.current?.form?.getFieldsValue?.(), [
|
||||
...dropFieldsFromForm
|
||||
])),
|
||||
...getDefaultSpec(item),
|
||||
...modelInfo,
|
||||
..._.omit(form.current?.form?.getFieldsValue?.(), [
|
||||
...dropFieldsFromForm,
|
||||
...pickFieldsFromSpec
|
||||
]),
|
||||
name: generateNameValue(item, modelInfo.name, manual),
|
||||
categories: getCategory(item)
|
||||
};
|
||||
|
||||
console.log('newFormValues:', newFormValues);
|
||||
|
||||
form.current?.setFieldsValue?.(newFormValues);
|
||||
form.current?.form?.setFieldsValue?.(newFormValues);
|
||||
|
||||
handleOnValuesChangeBefore({
|
||||
changedValues: {},
|
||||
|
||||
@@ -429,7 +429,6 @@ export const excludeFields = [
|
||||
'repo_id',
|
||||
'file_name',
|
||||
'replicas',
|
||||
'categories',
|
||||
'name',
|
||||
'description',
|
||||
'env',
|
||||
|
||||
@@ -634,6 +634,7 @@ export const useSelectModel = (data: { gpuOptions: any[] }) => {
|
||||
repo_id: selectModel.name,
|
||||
file_name: '',
|
||||
name: name,
|
||||
source: source,
|
||||
backend: backend
|
||||
};
|
||||
};
|
||||
|
||||
@@ -37,7 +37,7 @@ export const rerankerSamples: Record<
|
||||
}
|
||||
> = {
|
||||
'zh-CN': {
|
||||
query: '',
|
||||
query: '如何提高睡眠质量?',
|
||||
documents: [
|
||||
'保持规律的作息时间,晚上避免使用电子产品。',
|
||||
'参加更多社交活动有助于提高情绪。',
|
||||
|
||||
Reference in New Issue
Block a user