diff --git a/src/pages/llmodels/components/deploy-builtin-modal.tsx b/src/pages/llmodels/components/deploy-builtin-modal.tsx index 154a983a..3ce53104 100644 --- a/src/pages/llmodels/components/deploy-builtin-modal.tsx +++ b/src/pages/llmodels/components/deploy-builtin-modal.tsx @@ -131,7 +131,9 @@ const AddModal: React.FC = (props) => { const [quantizationOptions, setQuantizationOptions] = useState< Global.BaseOption[] >([]); - const [modeList, setModeList] = useState[]>([]); + const [modeList, setModeList] = useState< + Global.BaseOption[] + >([]); const sourceGroupMap = useRef({}); const axiosToken = useRef(null); const selectSpecRef = useRef({} as CatalogSpec); @@ -346,35 +348,35 @@ const AddModal: React.FC = (props) => { }; const handleBackendChange = (backend: string) => { - if (backend === backendOptionsMap.llamaBox) { - setIsGGUF(true); - } else { - setIsGGUF(false); - } + // if (backend === backendOptionsMap.llamaBox) { + // setIsGGUF(true); + // } else { + // setIsGGUF(false); + // } - const sizeList = handleSetSizeOptions({ - backend: backend - }); + // const sizeList = handleSetSizeOptions({ + // backend: backend + // }); - const size = checkSize(sizeList); + // const size = checkSize(sizeList); - const quantizaList = handleSetQuantizationOptions({ - size: size, - backend: backend - }); + // const quantizaList = handleSetQuantizationOptions({ + // size: size, + // backend: backend + // }); - const quantization = checkQuantization(quantizaList); + // const quantization = checkQuantization(quantizaList); - const data = getModelSpec({ - backend: backend, - size: size, - quantization: quantization - }); + // const data = getModelSpec({ + // backend: backend, + // size: size, + // quantization: quantization + // }); - form.current.setFieldsValue({ - ...defaultFormValues, - ...data - }); + // form.current.setFieldsValue({ + // ...defaultFormValues, + // ...data + // }); handleCheckFormData(); }; @@ -399,14 +401,17 @@ const AddModal: React.FC = (props) => { } ); const groupList = _.groupBy(res.items, 'source'); - const modes = _.groupBy(res.items, 'mode'); - const modeDataList = _.map(modes, (item: CatalogSpec, key: string) => { + const modes: string[] = res.items?.map((item: CatalogSpec) => { + return item.mode; + }); + + const modeDataList = [...new Set(modes)].map((key: string) => { return { - label: ModesMap[key] || key, + label: _.get(ModesMap, key, key || ''), isBuiltIn: ModesMap[key] ? true : false, value: key, - tips: ModesTipsMap[key] || '' + tips: _.get(ModesTipsMap, key, '') }; }); @@ -420,7 +425,6 @@ const AddModal: React.FC = (props) => { const list = _.sortBy(res.items, 'size'); - console.log('spec items:', res.items); hasF16Ref.current = _.some(res.items, (item: CatalogSpec) => { return AscendNPUQuant_F16.includes(_.toUpper(item.quantization)); }); diff --git a/src/pages/llmodels/config/form-context.ts b/src/pages/llmodels/config/form-context.ts index fc1592d1..af9ac420 100644 --- a/src/pages/llmodels/config/form-context.ts +++ b/src/pages/llmodels/config/form-context.ts @@ -30,7 +30,7 @@ interface FormContextProps { interface CatalogFormContextProps { sizeOptions: Global.BaseOption[]; quantizationOptions: Global.BaseOption[]; - modeList: Global.BaseOption[]; + modeList: Global.BaseOption[]; onModeChange: (val: string) => void; onSizeChange: (val: number) => void; onQuantizationChange: (val: string) => void; diff --git a/src/pages/llmodels/forms/performance.tsx b/src/pages/llmodels/forms/performance.tsx index c7dd5b8a..820a8fa8 100644 --- a/src/pages/llmodels/forms/performance.tsx +++ b/src/pages/llmodels/forms/performance.tsx @@ -37,7 +37,7 @@ const Performance: React.FC = () => { const intl = useIntl(); const form = Form.useFormInstance(); const { formKey } = useFormContext(); - const { modeList, onModeChange } = useCatalogFormContext(); + const { modeList = [], onModeChange } = useCatalogFormContext(); return ( <> @@ -49,15 +49,19 @@ const Performance: React.FC = () => { description={} label={intl.formatMessage({ id: 'models.form.mode' })} > - {modeList.map((item: any) => ( + {modeList?.map((item: any) => ( {item.isBuiltIn - ? intl.formatMessage({ id: item.label }) + ? intl.formatMessage({ id: item?.label || '' }) : item.label}