yera.runtime.blocks.struct
Stream a struct schema followed by incremental JSON content.
Entering a StructStream emits the selected Yera struct's JSON Schema before
any token chunks. Later chunks carry partial serialized content under the same
block identity so renderers can show structured generation before the complete
value is available.
Symbols
StructStream
_StreamHandleStream a generated struct schema followed by its JSON tokens.
Methods
StructStream.__init__
__init__(
block_id: str,
)Initialize a struct stream.
Parameters
Identity shared by all emitted chunks.
Struct type whose schema begins the stream.
StructStream.__enter__
__enter__()Open the stream and emit its struct schema.
Returns
This active struct stream.
StructStream.__exit__
__exit__(
exc_type: type[BaseException],
exc_value: BaseException | None,
traceback: TracebackType,
)Close the struct stream.
Parameters
Type of exception leaving the context, if any.
Exception leaving the context, if any.
Traceback associated with the exception, if any.
Returns
False so exceptions propagate from the managed block.
StructStream.emit_schema
emit_schema() → NoneEmit a schema chunk for a struct type.
Parameters
Struct type to describe.
StructStream.append
append(
content: str,
) → NoneAppend a JSON token chunk.
Parameters
Partial serialized struct content.