import { PageAction } from '@/config'; import DocLink from '@/pages/_components/doc-link'; import { genericReferLink } from '@/pages/model-routes/config'; import { CheckboxField, LabelSelector, Select as SealSelect } from '@gpustack/core-ui'; import { useIntl } from '@umijs/max'; import { Form } from 'antd'; import _ from 'lodash'; import { useMemo } from 'react'; import { modelCategories } from '../config'; import { useFormContext } from '../config/form-context'; import { FormData } from '../config/types'; import { backendOptionsMap } from '../constants/backend-parameters'; import BackendParametersList from './backend-parameters-list'; const AdvanceConfig = () => { const intl = useIntl(); const form = Form.useFormInstance(); const backend = Form.useWatch('backend', form); const modelRouteEnable = Form.useWatch('enable_model_route', form); const { onValuesChange, realAction, action, backendOptions, flatBackendOptions, isGGUF, modelContextData } = useFormContext(); const currentBackendOptions = useMemo(() => { return flatBackendOptions?.find((item) => item.value === backend); }, [backend, flatBackendOptions]); console.log('currentBackendOptions', currentBackendOptions); const onSelectorChange = (field: string, allowEmpty?: boolean) => { const workerSelector = form.getFieldValue(field); // check if all keys have values const hasEmptyValue = _.some(_.keys(workerSelector), (k: string) => { return !workerSelector[k]; }); if (!hasEmptyValue || allowEmpty) { onValuesChange?.({}, form.getFieldsValue()); } }; const handleEnvSelectorOnBlur = () => { onSelectorChange('env', true); }; const handleDeleteEnvSelector = (index: number) => { onValuesChange?.({}, form.getFieldsValue()); }; const handleContextLengthChange = _.debounce((value: number) => { onValuesChange?.({}, form.getFieldsValue()); }, 300); return ( <> name="categories" data-field="categories" style={{ scrollMarginTop: 200 }} > name="env"> {(backend === backendOptionsMap.custom || !currentBackendOptions?.isBuiltIn) && ( name="cpu_offloading" valuePropName="checked" style={{ marginBottom: 8 }} > )} {currentBackendOptions?.isBuiltIn && ( name="distributed_inference_across_workers" valuePropName="checked" style={{ marginBottom: 8 }} > )} name="restart_on_error" valuePropName="checked" style={{ marginBottom: 8 }} > {realAction === PageAction.COPY || action === PageAction.CREATE ? ( <> name="enable_model_route" valuePropName="checked" style={{ marginBottom: 8 }} > {modelRouteEnable && ( name="generic_proxy" valuePropName="checked" style={{ marginBottom: 8 }} > } label={intl.formatMessage({ id: 'models.form.generic_proxy' })} > )} ) : null} ); }; export default AdvanceConfig;