feat: dynamic backends

This commit is contained in:
jialin
2025-10-13 14:40:26 +08:00
parent ee95fabc47
commit bca1e8140e
19 changed files with 325 additions and 177 deletions
-52
View File
@@ -1,52 +0,0 @@
const MODEL_EVALUATIONS = '/model-evaluations';
let controller = new AbortController();
let signal = controller.signal;
self.onmessage = async (event) => {
const { list, modelSource, modelSourceMap } = event.data;
const repoList = list.map((item: any) => ({
source: modelSource,
...(modelSource === modelSourceMap.huggingface_value
? { huggingface_repo_id: item.name }
: { model_scope_model_id: item.name })
}));
try {
controller?.abort();
controller = new AbortController();
signal = controller.signal;
const response = await fetch(`v1/${MODEL_EVALUATIONS}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
signal,
body: JSON.stringify({ model_specs: repoList })
});
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
const evaluations = await response.json();
const { results } = evaluations;
const resultList = list.map((item: any, index: number) => {
return {
...item,
evaluateResult: results[index] || null
};
});
self.postMessage({ success: true, resultList });
} catch (error) {
self.postMessage({ success: false, resultList: list });
}
};
self.onmessage = (event) => {
if (event.data === 'abort') {
controller.abort();
}
};
+53
View File
@@ -20,6 +20,8 @@ export const MODEL_INSTANCE_API = '/model-instances';
export const MODEL_EVALUATIONS = '/model-evaluations';
export const BACKEND_LIST_API = '/inference-backend/list';
const setProxyUrl = (url: string) => {
return `/proxy?url=${encodeURIComponent(url)}`;
};
@@ -396,3 +398,54 @@ export async function evaluationsModelSpec(
})
};
}
export async function queryBackendList() {
// return request<{
// items: {
// backend_name: string;
// backend_show_name: string;
// from_config: boolean;
// default_version: string;
// default_backend_param: string[];
// versions: string[];
// }[];
// }>(BACKEND_LIST_API, {
// method: 'GET'
// });
return {
items: [
{
backend_name: 'vllm',
backend_show_name: 'vLLM',
from_config: false,
default_version: '0.10.1.1',
default_backend_param: null,
versions: ['0.10.1.1', '0.10.0', '0.9.2', '0.8.5', '0.8.3']
},
{
backend_name: 'ascend-mindie',
backend_show_name: 'Ascend MindIE',
from_config: false,
default_version: null,
default_backend_param: null,
versions: null
},
{
backend_name: 'custom',
backend_show_name: 'Custom',
from_config: false,
default_version: null,
default_backend_param: null,
versions: null
},
{
backend_name: 'test',
backend_show_name: null,
from_config: true,
default_version: 'v1',
default_backend_param: ['--host=0.0.0.0'],
versions: ['v1']
}
]
};
}