@juspay/neurolink
Version:
The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002
38 lines (37 loc) • 1.24 kB
TypeScript
/**
* Analytics utility functions for TokenUsage and AnalyticsData
* Provides helper functions to avoid manual field access patterns
*/
import type { TokenUsage, AnalyticsData } from "../types/index.js";
/**
* Format token usage as a human-readable string
*/
export declare function formatTokenUsage(usage: TokenUsage): string;
/**
* Calculate cost based on token usage and cost per token
*/
export declare function calculateTokenCost(usage: TokenUsage, costPerToken: number): number;
/**
* Combine multiple token usage objects into a single total
*/
export declare function combineTokenUsage(usages: TokenUsage[]): TokenUsage;
/**
* Format analytics data for display
*/
export declare function formatAnalyticsForDisplay(analytics: AnalyticsData): string;
/**
* Check if analytics data contains valid token usage
*/
export declare function hasValidTokenUsage(analytics: AnalyticsData): boolean;
/**
* Extract summary metrics from analytics data
*/
export declare function getAnalyticsSummary(analytics: AnalyticsData): {
totalTokens: number;
costPerToken: number | null;
requestsPerSecond: number;
};
/**
* Type guard for token usage
*/
export declare function isTokenUsage(value: unknown): value is TokenUsage;