UNPKG

@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

62 lines • 2.22 kB
/** * Shared CLI formatting utilities * * Common formatting functions used across CLI command modules. */ import chalk from "chalk"; /** * Format a table row with padding */ export function formatRow(label, value, width = 30) { const paddedLabel = label.padEnd(width); return `${paddedLabel} ${value}`; } /** * Format the status rows of the registered exporters */ export function formatExporterLines(exporters) { if (exporters.length === 0) { return [" None registered"]; } return exporters.flatMap((exporter) => { const state = !exporter.enabled ? "Stopped" : exporter.healthy ? "Active" : "Failing"; const counts = `pending ${exporter.pendingSpans}, delivered ${exporter.deliveredSpans}, failed ${exporter.failedSpans}`; return [ formatRow(` ${exporter.name}:`, `${state} (${counts})`), ...(exporter.lastExportTime ? [formatRow(" Last export:", exporter.lastExportTime)] : []), ...(exporter.errors ?? []).map((error) => formatRow(" Error:", error)), ]; }); } /** * @description Labels NeuroLink's OpenTelemetry export for the status commands. Beside a host TracerProvider NeuroLink exports nothing to the endpoint, so it is shown as ignored rather than active. * @param otel {{ enabled: boolean; endpoint?: string; usingExternalProvider?: boolean }} - `getTelemetryStatus().openTelemetry`. * @param on {string} - Label for an export NeuroLink runs. * @param off {string} - Label for no export. * @returns {string} The coloured label. */ export function formatOtelStatus(otel, on, off) { if (otel.usingExternalProvider) { return chalk.yellow(otel.endpoint ? "Ignored (a host TracerProvider is registered)" : "Host TracerProvider"); } return otel.enabled ? chalk.green(on) : chalk.gray(off); } /** * Format currency value */ export function formatCost(cost, currency = "USD") { return new Intl.NumberFormat("en-US", { style: "currency", currency, minimumFractionDigits: 4, }).format(cost); } //# sourceMappingURL=formatters.js.map