mirror of
https://github.com/open-jarvis/OpenJarvis.git
synced 2026-07-30 10:52:15 +00:00
- .github/workflows/frontend.yml: type-check + build on push/PR - ErrorBoundary component wraps App with catch + retry UI - API client reads VITE_API_URL env var for non-same-origin deploys - vite-env.d.ts declares ImportMetaEnv type Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
23 lines
819 B
TypeScript
23 lines
819 B
TypeScript
import type { ModelInfo, SavingsData, ServerInfo } from '../types';
|
|
|
|
const BASE = import.meta.env.VITE_API_URL || ''; // relative to same origin by default
|
|
|
|
export async function fetchModels(): Promise<ModelInfo[]> {
|
|
const res = await fetch(`${BASE}/v1/models`);
|
|
if (!res.ok) throw new Error(`Failed to fetch models: ${res.status}`);
|
|
const data = await res.json();
|
|
return data.data || [];
|
|
}
|
|
|
|
export async function fetchSavings(): Promise<SavingsData> {
|
|
const res = await fetch(`${BASE}/v1/savings`);
|
|
if (!res.ok) throw new Error(`Failed to fetch savings: ${res.status}`);
|
|
return res.json();
|
|
}
|
|
|
|
export async function fetchServerInfo(): Promise<ServerInfo> {
|
|
const res = await fetch(`${BASE}/v1/info`);
|
|
if (!res.ok) throw new Error(`Failed to fetch server info: ${res.status}`);
|
|
return res.json();
|
|
}
|