File tree Expand file tree Collapse file tree 4 files changed +19
-16
lines changed
examples/travel_app/lib/src
genui_google_generative_ai/lib/src
test/catalog/core_widgets Expand file tree Collapse file tree 4 files changed +19
-16
lines changed Original file line number Diff line number Diff line change @@ -353,11 +353,9 @@ the user can return to the main booking flow once they have done some research.
353353
354354## Controlling the UI
355355
356- Use the provided tools to build and manage the user interface in response to the
357- user's requests. To display or update a UI, you must first call the
358- `surfaceUpdate` tool to define all the necessary components. After defining the
359- components, you must call the `beginRendering` tool to specify the root
360- component that should be displayed.
356+ To display or update a UI, you must output a `surfaceUpdate` message in JSONL format.
357+ The `surfaceUpdate` message must define all necessary components and specify the root
358+ component in the `components` list. The root component must have the ID "root".
361359
362360- Adding surfaces: Most of the time, you should only add new surfaces to the
363361 conversation. This is less confusing for the user, because they can easily
@@ -368,9 +366,6 @@ component that should be displayed.
368366 user because it avoids confusing the conversation with many versions of the
369367 same itinerary etc.
370368
371- Once you add or update a surface and are waiting for user input, the
372- conversation turn is complete, and you should call the provideFinalOutput tool.
373-
374369If you are displaying more than one component, you should use a `Column` widget
375370as the root and add the other components as children.
376371
Original file line number Diff line number Diff line change @@ -203,8 +203,8 @@ class A2uiSchemas {
203203 properties: {
204204 'id' : S .string (
205205 description:
206- 'The unique identifier for this component. The root component '
207- "of the surface MUST have the id 'root'." ,
206+ 'The unique identifier for this component. The root '
207+ "component of the surface MUST have the id 'root'." ,
208208 ),
209209 'weight' : S .integer (
210210 description:
Original file line number Diff line number Diff line change @@ -32,10 +32,9 @@ void main() {
3232 SurfaceUpdate (surfaceId: surfaceId, components: components),
3333 );
3434 manager.handleMessage (const CreateSurface (surfaceId: surfaceId));
35- manager.dataModelForSurface (surfaceId).update (
36- DataPath ('/myValue' ),
37- 'initial' ,
38- );
35+ manager
36+ .dataModelForSurface (surfaceId)
37+ .update (DataPath ('/myValue' ), 'initial' );
3938
4039 await tester.pumpWidget (
4140 MaterialApp (
Original file line number Diff line number Diff line change @@ -274,7 +274,6 @@ class GoogleGenerativeAiContentGenerator implements ContentGenerator {
274274 final service = serviceFactory (configuration: this );
275275
276276 try {
277-
278277 // A local copy of the incoming messages which is updated with
279278 // tool results
280279 // as they are generated.
@@ -435,7 +434,17 @@ With functions:
435434
436435 void _processLine (String line) {
437436 line = line.trim ();
438- if (line.isEmpty) return ;
437+ if (line.isEmpty) {
438+ return ;
439+ }
440+
441+ // If the line doesn't start with '{', it's not a JSONL object.
442+ // We ignore it to prevent markdown artifacts or other noise from being
443+ // treated as text.
444+ if (! line.startsWith ('{' )) {
445+ genUiLogger.fine ('Ignored non-JSONL line: $line ' );
446+ return ;
447+ }
439448
440449 genUiLogger.fine ('Processing line: $line ' );
441450
You can’t perform that action at this time.
0 commit comments