Spaces:
Running
Running
File size: 820 Bytes
dff2be9 8cfdcec dff2be9 8cfdcec dff2be9 8cfdcec 268c9a8 8cfdcec |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
/**
* List here only the model IDs your endpoint exposes.
* Add/remove freely – nothing else in the codebase cares.
*/
export type ModelID = string;
let modelsCache: string[] | null = null;
export async function getModels(): Promise<string[]> {
if (modelsCache) {
return modelsCache;
}
try {
const response = await fetch("https://router.huggingface.co/v1/models");
const data = await response.json();
const modelIds = data.data
.filter((model: any) => model.id !== "THUDM/GLM-4.1V-9B-Thinking")
.slice(0, 5)
.map((model: any) => model.id);
modelsCache = modelIds;
return modelIds;
} catch (e) {
console.error(e);
return [];
}
}
export async function getDefaultModel(): Promise<ModelID> {
const models = await getModels();
return models[0] ?? "";
}
|