chore: deploy form context provider
This commit is contained in:
@@ -1,10 +1,3 @@
|
||||
import {
|
||||
HuggingFaceTaskMap,
|
||||
ModelscopeTaskMap,
|
||||
modelSourceMap,
|
||||
modelTaskMap
|
||||
} from './index';
|
||||
|
||||
export const HuggingFaceModels = [
|
||||
{
|
||||
type: 'stt',
|
||||
@@ -195,60 +188,3 @@ export const ModelScopeModels = [
|
||||
name: 'faster-whisper-large-v1'
|
||||
}
|
||||
];
|
||||
|
||||
const checkModelName = (
|
||||
modelName: string,
|
||||
item: { type: string; org: string; name: string }
|
||||
) => {
|
||||
let sourceName = `${item.org}/${item.name}`;
|
||||
if (item.name === '*') {
|
||||
sourceName = `${item.org}`;
|
||||
}
|
||||
return (
|
||||
`${sourceName}`.indexOf(modelName) > -1 ||
|
||||
modelName?.indexOf(`${sourceName}`) > -1
|
||||
);
|
||||
};
|
||||
|
||||
export const identifyModelTask = (source: string, modelName: string) => {
|
||||
let data = null;
|
||||
if (source === modelSourceMap.huggingface_value) {
|
||||
data = HuggingFaceModels.find((item) => checkModelName(modelName, item));
|
||||
}
|
||||
if (source === modelSourceMap.modelscope_value) {
|
||||
data = ModelScopeModels.find((item) => checkModelName(modelName, item));
|
||||
}
|
||||
if (data) {
|
||||
return modelTaskMap.audio;
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
export const handleRecognizeAudioModel = (selectModel: any, source: string) => {
|
||||
const modelTaskType = identifyModelTask(source, selectModel.name);
|
||||
let isAudio = modelTaskType === modelTaskMap.audio;
|
||||
|
||||
// Check if the model is audio type, if not, check if the task is audio
|
||||
if (!isAudio) {
|
||||
const modelTask =
|
||||
HuggingFaceTaskMap.audio.includes(selectModel.task) ||
|
||||
ModelscopeTaskMap.audio.includes(selectModel.task)
|
||||
? modelTaskMap.audio
|
||||
: '';
|
||||
|
||||
isAudio = modelTask === modelTaskMap.audio;
|
||||
}
|
||||
|
||||
const modelTaskData = {
|
||||
value: selectModel.task,
|
||||
type: isAudio ? modelTaskMap.audio : '',
|
||||
isAudio: isAudio,
|
||||
text2speech:
|
||||
HuggingFaceTaskMap[modelTaskMap.textToSpeech] === selectModel.task ||
|
||||
ModelscopeTaskMap[modelTaskMap.textToSpeech] === selectModel.task,
|
||||
speech2text:
|
||||
HuggingFaceTaskMap[modelTaskMap.speechToText] === selectModel.task ||
|
||||
ModelscopeTaskMap[modelTaskMap.speechToText] === selectModel.task
|
||||
};
|
||||
return modelTaskData;
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@ interface FormContextProps {
|
||||
gpuOptions?: any[];
|
||||
backendOptions: BackendOption[];
|
||||
onValuesChange?: (changedValues: any, allValues: any) => void;
|
||||
onBackendChange: (backend: string) => void;
|
||||
onBackendChange: (backend: string, option: any) => void;
|
||||
}
|
||||
|
||||
interface CatalogFormContextProps {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import _ from 'lodash';
|
||||
import { backendOptionsMap } from '../config/backend-parameters';
|
||||
import { FormData } from './types';
|
||||
|
||||
export const generateGPUSelector = (data: any, gpuOptions: any[]) => {
|
||||
const gpu_ids = _.get(data, 'gpu_selector.gpu_ids', []);
|
||||
@@ -31,3 +32,32 @@ export const generateGPUSelector = (data: any, gpuOptions: any[]) => {
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const generateGPUIds = (data: FormData) => {
|
||||
const gpu_ids = _.get(data, 'gpu_selector.gpu_ids', []);
|
||||
console.log('generateGPUIds', gpu_ids);
|
||||
if (!gpu_ids.length) {
|
||||
return {
|
||||
gpu_selector: null
|
||||
};
|
||||
}
|
||||
|
||||
const result = _.reduce(
|
||||
gpu_ids,
|
||||
(acc: string[], item: string | string[], index: number) => {
|
||||
if (Array.isArray(item)) {
|
||||
acc.push(item[1]);
|
||||
} else if (index === 1) {
|
||||
acc.push(item);
|
||||
}
|
||||
return acc;
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
return {
|
||||
gpu_selector: {
|
||||
gpu_ids: result || []
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user