feat(genui): support functions in prompts and verify rendering#921
Open
gspencergoog wants to merge 8 commits into
Open
feat(genui): support functions in prompts and verify rendering#921gspencergoog wants to merge 8 commits into
gspencergoog wants to merge 8 commits into
Conversation
- 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.
Contributor
There was a problem hiding this comment.
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.
- 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.
1a6de3d to
4134cb3
Compare
- 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.
c689ca3 to
1affaab
Compare
- 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #874 and related to #873.