Typed Helpers#

Generated from crates/node/typed.d.ts via sphinx-js.

typedLlmStreamExecute#

Execute a typed streaming LLM call through the JSON middleware pipeline.

Chunks yielded by func are converted to JSON via chunkCodec.toJson before entering the middleware pipeline. After interception, chunks are converted back via chunkCodec.fromJson before reaching collector. The finalizer result is converted via responseCodec.toJson. Kind: function

Parameters#

  • name string: Model/provider name.

  • request TRequest: The LLM request object ({headers, content}).

  • func (request: TRequest) => AsyncIterable<TChunk>: Async iterable producer for typed stream chunks.

  • collector (chunk: TChunk) => void: Callback invoked with each decoded typed chunk.

  • finalizer () => TResponse: Callback that returns the final typed aggregate response.

  • chunkCodec Codec<TChunk>: Codec for stream chunk serialization/deserialization.

  • responseCodec Codec<TResponse>: Codec for final response serialization/deserialization.

  • options TypedLlmStreamExecuteOptions: Optional scope handle, attributes, data, metadata, modelName.

Returns#

  • Promise<LlmStream>: A promise resolving to the native LlmStream handle.

Remarks#

  • The wrapper bridges async iteration back into the native stream lifecycle and closes the stream even when the source iterator throws.

TypedLlmStreamExecuteOptions#

Options for typedLlmStreamExecute. Kind: interface

Members#

  • handle? ScopeHandle

  • attributes? number

  • data? JsonValue

  • metadata? JsonValue

  • modelName? string

  • codec? LlmCodec

  • responseCodec? LlmResponseCodec

typedLlmExecute#

Execute a typed LLM call through the JSON middleware pipeline.

Forwards the JSON-shaped request payload into the native LLM lifecycle and decodes the final response with the supplied response codec before resolving. Kind: function

Parameters#

  • name string: Model/provider name.

  • request TRequest: The LLM request object ({headers, content}).

  • func (request: TRequest) => TResponse | Promise<TResponse>: The LLM implementation.

  • responseCodec Codec<TResponse>: Codec for response serialization/deserialization.

  • options TypedLlmExecuteOptions: Optional scope handle, attributes, data, metadata, modelName.

Returns#

  • Promise<TResponse>: A promise resolving to the decoded typed LLM response.

Remarks#

  • options.responseCodec only affects annotated response event payloads; failures while decoding those event payloads are downgraded to debug logging and do not rewrite the caller-visible response.

typedToolExecute#

Execute a typed tool call through the JSON middleware pipeline.

Converts args to JSON, runs the native tool execution lifecycle, and decodes the final JSON result back into the caller’s typed result shape. Kind: function

Parameters#

  • name string: Tool name.

  • args TArgs: Typed tool arguments.

  • func (args: TArgs) => TResult | Promise<TResult>: The tool implementation.

  • argsCodec Codec<TArgs>: Codec for args serialization/deserialization.

  • resultCodec Codec<TResult>: Codec for result serialization/deserialization.

  • options TypedToolExecuteOptions: Optional scope handle, attributes, data, metadata.

Returns#

  • Promise<TResult>: A promise resolving to the decoded typed tool result.

Remarks#

  • The wrapper accepts both synchronous and promise-returning tool implementations; codec failures and native execution errors propagate to the returned promise.

TypedLlmExecuteOptions#

Options for typedLlmExecute. Kind: interface

Members#

  • handle? ScopeHandle

  • attributes? number

  • data? JsonValue

  • metadata? JsonValue

  • modelName? string

  • codec? LlmCodec

  • responseCodec? LlmResponseCodec

TypedToolExecuteOptions#

Options for typedToolExecute. Kind: interface

Members#

  • handle? ScopeHandle

  • attributes? number

  • data? JsonValue

  • metadata? JsonValue

JsonPassthrough#

A passthrough codec that performs no conversion. Use when arguments or results are already plain JSON objects. Kind: class

Members#

  • toJson unknown: Convert a typed value to a JSON-serializable object.

  • fromJson unknown: Reconstruct a typed value from a JSON-serializable object.

Codec#

A codec that converts between a typed value T and a JSON-serializable representation (JsonValue by default). Kind: interface

Members#

  • toJson unknown: Convert a typed value to a JSON-serializable object.

  • fromJson unknown: Reconstruct a typed value from a JSON-serializable object.

LlmResponseCodec#

A codec for normalizing and decoding raw LLM responses into JsonValue.

Use when model output requires custom parsing or normalization before the response is consumed as plain JSON by the library. Kind: interface

Members#

  • decodeResponse unknown: Decode a raw LLM response payload into the normalized JSON shape expected by the library.

Implementations should return a JSON-serializable value and should prefer normalizing missing or provider-specific fields into a stable shape when possible.

LlmCodec#

A codec for annotating and unwrapping LLM JSON request payloads.

Use when an LLM integration needs custom request parsing or normalization before the raw payload is passed through the NeMo Flow LLM middleware pipeline. Kind: interface

Members#

  • decode unknown: Decode a raw LLM request payload into the normalized JSON shape used by the codec.

  • encode unknown: Encode an annotated request payload back into the JSON shape expected by the underlying LLM implementation.

LlmRequestShape#

Canonical JSON shape for an opaque LLM request payload. Kind: interface

Members#

  • headers JsonObject

  • content JsonValue

JsonValue#

Any JSON-serializable value accepted by the typed wrapper APIs.

Alias Of: JsonPrimitive | JsonObject | JsonArray

JsonArray#

A JSON array with recursively JSON-serializable values.

Alias Of: JsonValue[]

JsonObject#

A JSON object with recursively JSON-serializable values. Kind: interface

JsonPrimitive#

One JSON scalar value accepted by the typed wrapper APIs.

Alias Of: string | number | boolean | null

LlmStream#

No description available.

Alias Of: LlmStream

ScopeHandle#

Typed wrappers for NeMo Flow Node.js execute APIs.

Provides generic typed versions of toolCallExecute and llmCallExecute that use explicit Codec<T> objects to serialize/deserialize at the API boundary.

Alias Of: ScopeHandle