Skip to content

dyui.genui

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.
def feed(chunk: str) -> list[ParserEvent]

Consume a chunk of model output and return the events it produced.

def close() -> list[ParserEvent]

Flush at end of stream: finish complete lines, error a partial component.

True while inside a component block.

def parse_text(text: str, catalog: Any = None, **kwargs: Any) -> list[ParserEvent]

Parse a complete text in one go (convenience for tests and history).

def parse_partial(text: str) -> Any

Parse a possibly-incomplete JSON document.

Parameters

Name Type Description
text str A JSON prefix.

Returns

  • Any — The decoded value with open containers closed, or MISSING
  • Any — when nothing complete is available yet.

Raises

  • PartialJSONError — If the prefix is malformed (can never become valid).
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.

def action_text(
name: str,
data: Optional[Mapping[str, Any]] = None,
values: Optional[Mapping[str, Any]] = None,
) -> str

Return the LLM-friendly form of an action: [action:name] {data+values}.

def repair_message(error: Any, *, component: Optional[str] = None) -> str

Build 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":...}.

DyUI Docs assistant

Answers come from the DyUI docs. gpt-oss-120b via Groq. Press Escape or the close button to return to the page.