xz-rag 0.1.1

Multi-channel Retrieval-Augmented Generation engine
Documentation
#![warn(missing_docs)]

//! Multi-channel Retrieval-Augmented Generation (RAG) engine.
//!
//! `xz-rag` provides a composable RAG engine with multiple retrieval channels
//! (semantic, BM25, metadata, graph), result fusion (RRF), context window
//! management, query preprocessing (HYDE, expansion), and optional LLM generation.
//!
//! # Architecture
//!
//! - **Engine**: [`DefaultRagEngine`] coordinating retrieval, fusion, and generation
//! - **Channels**: `semantic`, `bm25`, `metadata`, `graph` retrieval backends
//! - **Pipeline**: Channel orchestration with RRF fusion and score normalization
//! - **Context**: Token budget management and citation formatting
//! - **Indexing**: Document chunking strategies (fixed, recursive, separator-based)
//! - **Caching**: Optional in-memory result caching via `moka`
//! - **Generation**: LLM integration via `xz-provider` (feature-gated)

/// Retrieval channel implementations (semantic, BM25, metadata, graph).
pub mod channels;

/// Context assembly: token budget management and citation formatting.
pub mod context;

/// Default RAG engine implementation.
pub mod engine;

/// RAG error types.
pub mod error;

/// LLM generation integration.
pub mod generation;

/// Document indexing and chunking strategies.
pub mod indexing;

/// Multi-channel pipeline orchestration.
pub mod pipeline;

/// Query preprocessing (HYDE, expansion).
pub mod preprocessing;

/// Core trait definitions.
pub mod traits;

/// Shared type definitions.
pub mod types;

/// In-memory result caching.
pub mod cache;

// Re-exports
pub use engine::{DefaultRagEngine, DefaultRagEngineBuilder};
pub use error::RagError;
pub use traits::RagEngine;
pub use types::chunk::{Chunk, ChunkMetadata};
pub use types::config::{RagConfig, RagEngineInfo};
pub use types::rag::{
    BuiltContext, ChatMessage, ChatRole, Citation, CitationFormat, ContextConfig, PromptTemplate,
    RagGenerationConfig, RagRequest, RagRequestBuilder, RagResponse, RagStreamEvent, RagTokenUsage,
    RequestOptions,
};
pub use types::retrieval::{
    ChannelStats, QueryPreprocessing, RetrieveRequest, RetrieveRequestBuilder, RetrieveResult,
    RetrievedChunk, StructuredFilter,
};

// Pipeline re-exports
pub use pipeline::channel::{ChannelConfig, ChannelPipeline, ChannelType};
pub use pipeline::fusion::RrfFusion;
pub use pipeline::normalize::{MinMaxNormalizer, ZScoreNormalizer};

// Context re-exports
pub use context::citation::format_citations_numeric;
pub use context::token_budget::ContextBuilder;

// Indexing re-exports
pub use indexing::chunker::ChunkStrategy;
pub use indexing::chunker::fixed::FixedSizeChunker;
pub use indexing::chunker::recursive::RecursiveCharacterChunker;
pub use indexing::chunker::semantic::SeparatorChunker;
pub use indexing::{DocumentIndexer, IndexDocument};

// Channel re-exports
#[cfg(feature = "bm25")]
pub use channels::bm25::Bm25ChannelExecutor;
pub use channels::graph::{GraphChannelExecutor, KnowledgeGraphSearch};
pub use channels::metadata::{MetadataChannelExecutor, MetadataStore};
pub use channels::semantic::{Embedder, SemanticChannelExecutor, SemanticSearch};