Skip to content

feat(genui): support functions in prompts and verify rendering#921

Open
gspencergoog wants to merge 8 commits into
flutter:mainfrom
gspencergoog:add_prompt_functions
Open

feat(genui): support functions in prompts and verify rendering#921
gspencergoog wants to merge 8 commits into
flutter:mainfrom
gspencergoog:add_prompt_functions

Conversation

@gspencergoog
Copy link
Copy Markdown
Collaborator

Description

  • Update PromptBuilder to include available functions in the prompt when present in the catalog.
  • Add a widget test to verify that function output (specifically pluralize) renders correctly.
  • Add a test to verify that PromptBuilder includes the functions section.

Fixes #874 and related to #873.

- Update PromptBuilder to include available functions in the prompt when present in the catalog.
- Add a widget test to verify that function output (specifically pluralize) renders correctly.
- Add a test to verify that PromptBuilder includes the functions section.

Follow-up for flutter#874 and flutter#873.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces logic to include available functions in the system prompt and adds tests for prompt generation and UI rendering of function-based components. Review feedback highlights security risks associated with exposing OpenUrlFunction and RegexFunction to potential prompt injection, recommending URL validation and regex execution timeouts. Additionally, the reviewer suggested refactoring the function serialization logic into a reusable toJson() method to improve maintainability.

Comment thread packages/genui/lib/src/facade/prompt_builder.dart Outdated
Comment thread packages/genui/lib/src/facade/prompt_builder.dart Outdated
- Refactor `PromptBuilder` to load `server_to_client.json` and `common_types.json` as assets and use `$refs` in the generated prompt.
- Make `PromptBuilder` creation asynchronous to support asset loading.
- Fix examples (`composer`, `simple_chat`, `travel_app`) to use the new async API.
- Add mock asset handlers in tests to support loading schemas.
- Update golden files for prompt builder tests.

Resolves flutter#873 and flutter#874.
@gspencergoog gspencergoog force-pushed the add_prompt_functions branch from 1a6de3d to 4134cb3 Compare May 15, 2026 00:16
- Use a `Set` to avoid duplicate entries when generating the `required` list for components in the catalog schema.
- Update golden files to reflect the fix.
- Add mock asset handler to `travel_app` tests to fix failing test.

Follow-up for flutter#873.
@gspencergoog gspencergoog force-pushed the add_prompt_functions branch from c689ca3 to 1affaab Compare May 15, 2026 00:30
- Update `A2uiSchemas` to use `Schema.combined($ref: '...')` for `DynamicString`, `DynamicNumber`, `DynamicBoolean`, `Action`, and `DynamicStringList`.
- Update golden files to reflect the use of refs in the generated prompt.
- Add a new test group for custom components in `prompt_builder_test.dart`.

Follow-up for flutter#873.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Verify that A2UI content using the basic catalog that refers to functions can render correctly

1 participant