feat: add ModelUsageEntry types and status API client functions
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -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 };
|
||||
|
||||
@@ -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<SystemStats> {
|
||||
return fetchAPI<SystemStats>('/status/stats');
|
||||
@@ -12,4 +12,14 @@ export async function getSystemHealth(): Promise<SystemHealth> {
|
||||
return fetchAPI<SystemHealth>('/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<ModelUsageResponse> {
|
||||
return fetchAPI<ModelUsageResponse>('/status/models');
|
||||
}
|
||||
|
||||
/** Active check: sends one minimal request to each enabled model, then returns fresh statuses. */
|
||||
export async function pingModelConnections(): Promise<ModelUsageResponse> {
|
||||
return fetchAPI<ModelUsageResponse>('/status/models/ping', { method: 'POST' });
|
||||
}
|
||||
|
||||
export type { ModelUsageResponse, SystemConfig, SystemHealth, SystemStats };
|
||||
|
||||
Reference in New Issue
Block a user