@@ -53,7 +53,7 @@ class GoogleGenerativeAiClient implements AiClient {
5353 /// [apiKey] is the API key to use for authentication.
5454 GoogleGenerativeAiClient ({
5555 required this .catalog,
56- this .systemInstruction,
56+ this .systemInstruction = const [] ,
5757 this .outputToolName = 'provideFinalOutput' ,
5858 this .serviceFactory = defaultGenerativeServiceFactory,
5959 this .additionalTools = const [],
@@ -65,7 +65,7 @@ class GoogleGenerativeAiClient implements AiClient {
6565 final Catalog catalog;
6666
6767 /// The system instruction to use for the AI model.
68- final String ? systemInstruction;
68+ final List < String > systemInstruction;
6969
7070 /// The name of an internal pseudo-tool used to retrieve the final structured
7171 /// output from the AI.
@@ -472,35 +472,19 @@ class GoogleGenerativeAiClient implements AiClient {
472472 var toolUsageCycle = 0 ;
473473 const maxToolUsageCycles = 40 ; // Safety break for tool loops
474474
475- // Build system instruction if provided
476- final parts = < google_ai.Part > [];
477- if (systemInstruction != null ) {
478- parts.add (google_ai.Part (text: systemInstruction));
479- }
480- parts.add (
481- google_ai.Part (
482- text:
483- 'Current Date: '
484- '${DateTime .now ().toIso8601String ().split ('T' ).first }\n '
485- 'You do not have the ability to execute code. If you need to '
486- 'perform calculations, do them yourself.' ,
487- ),
475+ final promptBuilder = PromptBuilder .custom (
476+ catalog: catalog,
477+ systemPromptFragments: systemInstruction,
478+ allowedOperations: SurfaceOperations .createAndUpdate (dataModel: true ),
479+ clientDataModel: clientDataModel,
488480 );
489- parts.add (google_ai.Part (text: BasicCatalogEmbed .basicCatalogRules));
490- final String catalogJson = A2uiMessage .a2uiMessageSchema (
491- catalog,
492- ).toJson (indent: ' ' );
493- if (clientDataModel != null ) {
494- final String dataString = const JsonEncoder .withIndent (
495- ' ' ,
496- ).convert (clientDataModel);
497- parts.add (google_ai.Part (text: 'Client Data Model:\n $dataString ' ));
498- }
499- parts.add (google_ai.Part (text: 'A2UI Message Schema:\n $catalogJson ' ));
500481
501- final systemInstructionContent = parts.isNotEmpty
502- ? [google_ai.Content (role: 'user' , parts: parts)]
503- : < google_ai.Content > [];
482+ final systemInstructionContent = [
483+ google_ai.Content (
484+ role: 'user' ,
485+ parts: [google_ai.Part (text: promptBuilder.systemPromptJoined ())],
486+ ),
487+ ];
504488
505489 while (toolUsageCycle < maxToolUsageCycles) {
506490 if (cancellationSignal? .isCancelled ?? false ) {
0 commit comments