UNPKG

@ai2070/l0

Version:

L0: The Missing Reliability Substrate for AI

57 lines 1.4 kB
export class Metrics { requests = 0; tokens = 0; retries = 0; networkRetryCount = 0; errors = 0; violations = 0; driftDetections = 0; fallbacks = 0; completions = 0; timeouts = 0; reset() { this.requests = 0; this.tokens = 0; this.retries = 0; this.networkRetryCount = 0; this.errors = 0; this.violations = 0; this.driftDetections = 0; this.fallbacks = 0; this.completions = 0; this.timeouts = 0; } snapshot() { return { requests: this.requests, tokens: this.tokens, retries: this.retries, networkRetryCount: this.networkRetryCount, errors: this.errors, violations: this.violations, driftDetections: this.driftDetections, fallbacks: this.fallbacks, completions: this.completions, timeouts: this.timeouts, }; } toJSON() { return this.snapshot(); } } export function createMetrics() { return new Metrics(); } let globalMetrics = null; export function getGlobalMetrics() { if (!globalMetrics) { globalMetrics = new Metrics(); } return globalMetrics; } export function resetGlobalMetrics() { if (globalMetrics) { globalMetrics.reset(); } } //# sourceMappingURL=metrics.js.map