chore: check compatibility ux
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
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();
|
||||
}
|
||||
};
|
||||
@@ -379,3 +379,17 @@ export async function evaluationsModelSpec(
|
||||
cancelToken: options?.token
|
||||
});
|
||||
}
|
||||
|
||||
// export const evaluationsModelSpec = async (
|
||||
// data: {
|
||||
// model_specs: EvaluateSpec[];
|
||||
// },
|
||||
// options: { token: any }
|
||||
// ) => {
|
||||
// const response = await fetch(`v1/${MODEL_EVALUATIONS}`, {
|
||||
// method: 'POST',
|
||||
// headers: { 'Content-Type': 'application/json' },
|
||||
// body: JSON.stringify(data)
|
||||
// });
|
||||
// return response.json();
|
||||
// };
|
||||
|
||||
Reference in New Issue
Block a user