fix: audio model use voxbox only

This commit is contained in:
jialin
2025-04-24 17:23:25 +08:00
parent dc8e9e3fef
commit 0497e2052d
6 changed files with 49 additions and 34 deletions
+2 -1
View File
@@ -247,7 +247,8 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
<FormInnerContext.Provider
value={{
onBackendChange: handleBackendChange
onBackendChange: handleBackendChange,
gpuOptions: gpuOptions
}}
>
<HuggingFaceForm></HuggingFaceForm>
@@ -20,7 +20,6 @@ import {
queryModelScopeModelFiles
} from '../apis';
import { backendOptionsMap, modelSourceMap } from '../config';
import { checkOnlyAscendNPU } from '../hooks';
import '../style/hf-model-file.less';
import ModelFileItem from './model-file-item';
import TitleWrapper from './title-wrapper';
@@ -237,9 +236,7 @@ const HFModelFile: React.FC<HFModelFileProps> = forwardRef((props, ref) => {
try {
const evaluateFileList = list.map((item: any) => {
return {
backend: checkOnlyAscendNPU(gpuOptions || [])
? backendOptionsMap.ascendMindie
: backendOptionsMap.llamaBox,
backend: backendOptionsMap.llamaBox,
source: modelSource,
...(modelSource === modelSourceMap.huggingface_value
? {
+9 -12
View File
@@ -21,11 +21,10 @@ import {
ModelScopeSortType,
ModelSortType,
ModelscopeTaskMap,
backendOptionsMap,
modelSourceMap
} from '../config';
import { handleRecognizeAudioModel } from '../config/audio-catalog';
import { checkOnlyAscendNPU } from '../hooks';
import { checkCurrentbackend } from '../hooks';
import SearchStyle from '../style/search-result.less';
import SearchInput from './search-input';
import SearchResult from './search-result';
@@ -215,17 +214,15 @@ const SearchModel: React.FC<SearchInputProps> = (props) => {
const res = handleRecognizeAudioModel(item, modelSource);
let backendObj = {};
if (checkOnlyAscendNPU?.(gpuOptions || [])) {
const backend = checkCurrentbackend({
isGGUF: item.isGGUF,
isAudio: res.isAudio,
gpuOptions: gpuOptions || []
});
if (backend) {
backendObj = {
backend: backendOptionsMap.ascendMindie
};
} else if (res.isAudio) {
backendObj = {
backend: backendOptionsMap.voxBox
};
} else if (item.isGGUF) {
backendObj = {
backend: backendOptionsMap.llamaBox
backend: backend
};
}
@@ -13,6 +13,7 @@ interface FormContextProps {
interface FormInnerContextProps {
onBackendChange?: (backend: string) => void;
gpuOptions?: any[];
}
export const FormContext = React.createContext<FormContextProps>(
+7 -4
View File
@@ -12,13 +12,14 @@ import {
} from '../config';
import { useFormContext, useFormInnerContext } 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 } = formInnerCtx;
const { onBackendChange, gpuOptions } = formInnerCtx;
const { byBuiltIn } = formCtx;
const { getRuleMessage } = useAppUtils();
const intl = useIntl();
@@ -37,14 +38,16 @@ const LocalPathForm: React.FC = () => {
const isBlobFile = value.split('/').pop().includes('sha256');
let backend = form.getFieldValue('backend');
if (
if (isEndwithGGUF || isBlobFile) {
backend = backendOptionsMap.llamaBox;
} else if (checkOnlyAscendNPU(gpuOptions || [])) {
backend = backendOptionsMap.ascendMindie;
} else if (
!isEndwithGGUF &&
!isBlobFile &&
backend === backendOptionsMap.llamaBox
) {
backend = backendOptionsMap.vllm;
} else if (isEndwithGGUF || isBlobFile) {
backend = backendOptionsMap.llamaBox;
}
form.setFieldValue('backend', backend);
+29 -13
View File
@@ -243,6 +243,27 @@ export const checkOnlyAscendNPU = (gpuOptions: any[]) => {
});
};
export const checkCurrentbackend = (data: {
isAudio: boolean;
isGGUF: boolean;
gpuOptions: any[];
defaultBackend?: string;
}) => {
const { isAudio, isGGUF, gpuOptions, defaultBackend } = data;
if (isAudio) {
return backendOptionsMap.voxBox;
}
if (isGGUF) {
return backendOptionsMap.llamaBox;
}
if (checkOnlyAscendNPU(gpuOptions)) {
return backendOptionsMap.ascendMindie;
}
return defaultBackend;
};
export const useCheckCompatibility = () => {
const intl = useIntl();
const cacheFormValuesRef = useRef<any>({});
@@ -559,24 +580,19 @@ export const useSelectModel = (data: { gpuOptions: any[] }) => {
const reg = /(-gguf)$/i;
name = _.toLower(name).replace(reg, '');
if (checkOnlyAscendNPU(gpuOptions)) {
return {
repo_id: selectModel.name,
name: name,
backend: backendOptionsMap.ascendMindie
};
}
const modelTaskData = handleRecognizeAudioModel(selectModel, source);
const backend = checkCurrentbackend({
defaultBackend: backendOptionsMap.vllm,
isAudio: modelTaskData.type === modelTaskMap.audio,
isGGUF: selectModel.isGGUF,
gpuOptions: gpuOptions
});
return {
repo_id: selectModel.name,
name: name,
backend:
modelTaskData.type === modelTaskMap.audio
? backendOptionsMap.voxBox
: selectModel.isGGUF
? backendOptionsMap.llamaBox
: backendOptionsMap.vllm
backend: backend
};
};