dyui.llm
dyui.llm.stream()
Section titled “dyui.llm.stream()”async def stream( model: str, messages: list[Any], *, system: str | None = None, components: Any = None, ui_mode: str = 'fence', max_tool_rounds: int = 8, rate_limit_retries: int = DEFAULT_RATE_LIMIT_RETRIES, base_url: str | None = None, api_key: str | None = None, client: Any = None, **kwargs: Any,) -> AsyncIterator[Any]Stream a completion as str text deltas and dyui.Reasoning deltas.
model is "provider/model" (see dyui.llm.PROVIDERS).
components is a catalog (anything with .prompt()); its prompt is merged
into system (at {dyui_components} if present, else appended).
ui_mode="fence" (default): the model writes ``dyui fences inside its text.
ui_mode="tools": one render_<name> tool per component (strict schemas via
components.tool_schemas); dyui runs the tool loop (at most max_tool_rounds
requests) and yields each completed call as a {"ui": name, ...props} dict.
A caller-supplied tools= list is merged; if the model calls one of those tools
the loop stops (custom tools need their own loop).
Rate limits: an HTTP 429 from the provider is retried up to rate_limit_retries
times, waiting for the provider’s Retry-After (or 2s, 4s, 8s…). Waits over a
minute (daily quotas) are not retried. Set rate_limit_retries=0 to disable.
`client`` lets you pass a pre-built async SDK client. Extra kwargs go to the SDK.
dyui.llm.complete()
Section titled “dyui.llm.complete()”async def complete(model: str, messages: list[Any], **kwargs: Any) -> strNon-streaming convenience: return the full text reply (reasoning dropped).
dyui.llm.Provider
Section titled “dyui.llm.Provider”class Provider( name: str, sdk: str, base_url: str | None = None, base_url_env: str | None = None, key_envs: tuple[str, ...] = (), key_required: bool = True,)dyui.llm.MissingDependencyError
Section titled “dyui.llm.MissingDependencyError”class MissingDependencyError(ImportError)Raised when an optional SDK (openai / anthropic) is not installed.