deerflow2/frontend/src/core/models/api.ts

19 lines
454 B
TypeScript

import { getBackendBaseURL } from "../config";
import type { Model } from "./types";
export async function loadModels() {
const res = await fetch(`${getBackendBaseURL()}/api/models`);
if (res.status >= 500 && res.status < 600) {
throw new Error(`Server error: ${res.status}`);
}
if (!res.ok) {
throw new Error(`HTTP error: ${res.status}`);
}
const { models } = (await res.json()) as { models: Model[] };
return models;
}