fix: audio model use voxbox only
This commit is contained in:
@@ -247,7 +247,8 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
|
|||||||
|
|
||||||
<FormInnerContext.Provider
|
<FormInnerContext.Provider
|
||||||
value={{
|
value={{
|
||||||
onBackendChange: handleBackendChange
|
onBackendChange: handleBackendChange,
|
||||||
|
gpuOptions: gpuOptions
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<HuggingFaceForm></HuggingFaceForm>
|
<HuggingFaceForm></HuggingFaceForm>
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import {
|
|||||||
queryModelScopeModelFiles
|
queryModelScopeModelFiles
|
||||||
} from '../apis';
|
} from '../apis';
|
||||||
import { backendOptionsMap, modelSourceMap } from '../config';
|
import { backendOptionsMap, modelSourceMap } from '../config';
|
||||||
import { checkOnlyAscendNPU } from '../hooks';
|
|
||||||
import '../style/hf-model-file.less';
|
import '../style/hf-model-file.less';
|
||||||
import ModelFileItem from './model-file-item';
|
import ModelFileItem from './model-file-item';
|
||||||
import TitleWrapper from './title-wrapper';
|
import TitleWrapper from './title-wrapper';
|
||||||
@@ -237,9 +236,7 @@ const HFModelFile: React.FC<HFModelFileProps> = forwardRef((props, ref) => {
|
|||||||
try {
|
try {
|
||||||
const evaluateFileList = list.map((item: any) => {
|
const evaluateFileList = list.map((item: any) => {
|
||||||
return {
|
return {
|
||||||
backend: checkOnlyAscendNPU(gpuOptions || [])
|
backend: backendOptionsMap.llamaBox,
|
||||||
? backendOptionsMap.ascendMindie
|
|
||||||
: backendOptionsMap.llamaBox,
|
|
||||||
source: modelSource,
|
source: modelSource,
|
||||||
...(modelSource === modelSourceMap.huggingface_value
|
...(modelSource === modelSourceMap.huggingface_value
|
||||||
? {
|
? {
|
||||||
|
|||||||
@@ -21,11 +21,10 @@ import {
|
|||||||
ModelScopeSortType,
|
ModelScopeSortType,
|
||||||
ModelSortType,
|
ModelSortType,
|
||||||
ModelscopeTaskMap,
|
ModelscopeTaskMap,
|
||||||
backendOptionsMap,
|
|
||||||
modelSourceMap
|
modelSourceMap
|
||||||
} from '../config';
|
} from '../config';
|
||||||
import { handleRecognizeAudioModel } from '../config/audio-catalog';
|
import { handleRecognizeAudioModel } from '../config/audio-catalog';
|
||||||
import { checkOnlyAscendNPU } from '../hooks';
|
import { checkCurrentbackend } from '../hooks';
|
||||||
import SearchStyle from '../style/search-result.less';
|
import SearchStyle from '../style/search-result.less';
|
||||||
import SearchInput from './search-input';
|
import SearchInput from './search-input';
|
||||||
import SearchResult from './search-result';
|
import SearchResult from './search-result';
|
||||||
@@ -215,17 +214,15 @@ const SearchModel: React.FC<SearchInputProps> = (props) => {
|
|||||||
const res = handleRecognizeAudioModel(item, modelSource);
|
const res = handleRecognizeAudioModel(item, modelSource);
|
||||||
|
|
||||||
let backendObj = {};
|
let backendObj = {};
|
||||||
if (checkOnlyAscendNPU?.(gpuOptions || [])) {
|
const backend = checkCurrentbackend({
|
||||||
|
isGGUF: item.isGGUF,
|
||||||
|
isAudio: res.isAudio,
|
||||||
|
gpuOptions: gpuOptions || []
|
||||||
|
});
|
||||||
|
|
||||||
|
if (backend) {
|
||||||
backendObj = {
|
backendObj = {
|
||||||
backend: backendOptionsMap.ascendMindie
|
backend: backend
|
||||||
};
|
|
||||||
} else if (res.isAudio) {
|
|
||||||
backendObj = {
|
|
||||||
backend: backendOptionsMap.voxBox
|
|
||||||
};
|
|
||||||
} else if (item.isGGUF) {
|
|
||||||
backendObj = {
|
|
||||||
backend: backendOptionsMap.llamaBox
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ interface FormContextProps {
|
|||||||
|
|
||||||
interface FormInnerContextProps {
|
interface FormInnerContextProps {
|
||||||
onBackendChange?: (backend: string) => void;
|
onBackendChange?: (backend: string) => void;
|
||||||
|
gpuOptions?: any[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const FormContext = React.createContext<FormContextProps>(
|
export const FormContext = React.createContext<FormContextProps>(
|
||||||
|
|||||||
@@ -12,13 +12,14 @@ import {
|
|||||||
} from '../config';
|
} from '../config';
|
||||||
import { useFormContext, useFormInnerContext } from '../config/form-context';
|
import { useFormContext, useFormInnerContext } from '../config/form-context';
|
||||||
import { FormData } from '../config/types';
|
import { FormData } from '../config/types';
|
||||||
|
import { checkOnlyAscendNPU } from '../hooks';
|
||||||
|
|
||||||
const LocalPathForm: React.FC = () => {
|
const LocalPathForm: React.FC = () => {
|
||||||
const form = Form.useFormInstance();
|
const form = Form.useFormInstance();
|
||||||
const formCtx = useFormContext();
|
const formCtx = useFormContext();
|
||||||
const formInnerCtx = useFormInnerContext();
|
const formInnerCtx = useFormInnerContext();
|
||||||
const source = Form.useWatch('source', form);
|
const source = Form.useWatch('source', form);
|
||||||
const { onBackendChange } = formInnerCtx;
|
const { onBackendChange, gpuOptions } = formInnerCtx;
|
||||||
const { byBuiltIn } = formCtx;
|
const { byBuiltIn } = formCtx;
|
||||||
const { getRuleMessage } = useAppUtils();
|
const { getRuleMessage } = useAppUtils();
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
@@ -37,14 +38,16 @@ const LocalPathForm: React.FC = () => {
|
|||||||
const isBlobFile = value.split('/').pop().includes('sha256');
|
const isBlobFile = value.split('/').pop().includes('sha256');
|
||||||
let backend = form.getFieldValue('backend');
|
let backend = form.getFieldValue('backend');
|
||||||
|
|
||||||
if (
|
if (isEndwithGGUF || isBlobFile) {
|
||||||
|
backend = backendOptionsMap.llamaBox;
|
||||||
|
} else if (checkOnlyAscendNPU(gpuOptions || [])) {
|
||||||
|
backend = backendOptionsMap.ascendMindie;
|
||||||
|
} else if (
|
||||||
!isEndwithGGUF &&
|
!isEndwithGGUF &&
|
||||||
!isBlobFile &&
|
!isBlobFile &&
|
||||||
backend === backendOptionsMap.llamaBox
|
backend === backendOptionsMap.llamaBox
|
||||||
) {
|
) {
|
||||||
backend = backendOptionsMap.vllm;
|
backend = backendOptionsMap.vllm;
|
||||||
} else if (isEndwithGGUF || isBlobFile) {
|
|
||||||
backend = backendOptionsMap.llamaBox;
|
|
||||||
}
|
}
|
||||||
form.setFieldValue('backend', backend);
|
form.setFieldValue('backend', backend);
|
||||||
|
|
||||||
|
|||||||
@@ -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 = () => {
|
export const useCheckCompatibility = () => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const cacheFormValuesRef = useRef<any>({});
|
const cacheFormValuesRef = useRef<any>({});
|
||||||
@@ -559,24 +580,19 @@ export const useSelectModel = (data: { gpuOptions: any[] }) => {
|
|||||||
const reg = /(-gguf)$/i;
|
const reg = /(-gguf)$/i;
|
||||||
name = _.toLower(name).replace(reg, '');
|
name = _.toLower(name).replace(reg, '');
|
||||||
|
|
||||||
if (checkOnlyAscendNPU(gpuOptions)) {
|
|
||||||
return {
|
|
||||||
repo_id: selectModel.name,
|
|
||||||
name: name,
|
|
||||||
backend: backendOptionsMap.ascendMindie
|
|
||||||
};
|
|
||||||
}
|
|
||||||
const modelTaskData = handleRecognizeAudioModel(selectModel, source);
|
const modelTaskData = handleRecognizeAudioModel(selectModel, source);
|
||||||
|
|
||||||
|
const backend = checkCurrentbackend({
|
||||||
|
defaultBackend: backendOptionsMap.vllm,
|
||||||
|
isAudio: modelTaskData.type === modelTaskMap.audio,
|
||||||
|
isGGUF: selectModel.isGGUF,
|
||||||
|
gpuOptions: gpuOptions
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
repo_id: selectModel.name,
|
repo_id: selectModel.name,
|
||||||
name: name,
|
name: name,
|
||||||
backend:
|
backend: backend
|
||||||
modelTaskData.type === modelTaskMap.audio
|
|
||||||
? backendOptionsMap.voxBox
|
|
||||||
: selectModel.isGGUF
|
|
||||||
? backendOptionsMap.llamaBox
|
|
||||||
: backendOptionsMap.vllm
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user