semtree-rag
The RAG pipeline for semtree: index, search, and build LLM context blocks from a codebase.
This is the crate most library users depend on. It ties semtree-parse, semtree-embed, and semtree-store together into an indexer, a search engine, and a context builder, with incremental re-indexing and hybrid (semantic + keyword) retrieval.
Usage
[]
= "0.2"
= "0.2"
= "0.2"
use Arc;
use FastEmbedder;
use UsearchStore;
use ;
async
API
| Item | Purpose |
|---|---|
Indexer |
Parse, embed, and store a directory of source files |
collect_indexable_files |
Enumerate the files an index run would process |
SearchEngine |
Vector similarity search over the store |
HybridSearcher / SearchMode |
Fuse semantic and BM25 lexical rankings via Reciprocal Rank Fusion |
LexicalIndex |
Standalone BM25 keyword index |
ContextBuilder / ContextWindow / ContextSnippet |
Assemble a token-bounded context block for an LLM prompt |
ChunkRegistry |
Map chunk IDs back to their source chunks |
FileManifest |
Per-file content hashes used for incremental indexing |
Search modes
SearchMode selects how a query matches the index:
Hybrid(default): fuses vector similarity and BM25 keyword matching. Catches concepts a grep misses while keeping the exact-identifier precision a pure vector search loses.Semantic: vector similarity only.Lexical: BM25 keyword matching only.
Incremental indexing
Passing a FileManifest to index_dir makes re-runs process only files whose content changed. Persist the manifest alongside the index to keep incremental behavior across runs.
License
MIT
Part of rustkit-ai - open source Rust tools for the AI development era.