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

34 lines (33 loc) • 2.59 kB
import type { LangfuseAttributePolicy, OtlpEncodedSpan, OtlpKeyValue, OtlpSpan, OtlpTraceRequest, SpanAttributes, SpanData } from "../types/index.js"; /** * @description Encodes attributes as OTLP/JSON key-values, dropping `undefined` and `null` entries. * @param attributes {SpanAttributes} - Attribute record to encode. * @returns {OtlpKeyValue[]} One typed key-value per kept attribute. */ export declare function toOtlpAttributes(attributes: SpanAttributes): OtlpKeyValue[]; /** * @description Encodes one span as OTLP/JSON, applying the exporter's attribute policy to its attributes (its events and status message are sent as they are), leaving GenAI model and usage keys off a plain span or event observation, and keeping the span's links and nanosecond times. Every span is sent as kind INTERNAL, as Langfuse has always received it. * @param span {SpanData} - Span to encode. * @param policy {LangfuseAttributePolicy} - Environment, release, redaction and mask settings. * @returns {OtlpSpan} The span in the shape Langfuse's ingestion endpoint reads. */ export declare function toOtlpSpan(span: SpanData, policy: LangfuseAttributePolicy): OtlpSpan; /** * @description Encodes a span together with the resource it was produced under, falling back to a generic service name for a span that carries none, and the instrumentation scope `sdk` that the Langfuse request has always named. * @param span {SpanData} - Span to encode. * @param policy {LangfuseAttributePolicy} - Environment, release, redaction and mask settings. * @returns {OtlpEncodedSpan} The encoded span with its resource and scope. */ export declare function toOtlpEncodedSpan(span: SpanData, policy: LangfuseAttributePolicy): OtlpEncodedSpan; /** * @description Builds an OTLP/JSON export request, grouping spans under the resource and instrumentation scope they were produced under. * @param items {OtlpEncodedSpan[]} - Encoded spans, in export order. * @returns {OtlpTraceRequest} The request body, with one `resourceSpans` entry per distinct resource and one `scopeSpans` entry per distinct scope within it. */ export declare function toOtlpRequest(items: OtlpEncodedSpan[]): OtlpTraceRequest; /** * @description Splits encoded spans into request-sized batches, bounded by span count and serialized bytes. * @param items {OtlpEncodedSpan[]} - Encoded spans, in export order. * @returns {OtlpEncodedSpan[][]} Batches that each fit one export request; a single oversized span still gets its own batch. */ export declare function chunkOtlpSpans(items: OtlpEncodedSpan[]): OtlpEncodedSpan[][];