Skip to content

Commit 546dab9

Browse files
committed
feat(genui): update core framework to v0.9
Major refactor of the GenUI core framework to align with the A2UI v0.9 protocol. Key changes: - Catalog: - Renamed `CoreCatalog` to `BasicCatalog` and moved widgets to `basic_catalog_widgets`. - Implemented new A2UI v0.9 compatible widgets (AudioPlayer, Button, CheckBox, etc.). - Architecture: - Introduced `SurfaceController`, `SurfaceRegistry`, and `DataModelStore` for better state management. - Added `PromptBuilder` and `Conversation` facade for simplified API usage. - Implemented `ExpressionParser` and function resolution logic. - Transport: - Added `A2uiTransportAdapter` and `A2uiParserTransformer` for handling A2UI messages. - Cleanup: - Removed legacy `ContentGenerator`, `UiTools`, and other obsolete core classes. - Deleted documentation and examples that are no longer relevant. - Submodules: - Added `submodules/a2ui`.
1 parent fd7725c commit 546dab9

142 files changed

Lines changed: 10729 additions & 6787 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎packages/genai_primitives/example/main.dart‎

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,22 @@ import 'dart:typed_data';
99

1010
import 'package:genai_primitives/genai_primitives.dart';
1111
import 'package:json_schema_builder/json_schema_builder.dart';
12+
import 'package:logging/logging.dart';
1213

1314
void main({void Function(Object?)? output}) {
14-
void print(Object? object) {
15+
Logger.root.level = Level.ALL;
16+
Logger.root.onRecord.listen((record) {
1517
if (output != null) {
16-
output(object);
18+
output(record.message);
1719
} else {
18-
core.print(object);
20+
// ignore: avoid_print
21+
core.print(record.message);
1922
}
20-
}
23+
});
24+
25+
final log = Logger('GenAIPrimitivesExample');
2126

22-
print('--- GenAI Primitives Example ---');
27+
log.info('--- GenAI Primitives Example ---');
2328

2429
// 1. Define a Tool
2530
final ToolDefinition<Object> getWeatherTool = ToolDefinition(
@@ -39,8 +44,8 @@ void main({void Function(Object?)? output}) {
3944
),
4045
);
4146

42-
print('\n[Tool Definition]');
43-
print(const JsonEncoder.withIndent(' ').convert(getWeatherTool.toJson()));
47+
log.info('\n[Tool Definition]');
48+
log.info(const JsonEncoder.withIndent(' ').convert(getWeatherTool.toJson()));
4449

4550
// 2. Create a conversation history
4651
final history = <ChatMessage>[
@@ -54,9 +59,9 @@ void main({void Function(Object?)? output}) {
5459
ChatMessage.user('What is the weather in London?'),
5560
];
5661

57-
print('\n[Initial Conversation]');
62+
log.info('\n[Initial Conversation]');
5863
for (final msg in history) {
59-
print('${msg.role.name}: ${msg.text}');
64+
log.info('${msg.role.name}: ${msg.text}');
6065
}
6166

6267
// 3. Simulate Model Response with Tool Call
@@ -73,10 +78,10 @@ void main({void Function(Object?)? output}) {
7378
);
7479
history.add(modelResponse);
7580

76-
print('\n[Model Response with Tool Call]');
81+
log.info('\n[Model Response with Tool Call]');
7782
if (modelResponse.hasToolCalls) {
7883
for (final ToolPart call in modelResponse.toolCalls) {
79-
print('Tool Call: ${call.toolName}(${call.arguments})');
84+
log.info('Tool Call: ${call.toolName}(${call.arguments})');
8085
}
8186
}
8287

@@ -93,8 +98,8 @@ void main({void Function(Object?)? output}) {
9398
);
9499
history.add(toolResult);
95100

96-
print('\n[Tool Result]');
97-
print('Result: ${toolResult.toolResults.first.result}');
101+
log.info('\n[Tool Result]');
102+
log.info('Result: ${toolResult.toolResults.first.result}');
98103

99104
// 5. Simulate Final Model Response with Data (e.g. an image generated or
100105
// returned)
@@ -110,19 +115,19 @@ void main({void Function(Object?)? output}) {
110115
);
111116
history.add(finalResponse);
112117

113-
print('\n[Final Model Response with Data]');
114-
print('Text: ${finalResponse.text}');
118+
log.info('\n[Final Model Response with Data]');
119+
log.info('Text: ${finalResponse.text}');
115120
if (finalResponse.parts.any((p) => p is DataPart)) {
116121
final DataPart dataPart = finalResponse.parts.whereType<DataPart>().first;
117-
print(
122+
log.info(
118123
'Attachment: ${dataPart.name} '
119124
'(${dataPart.mimeType}, ${dataPart.bytes.length} bytes)',
120125
);
121126
}
122127

123128
// 6. Demonstrate JSON serialization of the whole history
124-
print('\n[Full History JSON]');
125-
print(
129+
log.info('\n[Full History JSON]');
130+
log.info(
126131
const JsonEncoder.withIndent(
127132
' ',
128133
).convert(history.map((m) => m.toJson()).toList()),

‎packages/genai_primitives/pubspec.yaml‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ homepage: https://github.com/flutter/genui/tree/main/packages/genai_primitives
99
license: BSD-3-Clause
1010
issue_tracker: https://github.com/flutter/genui/issues
1111

12-
# This package is not included in monorepo, because:
13-
# 1. This dependency path requires one of the genui packages to be excluded from monorepo: genui_dartantic --> dartantic_ai --> genai_primitives
14-
# 2. We do not want the community to get new version of primitives with every change of genui
12+
# This package is not included in monorepo to avoid circular dependencies and unrelated updates.
1513

1614
environment:
1715
sdk: ">=3.9.2 <4.0.0"
@@ -20,6 +18,7 @@ dependencies:
2018
collection: ^1.19.1
2119
cross_file: ^0.3.5+1
2220
json_schema_builder: ^0.1.3
21+
logging: ^1.3.0
2322
meta: ^1.17.0
2423
mime: ^2.0.0
2524
path: ^1.9.1

‎packages/genui/.guides/docs/connect_to_agent_provider.md‎

Lines changed: 0 additions & 176 deletions
This file was deleted.

0 commit comments

Comments
 (0)