agentic_client 0.0.2
agentic_client: ^0.0.2 copied to clipboard
Dart chat client for rendering A2UI widgets over AGUI protocol
agentic_client #
A drop-in Flutter chat widget for AG-UI-compatible agent backends that renders the agent's generative-UI surfaces (A2UI v0.9) inline using a genui catalog of your own Flutter widgets.
[agentic_client example screenshot]
Features #
- One widget, full chat surface:
AguiChatowns the transport, theSurfaceController, and the conversation log; just give it abaseUrland aCatalog. - Streamed assistant text rendered as chat bubbles with a thinking indicator while a turn is in flight.
- Generative UI inline: A2UI surfaces emitted by the agent (tagged inside
AG-UI
TOOL_CALL_RESULTevents) are unpacked and rendered with the catalog widgets you provide.
Getting started #
Prerequisites:
- Flutter
>=3.35.7(Dart SDK^3.12.2). - An AG-UI-compatible agent endpoint reachable over HTTP. The widget POSTs each
turn to
"$baseUrl/". - A2UI ops from the agent must travel inside
TOOL_CALL_RESULT.contentunder thea2ui_operationsenvelope (the CopilotKit convention).
Add the package to your app's pubspec.yaml:
dependencies:
agentic_client: ^0.0.1
genui: ^0.9.2
Usage #
Build a Catalog of the widgets your agent is allowed to render,
then drop AguiChat into any Scaffold:
import 'package:agentic_client/agentic_client.dart';
import 'package:flutter/material.dart';
import 'package:genui/genui.dart';
class ChatScreen extends StatelessWidget {
const ChatScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Chat')),
body: AguiChat(
baseUrl: 'http://localhost:8123',
catalog: Catalog(
[
BasicCatalogItems.text,
BasicCatalogItems.column,
BasicCatalogItems.row,
// …plus your own CatalogItems
],
catalogId: 'my-app.catalog',
),
catalogDescription: '... optional A2UI prompt context ...',
hintText: 'Ask me anything…',
),
);
}
}
catalogDescription is shipped to the agent on every request via the AG-UI
context field. Use it to teach the model the wire format and the props each
of your components accepts. For fixed-schema backends (where the agent's tool
already knows the catalog), leave it null.
A complete runnable app, including custom ProductCard, WeatherTile and
Stat catalog items, lives in /example. Run it against any
AG-UI agent with:
cd example
flutter run --dart-define=AGENT_URL=http://localhost:8123