Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
jni
)

set(PLUGIN_BUNDLED_LIBRARIES)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ import video_player_avfoundation
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
FVPVideoPlayerPlugin.register(with: registry.registrar(forPlugin: "FVPVideoPlayerPlugin"))
VideoPlayerPlugin.register(with: registry.registrar(forPlugin: "VideoPlayerPlugin"))
}
1 change: 1 addition & 0 deletions dev_tools/composer/linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
jni
)

set(PLUGIN_BUNDLED_LIBRARIES)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin"))
ScreenRetrieverMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverMacosPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
FVPVideoPlayerPlugin.register(with: registry.registrar(forPlugin: "FVPVideoPlayerPlugin"))
VideoPlayerPlugin.register(with: registry.registrar(forPlugin: "VideoPlayerPlugin"))
WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin"))
}
1 change: 1 addition & 0 deletions dev_tools/composer/windows/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
jni
)

set(PLUGIN_BUNDLED_LIBRARIES)
Expand Down
1 change: 1 addition & 0 deletions examples/simple_chat/linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
jni
)

set(PLUGIN_BUNDLED_LIBRARIES)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ import video_player_avfoundation
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
FVPVideoPlayerPlugin.register(with: registry.registrar(forPlugin: "FVPVideoPlayerPlugin"))
VideoPlayerPlugin.register(with: registry.registrar(forPlugin: "VideoPlayerPlugin"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
jni
)

set(PLUGIN_BUNDLED_LIBRARIES)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
jni
)

set(PLUGIN_BUNDLED_LIBRARIES)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
FVPVideoPlayerPlugin.register(with: registry.registrar(forPlugin: "FVPVideoPlayerPlugin"))
VideoPlayerPlugin.register(with: registry.registrar(forPlugin: "VideoPlayerPlugin"))
}
9 changes: 7 additions & 2 deletions packages/genui/lib/src/facade/prompt_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ enum ProtocolMessages {
explanation: 'Creates a new surface.',
properties: '''
Requires `surfaceId` (you must always use a unique ID for each created surface),
`catalogId` (use the catalog ID provided in system instructions),
`catalogId` (use the active catalog ID if provided in system instructions),
and `sendDataModel: true`.
''',
// TODO: figure out why we instruct AI to always set sendDataModel: true,
Expand Down Expand Up @@ -284,7 +284,7 @@ You can control the UI by outputting valid A2UI JSON messages wrapped in markdow
if (create)
'''
To create a new UI:
1. Output a ${ProtocolMessages.createSurface.tickedName} message with a unique `surfaceId` and `catalogId` (use the catalog ID provided in system instructions).
1. Output a ${ProtocolMessages.createSurface.tickedName} message with a unique `surfaceId` and `catalogId` (use the active catalog ID if provided in system instructions).
2. Output an ${ProtocolMessages.updateComponents.tickedName} message with the `surfaceId` and the component definitions.
''',
if (!update)
Expand Down Expand Up @@ -363,9 +363,14 @@ final class _BasicPromptBuilder extends PromptBuilder {
catalog,
).toJson(indent: ' ');

final String? activeCatalogId = catalog.catalogId;

final fragments = <String>[
...systemPromptFragments,
'Use the provided tools to respond to user using rich UI elements.',
if (activeCatalogId != null)
'The active catalog ID is: "$activeCatalogId". '
'You must use this catalog ID when creating surfaces.',
...technicalPossibilities.systemPromptFragment(),
...catalog.systemPromptFragments,
...allowedOperations.systemPromptFragments,
Expand Down
7 changes: 6 additions & 1 deletion packages/genui/lib/src/model/a2ui_schemas.dart
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,12 @@ abstract final class A2uiSchemas {
'the component tree.',
properties: {
surfaceIdKey: S.string(description: 'The unique ID for the surface.'),
'catalogId': S.string(description: 'The URI of the component catalog.'),
'catalogId': S.string(
description:
'A string that uniquely identifies this catalog. This is typically '
'a URI, but the URI is never accessed, only used as a unique '
'identifier.',
),
'theme': S.object(
description: 'Theme parameters for the surface.',
additionalProperties: true,
Expand Down
18 changes: 18 additions & 0 deletions packages/genui/test/facade/prompt_builder_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,22 @@ void main() {
});
}
});

group('Catalog ID', () {
test('is surfaced in system prompt when provided', () {
final catalog = Catalog([
BasicCatalogItems.text,
], catalogId: 'my_custom_catalog');
final builder = PromptBuilder.chat(catalog: catalog);
final String prompt = builder.systemPromptJoined();
expect(prompt, contains('The active catalog ID is: "my_custom_catalog"'));
});

test('is not surfaced in system prompt when not provided', () {
final catalog = Catalog([BasicCatalogItems.text]);
final builder = PromptBuilder.chat(catalog: catalog);
final String prompt = builder.systemPromptJoined();
expect(prompt, isNot(contains('The active catalog ID is:')));
});
});
}
Comment thread
gspencergoog marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Use the provided tools to respond to user using rich UI elements.

