fix: edit gpu_selector failed
This commit is contained in:
@@ -2,25 +2,27 @@ import SealSelect from '@/components/seal-form/seal-select';
|
||||
import useAppUtils from '@/hooks/use-app-utils';
|
||||
import { Form } from 'antd';
|
||||
import React from 'react';
|
||||
import { useFormContext } from '../config/form-context';
|
||||
import { deployFormKeyMap } from '../config';
|
||||
import { useCatalogFormContext, useFormContext } from '../config/form-context';
|
||||
import { FormData } from '../config/types';
|
||||
|
||||
const CatalogForm: React.FC = () => {
|
||||
const formCtx = useFormContext();
|
||||
const catalogFormCtx = useCatalogFormContext();
|
||||
const { getRuleMessage } = useAppUtils();
|
||||
const { formKey } = formCtx;
|
||||
const {
|
||||
isGGUF,
|
||||
byBuiltIn,
|
||||
sizeOptions,
|
||||
quantizationOptions,
|
||||
onSizeChange,
|
||||
onQuantizationChange
|
||||
} = formCtx;
|
||||
const source = Form.useWatch('source');
|
||||
} = catalogFormCtx;
|
||||
|
||||
console.log('HuggingFaceForm', { source, isGGUF });
|
||||
|
||||
if (!byBuiltIn && !sizeOptions?.length && !quantizationOptions?.length) {
|
||||
if (
|
||||
formKey !== deployFormKeyMap.catalog &&
|
||||
!sizeOptions?.length &&
|
||||
!quantizationOptions?.length
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import SealInput from '@/components/seal-form/seal-input';
|
||||
import { PageAction } from '@/config';
|
||||
import useAppUtils from '@/hooks/use-app-utils';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { Form } from 'antd';
|
||||
import React from 'react';
|
||||
import { modelSourceMap } from '../config';
|
||||
import { deployFormKeyMap, modelSourceMap } from '../config';
|
||||
import { useFormContext } from '../config/form-context';
|
||||
import { FormData } from '../config/types';
|
||||
|
||||
@@ -12,18 +11,15 @@ const HuggingFaceForm: React.FC = () => {
|
||||
const formInstance = Form.useFormInstance();
|
||||
const formCtx = useFormContext();
|
||||
const { getRuleMessage } = useAppUtils();
|
||||
const intl = useIntl();
|
||||
const { isGGUF, byBuiltIn, pageAction, onValuesChange } = formCtx;
|
||||
const { formKey, pageAction, onValuesChange } = formCtx;
|
||||
const source = Form.useWatch('source');
|
||||
|
||||
console.log('HuggingFaceForm', { source, isGGUF });
|
||||
|
||||
if (
|
||||
![
|
||||
modelSourceMap.huggingface_value,
|
||||
modelSourceMap.modelscope_value
|
||||
].includes(source) ||
|
||||
byBuiltIn
|
||||
formKey === deployFormKeyMap.catalog
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
@@ -34,23 +30,65 @@ const HuggingFaceForm: React.FC = () => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item<FormData>
|
||||
name="repo_id"
|
||||
key="repo_id"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: getRuleMessage('input', 'models.form.repoid')
|
||||
}
|
||||
]}
|
||||
>
|
||||
<SealInput.Input
|
||||
label="Base Model"
|
||||
required
|
||||
disabled={pageAction === PageAction.CREATE}
|
||||
onBlur={handleOnBlur}
|
||||
></SealInput.Input>
|
||||
</Form.Item>
|
||||
{source === modelSourceMap.huggingface_value ? (
|
||||
<>
|
||||
<Form.Item<FormData>
|
||||
name="huggingface_repo_id"
|
||||
key="huggingface_repo_id"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: getRuleMessage('input', 'models.form.repoid')
|
||||
}
|
||||
]}
|
||||
>
|
||||
<SealInput.Input
|
||||
label="Base Model"
|
||||
required
|
||||
disabled={pageAction === PageAction.CREATE}
|
||||
onBlur={handleOnBlur}
|
||||
></SealInput.Input>
|
||||
</Form.Item>
|
||||
<Form.Item<FormData>
|
||||
hidden
|
||||
name="huggingface_filename"
|
||||
key="huggingface_filename"
|
||||
>
|
||||
<SealInput.Input
|
||||
disabled={pageAction === PageAction.CREATE}
|
||||
></SealInput.Input>
|
||||
</Form.Item>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Form.Item<FormData>
|
||||
name="model_scope_model_id"
|
||||
key="model_scope_model_id"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: getRuleMessage('input', 'models.form.repoid')
|
||||
}
|
||||
]}
|
||||
>
|
||||
<SealInput.Input
|
||||
label="Base Model"
|
||||
required
|
||||
disabled={pageAction === PageAction.CREATE}
|
||||
onBlur={handleOnBlur}
|
||||
></SealInput.Input>
|
||||
</Form.Item>
|
||||
<Form.Item<FormData>
|
||||
hidden
|
||||
name="model_scope_file_path"
|
||||
key="model_scope_file_path"
|
||||
>
|
||||
<SealInput.Input
|
||||
disabled={pageAction === PageAction.CREATE}
|
||||
></SealInput.Input>
|
||||
</Form.Item>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -5,24 +5,25 @@ import { useIntl } from '@umijs/max';
|
||||
import { Form } from 'antd';
|
||||
import _ from 'lodash';
|
||||
import React, { useRef } from 'react';
|
||||
import { localPathTipsList, modelSourceMap } from '../config';
|
||||
import { deployFormKeyMap, localPathTipsList, modelSourceMap } from '../config';
|
||||
import { backendOptionsMap } from '../config/backend-parameters';
|
||||
import { useFormContext, useFormInnerContext } from '../config/form-context';
|
||||
import { useFormContext } from '../config/form-context';
|
||||
import { FormData } from '../config/types';
|
||||
import { checkOnlyAscendNPU } from '../hooks';
|
||||
|
||||
const LocalPathForm: React.FC = () => {
|
||||
const form = Form.useFormInstance();
|
||||
const formCtx = useFormContext();
|
||||
const formInnerCtx = useFormInnerContext();
|
||||
const source = Form.useWatch('source', form);
|
||||
const { onBackendChange, onValuesChange, gpuOptions } = formInnerCtx;
|
||||
const { byBuiltIn } = formCtx;
|
||||
const { formKey, gpuOptions, onValuesChange, onBackendChange } = formCtx;
|
||||
const { getRuleMessage } = useAppUtils();
|
||||
const intl = useIntl();
|
||||
const localPathCache = useRef<string>(form.getFieldValue('local_path') || '');
|
||||
|
||||
if (![modelSourceMap.local_path_value].includes(source) || byBuiltIn) {
|
||||
if (
|
||||
![modelSourceMap.local_path_value].includes(source) ||
|
||||
formKey === deployFormKeyMap.catalog
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user