ai.stream.Stream

class in the ai package.

Reference version

Signature

class ai.stream.Stream<T>

Source:<builtin>/ai/ns_stream/stream.bamlbytes 31338–36207

Fields

_provider

string

_release

() -> null throws never

_span

trace.Span

_cache

baml.sap._ParseCache<T>

_text

string

_finished

bool

Instance methods

function

_fail

(
self,
error: ai.errors.InvokeError | trace.SpanError | baml.panics.Panic,
context: baml.errors.Context
) -> null throws never
function

_next

(
self
) -> T | ai.stream.Done throws reflect.errors.CompilationError | trace.SpanError | baml.errors.Timeout | baml.errors.UnknownError | ai.errors.Failure
function

_settle

(
self
) -> T throws reflect.errors.CompilationError | trace.SpanError | baml.errors.Timeout | baml.errors.UnknownError | ai.errors.Failure
function

cleanup

(self) -> null throws never

Release stream resources and end any still-open tracing lifetime. Abandonment does not imply cancellation or successful parsing.

function

final

(
self
) -> T throws reflect.errors.CompilationError | trace.SpanError | baml.errors.Timeout | baml.errors.UnknownError | ai.errors.Failure

Drain and return the cached final value, or rethrow the cached error.

function

next

(
self
) -> T | ai.stream.Done throws reflect.errors.CompilationError | trace.SpanError | baml.errors.Timeout | baml.errors.UnknownError | ai.errors.Failure

Return a partial value, or Done at EOF. EOF also settles the final parse; a final parse error is cached for final(), preserving Done.