Skip to main content

Crate lc_rag

Crate lc_rag 

Source
Expand description

RAG (Retrieval-Augmented Generation) module for LangChainRust.

Provides document loaders, text splitters, retrievers, BM25 search, hybrid retrieval, GraphRAG, HyDE, multi-query, reranking, multimodal (image+text) retrieval, and a full RAG pipeline builder.

Re-exports§

pub use adapter::RagRunnable;
pub use contextual::ContextualConfig;
pub use contextual::ContextualEnhancer;
pub use contextual::ContextualError;
pub use contextual::CONTEXTUAL_METADATA_KEY;
pub use parent_document::ParentDocumentRetriever;
pub use pipeline::RAGPipeline;
pub use pipeline::RAGPipelineBuilder;
pub use pipeline::RAGQueryResult;
pub use retriever_runnable::RetrieverRunnable;
pub use loaders::CSVLoader;
pub use loaders::DocumentLoader;
pub use loaders::DocxLoader;
pub use loaders::HTMLLoader;
pub use loaders::JSONLoader;
pub use loaders::LoaderError;
pub use loaders::MarkdownLoader;
pub use loaders::PDFLoader;
pub use loaders::SitemapLoader;
pub use loaders::TextLoader;
pub use loaders::WebScraperLoader;
pub use retriever::Retriever;
pub use retriever::RetrieverError;
pub use retriever::RetrieverTrait;
pub use retriever::SimilarityRetriever;
pub use self_query::SelfQueryArgs;
pub use self_query::SelfQueryRetriever;
pub use semantic_cache::CacheHitKind;
pub use semantic_cache::CachedRetriever;
pub use semantic_cache::SemanticCacheConfig;
pub use semantic_cache::SemanticCacheCore;
pub use semantic_splitter::SemanticSplitter;
pub use bm25::AutoMergingConfig;
pub use bm25::BM25Params;
pub use bm25::BM25Retriever;
pub use bm25::ChunkedBM25Retriever;
pub use bm25::ChunkedSearchResult;
pub use bm25::Tokenizer;
pub use hybrid::filter_by_score;
pub use hybrid::reciprocal_rank_fusion;
pub use hybrid::RetrievalSource;
pub use hybrid::RetrievedDocument;
pub use unified_hybrid::HybridIndexConfig;
pub use unified_hybrid::HybridSearchResult;
pub use unified_hybrid::UnifiedHybridIndex;
pub use multi_query::MultiQueryConfig;
pub use multi_query::MultiQueryError;
pub use multi_query::MultiQueryRetriever;
pub use multi_query::StaticQueryGenerator;
pub use multimodal::ImageAsset;
pub use multimodal::MediaBlock;
pub use multimodal::ModalityFilter;
pub use multimodal::MultimodalChunkConfig;
pub use multimodal::MultimodalChunker;
pub use multimodal::MultimodalRetriever;
pub use multimodal::MM_CAPTION_KEY;
pub use multimodal::MM_KIND_IMAGE;
pub use multimodal::MM_KIND_KEY;
pub use multimodal::MM_KIND_TEXT;
pub use multimodal::MM_MIME_KEY;
pub use multimodal::MM_URL_KEY;
pub use hyde::HyDEConfig;
pub use hyde::HyDEError;
pub use hyde::HyDERetriever;
pub use late_chunking::late_chunk;
pub use late_chunking::pool_tokens;
pub use late_chunking::LateChunk;
pub use late_chunking::LateChunkConfig;
pub use reranking::BM25Reranker;
pub use reranking::KeywordReranker;
pub use reranking::Reranker;
pub use reranking::RerankingConfig;
pub use reranking::RerankingError;
pub use reranking::RerankingExecutor;
pub use graph_rag::Community as GraphCommunity;
pub use graph_rag::Entity as GraphEntity;
pub use graph_rag::GraphStore;
pub use graph_rag::Relation as GraphRelation;
pub use graph_rag::GlobalLevel;
pub use graph_rag::GraphRAG;
pub use graph_rag::GraphRAGConfig;
pub use graph_rag::GraphRAGError;
pub use graph_rag::GraphRAGResult;
pub use graph_rag::QueryMode;

Modules§

adapter
RagRunnable adapter - bridges RAGPipeline to the Runnable trait.
bm25
BM25 retrieval module
contextual
Contextual Retrieval: index-time context injection for chunks (0.21.0 S4.1).
graph_rag
GraphRAG (Knowledge Graph RAG) module.
hybrid
Hybrid retrieval module
hyde
HyDE (Hypothetical Document Embedding) Retriever implementation
late_chunking
Late chunking: embed the whole document token by token first, then pool along chunk boundaries (0.21.0 S5.2).
loaders
Document loader implementations
multi_query
MultiQueryRetriever implementation
multimodal
Multimodal (image + text) chunking and retrieval (B7, v0.22.4).
parent_document
ParentDocumentRetriever — a parent/child document retriever
pipeline
RAGPipeline & RAGPipelineBuilder — a complete RAG pipeline in one line
reranking
Reranking implementation
retriever
Retriever implementations
retriever_runnable
RetrieverRunnable — a Runnable adapter to bring any retriever into an LCEL chain
self_query
SelfQueryRetriever — a self-querying retriever
semantic_cache
Semantic cache for retrieval results (0.21.0 S4.2).
semantic_splitter
Semantic chunking
splitter
Text splitter implementation
unified_hybrid
Unified Hybrid Index

Structs§

ChunkDocument
Chunk document (split document fragment).
ChunkedVectorStore
Chunked Vector Store
Document
Document structure.
InMemoryDocumentStore
In-memory document store
InMemoryVectorStore
In-memory vector store
MockEmbeddings
Mock embeddings for testing purposes.
OpenAIEmbeddings
OpenAI Embeddings client
RecursiveCharacterSplitter
Recursive character splitter
SearchResult
Search result.

Enums§

EmbeddingError
Embedding error type
ImageInput
Provider-neutral image input for vision embedding models.
VectorStoreError
Vector store error types.

Traits§

ChunkedDocumentStoreTrait
Document store trait supporting a parent-child structure
DocumentStore
Document store trait
Embeddings
Embedding model trait
TextSplitter
Text splitter trait
VectorStore
Vector store trait.
VisionEmbeddings
Cross-modal embedding model: images and text mapped to one shared space.

Functions§

cosine_similarity
Compute cosine similarity between two vectors.

Type Aliases§

ChunkedDocumentStore
Type alias for InMemoryChunkedDocumentStore