Skip to main content

Crate traitclaw_rag

Crate traitclaw_rag 

Source
Expand description

RAG (Retrieval-Augmented Generation) pipeline for the TraitClaw AI agent framework.

Provides a Retriever trait, grounding strategies, and a built-in KeywordRetriever with BM25-style scoring for text search.

§Quick Start

use traitclaw_rag::{Document, KeywordRetriever, Retriever, GroundingStrategy, PrependStrategy};

let mut retriever = KeywordRetriever::new();
retriever.add(Document::new("doc1", "Rust is a systems programming language"));
retriever.add(Document::new("doc2", "Python is great for AI"));

let docs = retriever.retrieve("Rust systems", 5).await?;
assert!(!docs.is_empty());

let strategy = PrependStrategy;
let context = strategy.ground(&docs);
assert!(context.contains("Rust"));

Re-exports§

pub use chunker::Chunker;
pub use chunker::FixedSizeChunker;
pub use chunker::RecursiveChunker;
pub use chunker::SentenceChunker;
pub use embedding::EmbeddingProvider;
pub use embedding::EmbeddingRetriever;
pub use hybrid::CitationStrategy;
pub use hybrid::ContextWindowStrategy;
pub use hybrid::HybridRetriever;
pub use rag_context::RagContextManager;

Modules§

chunker
Document chunking strategies for RAG pipelines.
embedding
Embedding-based vector retrieval for RAG pipelines.
hybrid
Hybrid retrieval combining keyword and embedding-based search.
rag_context
RagContextManager — automatic document retrieval and injection.

Structs§

Document
A document for retrieval.
KeywordRetriever
BM25-style keyword retriever for in-memory text search.
PrependStrategy
Simple grounding strategy that prepends documents as numbered context.

Traits§

GroundingStrategy
Strategy for grounding agent context with retrieved documents.
Retriever
Trait for document retrieval.