dyui.genui
dyui.genui.parser.FenceParser
Section titled “dyui.genui.parser.FenceParser”class FenceParser( catalog: Any = None, *, id_factory: Optional[Callable[[], str]] = None, used_ids: Optional[set[str]] = None, clock: Callable[[], float] = time.monotonic, throttle_chars: int = 24, throttle_seconds: float = 0.06,)Incremental parser turning LLM text into prose + component events.
Parameters
| Name | Type | Description |
|---|---|---|
catalog |
Any |
Components the model may use (default: every built-in). |
id_factory |
Optional[Callable[[], str]] |
Returns fresh node ids (default c_<8hex>). |
used_ids |
Optional[set[str]] |
Ids already used in the message (kept unique; shared and updated). |
clock |
Callable[[], float] |
Monotonic clock used for update throttling. |
throttle_chars |
int |
Emit a partial update after this many new characters… |
throttle_seconds |
float |
…or after this much time, whichever comes first. |
FenceParser.feed()
Section titled “FenceParser.feed()”def feed(chunk: str) -> list[ParserEvent]Consume a chunk of model output and return the events it produced.
FenceParser.close()
Section titled “FenceParser.close()”def close() -> list[ParserEvent]Flush at end of stream: finish complete lines, error a partial component.
FenceParser.in_block bool
Section titled “FenceParser.in_block bool”True while inside a component block.
dyui.genui.parser.parse_text()
Section titled “dyui.genui.parser.parse_text()”def parse_text(text: str, catalog: Any = None, **kwargs: Any) -> list[ParserEvent]Parse a complete text in one go (convenience for tests and history).
dyui.genui.partial_json.parse_partial()
Section titled “dyui.genui.partial_json.parse_partial()”def parse_partial(text: str) -> AnyParse a possibly-incomplete JSON document.
Parameters
| Name | Type | Description |
|---|---|---|
text |
str |
A JSON prefix. |
Returns
Any— The decoded value with open containers closed, orMISSINGAny— when nothing complete is available yet.
Raises
PartialJSONError— If the prefix is malformed (can never become valid).
dyui.genui.history.serialize_history()
Section titled “dyui.genui.history.serialize_history()”def serialize_history(messages: Iterable[Mapping[str, Any]]) -> list[dict[str, str]]Convert stored messages to OpenAI-style [{"role", "content"}].
Empty messages (e.g. an assistant turn that only ran steps) are skipped.
dyui.genui.history.action_text()
Section titled “dyui.genui.history.action_text()”def action_text( name: str, data: Optional[Mapping[str, Any]] = None, values: Optional[Mapping[str, Any]] = None,) -> strReturn the LLM-friendly form of an action: [action:name] {data+values}.
dyui.genui.validate.repair_message()
Section titled “dyui.genui.validate.repair_message()”def repair_message(error: Any, *, component: Optional[str] = None) -> strBuild the compact repair hint sent back to a model after a failed component.
Accepts a ValidationFailure, a parser ComponentError, a pydantic
ValidationError or an invalid node dict.
Parameters
| Name | Type | Description |
|---|---|---|
error |
Any |
The failure. |
component |
Optional[str] |
The component name, if not carried by error. |
Returns
str— JSON text:{"error":"VALIDATION_FAILED","component":...,"path":...,"message":...}.