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_next_text
() -> string | null throws ai.errors.InvokeError_release
() -> null throws never_span
trace.Span_cache
baml.sap._ParseCache<T>_text
string_finished
bool_result
ai.stream._StreamValue<T> | ai.stream._StreamError | nullInstance 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 neverRelease 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.