services/rag_engine library

Unified RAG engine with simplified initialization.

This class combines tokenizer, embedding model, and RAG service initialization into a single initialize() call.

Quick Start

import 'package:mobile_rag_engine/mobile_rag_engine.dart';

// NOTE: For most apps, use [MobileRag] singleton instead.
// It wraps this class and handles global access.

// If you need a standalone engine instance:
final rag = await RagEngine.initialize(
  config: RagConfig.fromAssets(
    tokenizerAsset: 'assets/tokenizer.json',
    modelAsset: 'assets/model.onnx',
  ),
);

// Use the engine
await rag.addDocument('Your document text here');
await rag.rebuildIndex();
final result = await rag.search('query', tokenBudget: 2000);

Classes

ClearAndRestartConfirmation
Typed acknowledgment that the caller understands clearAndRestart deletes every on-device embedding BLOB. Required as an explicit parameter so the destructive choice is visible at every call site.
RagEmbeddingFingerprintLock
Snapshot of an active embedding fingerprint mismatch.
RagEngine
Unified RAG engine with simplified initialization.
RagReembedProgress
Progress event emitted during reembedAll(progress:).