-------------------------------------

The active catalog ID is: "test_catalog". You must use this catalog ID when creating surfaces.

-------------------------------------

IMPORTANT: You do not have the ability to execute code. If you need to perform calculations, do them yourself.

-------------------------------------
Expand Down Expand Up @@ -100,14 +104,14 @@ Supported messages are: `createSurface`, `updateComponents`, `deleteSurface`.
Properties:

- `createSurface`: Requires `surfaceId` (you must always use a unique ID for each created surface),
`catalogId` (use the catalog ID provided in system instructions),
`catalogId` (use the active catalog ID if provided in system instructions),
and `sendDataModel: true`.
- `updateComponents`: Requires `surfaceId` and a list of `components`.
One component MUST have `id: "root"`.
- `deleteSurface`: Requires `surfaceId`.

To create a new UI:
1. Output a `createSurface` message with a unique `surfaceId` and `catalogId` (use the catalog ID provided in system instructions).
1. Output a `createSurface` message with a unique `surfaceId` and `catalogId` (use the active catalog ID if provided in system instructions).
2. Output an `updateComponents` message with the `surfaceId` and the component definitions.

To update an existing UI:
Expand Down Expand Up @@ -147,7 +151,7 @@ When constructing UI, you must output a VALID A2UI JSON object representing one
},
"catalogId": {
"type": "string",
"description": "The URI of the component catalog."
"description": "A string that uniquely identifies this catalog. It is recommended to prefix this with an internet domain that you own, to avoid conflicts e.g. 'mycompany.com:somecatalog'."
},
"theme": {
"type": "object",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Use the provided tools to respond to user using rich UI elements.

-------------------------------------

The active catalog ID is: "test_catalog". You must use this catalog ID when creating surfaces.

-------------------------------------

IMPORTANT: You do not have the ability to execute code. If you need to perform calculations, do them yourself.

-------------------------------------
Expand Down Expand Up @@ -101,15 +105,15 @@ Supported messages are: `createSurface`, `updateComponents`, `deleteSurface`, `u
Properties:

- `createSurface`: Requires `surfaceId` (you must always use a unique ID for each created surface),
`catalogId` (use the catalog ID provided in system instructions),
`catalogId` (use the active catalog ID if provided in system instructions),
and `sendDataModel: true`.
- `updateComponents`: Requires `surfaceId` and a list of `components`.
One component MUST have `id: "root"`.
- `deleteSurface`: Requires `surfaceId`.
- `updateDataModel`: Requires `surfaceId`, `path` and `value`.

To create a new UI:
1. Output a `createSurface` message with a unique `surfaceId` and `catalogId` (use the catalog ID provided in system instructions).
1. Output a `createSurface` message with a unique `surfaceId` and `catalogId` (use the active catalog ID if provided in system instructions).
2. Output an `updateComponents` message with the `surfaceId` and the component definitions.

To update an existing UI:
Expand Down Expand Up @@ -149,7 +153,7 @@ When constructing UI, you must output a VALID A2UI JSON object representing one
},
"catalogId": {
"type": "string",
"description": "The URI of the component catalog."
"description": "A string that uniquely identifies this catalog. It is recommended to prefix this with an internet domain that you own, to avoid conflicts e.g. 'mycompany.com:somecatalog'."
},
"theme": {
"type": "object",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Use the provided tools to respond to user using rich UI elements.

-------------------------------------

The active catalog ID is: "test_catalog". You must use this catalog ID when creating surfaces.

-------------------------------------

IMPORTANT: You do not have the ability to execute code. If you need to perform calculations, do them yourself.

-------------------------------------
Expand Down Expand Up @@ -99,13 +103,13 @@ Supported messages are: `createSurface`, `updateComponents`.
Properties:

- `createSurface`: Requires `surfaceId` (you must always use a unique ID for each created surface),
`catalogId` (use the catalog ID provided in system instructions),
`catalogId` (use the active catalog ID if provided in system instructions),
and `sendDataModel: true`.
- `updateComponents`: Requires `surfaceId` and a list of `components`.
One component MUST have `id: "root"`.

To create a new UI:
1. Output a `createSurface` message with a unique `surfaceId` and `catalogId` (use the catalog ID provided in system instructions).
1. Output a `createSurface` message with a unique `surfaceId` and `catalogId` (use the active catalog ID if provided in system instructions).
2. Output an `updateComponents` message with the `surfaceId` and the component definitions.

To update an existing UI:
Expand Down Expand Up @@ -145,7 +149,7 @@ When constructing UI, you must output a VALID A2UI JSON object representing one
},
"catalogId": {
"type": "string",
"description": "The URI of the component catalog."
"description": "A string that uniquely identifies this catalog. It is recommended to prefix this with an internet domain that you own, to avoid conflicts e.g. 'mycompany.com:somecatalog'."
},
"theme": {
"type": "object",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Use the provided tools to respond to user using rich UI elements.

-------------------------------------

The active catalog ID is: "test_catalog". You must use this catalog ID when creating surfaces.

-------------------------------------

IMPORTANT: You do not have the ability to execute code. If you need to perform calculations, do them yourself.

-------------------------------------
Expand Down Expand Up @@ -100,14 +104,14 @@ Supported messages are: `createSurface`, `updateComponents`, `updateDataModel`.
Properties:

- `createSurface`: Requires `surfaceId` (you must always use a unique ID for each created surface),
`catalogId` (use the catalog ID provided in system instructions),
`catalogId` (use the active catalog ID if provided in system instructions),
and `sendDataModel: true`.
- `updateComponents`: Requires `surfaceId` and a list of `components`.
One component MUST have `id: "root"`.
- `updateDataModel`: Requires `surfaceId`, `path` and `value`.

To create a new UI:
1. Output a `createSurface` message with a unique `surfaceId` and `catalogId` (use the catalog ID provided in system instructions).
1. Output a `createSurface` message with a unique `surfaceId` and `catalogId` (use the active catalog ID if provided in system instructions).
2. Output an `updateComponents` message with the `surfaceId` and the component definitions.

To update an existing UI:
Expand Down Expand Up @@ -147,7 +151,7 @@ When constructing UI, you must output a VALID A2UI JSON object representing one
},
"catalogId": {
"type": "string",
"description": "The URI of the component catalog."
"description": "A string that uniquely identifies this catalog. It is recommended to prefix this with an internet domain that you own, to avoid conflicts e.g. 'mycompany.com:somecatalog'."
},
"theme": {
"type": "object",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Use the provided tools to respond to user using rich UI elements.

-------------------------------------

The active catalog ID is: "test_catalog". You must use this catalog ID when creating surfaces.

-------------------------------------

IMPORTANT: You do not have the ability to execute code. If you need to perform calculations, do them yourself.

-------------------------------------
Expand Down Expand Up @@ -99,13 +103,13 @@ Supported messages are: `createSurface`, `updateComponents`.
Properties:

- `createSurface`: Requires `surfaceId` (you must always use a unique ID for each created surface),
`catalogId` (use the catalog ID provided in system instructions),
`catalogId` (use the active catalog ID if provided in system instructions),
and `sendDataModel: true`.
- `updateComponents`: Requires `surfaceId` and a list of `components`.
One component MUST have `id: "root"`.

To create a new UI:
1. Output a `createSurface` message with a unique `surfaceId` and `catalogId` (use the catalog ID provided in system instructions).
1. Output a `createSurface` message with a unique `surfaceId` and `catalogId` (use the active catalog ID if provided in system instructions).
2. Output an `updateComponents` message with the `surfaceId` and the component definitions.

IMPORTANT: DO NOT update or modify surfaces created in previous turns. If the UI needs to change, you MUST create a NEW surface with a new unique `surfaceId`. You may only use `updateComponents` to populate the components of a freshly created surface.
Expand Down Expand Up @@ -144,7 +148,7 @@ When constructing UI, you must output a VALID A2UI JSON object representing one
},
"catalogId": {
"type": "string",
"description": "The URI of the component catalog."
"description": "A string that uniquely identifies this catalog. It is recommended to prefix this with an internet domain that you own, to avoid conflicts e.g. 'mycompany.com:somecatalog'."
},
"theme": {
"type": "object",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Use the provided tools to respond to user using rich UI elements.

-------------------------------------

The active catalog ID is: "test_catalog". You must use this catalog ID when creating surfaces.

-------------------------------------

IMPORTANT: You do not have the ability to execute code. If you need to perform calculations, do them yourself.

-------------------------------------
Expand Down Expand Up @@ -100,14 +104,14 @@ Supported messages are: `createSurface`, `updateComponents`, `updateDataModel`.
Properties:

- `createSurface`: Requires `surfaceId` (you must always use a unique ID for each created surface),
`catalogId` (use the catalog ID provided in system instructions),
`catalogId` (use the active catalog ID if provided in system instructions),
and `sendDataModel: true`.
- `updateComponents`: Requires `surfaceId` and a list of `components`.
One component MUST have `id: "root"`.
- `updateDataModel`: Requires `surfaceId`, `path` and `value`.

To create a new UI:
1. Output a `createSurface` message with a unique `surfaceId` and `catalogId` (use the catalog ID provided in system instructions).
1. Output a `createSurface` message with a unique `surfaceId` and `catalogId` (use the active catalog ID if provided in system instructions).
2. Output an `updateComponents` message with the `surfaceId` and the component definitions.

IMPORTANT: DO NOT update or modify surfaces created in previous turns. If the UI needs to change, you MUST create a NEW surface with a new unique `surfaceId`. You may only use `updateComponents` to populate the components of a freshly created surface.
Expand Down Expand Up @@ -146,7 +150,7 @@ When constructing UI, you must output a VALID A2UI JSON object representing one
},
"catalogId": {
"type": "string",
"description": "The URI of the component catalog."
"description": "A string that uniquely identifies this catalog. It is recommended to prefix this with an internet domain that you own, to avoid conflicts e.g. 'mycompany.com:somecatalog'."
},
"theme": {
"type": "object",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Use the provided tools to respond to user using rich UI elements.

-------------------------------------

The active catalog ID is: "test_catalog". You must use this catalog ID when creating surfaces.

-------------------------------------

IMPORTANT: You do not have the ability to execute code. If you need to perform calculations, do them yourself.

-------------------------------------
Expand Down Expand Up @@ -137,7 +141,7 @@ When constructing UI, you must output a VALID A2UI JSON object representing one
},
"catalogId": {
"type": "string",
"description": "The URI of the component catalog."
"description": "A string that uniquely identifies this catalog. It is recommended to prefix this with an internet domain that you own, to avoid conflicts e.g. 'mycompany.com:somecatalog'."
},
"theme": {
"type": "object",
Expand Down
Loading
Loading