infria 0.1.1
infria: ^0.1.1 copied to clipboard
A clean, customizable Flutter UI SDK and runtime controller for AI chat interfaces, RAG, and dynamic client-side function calling.
INFRIA Flutter SDK #
INFRIA is a complete AI Infrastructure SDK and conversational UI suite for Flutter applications. It enables seamless integration of RAG (Retrieval-Augmented Generation) knowledge bases and Dynamic Client-Side Function Calling (Tool Use) directly into your mobile apps without managing complex AI pipelines or exposing private LLM API keys.
๐ Key Features #
- ๐ฌ Ready-to-Use Inclusive Chat UI (
InfriaChat): Modern, customizable chat interface supporting Light/Dark themes, avatar customization, typing indicator animations, auto-scrolling, and responsive layouts. - โก Dynamic Client-Side Function Calling: Cloud LLMs can securely request and execute native functions on the mobile device (e.g., querying local hospital SIMRS APIs, retrieving GPS coordinates, accessing device sensors, local SQLite data) with automated round-trip response orchestration.
- ๐ BYOK (Bring Your Own Key) Security: Private LLM keys (Gemini / OpenAI) and cloud vector databases remain encrypted on the server side โ never embedded in the mobile client.
- ๐ก Inclusive UX Design:
- Suggestion Chips: Quick action & contextual question buttons above the input bar.
- Function Execution Indicator: Visual status indicators while the device executes local handlers.
- Confirmation Dialog: Built-in confirmation modals for sensitive client actions.
- User Feedback Loop: Thumbs up/down rating bars (๐ / ๐) to track answer quality and detect knowledge gaps.
- ๐ Session Management: Isolated conversation session handling with auto-generated UUIDs.
- ๐จ Flexible Presentation Modes: Fullscreen views, Modal Bottom Sheets (
showInfriaChatBottomSheet), Dialog overlays (showInfriaChatDialog), and Floating Action Buttons (InfriaChatFloatingButton). - ๐ ๏ธ Developer Tooling (CLI): Dedicated CLI tool (
infria login,infria init,infria current,infria use) with official Google Sign-In and automated options generation.
๐๏ธ Architecture Overview #
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Flutter Client Application โ
โ - InfriaSDK & DefaultInfriaOptions โ
โ - ChatController & InfriaChat UI โ
โ - FunctionRegistry & FunctionExecutor (On-Device) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ HTTPS / WSS / SSE (/v1/runtime/chat)
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ INFRIA RUNTIME GATEWAY โ
โ - Firebase Cloud Functions & Multi-Tenant Gateway โ
โ - Firestore & Encrypted Secret Vault (BYOK Keys) โ
โ - RAG Vector Knowledge Retrieval & Search Engine โ
โ - LLM Orchestrator (Google Gemini / OpenAI) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Quickstart Guide #
1. Installation #
Add infria to your pubspec.yaml dependencies:
flutter pub add infria
Install the INFRIA CLI globally:
dart pub global activate infria
2. Configure Your Project via CLI #
Sign in with your Google account and link your AI project:
# Authenticate with Google
infria login
# Link your active INFRIA project (generates lib/infria_options.dart)
infria init
3. Initialize in lib/main.dart #
import 'package:flutter/material.dart';
import 'package:infria/infria.dart';
import 'infria_options.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Initialize INFRIA SDK (Developer experience similar to FlutterFire)
await InfriaSDK.initializeApp(
options: DefaultInfriaOptions.currentPlatform,
);
runApp(const MyApp());
}
4. Register Client-Side Functions (Tool Calling) #
Register Dart handlers that the cloud AI can dynamically invoke:
// Example: Registering a queue check function
InfriaSDK.onFunctionCall(
'check_queue_status',
(Map<String, dynamic> args) async {
final poliType = args['poli_type'] as String;
// Call your local backend / hospital SIMRS database
final queueInfo = await HospitalApi.getQueue(poliType);
return {
'current_number': queueInfo.current,
'patient_number': queueInfo.patient,
'remaining': queueInfo.remaining,
};
},
);
5. Display the Chat Interface #
class ChatScreen extends StatefulWidget {
const ChatScreen({super.key});
@override
State<ChatScreen> createState() => _ChatScreenState();
}
class _ChatScreenState extends State<ChatScreen> {
late final ChatController _controller;
@override
void initState() {
super.initState();
// Auto-binds to the initialized InfriaSDK instance
_controller = ChatController();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('AI Health Assistant')),
body: InfriaChat(
controller: _controller,
title: 'Hospital Assistant',
theme: InfriaChatTheme.light(),
suggestions: const [
'๐ฉบ Check Queue Status',
'๐
Specialist Doctor Schedule',
'๐ Insurance Referral Info',
],
enableFeedback: true,
onFeedback: (messageId, isHelpful, reason) {
debugPrint('Feedback for $messageId: $isHelpful ($reason)');
},
),
);
}
}
๐จ Presentation Overlays #
Modal Bottom Sheet #
showInfriaChatBottomSheet(
context: context,
controller: _controller,
title: 'AI Support',
theme: InfriaChatTheme.dark(),
);
Floating Action Button #
Scaffold(
body: const HomeScreen(),
floatingActionButton: InfriaChatFloatingButton(
controller: _controller,
title: 'Ask AI',
showBadge: true,
),
);
๐ ๏ธ CLI Commands Reference #
| Command | Description |
|---|---|
infria login |
Sign in to INFRIA Web Console via Google Authentication. |
infria init |
Interactive project selector & generates lib/infria_options.dart. |
infria current |
Inspect active developer session & currently configured project. |
infria use <id> |
Switch the active project in lib/infria_options.dart instantly. |
infria unlink |
Remove active project configuration from this workspace. |
infria projects |
List all AI projects associated with your authenticated account. |
infria logout |
Sign out and remove local credentials. |
๐งช Testing & Reliability #
All components are rigorously tested with 100% test pass rate:
flutter test
dart analyze
๐ License #
This project is licensed under the MIT License โ see the LICENSE file for details.
Developed with โค๏ธ by the INFRIA Team โข https://infria.dev