ai.stream.Stream

The typed partial-value stream returned by an LLM function's `@stream` projection. This is the one canonical host-stream class; tagged handles carry its FQN across FFI so host bridges do not need to hardcode a namespace.

Reference version

Signature

class ai.stream.Stream<TStream, TFinal>

The typed partial-value stream returned by an LLM function's @stream projection. This is the one canonical host-stream class; tagged handles carry its FQN across FFI so host bridges do not need to hardcode a namespace.

Source:<builtin>/ai/ns_stream/stream.bamlbytes 2126422773

Fields

_cache

baml.sap._ParseCache<TStream, TFinal>

_text

string

_finished

bool

Instance methods

function

final

(
self
) -> TFinal throws baml.errors.LlmClient | baml.errors.Timeout | baml.errors.UnknownError | reflect.errors.CompilationError | ai.errors.Failure

Drain the stream and parse the accumulated text as the final value.

function

next

(
self
) -> TStream | ai.stream.Done throws baml.errors.LlmClient | baml.errors.Timeout | baml.errors.UnknownError | reflect.errors.CompilationError | ai.errors.Failure

Return the next parsed partial value, or Done after EOF.