fix: update form options when open modal
This commit is contained in:
@@ -365,6 +365,7 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
|
|||||||
];
|
];
|
||||||
}, [
|
}, [
|
||||||
form,
|
form,
|
||||||
|
source,
|
||||||
intl,
|
intl,
|
||||||
gpuOptions,
|
gpuOptions,
|
||||||
paramsConfig,
|
paramsConfig,
|
||||||
|
|||||||
@@ -102,6 +102,9 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
|
|||||||
},
|
},
|
||||||
getFieldValue: (name: string) => {
|
getFieldValue: (name: string) => {
|
||||||
return form.getFieldValue(name);
|
return form.getFieldValue(name);
|
||||||
|
},
|
||||||
|
resetFields() {
|
||||||
|
form.resetFields();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -129,11 +132,12 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
|
|||||||
const handleLocalPathBlur = (e: any) => {
|
const handleLocalPathBlur = (e: any) => {
|
||||||
const value = e.target.value;
|
const value = e.target.value;
|
||||||
const isEndwithGGUF = _.endsWith(value, '.gguf');
|
const isEndwithGGUF = _.endsWith(value, '.gguf');
|
||||||
if (isEndwithGGUF) {
|
let backend = backendOptionsMap.llamaBox;
|
||||||
props.onBackendChange?.(backendOptionsMap.llamaBox);
|
if (!isEndwithGGUF) {
|
||||||
} else {
|
backend = backendOptionsMap.vllm;
|
||||||
props.onBackendChange?.(backendOptionsMap.vllm);
|
|
||||||
}
|
}
|
||||||
|
props.onBackendChange?.(backend);
|
||||||
|
form.setFieldValue('backend', backend);
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderHuggingfaceFields = () => {
|
const renderHuggingfaceFields = () => {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { CloseOutlined } from '@ant-design/icons';
|
|||||||
import { useIntl } from '@umijs/max';
|
import { useIntl } from '@umijs/max';
|
||||||
import { Button, Drawer } from 'antd';
|
import { Button, Drawer } from 'antd';
|
||||||
import { debounce } from 'lodash';
|
import { debounce } from 'lodash';
|
||||||
import { memo, useCallback, useEffect, useRef, useState } from 'react';
|
import { memo, useCallback, useEffect, useId, useRef, useState } from 'react';
|
||||||
import { backendOptionsMap, modelSourceMap } from '../config';
|
import { backendOptionsMap, modelSourceMap } from '../config';
|
||||||
import { FormData, ListItem } from '../config/types';
|
import { FormData, ListItem } from '../config/types';
|
||||||
import ColumnWrapper from './column-wrapper';
|
import ColumnWrapper from './column-wrapper';
|
||||||
@@ -40,6 +40,7 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
|||||||
modelSourceMap.huggingface_value,
|
modelSourceMap.huggingface_value,
|
||||||
modelSourceMap.modelscope_value
|
modelSourceMap.modelscope_value
|
||||||
];
|
];
|
||||||
|
const uid = useId();
|
||||||
const form = useRef<any>({});
|
const form = useRef<any>({});
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const [selectedModel, setSelectedModel] = useState<any>({});
|
const [selectedModel, setSelectedModel] = useState<any>({});
|
||||||
@@ -81,6 +82,11 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleCancel = useCallback(() => {
|
||||||
|
onCancel?.();
|
||||||
|
setIsGGUF(false);
|
||||||
|
}, [onCancel]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
handleSelectModelFile({ fakeName: '' });
|
handleSelectModelFile({ fakeName: '' });
|
||||||
}, [selectedModel]);
|
}, [selectedModel]);
|
||||||
@@ -110,13 +116,13 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
|||||||
>
|
>
|
||||||
{title}
|
{title}
|
||||||
</span>
|
</span>
|
||||||
<Button type="text" size="small" onClick={onCancel}>
|
<Button type="text" size="small" onClick={handleCancel}>
|
||||||
<CloseOutlined></CloseOutlined>
|
<CloseOutlined></CloseOutlined>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
open={open}
|
open={open}
|
||||||
onClose={onCancel}
|
onClose={handleCancel}
|
||||||
destroyOnClose={true}
|
destroyOnClose={true}
|
||||||
closeIcon={false}
|
closeIcon={false}
|
||||||
maskClosable={false}
|
maskClosable={false}
|
||||||
@@ -173,7 +179,7 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
|||||||
<ColumnWrapper
|
<ColumnWrapper
|
||||||
footer={
|
footer={
|
||||||
<ModalFooter
|
<ModalFooter
|
||||||
onCancel={onCancel}
|
onCancel={handleCancel}
|
||||||
onOk={handleSumit}
|
onOk={handleSumit}
|
||||||
style={{
|
style={{
|
||||||
padding: '16px 24px',
|
padding: '16px 24px',
|
||||||
|
|||||||
Reference in New Issue
Block a user