40 lines
904 B
TypeScript
40 lines
904 B
TypeScript
import { serverRequest } from "./serverConnection";
|
|
|
|
export interface ProviderHealthEntry {
|
|
status: string;
|
|
lastCheck: string | null;
|
|
lastError: string | null;
|
|
details: Record<string, unknown> | null;
|
|
}
|
|
|
|
export interface CallStatRow {
|
|
provider: string;
|
|
model: string;
|
|
status: string;
|
|
count: string;
|
|
avg_ms: string | null;
|
|
total_cost: string | null;
|
|
}
|
|
|
|
export interface KeyStatRow {
|
|
provider: string;
|
|
total_keys: string;
|
|
active_keys: string;
|
|
current_load: string;
|
|
}
|
|
|
|
export interface ProviderHealthResponse {
|
|
health: Record<string, ProviderHealthEntry>;
|
|
callStats: CallStatRow[];
|
|
keyStats: KeyStatRow[];
|
|
checkedAt: string;
|
|
}
|
|
|
|
export const providerHealthClient = {
|
|
async getStatus(): Promise<ProviderHealthResponse> {
|
|
return serverRequest<ProviderHealthResponse>("admin/providers/status", {
|
|
fallbackMessage: "Provider health request failed",
|
|
});
|
|
},
|
|
};
|