-
Notifications
You must be signed in to change notification settings - Fork 99
Should Move project to 160 of 160 points - uses simple_chat as project example. #629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hunterino
wants to merge
4
commits into
flutter:main
Choose a base branch
from
tps-reports:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| # Examples | ||
|
|
||
| This directory contains example applications demonstrating the `genui` SDK capabilities. | ||
|
|
||
| ## Overview | ||
|
|
||
| | Example | Complexity | Backend | Description | | ||
| |---------|------------|---------|-------------| | ||
| | [catalog_gallery](#catalog_gallery) | Simple | None | Visual reference for core catalog widgets | | ||
| | [custom_backend](#custom_backend) | Intermediate | Custom/Saved | Demonstrates custom backend integration | | ||
| | [travel_app](#travel_app) | Advanced | Firebase/Google AI | Full travel planning assistant with custom catalog | | ||
| | [verdure](#verdure) | Advanced | Python A2A Server | Full-stack landscape design agent | | ||
|
|
||
| ## Running Examples | ||
|
|
||
| Most examples support multiple AI backends. The default is typically Google Generative AI which requires an API key: | ||
|
|
||
| ```bash | ||
| # Get API key from https://aistudio.google.com/app/apikey | ||
| flutter run --dart-define=GEMINI_API_KEY=YOUR_API_KEY | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## catalog_gallery | ||
|
|
||
| A developer tool for visualizing and testing the core widget catalog. Displays all available `CoreCatalogItems` widgets and allows interaction testing. | ||
|
|
||
| **Key Features:** | ||
| - Browse all core catalog widgets | ||
| - Interactive widget testing with event logging | ||
| - Sample file loading support | ||
|
|
||
| **Run:** | ||
| ```bash | ||
| cd examples/catalog_gallery | ||
| flutter run | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## custom_backend | ||
|
|
||
| Demonstrates integrating genui with a custom backend without using predefined provider packages (`genui_firebase_ai`, `genui_google_generative_ai`). | ||
|
|
||
| **Key Features:** | ||
| - Direct integration with `A2uiMessageProcessor` | ||
| - Manual tool call parsing and handling | ||
| - Saved response testing for development without API calls | ||
| - Shows how to build `UiSchemaDefinition` and `catalogToFunctionDeclaration` | ||
|
|
||
| **Key Files:** | ||
| - `lib/backend.dart` - Custom backend implementation | ||
| - `lib/gemini_client.dart` - Direct Gemini API client | ||
| - `assets/data/saved-response-*.json` - Pre-recorded responses for testing | ||
|
|
||
| **Run:** | ||
| ```bash | ||
| cd examples/custom_backend | ||
| flutter run --dart-define=GEMINI_API_KEY=YOUR_API_KEY | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## travel_app | ||
|
|
||
| A full-featured travel planning assistant demonstrating advanced genui capabilities with a custom domain-specific widget catalog. | ||
|
|
||
| **Key Features:** | ||
| - Custom widget catalog with travel-specific components (carousel, itinerary, filter chips) | ||
| - Tool use (`ListHotelsTool` for fetching hotel data) | ||
| - System prompt engineering for AI behavior | ||
| - Dynamic UI generation based on conversation | ||
| - Supports Firebase AI and Google Generative AI backends | ||
|
|
||
| **Key Files:** | ||
| - `lib/src/catalog.dart` - Custom travel widgets catalog | ||
| - `lib/src/catalog/` - Individual widget implementations | ||
| - `lib/src/travel_planner_page.dart` - Main page with system prompt | ||
| - `lib/src/tools/booking/` - AI tool implementations | ||
| - `lib/src/config/configuration.dart` - Backend configuration | ||
|
|
||
| **Custom Widgets:** | ||
| - `TravelCarousel` - Image carousel for destinations | ||
| - `OptionsFilterChipInput` / `CheckboxFilterChipsInput` - User preference inputs | ||
| - `Itinerary` / `ItineraryEntry` - Trip planning display | ||
| - `ListingsBooker` - Hotel booking interface | ||
| - `Trailhead` - Suggested follow-up questions | ||
| - `TabbedSections` - Tabbed content display | ||
|
|
||
| **Run:** | ||
| ```bash | ||
| cd examples/travel_app | ||
| flutter run --dart-define=GEMINI_API_KEY=YOUR_API_KEY | ||
| ``` | ||
|
|
||
| **Switch to Firebase:** | ||
| 1. Edit `lib/src/config/configuration.dart`: set `aiBackend = AiBackend.firebase` | ||
| 2. Uncomment Firebase imports in `lib/main.dart` | ||
| 3. Run `flutterfire configure` to generate Firebase options | ||
|
|
||
| --- | ||
|
|
||
| ## verdure | ||
|
|
||
| A full-stack example with a Python server and Flutter client demonstrating the A2A (Agent-to-Agent) protocol for landscape design. | ||
|
|
||
| **Prerequisites:** | ||
| - Python 3.13+ | ||
| - [UV](https://docs.astral.sh/uv/) package manager | ||
| - Gemini API key | ||
|
|
||
| **Architecture:** | ||
| ``` | ||
| verdure/ | ||
| ├── server/ # Python A2A server | ||
| │ └── verdure/ # Agent implementation | ||
| └── client/ # Flutter client app | ||
| ``` | ||
|
|
||
| **Run Server:** | ||
| ```bash | ||
| cd examples/verdure/server/verdure | ||
| echo "GEMINI_API_KEY=YOUR_API_KEY" > .env | ||
| uv run . | ||
| # Server starts on http://localhost:10002 | ||
| ``` | ||
|
|
||
| **Run Client:** | ||
| ```bash | ||
| cd examples/verdure/client | ||
| flutter run | ||
| ``` | ||
|
|
||
| **Android Emulator:** | ||
| The emulator uses `10.0.2.2` as localhost alias. Start server with: | ||
| ```bash | ||
| uv run . --base-url="http://10.0.2.2:10002" | ||
| ``` | ||
|
|
||
| **Key Files:** | ||
| - `server/verdure/agent.py` - AI agent logic | ||
| - `server/verdure/a2ui_schema.py` - A2UI protocol schema | ||
| - `client/lib/features/ai/ai_provider.dart` - Client AI integration | ||
|
|
||
| --- | ||
|
|
||
| ## Choosing an Example | ||
|
|
||
| | Goal | Recommended Example | | ||
| |------|---------------------| | ||
| | Understand core widgets | `catalog_gallery` | | ||
| | Build custom backend integration | `custom_backend` | | ||
| | Build a production-like app with custom catalog | `travel_app` | | ||
| | Implement client-server architecture with A2A | `verdure` | | ||
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
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
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.