fix: backend change

This commit is contained in:
jialin
2025-11-03 10:14:30 +08:00
parent 57d41e79c7
commit 86c2f8eda1
3 changed files with 42 additions and 34 deletions
@@ -131,7 +131,9 @@ const AddModal: React.FC<AddModalProps> = (props) => {
const [quantizationOptions, setQuantizationOptions] = useState< const [quantizationOptions, setQuantizationOptions] = useState<
Global.BaseOption<string>[] Global.BaseOption<string>[]
>([]); >([]);
const [modeList, setModeList] = useState<Global.BaseOption<string>[]>([]); const [modeList, setModeList] = useState<
Global.BaseOption<string, { isBuiltIn: boolean; tips: string }>[]
>([]);
const sourceGroupMap = useRef<any>({}); const sourceGroupMap = useRef<any>({});
const axiosToken = useRef<any>(null); const axiosToken = useRef<any>(null);
const selectSpecRef = useRef<CatalogSpec>({} as CatalogSpec); const selectSpecRef = useRef<CatalogSpec>({} as CatalogSpec);
@@ -346,35 +348,35 @@ const AddModal: React.FC<AddModalProps> = (props) => {
}; };
const handleBackendChange = (backend: string) => { const handleBackendChange = (backend: string) => {
if (backend === backendOptionsMap.llamaBox) { // if (backend === backendOptionsMap.llamaBox) {
setIsGGUF(true); // setIsGGUF(true);
} else { // } else {
setIsGGUF(false); // setIsGGUF(false);
} // }
const sizeList = handleSetSizeOptions({ // const sizeList = handleSetSizeOptions({
backend: backend // backend: backend
}); // });
const size = checkSize(sizeList); // const size = checkSize(sizeList);
const quantizaList = handleSetQuantizationOptions({ // const quantizaList = handleSetQuantizationOptions({
size: size, // size: size,
backend: backend // backend: backend
}); // });
const quantization = checkQuantization(quantizaList); // const quantization = checkQuantization(quantizaList);
const data = getModelSpec({ // const data = getModelSpec({
backend: backend, // backend: backend,
size: size, // size: size,
quantization: quantization // quantization: quantization
}); // });
form.current.setFieldsValue({ // form.current.setFieldsValue({
...defaultFormValues, // ...defaultFormValues,
...data // ...data
}); // });
handleCheckFormData(); handleCheckFormData();
}; };
@@ -399,14 +401,17 @@ const AddModal: React.FC<AddModalProps> = (props) => {
} }
); );
const groupList = _.groupBy(res.items, 'source'); 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 { return {
label: ModesMap[key] || key, label: _.get(ModesMap, key, key || ''),
isBuiltIn: ModesMap[key] ? true : false, isBuiltIn: ModesMap[key] ? true : false,
value: key, value: key,
tips: ModesTipsMap[key] || '' tips: _.get(ModesTipsMap, key, '')
}; };
}); });
@@ -420,7 +425,6 @@ const AddModal: React.FC<AddModalProps> = (props) => {
const list = _.sortBy(res.items, 'size'); const list = _.sortBy(res.items, 'size');
console.log('spec items:', res.items);
hasF16Ref.current = _.some(res.items, (item: CatalogSpec) => { hasF16Ref.current = _.some(res.items, (item: CatalogSpec) => {
return AscendNPUQuant_F16.includes(_.toUpper(item.quantization)); return AscendNPUQuant_F16.includes(_.toUpper(item.quantization));
}); });
+1 -1
View File
@@ -30,7 +30,7 @@ interface FormContextProps {
interface CatalogFormContextProps { interface CatalogFormContextProps {
sizeOptions: Global.BaseOption<number>[]; sizeOptions: Global.BaseOption<number>[];
quantizationOptions: Global.BaseOption<string>[]; quantizationOptions: Global.BaseOption<string>[];
modeList: Global.BaseOption<string & { isBuiltIn: boolean; tips: string }>[]; modeList: Global.BaseOption<string, { isBuiltIn: boolean; tips: string }>[];
onModeChange: (val: string) => void; onModeChange: (val: string) => void;
onSizeChange: (val: number) => void; onSizeChange: (val: number) => void;
onQuantizationChange: (val: string) => void; onQuantizationChange: (val: string) => void;
+8 -4
View File
@@ -37,7 +37,7 @@ const Performance: React.FC = () => {
const intl = useIntl(); const intl = useIntl();
const form = Form.useFormInstance(); const form = Form.useFormInstance();
const { formKey } = useFormContext(); const { formKey } = useFormContext();
const { modeList, onModeChange } = useCatalogFormContext(); const { modeList = [], onModeChange } = useCatalogFormContext();
return ( return (
<> <>
@@ -49,15 +49,19 @@ const Performance: React.FC = () => {
description={<TooltipList list={modeTipsList}></TooltipList>} description={<TooltipList list={modeTipsList}></TooltipList>}
label={intl.formatMessage({ id: 'models.form.mode' })} label={intl.formatMessage({ id: 'models.form.mode' })}
> >
{modeList.map((item: any) => ( {modeList?.map((item: any) => (
<Select.Option key={item.value} value={item.value}> <Select.Option key={item.value} value={item.value}>
<AutoTooltip <AutoTooltip
showTitle={item.isBuiltIn} showTitle={item.isBuiltIn}
ghost ghost
title={intl.formatMessage({ id: item.tips })} title={
item?.tips
? intl.formatMessage({ id: item?.tips || '' })
: false
}
> >
{item.isBuiltIn {item.isBuiltIn
? intl.formatMessage({ id: item.label }) ? intl.formatMessage({ id: item?.label || '' })
: item.label} : item.label}
</AutoTooltip> </AutoTooltip>
</Select.Option> </Select.Option>