chore: image custom params

This commit is contained in:
jialin
2024-11-27 17:07:22 +08:00
parent ba76498acc
commit 230120fff5
19 changed files with 473 additions and 206 deletions
+17 -25
View File
@@ -117,16 +117,10 @@ export async function queryModelInstanceLogs(id: number) {
// ===================== call huggingface quicksearch api =====================
const HUGGINGFACE_API = '/proxy?url=https://huggingface.co/api/models';
const MODEL_SCOPE_LIST_MODEL_API =
'/proxy?url=https://www.modelscope.cn/api/v1/dolphin/models';
'https://www.modelscope.cn/api/v1/dolphin/models';
const MODEL_SCOPE_DETAIL_MODEL_API =
'/proxy?url=https://www.modelscope.cn/api/v1/dolphin/models/';
const MODE_SCOPE_MODEL_FIELS_API =
'/proxy?url=https://modelscope.cn/api/v1/models/';
const MODE_SCOPE_MODEL_FIELS_API = 'https://modelscope.cn/api/v1/models/';
export async function queryHuggingfaceModelDetail(
params: { repo: string },
@@ -165,7 +159,7 @@ export async function queryModelScopeModels(
Criterion: [...(tagsCriterion || []), ...(tasksCriterion || [])]
}
: {};
const res = await fetch(`${MODEL_SCOPE_LIST_MODEL_API}`, {
const res = await fetch(setProxyUrl(`${MODEL_SCOPE_LIST_MODEL_API}`), {
method: 'PUT',
signal: config?.signal,
headers: {
@@ -190,7 +184,7 @@ export async function queryModelScopeModelDetail(
params: { name: string },
options?: any
) {
return request(`${MODE_SCOPE_MODEL_FIELS_API}${params.name}`, {
return request(setProxyUrl(`${MODE_SCOPE_MODEL_FIELS_API}${params.name}`), {
method: 'GET',
cancelToken: options?.token
});
@@ -200,18 +194,18 @@ export async function queryModelScopeModelFiles(
params: { name: string; revision: string },
options?: any
) {
const res = await fetch(
`${MODE_SCOPE_MODEL_FIELS_API}${params.name}/repo/files?${qs.stringify({
const url = `${MODE_SCOPE_MODEL_FIELS_API}${params.name}/repo/files?${qs.stringify(
{
Revision: params.revision,
Recursive: true,
Root: ''
})}`,
{
method: 'GET',
signal: options?.signal,
body: null
}
);
)}`;
const res = await fetch(setProxyUrl(url), {
method: 'GET',
signal: options?.signal,
body: null
});
if (!res.ok) {
throw new Error('Network response was not ok');
@@ -310,13 +304,11 @@ export async function downloadModelScopeModelfile(
params: { name: string },
options?: any
) {
const res = await fetch(
`${MODE_SCOPE_MODEL_FIELS_API}${params.name}/resolve/master/config.json`,
{
method: 'GET',
signal: options?.signal
}
);
const url = `${MODE_SCOPE_MODEL_FIELS_API}${params.name}/resolve/master/config.json`;
const res = await fetch(setProxyUrl(url), {
method: 'GET',
signal: options?.signal
});
if (!res.ok) {
throw new Error('Network response was not ok');
}
@@ -35,7 +35,7 @@ interface AdvanceConfigProps {
gpuOptions: Array<any>;
action: PageActionType;
source: string;
modelTask: string;
modelTask: Record<string, any>;
}
const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
+22 -6
View File
@@ -23,6 +23,7 @@ import {
modelTaskMap,
ollamaModelOptions
} from '../config';
import { HuggingFaceModels, ModelScopeModels } from '../config/audio-catalog';
import { FormData, GPUListItem } from '../config/types';
import AdvanceConfig from './advance-config';
@@ -120,11 +121,30 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
[]
);
const identifyModelTask = () => {
let data = null;
if (props.source === modelSourceMap.huggingface_value) {
data = HuggingFaceModels.find(
(item) => `${item.org}/${item.name}` === props.selectedModel.name
);
}
if (props.source === modelSourceMap.modelscope_value) {
data = ModelScopeModels.find(
(item) => `${item.org}/${item.name}` === props.selectedModel.name
);
}
if (data) {
return modelTaskMap.audio;
}
return '';
};
const handleOnSelectModel = () => {
let name = _.split(props.selectedModel.name, '/').slice(-1)[0];
const reg = /(-gguf)$/i;
name = _.toLower(name).replace(reg, '');
const modelTaskType = identifyModelTask();
const modelTask =
HuggingFaceTaskMap.audio.includes(props.selectedModel.task) ||
ModelscopeTaskMap.audio.includes(props.selectedModel.task)
@@ -133,7 +153,7 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
setModelTask({
value: props.selectedModel.task,
type: modelTask,
type: modelTaskType || modelTask,
text2speech:
HuggingFaceTaskMap[modelTaskMap.textToSpeech] ===
props.selectedModel.task ||
@@ -351,8 +371,6 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
if (gpu) {
onOk({
..._.omit(formdata, ['scheduleType']),
speech_to_text: modelTask.speech2text,
text_to_speech: modelTask.text2speech,
gpu_selector: {
gpu_name: gpu.name,
gpu_index: gpu.index,
@@ -361,9 +379,7 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
});
} else {
onOk({
..._.omit(formdata, ['scheduleType']),
speech_to_text: modelTask.speech2text,
text_to_speech: modelTask.text2speech
..._.omit(formdata, ['scheduleType'])
});
}
};
@@ -130,12 +130,6 @@ const ModelCard: React.FC<{
// huggingface model card data
const getHuggingfaceModelDetail = async () => {
try {
const configjson = await loadConfig(
props.selectedModel.name,
'main'
).catch(() => {
return null;
});
const [modelcard, readme] = await Promise.all([
queryHuggingfaceModelDetail(
{ repo: props.selectedModel.name },
@@ -183,11 +177,6 @@ const ModelCard: React.FC<{
const getModelScopeModelDetail = async () => {
try {
const configjson = await loadModelscopeModelConfig(
props.selectedModel.name
).catch(() => {
return null;
});
const data = await queryModelScopeModelDetail(
{
name: props.selectedModel.name
@@ -200,7 +189,6 @@ const ModelCard: React.FC<{
...data?.Data,
name: `${data.Data?.Path}/${data.Data?.Name}`
});
console.log('modelData++++++++++++', configjson, data?.Data);
setReadmeText(data?.Data?.ReadMeContent);
const isGGUF = some(
data?.Data?.Tags,
+17 -48
View File
@@ -10,7 +10,6 @@ import {
ModelSortType,
ModelscopeTaskMap,
modelSourceMap,
modelTaskMap,
ollamaModelOptions
} from '../config';
import SearchStyle from '../style/search-result.less';
@@ -233,22 +232,15 @@ const SearchModel: React.FC<SearchInputProps> = (props) => {
modelSource={modelSource}
></SearchInput>
<div className={SearchStyle.filter}>
{/* <span>
<span>
<span className="value">
{intl.formatMessage(
{ id: 'models.search.result' },
{ count: dataSource.repoOptions.length }
)}
</span>
</span> */}
<span
style={{
flex: 1,
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center'
}}
>
</span>
<span>
<Checkbox
onChange={handleFilterGGUFChange}
className="m-r-5"
@@ -271,43 +263,20 @@ const SearchModel: React.FC<SearchInputProps> = (props) => {
<InfoCircleOutlined className="m-l-4" />
</Tooltip>
</Checkbox>
<span className="flex gap-6">
<Select
allowClear
value={filterTaskRef.current}
onChange={handleFilterTaskChange}
options={[
{
label: intl.formatMessage({
id: 'playground.audio.texttospeech'
}),
value: modelTaskMap.textToSpeech
},
{
label: intl.formatMessage({
id: 'playground.audio.speechtotext'
}),
value: modelTaskMap.speechToText
}
]}
size="middle"
style={{ width: '140px' }}
></Select>
<Select
value={dataSource.sortType}
onChange={handleSortChange}
labelRender={({ label }) => {
return (
<span>
{intl.formatMessage({ id: 'model.deploy.sort' })}: {label}
</span>
);
}}
options={modelFilesSortOptions.current}
size="middle"
style={{ width: '140px' }}
></Select>
</span>
<Select
value={dataSource.sortType}
onChange={handleSortChange}
labelRender={({ label }) => {
return (
<span>
{intl.formatMessage({ id: 'model.deploy.sort' })}: {label}
</span>
);
}}
options={modelFilesSortOptions.current}
size="middle"
style={{ width: '150px' }}
></Select>
</span>
</div>
</>
+105
View File
@@ -0,0 +1,105 @@
export const HuggingFaceModels = [
{
type: 'stt',
org: 'funasr',
name: 'paraformer-zh'
},
{
type: 'stt',
org: 'funasr',
name: 'paraformer-zh-streaming'
},
{
type: 'stt',
org: 'funasr',
name: 'paraformer-en'
},
{
type: 'stt',
org: 'funasr',
name: 'conformer-en'
},
{
type: 'stt',
org: 'Qwen',
name: 'Qwen-Audio'
},
{
type: 'stt',
org: 'Qwen',
name: 'Qwen-Audio-Chat'
},
{
type: 'stt',
org: 'FunAudioLLM',
name: 'SenseVoiceSmall'
},
{
type: 'stt',
org: 'Systran',
name: '*'
},
{
type: 'tts',
org: 'suno',
name: 'bark'
},
{
type: 'tts',
org: 'suno',
name: 'bark-small'
},
{
type: 'tts',
org: 'FunAudioLLM',
name: 'CosyVoice-300M-Instruct'
},
{
type: 'tts',
org: 'FunAudioLLM',
name: 'CosyVoice-300M-SFT'
},
{
type: 'tts',
org: 'FunAudioLLM',
name: 'CosyVoice-300M'
}
];
export const ModelScopeModels = [
{
type: 'stt',
org: 'iic',
name: 'SenseVoiceSmall'
},
{
type: 'stt',
org: 'iic',
name: 'Whisper-large-v3'
},
{
type: 'stt',
org: 'iic',
name: 'Whisper-large-v3-turbo'
},
{
type: 'tts',
org: 'iic',
name: 'CosyVoice-300M-Instruct'
},
{
type: 'tts',
org: 'iic',
name: 'CosyVoice-300M'
},
{
type: 'tts',
org: 'iic',
name: 'CosyVoice-300M-25Hz'
},
{
type: 'tts',
org: 'iic',
name: 'CosyVoice-300M-SFT'
}
];