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<
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 axiosToken = useRef<any>(null);
const selectSpecRef = useRef<CatalogSpec>({} as CatalogSpec);
@@ -346,35 +348,35 @@ const AddModal: React.FC<AddModalProps> = (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<AddModalProps> = (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<AddModalProps> = (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));
});
+1 -1
View File
@@ -30,7 +30,7 @@ interface FormContextProps {
interface CatalogFormContextProps {
sizeOptions: Global.BaseOption<number>[];
quantizationOptions: Global.BaseOption<string>[];
modeList: Global.BaseOption<string & { isBuiltIn: boolean; tips: string }>[];
modeList: Global.BaseOption<string, { isBuiltIn: boolean; tips: string }>[];
onModeChange: (val: string) => void;
onSizeChange: (val: number) => void;
onQuantizationChange: (val: string) => void;
+8 -4
View File
@@ -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={<TooltipList list={modeTipsList}></TooltipList>}
label={intl.formatMessage({ id: 'models.form.mode' })}
>
{modeList.map((item: any) => (
{modeList?.map((item: any) => (
<Select.Option key={item.value} value={item.value}>
<AutoTooltip
showTitle={item.isBuiltIn}
ghost
title={intl.formatMessage({ id: item.tips })}
title={
item?.tips
? intl.formatMessage({ id: item?.tips || '' })
: false
}
>
{item.isBuiltIn
? intl.formatMessage({ id: item.label })
? intl.formatMessage({ id: item?.label || '' })
: item.label}
</AutoTooltip>
</Select.Option>