@@ -21,16 +21,16 @@ alpha and is likely to change.
2121
2222The [ ` genui ` ] [ ] package is built around the following main components:
2323
24- ` GenUiConversation `
24+ ` Conversation `
2525: The primary facade and entry point for the package.
26- It includes the ` A2uiMessageProcessor ` and ` ContentGenerator ` classes ,
26+ It includes the ` SurfaceController ` class ,
2727 manages the conversation history,
2828 and orchestrates the entire generative UI process.
2929
3030` Catalog `
3131: A collection of ` CatalogItem ` objects that defines
3232 the set of widgets that the AI is allowed to use.
33- The ` A2uiMessageProcessor ` supports multiple catalogs,
33+ The ` SurfaceController ` supports multiple catalogs,
3434 allowing you to organize your widgets into logical groups.
3535 Each ` CatalogItem ` specifies a widget's name (for the AI
3636 to reference), a data schema for its properties, and a
@@ -41,70 +41,68 @@ The [`genui`][] package is built around the following main components:
4141 Widgets are _ bound_ to data in this model. When data changes,
4242 only the widgets that depend on that specific piece of data are rebuilt.
4343
44- ` ContentGenerator `
45- : An interface for communicating with a generative AI model.
46- This interface uses streams to send ` A2uiMessage ` commands,
47- text responses, and errors back to the ` GenUiConversation ` .
44+ ` A2uiTransportAdapter `
45+ : A bridge that parses raw text streams coming from your LLM into
46+ ` A2uiMessage ` commands for the ` SurfaceController ` .
4847
4948` A2uiMessage `
5049: A message sent from the AI
51- (through the ` ContentGenerator ` ) to the UI,
52- instructing it to perform actions like ` beginRendering ` ,
50+ (parsed by the ` A2uiTransportAdapter ` ) to the UI,
51+ instructing it to perform actions like ` createSurface ` ,
5352 ` surfaceUpdate ` , ` dataModelUpdate ` , or ` deleteSurface ` .
5453
55- ` A2uiMessageProcessor `
54+ ` SurfaceController `
5655: Handles the processing of ` A2uiMessage ` s,
5756 manages the ` DataModel ` , and maintains the state of UI surfaces.
5857
58+
5959## How it works
6060
61- The ` GenUiConversation ` manages the interaction cycle:
61+ The ` Conversation ` manages the interaction cycle:
6262
6363 1 . ** User input**
6464
6565 The user provides a prompt (for example, through a text field).
66- The app calls ` genUiConversation.sendRequest ()` .
66+ The app calls ` conversation.sendMessage ()` .
6767
6868 2 . ** AI invocation**
6969
70- The ` GenUiConversation ` adds the user's message to its
71- internal conversation history and calls ` contentGenerator.sendRequest() ` .
70+ The ` Conversation ` sends the user's message to the LLM SDK.
7271
7372 3 . ** AI response**
7473
75- The ` ContentGenerator ` interacts with the AI model.
76- The AI, guided by the widget schemas, sends back responses.
74+ The LLM, guided by the widget schemas provided in its system prompt,
75+ sends back responses.
7776
7877 4 . ** Stream handling**
7978
80- The ` ContentGenerator ` emits A2uiMessages,
81- text responses, or errors on its streams.
79+ The text stream from the LLM SDK is fed into the ` A2uiTransportAdapter ` .
8280
8381 5 . ** UI state update**
8482
85- ` GenUiConversation ` listens to these streams.
86- ` A2uiMessages ` are passed to ` A2uiMessageProcessor .handleMessage()` ,
87- which updates the UI state and ` DataModel ` .
83+ ` A2uiMessages ` parsed by the adapter are passed to
84+ ` SurfaceController .handleMessage()` , which updates
85+ the UI state and ` DataModel ` .
8886
8987 6 . ** UI rendering**
9088
91- The ` A2uiMessageProcessor ` broadcasts an update,
92- and any ` GenUiSurface ` widgets listening for that surface ID will rebuild.
89+ The ` SurfaceController ` broadcasts an update,
90+ and any ` Surface ` widgets listening for that surface ID will rebuild.
9391 Widgets are bound to the ` DataModel ` , so they update automatically
9492 when their data changes.
9593
9694 7 . ** Callbacks**
9795
98- Text responses and errors trigger the ` onTextResponse `
99- and ` onError ` callbacks on ` GenUiConversation ` .
96+ Text responses and errors trigger callbacks on the ` Conversation ` or
97+ are handled by your specific LLM integration flow .
10098
10199 8 . ** User interaction**
102100
103101 The user interacts with the newly generated UI
104102 (for example, by typing in a text field). This interaction directly
105103 updates the ` DataModel ` . If the interaction is an action (like a button click),
106- the ` GenUiSurface ` captures the event and forwards it to the
107- ` GenUiConversation ` 's ` A2uiMessageProcessor ` , which automatically creates
104+ the ` Surface ` captures the event and forwards it to the
105+ ` SurfaceController ` , which automatically creates
108106 a new ` UserMessage ` containing the current state of the data model
109107 and restarts the cycle.
110108
0 commit comments