flutter_rag 0.1.0
flutter_rag: ^0.1.0 copied to clipboard
A pure Dart Retrieval-Augmented Generation (RAG) engine for Flutter apps. Supports document ingestion, vector search, and LLM integration for building AI knowledge chatbots.
flutter_rag #
GitHub Repository
A pure Dart Retrieval‑Augmented Generation (RAG) engine for Flutter applications. It provides document ingestion, chunking, vector search, and seamless integration with OpenAI LLMs to build powerful AI‑assisted chatbots and knowledge bases.
Features #

- Document loaders for PDF, CSV, Excel, and plain text.
- Recursive chunk splitter with configurable size and overlap.
- In‑memory vector store (with optional persistence adapters).
- OpenAI embeddings & LLM integration out of the box.
- Typed API for adding documents, querying, and retrieving answers.
- Zero external native dependencies – works on Android, iOS, Web, and Desktop.
Installation #
Add the package to your pubspec.yaml:
dependencies:
flutter_rag: ^0.1.0
Then run:
flutter pub get
Quick Start #
import 'package:flutter_rag/flutter_rag.dart';
void main() async {
const apiKey = String.fromEnvironment('OPENAI_API_KEY');
final rag = FlutterRag(
apiKey: apiKey,
chunkSize: 500,
chunkOverlap: 50,
);
await rag.addDocument(PdfLoader('assets/knowledge.pdf'));
final answer = await rag.ask('What are the main benefits of RAG?');
print('Answer: $answer');
}
The example in example/lib/main.dart demonstrates a full UI that lets users upload PDFs/CSVs, view status, and chat with the engine.
API Overview #
| Class / Function | Description |
|---|---|
FlutterRag |
Core engine – configure embeddings, LLM, chunking, and vector store. |
PdfLoader, CsvLoader, ExcelLoader |
Helpers to read common document formats and return a list of Document objects. |
RecursiveCharacterTextSplitter |
Splits large texts into overlapping chunks for better retrieval. |
VectorStoreRetriever |
Retrieves the top‑k most similar chunks from the vector store. |
RagEngine.invoke(String query) |
Executes the full RAG pipeline (retrieval → LLM) and returns an Answer object. |
Contributing #
Contributions are welcome! Please:
- Fork the repository.
- Create a feature branch (
git checkout -b feature/awesome‑feature). - Write tests and run
flutter test. - Submit a pull request.
Make sure to follow the existing code style and run dart format . before committing.
Maintainer #
👨💻 Project Maintainer #
Md. Hamid Hosen
Associate Software Engineer @P2M Soft
GitHub Profile | Contributions
License #
This project is licensed under the MIT License – see the LICENSE file for details.
Publishing to pub.dev #
When you are ready to release a new version:
- Update the version in
pubspec.yaml(e.g.,version: 0.2.0). - Run
dart pub publish --dry-runto verify the package. - Fix any warnings or missing assets.
- Execute
dart pub publishand follow the prompts.
Make sure your README.md and CHANGELOG.md are up‑to‑date before publishing.
