infria 0.1.2
infria: ^0.1.2 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: Feedback 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,infria unlink) 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
Note: The CLI prompts you to enter the Public API Key (
infria_pk_...) generated from your INFRIA Web Console (https://dashinfria.vercel.app/<PROJECT_ID>/sdk).
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 clinicType = args['clinic_type'] as String;
// Call your local backend / hospital SIMRS database
final queueInfo = await HospitalApi.getQueue(clinicType);
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 & Verification #
All components are tested with complete test suites:
flutter test
dart analyze
License #
This project is licensed under the MIT License - see the LICENSE file for details.
Developed by the INFRIA Team - https://infria.dev