@juspay/neurolink 13.13.6 → 13.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -3
- package/dist/browser/neurolink.min.js +604 -604
- package/dist/constants/langfuse.d.ts +8 -0
- package/dist/constants/langfuse.js +12 -0
- package/dist/constants/telemetry.d.ts +2 -0
- package/dist/constants/telemetry.js +2 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/neurolink.d.ts +1 -0
- package/dist/neurolink.js +31 -14
- package/dist/providers/systemOneDecision.js +12 -4
- package/dist/services/server/ai/observability/instrumentation.d.ts +13 -3
- package/dist/services/server/ai/observability/instrumentation.js +129 -9
- package/dist/types/observability.d.ts +36 -0
- package/docs-site/static/search-index.json +1 -0
- package/package.json +1 -1
|
@@ -5,6 +5,14 @@ export declare const TRACES_PATH = "/api/public/otel/v1/traces";
|
|
|
5
5
|
export declare const HEALTH_PATH = "/api/public/health";
|
|
6
6
|
/** @description Langfuse Cloud base URL used when none is configured. */
|
|
7
7
|
export declare const DEFAULT_BASE_URL = "https://cloud.langfuse.com";
|
|
8
|
+
/** @description Milliseconds a fetched Langfuse prompt is served from the cache before it is refreshed in the background. */
|
|
9
|
+
export declare const DEFAULT_PROMPT_CACHE_TTL_MS = 60000;
|
|
10
|
+
/** @description Milliseconds a Langfuse prompt fetch waits before the fallback is used. */
|
|
11
|
+
export declare const DEFAULT_PROMPT_TIMEOUT_MS = 2000;
|
|
12
|
+
/** @description Prompt cache entries kept per process; the least recently fetched is evicted beyond it. */
|
|
13
|
+
export declare const MAX_CACHED_PROMPTS = 500;
|
|
14
|
+
/** @description Trace metadata keys `setLangfuseContext` writes for a prompt; an inner prompt drops the inherited ones. */
|
|
15
|
+
export declare const PROMPT_METADATA_KEYS: Set<string>;
|
|
8
16
|
/** @description Spans buffered before an automatic flush. */
|
|
9
17
|
export declare const DEFAULT_FLUSH_AT = 15;
|
|
10
18
|
/** @description Milliseconds between scheduled flushes. */
|
|
@@ -5,6 +5,18 @@ export const TRACES_PATH = "/api/public/otel/v1/traces";
|
|
|
5
5
|
export const HEALTH_PATH = "/api/public/health";
|
|
6
6
|
/** @description Langfuse Cloud base URL used when none is configured. */
|
|
7
7
|
export const DEFAULT_BASE_URL = "https://cloud.langfuse.com";
|
|
8
|
+
/** @description Milliseconds a fetched Langfuse prompt is served from the cache before it is refreshed in the background. */
|
|
9
|
+
export const DEFAULT_PROMPT_CACHE_TTL_MS = 60_000;
|
|
10
|
+
/** @description Milliseconds a Langfuse prompt fetch waits before the fallback is used. */
|
|
11
|
+
export const DEFAULT_PROMPT_TIMEOUT_MS = 2_000;
|
|
12
|
+
/** @description Prompt cache entries kept per process; the least recently fetched is evicted beyond it. */
|
|
13
|
+
export const MAX_CACHED_PROMPTS = 500;
|
|
14
|
+
/** @description Trace metadata keys `setLangfuseContext` writes for a prompt; an inner prompt drops the inherited ones. */
|
|
15
|
+
export const PROMPT_METADATA_KEYS = new Set([
|
|
16
|
+
"promptName",
|
|
17
|
+
"promptVersion",
|
|
18
|
+
"promptLabel",
|
|
19
|
+
]);
|
|
8
20
|
/** @description Spans buffered before an automatic flush. */
|
|
9
21
|
export const DEFAULT_FLUSH_AT = 15;
|
|
10
22
|
/** @description Milliseconds between scheduled flushes. */
|
|
@@ -14,6 +14,8 @@ export declare const WARNING_FINISH_REASONS: Set<string>;
|
|
|
14
14
|
export declare const TRUNCATION_NOTE_ALLOWANCE_CHARS = 48;
|
|
15
15
|
/** @description Name of the OpenTelemetry context key that carries a trace's full metadata. */
|
|
16
16
|
export declare const TRACE_METADATA_CONTEXT_KEY = "neurolink.trace.metadata";
|
|
17
|
+
/** @description Name of the OpenTelemetry context key that carries the trace tag of the prompt `setLangfuseContext` was last given. */
|
|
18
|
+
export declare const PROMPT_TAG_CONTEXT_KEY = "neurolink.trace.promptTag";
|
|
17
19
|
/** @description Log prefix for NeuroLink's OpenTelemetry setup. */
|
|
18
20
|
export declare const OTEL_LOG_PREFIX = "[OpenTelemetry]";
|
|
19
21
|
/** @description Most open and most ended spans the exporter span processor remembers for re-parenting; the oldest are forgotten first. */
|
|
@@ -28,6 +28,8 @@ export const WARNING_FINISH_REASONS = new Set([
|
|
|
28
28
|
export const TRUNCATION_NOTE_ALLOWANCE_CHARS = 48;
|
|
29
29
|
/** @description Name of the OpenTelemetry context key that carries a trace's full metadata. */
|
|
30
30
|
export const TRACE_METADATA_CONTEXT_KEY = "neurolink.trace.metadata";
|
|
31
|
+
/** @description Name of the OpenTelemetry context key that carries the trace tag of the prompt `setLangfuseContext` was last given. */
|
|
32
|
+
export const PROMPT_TAG_CONTEXT_KEY = "neurolink.trace.promptTag";
|
|
31
33
|
/** @description Log prefix for NeuroLink's OpenTelemetry setup. */
|
|
32
34
|
export const OTEL_LOG_PREFIX = "[OpenTelemetry]";
|
|
33
35
|
/** @description Most open and most ended spans the exporter span processor remembers for re-parenting; the oldest are forgotten first. */
|
package/dist/index.d.ts
CHANGED
|
@@ -85,8 +85,8 @@ export { HITLManager } from "./hitl/hitlManager.js";
|
|
|
85
85
|
export { ProviderRegistry } from "./factories/providerRegistry.js";
|
|
86
86
|
import { NeuroLink } from "./neurolink.js";
|
|
87
87
|
export { NeuroLink };
|
|
88
|
-
import { ensureTelemetry, flushOpenTelemetry, getLangfuseHealthStatus, isOpenTelemetryInitialized, setLangfuseContext, shutdownOpenTelemetry } from "./services/server/ai/observability/instrumentation.js";
|
|
89
|
-
export { ensureTelemetry, shutdownOpenTelemetry, flushOpenTelemetry, getLangfuseHealthStatus, setLangfuseContext, isOpenTelemetryInitialized, };
|
|
88
|
+
import { ensureTelemetry, flushOpenTelemetry, getLangfuseHealthStatus, getLangfusePrompt, isOpenTelemetryInitialized, setLangfuseContext, shutdownOpenTelemetry } from "./services/server/ai/observability/instrumentation.js";
|
|
89
|
+
export { ensureTelemetry, shutdownOpenTelemetry, flushOpenTelemetry, getLangfuseHealthStatus, getLangfusePrompt, setLangfuseContext, isOpenTelemetryInitialized, };
|
|
90
90
|
export { clearAnalyticsMetrics, createAnalyticsMiddleware, getAnalyticsMetrics, } from "./middleware/builtin/analytics.js";
|
|
91
91
|
export { createLifecycleMiddleware } from "./middleware/builtin/lifecycle.js";
|
|
92
92
|
export { MiddlewareFactory } from "./middleware/factory.js";
|
package/dist/index.js
CHANGED
|
@@ -174,8 +174,8 @@ export { ProviderRegistry } from "./factories/providerRegistry.js";
|
|
|
174
174
|
import { NeuroLink } from "./neurolink.js";
|
|
175
175
|
export { NeuroLink };
|
|
176
176
|
// Observability configuration types
|
|
177
|
-
import { ensureTelemetry, flushOpenTelemetry, getLangfuseHealthStatus, isOpenTelemetryInitialized, setLangfuseContext, shutdownOpenTelemetry, } from "./services/server/ai/observability/instrumentation.js";
|
|
178
|
-
export { ensureTelemetry, shutdownOpenTelemetry, flushOpenTelemetry, getLangfuseHealthStatus, setLangfuseContext, isOpenTelemetryInitialized, };
|
|
177
|
+
import { ensureTelemetry, flushOpenTelemetry, getLangfuseHealthStatus, getLangfusePrompt, isOpenTelemetryInitialized, setLangfuseContext, shutdownOpenTelemetry, } from "./services/server/ai/observability/instrumentation.js";
|
|
178
|
+
export { ensureTelemetry, shutdownOpenTelemetry, flushOpenTelemetry, getLangfuseHealthStatus, getLangfusePrompt, setLangfuseContext, isOpenTelemetryInitialized, };
|
|
179
179
|
// Analytics Middleware exports
|
|
180
180
|
export { clearAnalyticsMetrics, createAnalyticsMiddleware, getAnalyticsMetrics, } from "./middleware/builtin/analytics.js";
|
|
181
181
|
export { createLifecycleMiddleware } from "./middleware/builtin/lifecycle.js";
|
package/dist/neurolink.d.ts
CHANGED
|
@@ -2937,6 +2937,7 @@ export declare class NeuroLink {
|
|
|
2937
2937
|
* on the request.
|
|
2938
2938
|
*/
|
|
2939
2939
|
private siteDecide;
|
|
2940
|
+
private siteDecideLinked;
|
|
2940
2941
|
/**
|
|
2941
2942
|
* `decide()` proper. A request stamped with a site — every built-in
|
|
2942
2943
|
* consumer's, and a host-wired consumer's — adds `decision.site` and
|
package/dist/neurolink.js
CHANGED
|
@@ -137,7 +137,7 @@ import { BinaryTaskClassifier } from "./utils/taskClassifier.js";
|
|
|
137
137
|
// Transformation utilities
|
|
138
138
|
import { extractToolNames, optimizeToolForCollection, transformAvailableTools, transformParamsForLogging, transformToolExecutionsForMCP, transformToolsForMCP, transformToolsToDescriptions, transformToolsToExpectedFormat, } from "./utils/transformationUtils.js";
|
|
139
139
|
import { toToolExecutionRecords } from "./core/toolExecutionRecorder.js";
|
|
140
|
-
import { isNonNullObject } from "./utils/typeUtils.js";
|
|
140
|
+
import { isNonNullObject, isObject } from "./utils/typeUtils.js";
|
|
141
141
|
import { getWorkflow } from "./workflow/core/workflowRegistry.js";
|
|
142
142
|
import { runWorkflow } from "./workflow/core/workflowRunner.js";
|
|
143
143
|
import { ModelPool, classifyProviderError } from "./routing/index.js";
|
|
@@ -891,6 +891,11 @@ export class NeuroLink {
|
|
|
891
891
|
const ctx = options.context;
|
|
892
892
|
const outer = getPropagatedAttributesFromContext(context.active());
|
|
893
893
|
const unset = (key, value) => typeof value === "string" && !outer[key] ? value : undefined;
|
|
894
|
+
const isPromptRef = (value) => isObject(value) &&
|
|
895
|
+
typeof value.name === "string" &&
|
|
896
|
+
Number.isInteger(value.version ?? 0) &&
|
|
897
|
+
typeof (value.label ?? "") === "string" &&
|
|
898
|
+
typeof (value.isFallback ?? false) === "boolean";
|
|
894
899
|
return await setLangfuseContext({
|
|
895
900
|
userId: unset(LangfuseOtelSpanAttributes.TRACE_USER_ID, ctx.userId),
|
|
896
901
|
sessionId: unset(LangfuseOtelSpanAttributes.TRACE_SESSION_ID, ctx.sessionId),
|
|
@@ -905,6 +910,7 @@ export class NeuroLink {
|
|
|
905
910
|
metadata: ctx.metadata && typeof ctx.metadata === "object"
|
|
906
911
|
? ctx.metadata
|
|
907
912
|
: undefined,
|
|
913
|
+
...(isPromptRef(ctx.prompt) && { prompt: ctx.prompt }),
|
|
908
914
|
}, callback);
|
|
909
915
|
}
|
|
910
916
|
createMetricsTraceContext() {
|
|
@@ -14896,14 +14902,23 @@ Current user's request: ${currentInput}`;
|
|
|
14896
14902
|
* on the request.
|
|
14897
14903
|
*/
|
|
14898
14904
|
async siteDecide(request, outer) {
|
|
14905
|
+
// Either cancellation must win: the outer call's abort and the site's own
|
|
14906
|
+
// deadline are independent limits. Scoped, not AbortSignal.any: a source
|
|
14907
|
+
// holds its `any` dependant only weakly, so a decision its caller stopped
|
|
14908
|
+
// awaiting could lose the link and never see the abort.
|
|
14909
|
+
const linked = composeAbortSignalsScoped(outer?.signal, request.signal);
|
|
14910
|
+
try {
|
|
14911
|
+
return await this.siteDecideLinked(request, outer, linked.signal);
|
|
14912
|
+
}
|
|
14913
|
+
finally {
|
|
14914
|
+
linked.dispose();
|
|
14915
|
+
}
|
|
14916
|
+
}
|
|
14917
|
+
async siteDecideLinked(request, outer, signal) {
|
|
14899
14918
|
const merged = {
|
|
14900
14919
|
...request,
|
|
14901
14920
|
credentials: outer?.credentials ?? request.credentials,
|
|
14902
|
-
|
|
14903
|
-
// own deadline are independent limits.
|
|
14904
|
-
signal: outer?.signal && request.signal
|
|
14905
|
-
? AbortSignal.any([outer.signal, request.signal])
|
|
14906
|
-
: (outer?.signal ?? request.signal),
|
|
14921
|
+
signal,
|
|
14907
14922
|
sessionId: outer?.sessionId ?? request.sessionId,
|
|
14908
14923
|
requestId: outer?.requestId ?? request.requestId,
|
|
14909
14924
|
};
|
|
@@ -14915,14 +14930,16 @@ Current user's request: ${currentInput}`;
|
|
|
14915
14930
|
providerDeadline = AbortSignal.timeout(outer.providerTimeoutMs);
|
|
14916
14931
|
outer.onProviderDeadline?.(providerDeadline);
|
|
14917
14932
|
}
|
|
14918
|
-
const
|
|
14919
|
-
|
|
14920
|
-
|
|
14921
|
-
|
|
14922
|
-
|
|
14923
|
-
|
|
14924
|
-
|
|
14925
|
-
|
|
14933
|
+
const wireSignal = composeAbortSignalsScoped(wireRequest.signal, providerDeadline);
|
|
14934
|
+
let wireResult;
|
|
14935
|
+
try {
|
|
14936
|
+
wireResult = await this.tryRunDecide(providerDeadline
|
|
14937
|
+
? { ...wireRequest, signal: wireSignal.signal }
|
|
14938
|
+
: wireRequest);
|
|
14939
|
+
}
|
|
14940
|
+
finally {
|
|
14941
|
+
wireSignal.dispose();
|
|
14942
|
+
}
|
|
14926
14943
|
outer?.onProviderReturned?.();
|
|
14927
14944
|
return wireResult;
|
|
14928
14945
|
};
|
|
@@ -6,6 +6,7 @@ import { ProviderError } from "../types/index.js";
|
|
|
6
6
|
import { prepareDecisionMedia } from "../utils/decisionMedia.js";
|
|
7
7
|
import { logger } from "../utils/logger.js";
|
|
8
8
|
import { redactUrlsInText } from "../utils/logSanitize.js";
|
|
9
|
+
import { composeAbortSignalsScoped } from "../utils/timeout.js";
|
|
9
10
|
import { estimateDecisionStateTokens, resolveDecisionLimitsReading, unsupportedDecisionQuestion, } from "../utils/decisionLimits.js";
|
|
10
11
|
import { systemOneDialect } from "./decide/dialects/systemOne.js";
|
|
11
12
|
import { asNumber, isRecord } from "./decide/guards.js";
|
|
@@ -297,11 +298,15 @@ export class SystemOneDecisionProvider extends BaseProvider {
|
|
|
297
298
|
let lastError;
|
|
298
299
|
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
|
|
299
300
|
const startedAt = Date.now();
|
|
301
|
+
const timeout = AbortSignal.timeout(timeoutMs);
|
|
302
|
+
// Scoped, not AbortSignal.any: a source holds its `any` dependant only
|
|
303
|
+
// weakly, so once a caller stopped awaiting this call (tool routing's
|
|
304
|
+
// deadline race) the composed signal could be collected with the
|
|
305
|
+
// stalled body read; the caller's deadline then never reached fetch and
|
|
306
|
+
// the call never settled. Plain listeners keep the link strong.
|
|
307
|
+
const { signal: composed, dispose: disposeSignal } = composeAbortSignalsScoped(request.signal, timeout);
|
|
308
|
+
const signal = composed ?? timeout;
|
|
300
309
|
try {
|
|
301
|
-
const timeout = AbortSignal.timeout(timeoutMs);
|
|
302
|
-
const signal = request.signal
|
|
303
|
-
? AbortSignal.any([request.signal, timeout])
|
|
304
|
-
: timeout;
|
|
305
310
|
const response = await this.proxyFetch(this.decisionEndpoint(resolvedModel), {
|
|
306
311
|
method: "POST",
|
|
307
312
|
headers: this.decisionHeaders(),
|
|
@@ -444,6 +449,9 @@ export class SystemOneDecisionProvider extends BaseProvider {
|
|
|
444
449
|
});
|
|
445
450
|
}
|
|
446
451
|
}
|
|
452
|
+
finally {
|
|
453
|
+
disposeSignal();
|
|
454
|
+
}
|
|
447
455
|
}
|
|
448
456
|
throw this.decisionError(lastError ?? {
|
|
449
457
|
kind: "network",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Context } from "@opentelemetry/api";
|
|
2
|
-
import type { NeurolinkTraceContext, ObservabilityConfig, SpanContent } from "../../../../types/index.js";
|
|
2
|
+
import type { LangfusePrompt, LangfusePromptOptions, NeurolinkTraceContext, ObservabilityConfig, SpanContent } from "../../../../types/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* @description Starts NeuroLink's tracing once per process, synchronously. Every span created through the shared tracers calls it first once this module is loaded, as the main, server and livekit entries do, so direct provider calls without a NeuroLink instance are traced too. Langfuse is enabled unless `config.langfuse` is `false` or has `enabled: false`, when `config.langfuse` is `true` or an options object, or when `LANGFUSE_PUBLIC_KEY` and `LANGFUSE_SECRET_KEY` are set and `LANGFUSE_ENABLED` is not `false`, `0`, `off` or `no`; an OTLP exporter is added when `OTEL_EXPORTER_OTLP_ENDPOINT` is set. When the host already registered a TracerProvider no provider is created and `OTEL_EXPORTER_OTLP_ENDPOINT` is ignored with a warning; the Langfuse exporter, if configured, is registered on the shared exporter registry and the host adds `createExporterSpanProcessor()` to its provider. The first call that finds tracing configured decides the setup and a later `config` is ignored, with a warning naming the options that differ from the first when it does differ; calls made before anything is configured start nothing, so a later config or environment can still start tracing, unless `langfuse: false` was passed. Langfuse enabled without both keys (in config or the environment) exports nothing to Langfuse, and a warning says so once. With `langfuse: true` or the environment alone that counts as not configured, so only an OTLP endpoint starts tracing; an options object starts tracing anyway, as it always did, so exporters registered on the shared registry receive the spans. Pending spans and metrics are flushed when the process runs out of work (`beforeExit`), within the same budget as `flushOpenTelemetry`, which an explicit `process.exit()` skips; `NEUROLINK_TELEMETRY_EXIT_FLUSH` set to `false`, `0`, `off` or `no` skips that flush too, and the process ends as soon as it has no work. After `shutdownOpenTelemetry` it does nothing.
|
|
5
5
|
* @param config {ObservabilityConfig | undefined} - Observability options, honoured only when this is the first call.
|
|
@@ -53,11 +53,21 @@ export declare function getLangfuseHealthStatus(): {
|
|
|
53
53
|
*/
|
|
54
54
|
export declare function traceMetadataFromContext(ctx: Context): Record<string, SpanContent>;
|
|
55
55
|
/**
|
|
56
|
-
* @description Runs `fn` with trace attributes propagated to every span it creates. `conversationId` and `requestId` become metadata; empty values are dropped. Metadata values of up to 200 characters once stringified are on every observation; longer values and arrays are recorded in full on the trace only, written by the trace root.
|
|
57
|
-
* @param params {NeurolinkTraceContext} - User, session, trace name, tags and
|
|
56
|
+
* @description Runs `fn` with trace attributes propagated to every span it creates. `conversationId` and `requestId` become metadata; empty values are dropped. `prompt` adds the trace tag `prompt:<name>@<version>` (`@fallback` for a fallback, no suffix without a version) and `promptName`, `promptVersion` and `promptLabel` metadata, and links generations to the prompt version unless it is a fallback; it replaces an enclosing prompt's tag, metadata and link. Metadata values of up to 200 characters once stringified are on every observation; longer values and arrays are recorded in full on the trace only, written by the trace root.
|
|
57
|
+
* @param params {NeurolinkTraceContext} - User, session, trace name, tags, metadata and prompt for the trace.
|
|
58
58
|
* @param fn {() => T} - Work to run inside the propagated context.
|
|
59
59
|
* @returns {T} Whatever `fn` returns.
|
|
60
60
|
* @example
|
|
61
61
|
* await setLangfuseContext({ userId: "u1", sessionId: "s1" }, () => neurolink.generate({ input: { text: "hi" } }));
|
|
62
62
|
*/
|
|
63
63
|
export declare function setLangfuseContext<T>(params: NeurolinkTraceContext, fn: () => T): T;
|
|
64
|
+
/**
|
|
65
|
+
* @description Fetches a text prompt from Langfuse with the keys and host NeuroLink's tracing was started with, falling back to `LANGFUSE_PUBLIC_KEY`, `LANGFUSE_SECRET_KEY` and `LANGFUSE_BASE_URL`. Prompts are cached per project, host, name and label: within `cacheTtlMs` no request is made, and an expired entry is returned at once while one background request refreshes it. Concurrent callers share one request. Missing keys, an error, a timeout, a missing prompt or a chat prompt return the fallback, after a warning for all but missing keys; a failed request is not repeated within `cacheTtlMs`, and a prompt fetched before stays in use. `text` is returned as stored, with `{{variable}}` placeholders not filled in. The fetch ignores `langfuse: false` and `LANGFUSE_ENABLED`, so a caller with its own switch checks it first.
|
|
66
|
+
* @param name {string} - Prompt name in Langfuse.
|
|
67
|
+
* @param options {LangfusePromptOptions} - Label, fallback text, cache TTL and request timeout.
|
|
68
|
+
* @returns {Promise<LangfusePrompt>} The prompt, or `{ name, text: fallback, label, isFallback: true }`; never rejects.
|
|
69
|
+
* @example
|
|
70
|
+
* const prompt = await getLangfusePrompt("support-agent", { fallback: "You are a helpful agent." });
|
|
71
|
+
* await setLangfuseContext({ prompt }, () => neurolink.generate({ input: { text: "hi" }, systemPrompt: prompt.text }));
|
|
72
|
+
*/
|
|
73
|
+
export declare const getLangfusePrompt: (name: string, options: LangfusePromptOptions) => Promise<LangfusePrompt>;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { LangfuseAPIClient, LangfuseAPIError, LangfuseOtelContextKeys, } from "@langfuse/core";
|
|
1
2
|
import { propagateAttributes, setLangfuseTracerProvider, } from "@langfuse/tracing";
|
|
2
3
|
import { context, createContextKey, metrics, } from "@opentelemetry/api";
|
|
3
4
|
import { W3CTraceContextPropagator } from "@opentelemetry/core";
|
|
4
5
|
import { resourceFromAttributes, } from "@opentelemetry/resources";
|
|
5
6
|
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
|
|
6
7
|
import { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION, } from "@opentelemetry/semantic-conventions";
|
|
7
|
-
import { DEFAULT_FLUSH_BUDGET_MS } from "../../../../constants/langfuse.js";
|
|
8
|
-
import { OTEL_LOG_PREFIX, TRACE_METADATA_CONTEXT_KEY, } from "../../../../constants/telemetry.js";
|
|
8
|
+
import { DEFAULT_BASE_URL, DEFAULT_FLUSH_BUDGET_MS, DEFAULT_PROMPT_CACHE_TTL_MS, DEFAULT_PROMPT_TIMEOUT_MS, MAX_CACHED_PROMPTS, PROMPT_METADATA_KEYS, } from "../../../../constants/langfuse.js";
|
|
9
|
+
import { OTEL_LOG_PREFIX, PROMPT_TAG_CONTEXT_KEY, TRACE_METADATA_CONTEXT_KEY, } from "../../../../constants/telemetry.js";
|
|
9
10
|
import { getExporterRegistry } from "../../../../observability/exporterRegistry.js";
|
|
10
11
|
import { ExporterSpanProcessor } from "../../../../observability/exporterSpanProcessor.js";
|
|
11
12
|
import { LangfuseExporter } from "../../../../observability/exporters/langfuseExporter.js";
|
|
@@ -17,6 +18,7 @@ import { createOtlpConnections, createOtlpMeterProvider, createOtlpSpanProcessor
|
|
|
17
18
|
const MAX_PROPAGATED_CHARS = 200;
|
|
18
19
|
const LANGFUSE_EXPORTER_NAME = "langfuse";
|
|
19
20
|
const TRACE_METADATA_KEY = createContextKey(TRACE_METADATA_CONTEXT_KEY);
|
|
21
|
+
const PROMPT_TAG_KEY = createContextKey(PROMPT_TAG_CONTEXT_KEY);
|
|
20
22
|
const CONTEXT_PROBE_KEY = createContextKey("neurolink.context-manager-probe");
|
|
21
23
|
// `false`, `0`, `off` or `no` skips the flush at process exit; the released build had none.
|
|
22
24
|
const EXIT_FLUSH_SWITCH = "NEUROLINK_TELEMETRY_EXIT_FLUSH";
|
|
@@ -40,6 +42,8 @@ let terminationLogged = false;
|
|
|
40
42
|
let unconfiguredLogged = false;
|
|
41
43
|
let missingKeysLogged = false;
|
|
42
44
|
let holders = 0;
|
|
45
|
+
const promptCache = new Map();
|
|
46
|
+
const promptRefreshes = new Map();
|
|
43
47
|
function differingConfigFields(first, later) {
|
|
44
48
|
const firstLangfuse = first?.langfuse;
|
|
45
49
|
const laterLangfuse = later.langfuse;
|
|
@@ -414,21 +418,56 @@ export function traceMetadataFromContext(ctx) {
|
|
|
414
418
|
? stored
|
|
415
419
|
: {};
|
|
416
420
|
}
|
|
421
|
+
const withoutPrompt = (metadata) => Object.fromEntries(Object.entries(metadata).filter(([key]) => !PROMPT_METADATA_KEYS.has(key)));
|
|
422
|
+
const promptScope = (active, prompt) => {
|
|
423
|
+
if (!prompt) {
|
|
424
|
+
return active;
|
|
425
|
+
}
|
|
426
|
+
const inherited = active.getValue(LangfuseOtelContextKeys.metadata);
|
|
427
|
+
const tags = active.getValue(LangfuseOtelContextKeys.tags);
|
|
428
|
+
const outerTag = active.getValue(PROMPT_TAG_KEY);
|
|
429
|
+
const cleared = active
|
|
430
|
+
.deleteValue(LangfuseOtelContextKeys.promptName)
|
|
431
|
+
.deleteValue(LangfuseOtelContextKeys.promptVersion)
|
|
432
|
+
.setValue(LangfuseOtelContextKeys.metadata, withoutPrompt(inherited && typeof inherited === "object" ? inherited : {}))
|
|
433
|
+
.setValue(TRACE_METADATA_KEY, withoutPrompt(traceMetadataFromContext(active)))
|
|
434
|
+
.setValue(LangfuseOtelContextKeys.tags, Array.isArray(tags) ? tags.filter((tag) => tag !== outerTag) : [])
|
|
435
|
+
.setValue(PROMPT_TAG_KEY, promptTagOf(prompt));
|
|
436
|
+
return !prompt.isFallback && Number.isInteger(prompt.version)
|
|
437
|
+
? cleared
|
|
438
|
+
.setValue(LangfuseOtelContextKeys.promptName, prompt.name)
|
|
439
|
+
.setValue(LangfuseOtelContextKeys.promptVersion, prompt.version)
|
|
440
|
+
: cleared;
|
|
441
|
+
};
|
|
442
|
+
const promptTagOf = ({ name, version, isFallback, }) => {
|
|
443
|
+
if (isFallback) {
|
|
444
|
+
return `prompt:${name}@fallback`;
|
|
445
|
+
}
|
|
446
|
+
return typeof version === "number"
|
|
447
|
+
? `prompt:${name}@${version}`
|
|
448
|
+
: `prompt:${name}`;
|
|
449
|
+
};
|
|
417
450
|
/**
|
|
418
|
-
* @description Runs `fn` with trace attributes propagated to every span it creates. `conversationId` and `requestId` become metadata; empty values are dropped. Metadata values of up to 200 characters once stringified are on every observation; longer values and arrays are recorded in full on the trace only, written by the trace root.
|
|
419
|
-
* @param params {NeurolinkTraceContext} - User, session, trace name, tags and
|
|
451
|
+
* @description Runs `fn` with trace attributes propagated to every span it creates. `conversationId` and `requestId` become metadata; empty values are dropped. `prompt` adds the trace tag `prompt:<name>@<version>` (`@fallback` for a fallback, no suffix without a version) and `promptName`, `promptVersion` and `promptLabel` metadata, and links generations to the prompt version unless it is a fallback; it replaces an enclosing prompt's tag, metadata and link. Metadata values of up to 200 characters once stringified are on every observation; longer values and arrays are recorded in full on the trace only, written by the trace root.
|
|
452
|
+
* @param params {NeurolinkTraceContext} - User, session, trace name, tags, metadata and prompt for the trace.
|
|
420
453
|
* @param fn {() => T} - Work to run inside the propagated context.
|
|
421
454
|
* @returns {T} Whatever `fn` returns.
|
|
422
455
|
* @example
|
|
423
456
|
* await setLangfuseContext({ userId: "u1", sessionId: "s1" }, () => neurolink.generate({ input: { text: "hi" } }));
|
|
424
457
|
*/
|
|
425
458
|
export function setLangfuseContext(params, fn) {
|
|
459
|
+
const { prompt } = params;
|
|
426
460
|
const full = {};
|
|
427
461
|
const propagated = {};
|
|
428
462
|
for (const [key, value] of Object.entries({
|
|
429
463
|
...params.metadata,
|
|
430
464
|
conversationId: params.conversationId,
|
|
431
465
|
requestId: params.requestId,
|
|
466
|
+
...(prompt && {
|
|
467
|
+
promptName: prompt.name,
|
|
468
|
+
promptVersion: prompt.version,
|
|
469
|
+
promptLabel: prompt.label,
|
|
470
|
+
}),
|
|
432
471
|
})) {
|
|
433
472
|
if (value === undefined || value === null || value === "") {
|
|
434
473
|
continue;
|
|
@@ -439,17 +478,98 @@ export function setLangfuseContext(params, fn) {
|
|
|
439
478
|
propagated[key] = text;
|
|
440
479
|
}
|
|
441
480
|
}
|
|
442
|
-
const tags =
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
481
|
+
const tags = [
|
|
482
|
+
...(params.tags ?? []),
|
|
483
|
+
...(prompt ? [promptTagOf(prompt)] : []),
|
|
484
|
+
].filter((tag) => tag.length > 0);
|
|
485
|
+
const scoped = promptScope(context.active(), prompt);
|
|
486
|
+
const withMetadata = scoped.setValue(TRACE_METADATA_KEY, {
|
|
487
|
+
...traceMetadataFromContext(scoped),
|
|
446
488
|
...full,
|
|
447
489
|
});
|
|
448
490
|
return context.with(withMetadata, () => propagateAttributes({
|
|
449
491
|
userId: params.userId || undefined,
|
|
450
492
|
sessionId: params.sessionId || undefined,
|
|
451
493
|
traceName: params.traceName || undefined,
|
|
452
|
-
...(tags
|
|
494
|
+
...(tags.length > 0 && { tags }),
|
|
453
495
|
...(Object.keys(propagated).length > 0 && { metadata: propagated }),
|
|
454
496
|
}, fn));
|
|
455
497
|
}
|
|
498
|
+
const cachePrompt = (key, cacheTtlMs, prompt) => {
|
|
499
|
+
promptCache.delete(key);
|
|
500
|
+
promptCache.set(key, { prompt, expiresAt: Date.now() + cacheTtlMs });
|
|
501
|
+
if (promptCache.size > MAX_CACHED_PROMPTS) {
|
|
502
|
+
const [oldest] = promptCache.keys();
|
|
503
|
+
promptCache.delete(oldest);
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
const refreshPrompt = async (key, client, name, { label, cacheTtlMs = DEFAULT_PROMPT_CACHE_TTL_MS, timeoutMs = DEFAULT_PROMPT_TIMEOUT_MS, }) => {
|
|
507
|
+
const previous = promptCache.get(key)?.prompt;
|
|
508
|
+
try {
|
|
509
|
+
const prompt = await client.prompts.get(name, { label }, {
|
|
510
|
+
abortSignal: AbortSignal.timeout(timeoutMs),
|
|
511
|
+
timeoutInSeconds: timeoutMs / 1000,
|
|
512
|
+
maxRetries: 0,
|
|
513
|
+
});
|
|
514
|
+
if (prompt.type === "text" &&
|
|
515
|
+
typeof prompt.prompt === "string" &&
|
|
516
|
+
Number.isInteger(prompt.version)) {
|
|
517
|
+
cachePrompt(key, cacheTtlMs, {
|
|
518
|
+
name,
|
|
519
|
+
text: prompt.prompt,
|
|
520
|
+
version: prompt.version,
|
|
521
|
+
label,
|
|
522
|
+
isFallback: false,
|
|
523
|
+
});
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
logger.warn(`${OTEL_LOG_PREFIX} Langfuse prompt "${name}" is not a text prompt; using the fallback`);
|
|
527
|
+
}
|
|
528
|
+
catch (error) {
|
|
529
|
+
logger.warn(`${OTEL_LOG_PREFIX} Could not fetch Langfuse prompt "${name}"; using the fallback`, error instanceof LangfuseAPIError && typeof error.statusCode === "number"
|
|
530
|
+
? { status: error.statusCode }
|
|
531
|
+
: { error: error instanceof Error ? error.message : String(error) });
|
|
532
|
+
}
|
|
533
|
+
cachePrompt(key, cacheTtlMs, previous);
|
|
534
|
+
};
|
|
535
|
+
/**
|
|
536
|
+
* @description Fetches a text prompt from Langfuse with the keys and host NeuroLink's tracing was started with, falling back to `LANGFUSE_PUBLIC_KEY`, `LANGFUSE_SECRET_KEY` and `LANGFUSE_BASE_URL`. Prompts are cached per project, host, name and label: within `cacheTtlMs` no request is made, and an expired entry is returned at once while one background request refreshes it. Concurrent callers share one request. Missing keys, an error, a timeout, a missing prompt or a chat prompt return the fallback, after a warning for all but missing keys; a failed request is not repeated within `cacheTtlMs`, and a prompt fetched before stays in use. `text` is returned as stored, with `{{variable}}` placeholders not filled in. The fetch ignores `langfuse: false` and `LANGFUSE_ENABLED`, so a caller with its own switch checks it first.
|
|
537
|
+
* @param name {string} - Prompt name in Langfuse.
|
|
538
|
+
* @param options {LangfusePromptOptions} - Label, fallback text, cache TTL and request timeout.
|
|
539
|
+
* @returns {Promise<LangfusePrompt>} The prompt, or `{ name, text: fallback, label, isFallback: true }`; never rejects.
|
|
540
|
+
* @example
|
|
541
|
+
* const prompt = await getLangfusePrompt("support-agent", { fallback: "You are a helpful agent." });
|
|
542
|
+
* await setLangfuseContext({ prompt }, () => neurolink.generate({ input: { text: "hi" }, systemPrompt: prompt.text }));
|
|
543
|
+
*/
|
|
544
|
+
export const getLangfusePrompt = async (name, options) => {
|
|
545
|
+
const fallback = {
|
|
546
|
+
name,
|
|
547
|
+
text: options.fallback,
|
|
548
|
+
label: options.label,
|
|
549
|
+
isFallback: true,
|
|
550
|
+
};
|
|
551
|
+
const langfuse = typeof startedConfig?.langfuse === "object" ? startedConfig.langfuse : {};
|
|
552
|
+
const publicKey = langfuse.publicKey ?? process.env.LANGFUSE_PUBLIC_KEY;
|
|
553
|
+
const secretKey = langfuse.secretKey ?? process.env.LANGFUSE_SECRET_KEY;
|
|
554
|
+
if (!publicKey || !secretKey) {
|
|
555
|
+
return fallback;
|
|
556
|
+
}
|
|
557
|
+
const host = langfuse.baseUrl || process.env.LANGFUSE_BASE_URL || DEFAULT_BASE_URL;
|
|
558
|
+
const key = JSON.stringify([publicKey, host, name, options.label]);
|
|
559
|
+
const cached = promptCache.get(key);
|
|
560
|
+
if (!cached || cached.expiresAt <= Date.now()) {
|
|
561
|
+
const refresh = promptRefreshes.get(key) ??
|
|
562
|
+
refreshPrompt(key, new LangfuseAPIClient({
|
|
563
|
+
environment: "",
|
|
564
|
+
baseUrl: host,
|
|
565
|
+
username: publicKey,
|
|
566
|
+
password: secretKey,
|
|
567
|
+
}), name, options).finally(() => promptRefreshes.delete(key));
|
|
568
|
+
promptRefreshes.set(key, refresh);
|
|
569
|
+
if (!cached) {
|
|
570
|
+
await refresh;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
const prompt = promptCache.get(key)?.prompt;
|
|
574
|
+
return prompt ? { ...prompt } : fallback;
|
|
575
|
+
};
|
|
@@ -110,6 +110,42 @@ export type NeurolinkTraceContext = {
|
|
|
110
110
|
metadata?: Record<string, SpanContent | undefined>;
|
|
111
111
|
/** Name of the root observation of this `generate` or `stream` call; not propagated to child observations and not the trace name. */
|
|
112
112
|
observationName?: string | null;
|
|
113
|
+
/** Langfuse prompt the call ran with, such as a `getLangfusePrompt` result; recorded as a `prompt:` trace tag and `promptName`, `promptVersion` and `promptLabel` metadata, replacing an enclosing prompt's tag and metadata. */
|
|
114
|
+
prompt?: LangfusePromptRef;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* @description A Langfuse prompt version a trace was produced with. Generations are linked to it when it has a `version` and is not a fallback.
|
|
118
|
+
*/
|
|
119
|
+
export type LangfusePromptRef = {
|
|
120
|
+
/** Prompt name in Langfuse. */
|
|
121
|
+
name: string;
|
|
122
|
+
/** Prompt version; generations are linked only when it is set. */
|
|
123
|
+
version?: number;
|
|
124
|
+
/** Deployment label the version was fetched by. */
|
|
125
|
+
label?: string;
|
|
126
|
+
/** Whether the prompt text is a local fallback rather than a Langfuse version. */
|
|
127
|
+
isFallback?: boolean;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* @description Options for `getLangfusePrompt`.
|
|
131
|
+
*/
|
|
132
|
+
export type LangfusePromptOptions = {
|
|
133
|
+
/** Deployment label to fetch; Langfuse serves `production` when omitted. */
|
|
134
|
+
label?: string;
|
|
135
|
+
/** Text returned when the prompt cannot be fetched as a text prompt. */
|
|
136
|
+
fallback: string;
|
|
137
|
+
/** Milliseconds before a cached prompt is refreshed in the background; defaults to 60000. The call that fetches an entry sets it for every caller of that name and label. */
|
|
138
|
+
cacheTtlMs?: number;
|
|
139
|
+
/** Milliseconds a fetch, body included, waits for Langfuse; defaults to 2000. */
|
|
140
|
+
timeoutMs?: number;
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* @description A text prompt resolved by `getLangfusePrompt`. `isFallback` is `true` when `text` is the caller's fallback, which carries no `version`.
|
|
144
|
+
*/
|
|
145
|
+
export type LangfusePrompt = LangfusePromptRef & {
|
|
146
|
+
/** Prompt text to send to the model. */
|
|
147
|
+
text: string;
|
|
148
|
+
isFallback: boolean;
|
|
113
149
|
};
|
|
114
150
|
/**
|
|
115
151
|
* Retry policy type for observability exporters.
|
|
@@ -3521,6 +3521,7 @@
|
|
|
3521
3521
|
{"objectID":"304f3b3f1d3d11c91945e49e4ae3f60d2b9a826b87a3948f18fd137a16b38c45","title":"Disable or override","url":"/docs/features/observability#disable-or-override","content":"Every field is optional. publicKey, secretKey, baseUrl, environment and release fall back to the variables above; the others have the defaults below. The type is NeurolinkLangfuseConfig.\n\n| Field | Meaning |\n| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| enabled | false turns Langfuse off although keys are set (from untyped config, the strings \"false\", \"0\", \"off\" and \"no\" do too); any other value, or leaving it out, leaves it on.","hierarchy":{"lvl0":"Features","lvl1":"Observability Guide","lvl2":"Disable or override","lvl3":""}},
|
|
3522
3522
|
{"objectID":"d5c2e109ca689299bbc1e1068341dfd6ba1294b1ee3c11cebe6489977865892e","title":"Per-call context","url":"/docs/features/observability#per-call-context","content":"Pass context on generate, stream and decide. The values are attached to every span the call creates, including tool calls and fallback attempts, so one call is one trace.\n\n| Field | Recorded as |\n| ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |\n| userId | Trace user |\n| sessionId | Trace session |\n| tags | Trace tags |\n| traceName | Trace name |\n| conversationId | Metadata key conversationId |\n| requestId | Metadata key requestId |\n| metadata | Metadata; values up to 200 characters are on every observation, longer values and arrays are recorded in full on the trace only |\n| observationName | Name of the root observation of this call; default generate or stream; not propagated to child observations or used as the trace name |","hierarchy":{"lvl0":"Features","lvl1":"Observability Guide","lvl2":"Per-call context","lvl3":""}},
|
|
3523
3523
|
{"objectID":"d262ba0787c1b57c76e303845fc9c6f447a3a2f747a880270f15c61fcc1863bb","title":"setLangfuseContext","url":"/docs/features/observability#setlangfusecontext","content":"Wrap your own code to attach the same attributes to everything inside it, including spans you create yourself.\n\nsetLangfuseContext(params: NeurolinkTraceContext, fn) returns whatever fn returns. It is a thin wrapper over Langfuse's propagateAttributes.","hierarchy":{"lvl0":"Features","lvl1":"Observability Guide","lvl2":"setLangfuseContext","lvl3":""}},
|
|
3524
|
+
{"objectID":"ebe52665a13e8e28856b65cd1d82bb2709538cb3fdd9b2ab6e54cd7061a8fb0d","title":"Langfuse prompts","url":"/docs/features/observability#langfuse-prompts","content":"getLangfusePrompt(name, options) fetches a text prompt from Langfuse Prompt Management with the keys and host tracing uses (observability.langfuse, then LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY, LANGFUSE_BASE_URL). Pass the result as prompt to setLangfuseContext and Langfuse links the generations inside to that prompt version.\n\n| Option | Default | Effect |\n| ------------ | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| label | production | Deployment label to fetch |\n| fallback | required | Text returned when the prompt cannot be fetched as a text prompt |\n| cacheTtlMs | 60000 | How long a prompt is served from the cache before it is refreshed in the background; the call that fetches an entry sets it for every caller of that name and label |\n| timeoutMs | 2000 | How long one fetch waits for Langfuse |\n\nIt never throws. Prompts are cached per project, host, name and label, up to 500 entries (the least recently fetched is dropped first), and each call gets its own copy; concurrent callers share one request, and an expired entry is returned at once while it refreshes.","hierarchy":{"lvl0":"Features","lvl1":"Observability Guide","lvl2":"Langfuse prompts","lvl3":""}},
|
|
3524
3525
|
{"objectID":"542eff7388511fe18f61b3de966dff32a0a0ccfa5c95df170298790e0233739d","title":"Naming","url":"/docs/features/observability#naming","content":"The observations below (generate, stream, decide, attempts, steps and tools) carry no product name in their span names, attribute keys or metadata keys. Names never carry per-execution values: the model and provider are fields, the step number is metadata. The product name remains in the plain spans listed under Other spans and in the proxy root's neurolink.user_id, neurolink.session_id and neurolink.conversation_id attributes.\n\n| Observation | Name | Langfuse type | Parent |\n| -------------------------- | ------------------------------------- | ------------- | ---------------------- |\n| generate / stream call | generate / stream | agent | none (trace root) |\n| Fallback attempt | generate.attempt / stream.attempt | span | root |\n| Agent loop step | step (step_index metadata) | span | the attempt span |\n| One model request | generate / stream | generation | its step |\n| Tool execution | the tool's name, e.g. get_weather | tool | the step that ran it |\n| decide | decide | generation | caller or root |\n\nA model request is named after the API the caller used (NeuroLink.generate or provider.generate gives generate, NeuroLink.stream or provider.stream gives stream). Its model is the observation's model field (the model the provider reported, falling back to the requested one) and the provider id is the provider metadata key.\n\nThe trace name is context.traceName when given, otherwise the operation name (generate, stream). An outer setLangfuseContext takes precedence over per-call context for user, session and trace name.\n\nEmbeddings, transcribe, TTS and media tracing are not yet recorded. The root also sets trace-level input and output; a generate or stream nested inside another turn does not.","hierarchy":{"lvl0":"Features","lvl1":"Observability Guide","lvl2":"Naming","lvl3":""}},
|
|
3525
3526
|
{"objectID":"bec7707961c02d5123e4dceed9e13f5f5311e2f47783dd81fc290b467f50ff7a","title":"Other spans","url":"/docs/features/observability#other-spans","content":"Spans from the RAG, workflow, file, memory, context and evaluation code are exported as plain span records with their name, timing, status and their own attributes. They keep their neurolink.* names: neurolink.rag.search, neurolink.rag.rerank, neurolink.rag.chunk, neurolink.workflow.* (run, run.streaming, response.condition, judge.score, ensemble.execute, layers.execute), neurolink.file.process, neurolink.file.video.process, neurolink.context.compact, neurolink.memory.summarize and neurolink.evaluation.ragas.","hierarchy":{"lvl0":"Features","lvl1":"Observability Guide","lvl2":"Other spans","lvl3":""}},
|
|
3526
3527
|
{"objectID":"ceb0e84f71b6a9deb6a57e236efa009236e933eb892ad569d59e36ba873292f3","title":"Steps and chat format","url":"/docs/features/observability#steps-and-chat-format","content":"Each iteration of the agent loop gets one step span with its one-based index in the step_index metadata. It parents that iteration's generation and the tool observations the model requested in it, so a multi-tool turn reads as step 1 (call, tools), step 2 (call, tools), and so on.\n\nGeneration input is a chat message array with the system message first. Generation output is an assistant message array: content, plus reasoning and tool_calls ({ id, type: \"function\", function: { name, arguments } }) when present. Langfuse renders both as a conversation.\n\nGeneration details:\nUsage includes input, output, total, cache read, cache creation and reasoning tokens, whatever naming the provider uses.\nCost is computed from NeuroLink's pricing table and recorded as costDetails.total.\nModel parameters are temperature, max tokens, top-p and thinking level.\nTime to first token is recorded as the generation's completion start time for streams.\nLevel is WARNING for a length or content-filter finish, an aborted call, an early break out of a stream, or an empty output, and ERROR when the call throws.\nStreams end their spans when the stream finishes, is abandoned or is aborted.","hierarchy":{"lvl0":"Features","lvl1":"Observability Guide","lvl2":"Steps and chat format","lvl3":""}},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juspay/neurolink",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.14.0",
|
|
4
4
|
"packageManager": "pnpm@10.34.9+sha512.f49b5a8ea0fdedb44bb3c0c1d6575092a53c2950d95b7ad15df11f17974877a2de3a01c07e934e9b28ce716e51c09a94962c7306d09be2e1e4b18a8c8762fd32",
|
|
5
5
|
"description": "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/call) for routing, tool selection and context budgeting. MCP-native (4 transports), voice TTS/STT/realtime, RAG, agents, memory, compaction, 9 observability exporters. OpenAI · Anthropic · Gemini · Bedrock · Azure · Ollama · TypeSafe Jev and more.",
|
|
6
6
|
"author": {
|