Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ed6ad78
All 44 tests still pass. The example app is now complete and ready to…
csells Dec 7, 2025
99303b8
The analysis shows 2 warnings and 56 info-level issues. The warnings …
csells Dec 7, 2025
898cc1d
Done! Here's a summary of the analysis fixes:
csells Dec 7, 2025
e5ad8d6
Done! I've added a VS Code launch configuration for the genui_dartant…
csells Dec 7, 2025
b1c3bb3
Done! Here's a summary of the changes:
csells Dec 7, 2025
c48ed6e
Done! Here's a summary of what was accomplished:
csells Dec 7, 2025
f830fb1
Good question. Looking at the dartantic_ai documentation more careful…
csells Dec 7, 2025
3b7f8b4
Done! Here's a summary of the changes:
csells Dec 7, 2025
79169b4
The dartantic example has been fixed. Here's what was done:
csells Dec 7, 2025
2a5e643
The refactoring is complete. Here's a summary of what changed:
csells Dec 8, 2025
8c069c7
Refactor Dartantic content handling to support multimodal messages
csells Dec 8, 2025
58b558d
Update example project configuration and refactor main application st…
csells Dec 9, 2025
8271ad6
test fixes
csells Dec 9, 2025
cb085de
docs and bug fix
csells Dec 9, 2025
927d131
Update packages/genui_dartantic/example/lib/src/asset_images.dart
csells Dec 9, 2025
9a075a0
Update packages/genui_dartantic/example/lib/src/catalog/date_input_ch…
csells Dec 9, 2025
8229ad6
Update packages/genui_dartantic/example/lib/src/catalog/travel_carous…
csells Dec 9, 2025
bf6a855
Update packages/genui_dartantic/example/lib/src/catalog/itinerary.dart
csells Dec 9, 2025
9a0f479
Update packages/genui_dartantic/example/lib/src/travel_planner_page.dart
csells Dec 9, 2025
e9332de
Update packages/genui_dartantic/example/lib/src/catalog/listings_book…
csells Dec 9, 2025
6da8bf0
fix the gemini review bot fixes
csells Dec 9, 2025
05923e8
formatting
csells Dec 9, 2025
62a326f
copyright
csells Dec 9, 2025
2bb8876
Refactor schema adaptation in Dartantic to use a map to convert from …
csells Dec 9, 2025
66db9b1
formatting
csells Dec 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,5 @@ app.*.map.json
# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
/android/app/release
.vscode/settings.json
16 changes: 14 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
"name": "travel_app",
"cwd": "examples/travel_app",
"request": "launch",
"type": "dart"
"type": "dart",
"args": [
"--dart-define=GEMINI_API_KEY=${env:GEMINI_API_KEY}"
]
},
{
"name": "catalog_gallery",
Expand All @@ -28,6 +31,15 @@
"request": "launch",
"type": "dart"
},
{
"name": "travel_app (dartantic)",
"cwd": "packages/genui_dartantic/example",
"request": "launch",
"type": "dart",
"args": [
"--dart-define=GEMINI_API_KEY=${env:GEMINI_API_KEY}"
]
},
{
"name": "fix_copyright",
"request": "launch",
Expand All @@ -41,4 +53,4 @@
"console": "debugConsole"
}
]
}
}
115 changes: 115 additions & 0 deletions packages/genui_dartantic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# genui_dartantic

This package provides the integration between `genui` and the Dartantic AI
package. It allows you to use multiple AI providers (OpenAI, Anthropic, Google,
Mistral, Cohere, Ollama) to generate dynamic user interfaces in your Flutter
applications.

## Features

- **DartanticContentGenerator:** An implementation of `ContentGenerator` that
uses the dartantic_ai package to connect to various AI providers.
- **Multi-Provider Support:** Use any provider supported by dartantic_ai
including OpenAI, Anthropic, Google, Mistral, Cohere, and Ollama.
- **DartanticContentConverter:** Converts between GenUI `ChatMessage` types and
dartantic_ai `ChatMessage` types.
- **Schema Adaptation:** Converts schemas from `json_schema_builder` to the
`json_schema` format used by dartantic_ai.
- **Additional Tools:** Supports adding custom `AiTool`s to extend the AI's
capabilities via the `additionalTools` parameter.
- **Error Handling:** Exposes an `errorStream` to listen for and handle any
errors during content generation.

## Getting Started

To use this package, you will need to configure API keys for your chosen
provider (see API Keys section below).

Then, you can create an instance of `DartanticContentGenerator` and pass it to
your `GenUiConversation`:

```dart
import 'package:dartantic_ai/dartantic_ai.dart';
import 'package:genui/genui.dart';
import 'package:genui_dartantic/genui_dartantic.dart';

final catalog = CoreCatalogItems.asCatalog();
final genUiManager = GenUiManager(catalog: catalog);

// Example of a custom tool
final myCustomTool = DynamicAiTool<Map<String, Object?>>(
name: 'my_custom_action',
description: 'Performs a custom action.',
parameters: S.object(properties: {
'detail': S.string(),
}),
invokeFunction: (args) async {
print('Custom action called with: $args');
return {'status': 'ok'};
},
);

final contentGenerator = DartanticContentGenerator(
provider: Providers.google, // or Providers.openai, Providers.anthropic, etc.
catalog: catalog,
systemInstruction: 'You are a helpful assistant.',
additionalTools: [myCustomTool],
);

final genUiConversation = GenUiConversation(
genUiManager: genUiManager,
contentGenerator: contentGenerator,
...
);
```

## Supported Providers

The following AI providers are supported through dartantic_ai:

- **Google (Gemini):** `GoogleProvider`
- **OpenAI:** `OpenAIProvider`
- **Anthropic (Claude):** `AnthropicProvider`
- **Mistral:** `MistralProvider`
- **Cohere:** `CohereProvider`
- **Ollama:** `OllamaProvider`

## API Keys

API keys can be configured in dartantic_ai via environment variables:
- `GEMINI_API_KEY` for Google/Gemini
- `OPENAI_API_KEY` for OpenAI
- `ANTHROPIC_API_KEY` for Anthropic
- etc.

## Configuration

You can control which actions the AI is allowed to perform using
`GenUiConfiguration`:

```dart
final contentGenerator = DartanticContentGenerator(
provider: Providers.google,
catalog: catalog,
configuration: const GenUiConfiguration(
actions: ActionsConfig(
allowCreate: true, // Allow creating new UI surfaces
allowUpdate: true, // Allow updating existing surfaces
allowDelete: false, // Disallow deleting surfaces
),
),
);
```

## Notes

- **Stateless Design:** The `DartanticContentGenerator` is stateless and does
not maintain internal conversation history. It uses the `history` parameter
passed to `sendRequest` by `GenUiConversation`, converting GenUI messages to
dartantic format via `DartanticContentConverter`.
- **Image Handling:** Currently, `ImagePart`s provided with only a `url`
(without `bytes` or `base64` data) will be sent to the model as a text
description of the URL, as the image data is not automatically fetched by the
converter.
- **Structured Output:** Uses dartantic_ai's built-in support for structured
output with JSON schemas, which works with tool calling across all providers.
45 changes: 45 additions & 0 deletions packages/genui_dartantic/example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.build/
.buildlog/
.history
.svn/
.swiftpm/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins-dependencies
.pub-cache/
.pub/
/build/
/coverage/

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
8 changes: 8 additions & 0 deletions packages/genui_dartantic/example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright 2025 The Flutter Authors.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

include: package:flutter_lints/flutter.yaml
analyzer:
errors:
strict_top_level_inference: ignore
29 changes: 29 additions & 0 deletions packages/genui_dartantic/example/assets/booking_service/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Hotel Image Generation Prompts

This document contains the prompts used to generate images for the fictional "Dart Inn" and "Grand Flutter Hotel" for the travel app.

## The Dart Inn

### Core Prompt

A beautiful, modern hotel named **'The Dart Inn'**. It features sleek, minimalist architecture with sharp, clean lines. The building has a subtle color palette of deep blues and teals, inspired by the Dart language logo, with glowing white accents. The scene is at dusk, with warm interior lights contrasting the cool exterior tones, creating a professional and inviting atmosphere.

### Style & Format

- **Style:** Photorealistic, high-resolution, architectural photography.
- **Inspiration:** Use the Dart language logo for color and style inspiration.
- **Application:** The image is for a mobile app. Details should be clear but not overly complex, with the hotel name and any logos being large and easily visible.
- **Format:** 1:1 aspect ratio.

## The Grand Flutter Hotel

### Core Prompt

A stunning, vibrant hotel called **'The Grand Flutter Hotel'**. The architecture is expressive and fluid, with graceful curves and beautiful, layered balconies. The hotel is adorned with the bright, friendly blue of the Flutter logo, and its facade features a dynamic, colorful light display. The setting is a bright, sunny day, making the hotel look welcoming and full of creative energy.

### Style & Format

- **Style:** Photorealistic, high-resolution, capturing a feeling of beauty and innovation.
- **Inspiration:** Use the Flutter logo for color and style inspiration.
- **Application:** The image is for a mobile app. Details should be clear but not overly complex, with the hotel name and any logos being large and easily visible.
- **Format:** 1:1 aspect ratio.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This folder contains prompt images for the assets generation.
It should not be included into the section `assets` in pubspec.yaml.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading