traitclaw-rag
RAG pipeline for TraitClaw — Retriever trait, grounding strategies, and BM25 keyword search.
Build Retrieval-Augmented Generation pipelines in Rust with pluggable retrieval backends. Includes a built-in KeywordRetriever with BM25-style scoring so you can get started without any external vector database.
Usage
use ;
// 1. Index documents
let mut retriever = new;
retriever.add;
retriever.add;
// 2. Retrieve relevant documents
let docs = retriever.retrieve.await?;
// 3. Ground context for the agent
let context = PrependStrategy.ground;
// → "Relevant context:\n\n[1] Rust is a systems..."
Architecture
Query → Retriever → Documents → GroundingStrategy → Context → Agent
| Component | Description |
|---|---|
Document |
Content with ID, metadata, and relevance score |
Retriever (trait) |
Pluggable retrieval backend — implement for vector DBs, APIs, etc. |
KeywordRetriever |
Built-in BM25-style keyword matching (no external deps) |
GroundingStrategy (trait) |
Converts retrieved documents into agent context |
PrependStrategy |
Numbers and prepends documents as context |
Custom Retrievers
Implement the Retriever trait for your backend:
License
Licensed under either of Apache License, Version 2.0 or MIT License at your option.