RagEngine class

Unified RAG engine with simplified initialization.

Wraps SourceRagService with automatic dependency initialization.

Properties

dbPath String
Path to the SQLite database.
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
service SourceRagService
Access to the underlying SourceRagService for advanced operations.
no setter
vocabSize int
Vocabulary size of the loaded tokenizer.
final

Methods

addDocument(String content, {String? metadata, String? filePath, ChunkingStrategy? strategy, void onProgress(int done, int total)?}) Future<SourceAddResult>
Add a document with automatic chunking and embedding.
formatPrompt(String query, RagSearchResult result) String
Format search results as an LLM prompt.
getStats() Future<SourceStats>
Get statistics about stored sources and chunks.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
rebuildIndex() Future<void>
Rebuild the HNSW index after adding documents.
regenerateAllEmbeddings({void onProgress(int done, int total)?}) Future<void>
Regenerate embeddings for all existing chunks.
removeSource(int sourceId) Future<void>
Remove a source and all its chunks from the database.
saveIndex() Future<void>
Save the HNSW index marker to disk.
Search for relevant chunks and assemble context for LLM.
searchHybrid(String query, {int topK = 10, double vectorWeight = 0.5, double bm25Weight = 0.5}) Future<List<HybridSearchResult>>
Hybrid search combining vector and keyword (BM25) search.
searchHybridWithContext(String query, {int topK = 10, int tokenBudget = 2000, ContextStrategy strategy = ContextStrategy.relevanceFirst, double vectorWeight = 0.5, double bm25Weight = 0.5}) Future<RagSearchResult>
Hybrid search with context assembly for LLM.
toString() String
A string representation of this object.
inherited
tryLoadCachedIndex() Future<bool>
Try to load a cached HNSW index from disk.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

dispose() → void
Dispose of resources.
initialize({required RagConfig config, void onProgress(String status)?}) Future<RagEngine>
Initialize RagEngine with all dependencies.