diff --git a/frontend/src/api/index.ts b/frontend/src/api/index.ts index d7bdfd3..40205cf 100644 --- a/frontend/src/api/index.ts +++ b/frontend/src/api/index.ts @@ -294,4 +294,27 @@ export interface SystemHealth { sessions: { active: number; max: number }; } +export type ModelRole = 'main_llm' | 'hyde_llm' | 'embedding' | 'reranker'; +export type ModelStatus = 'ok' | 'error' | 'never_called' | 'disabled'; + +export interface ModelUsageEntry { + role: ModelRole; + role_label: string; + provider: string; + model: string; + enabled: boolean; + status: ModelStatus; + total_tokens: number; + call_count_ok: number; + call_count_error: number; + last_called_at: string | null; + last_latency_ms: number | null; + last_error: string | null; + shares_usage_with: ModelRole | null; +} + +export interface ModelUsageResponse { + models: ModelUsageEntry[]; +} + export { API_BASE_URL }; diff --git a/frontend/src/api/status.ts b/frontend/src/api/status.ts index d81026a..dda28e7 100644 --- a/frontend/src/api/status.ts +++ b/frontend/src/api/status.ts @@ -1,4 +1,4 @@ -import { fetchAPI, type SystemConfig, type SystemHealth, type SystemStats } from './index'; +import { fetchAPI, type ModelUsageResponse, type SystemConfig, type SystemHealth, type SystemStats } from './index'; export async function getSystemStats(): Promise { return fetchAPI('/status/stats'); @@ -12,4 +12,14 @@ export async function getSystemHealth(): Promise { return fetchAPI('/status/health'); } -export type { SystemConfig, SystemHealth, SystemStats }; +/** Passive read: current connection status + cumulative token usage for all 4 AI model roles. */ +export async function getModelUsage(): Promise { + return fetchAPI('/status/models'); +} + +/** Active check: sends one minimal request to each enabled model, then returns fresh statuses. */ +export async function pingModelConnections(): Promise { + return fetchAPI('/status/models/ping', { method: 'POST' }); +} + +export type { ModelUsageResponse, SystemConfig, SystemHealth, SystemStats };