Spaces:
Sleeping
Sleeping
| /** | |
| * 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("/static-proxy?url=https%3A%2F%2Frouter.huggingface.co%2Fv1%2Fmodels%26quot%3B%3C%2Fspan%3E)%3B%3C!-- HTML_TAG_END --> | |
| 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] ?? ""; | |
| } | |