API Reference OpenUI v#0.1.1

Copy Markdown View Source

Modules

An Elixir implementation of OpenUI Lang 1.0, the language a model writes to describe a user interface, with an optional Phoenix LiveView renderer.

The actions a component triggers, in order (language.md, section 6.3).

A two-way binding of a bindable prop to a state variable (language.md, section 5.2).

The names the language reserves for built-in functions and action steps (language.md, sections 1.3, 3.4 and 6.3).

The canonical form of a program at stream end, as the OpenUI conformance fixtures summarize it (spec/fixtures/1.0/README.md, "How the tree is summarized").

Incremental editing (language.md, section 7): merges a patch, the changed statements a model answers with in edit mode, into the current program.

A component in a program tree. props maps prop names to values; before evaluation a value may still be an expression.

An error in the shape of language.md, section 8.3, ready to send back to the model. to_map/1 gives the wire form.

An action that reaches the host (language.md, section 6.3): continue_conversation from @ToAssistant, open_url from @OpenUrl, or the name of a library action.

JSON on top of Elixir's JSON that keeps the key order of objects.

A JSON object that keeps the order of its keys.

A component library: the components, custom functions, custom actions and groups a program may use (prompt.md, section 2).

A custom function or action of a library.

Checks that a new version of a LibrarySpec keeps stored programs readable (prompt.md, section 3.2): props of components, functions and actions are only added at the end, never moved or removed, and a new required prop carries a default.

A component of a library: its prompt signature, description and positional props.

The macros of use OpenUI.Library: component/2, function/2, action/2 and group/3. See OpenUI.Library for an example.

A titled group of components in the prompt's component list.

One positional argument of a component, function or action.

The definition-time rules of a library (prompt.md, section 3.1).

Renders OpenUI programs in Phoenix LiveView.

Maps a library's components to the host's function components.

The protocol a host stores responses with (prompt.md, section 7): the program wrapped in ]]>openui:content, ]]>openui:context and ]]>openui:end marker lines. The model never writes or sees these lines.

Parses OpenUI Lang into an OpenUI.Program (language.md, sections 1, 2 and 8).

Parses tokens into an expression tree (language.md, sections 1.5 and 1.6) by precedence climbing, and classifies statements (section 2.1).

Turns OpenUI Lang source into tokens (language.md, section 1.3).

Prepares response text for parsing (language.md, section 1.2): fence extraction, comment stripping and trimming, in that order.

Statement boundaries (language.md, section 1.4) and implicit closing (section 4, rule 2).

A parsed program: its statements, the materialized entry, state defaults, queries, mutations and the parse metadata of language.md, section 2.

A Mutation(tool, args) statement (language.md, section 6.2).

A Query(tool, args, defaults, refresh) statement (language.md, section 6.1). deps are the state variables written literally in args: a change in one of them fetches again.

Generates the system prompt that teaches a model a library (prompt.md, section 4). For the same library and options the prompt is byte-identical to the official generateSystemPrompt.

A rendered program as a pure value: its state store, form fields, query results and mutations, with the interactions of language.md, sections 5 and 6.

The built-in functions that evaluate their arguments up front (language.md, section 3.4). @Each is lazy and lives in the evaluator.

String order for @Sort, close to the ICU root collation that ECMAScript's localeCompare uses (language.md, section 3.4).

What evaluation reads: the library, the state store, the current result of each query and the status of each mutation.

Evaluates a parsed program into a tree of plain values (language.md, sections 3 and 6.3).

Turns Elixir data from the host, such as tool results, into the JSON-like values programs work with.

Field validation rules (language.md, section 5.4): required, email, url, numeric, minLength, maxLength, min, max and pattern.

The value semantics of OpenUI Lang (language.md, sections 3.1 and 3.2).

Writes a rendered tree back to OpenUI Lang (language.md, section 9.2).

One name = expression statement of a program (language.md, section 2.1).

Parses a response a chunk at a time (language.md, section 4).

Marks where a component the library does not know sat in a list of components. It renders nothing, or the host's diagnostic for unknown components (language.md, section 10). It is not part of the canonical tree.

Mix Tasks

Writes the LibrarySpec of a library module, the library.json other clients (a React app, a mobile app) build their library from.