fix: update backend parameters after changing backend

This commit is contained in:
jialin
2025-10-15 13:30:58 +08:00
parent 059416bb47
commit ca9ceda2f7
3 changed files with 32 additions and 26 deletions
@@ -1,3 +1,4 @@
import AlertBlockInfo from '@/components/alert-info/block';
import TransferInner from '@/pages/_components/transfer';
import { queryUsersList } from '@/pages/users/apis';
import { useIntl } from '@umijs/max';
@@ -132,6 +133,16 @@ const AccessControlForm = forwardRef((props: AccessControlFormProps, ref) => {
]}
></Radio.Group>
</Form.Item>
{accessPolicy === 'public' && (
<div style={{ marginBlock: '16px 12px' }}>
<AlertBlockInfo
type="danger"
message={intl.formatMessage({
id: 'models.accessSettings.public.tips'
})}
></AlertBlockInfo>
</div>
)}
{accessPolicy === 'allowed_users' && (
<>
<Label>
@@ -127,33 +127,7 @@ const UpdateModal: React.FC<AddModalProps> = (props) => {
}
}, 100);
// voxbox is not support multi gpu
const handleSetGPUIds = (backend: string) => {
const gpuids =
formRef.current?.getFieldValue(['gpu_selector', 'gpu_ids']) || [];
if (backend === backendOptionsMap.voxBox && gpuids.length > 0) {
formRef.current?.setFieldValue(['gpu_selector', 'gpu_ids'], [gpuids[0]]);
}
};
const handleBackendChange = (backend: string) => {
const updates = {
backend_version: ''
};
if (backend === backendOptionsMap.llamaBox) {
Object.assign(updates, {
distributed_inference_across_workers: true,
cpu_offloading: true
});
}
formRef.current?.setFieldsValue({
...updates,
backend_parameters: [],
env: null
});
handleSetGPUIds(backend);
const data = formRef.current?.getFieldsValue?.();
const res = handleBackendChangeBefore(data);
if (res.show) {
+21
View File
@@ -80,6 +80,27 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
};
};
const checkIsGGUF = () => {
const huggingface_filename = form.getFieldValue('huggingface_filename');
const model_scope_model_id = form.getFieldValue('model_scope_model_id');
const local_path = form.getFieldValue('local_path');
if (local_path) {
const isEndwithGGUF = _.endsWith(local_path, '.gguf');
const isBlobFile = local_path.split('/').pop().includes('sha256');
return isEndwithGGUF || isBlobFile;
}
return huggingface_filename || model_scope_model_id;
};
const updateFieldsOnGGUF = () => {
// when isGGUF is true, set distributed_inference_across_workers and cpu_offloading to true
return {
distributed_inference_across_workers: true,
cpu_offloading: true
};
};
const handleBackendChange = async (val: string, option: BackendOption) => {
form.setFieldsValue({
env: null,