Expand description
Β§RRAG - Enterprise Rust RAG Framework
RRAG (Rust RAG) is a high-performance, enterprise-ready framework for building Retrieval-Augmented Generation applications in Rust. Built from the ground up with safety, performance, and developer experience in mind.
Β§π― Why RRAG?
- π Native Performance: Zero-cost abstractions with compile-time optimizations
- π‘οΈ Memory Safety: Rustβs ownership system prevents data races and memory leaks
- β‘ Async First: Built on Tokio for maximum concurrency
- π― Type Safety: Compile-time guarantees eliminate runtime errors
- π Modular Design: Pluggable architecture with swappable components
- π Production Ready: Built-in observability, security, and monitoring
Β§ποΈ Architecture Overview
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Documents βββββΆβ Processing βββββΆβ Vector Store β
β (Input) β β Pipeline β β (Storage) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β
βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Responses ββββββ Agent ββββββ Retriever β
β (Output) β β (rsllm) β β (Search) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββΒ§β‘ Quick Start
Add RRAG to your Cargo.toml:
[dependencies]
rrag = { version = "0.1", features = ["rsllm-client"] }
tokio = { version = "1.0", features = ["full"] }Β§Basic RAG Application
use rrag::prelude::*;
#[tokio::main]
async fn main() -> RragResult<()> {
// Create a RAG system
let rag = RragSystem::builder()
.with_rsllm_client("http://localhost:8080")
.with_vector_store(InMemoryStorage::new())
.with_chunk_size(512)
.build()
.await?;
// Add documents
rag.ingest_documents(vec![
Document::new("Rust is a systems programming language..."),
Document::new("RAG combines retrieval with generation..."),
]).await?;
// Query the system
let response = rag.query("What is Rust?").await?;
println!("Response: {}", response.text);
Ok(())
}Β§π Core Features
Β§π Advanced Retrieval
- Hybrid Search: Combines semantic and keyword search with multiple fusion strategies
- Graph-Based Retrieval: Knowledge graph construction with entity extraction
- Multi-Modal Support: Process text, images, tables, charts, and documents
- Smart Reranking: Cross-encoder models for precise result ranking
Β§π§ Intelligent Agents
- Tool Integration: Built-in calculator, HTTP client, and custom tool support
- Memory Management: Conversation buffers, token limits, and summarization
- Streaming Responses: Real-time token streaming with async iterators
Β§β‘ Performance & Scalability
- Intelligent Caching: Multi-level caching with semantic similarity
- Incremental Indexing: Efficient document updates without full rebuilds
- Batch Processing: High-throughput document ingestion
Β§π Production Features
- Observability Dashboard: Real-time monitoring with web UI and metrics
- Security & Rate Limiting: Authentication, authorization, and abuse prevention
- Health Checks: Component monitoring and dependency tracking
Β§π Documentation
Visit docs.rs/rrag for complete API documentation and examples.
Β§π§ Feature Flags
[dependencies.rrag]
version = "0.1"
features = [
"rsllm-client", # rsllm integration
"http", # HTTP tools and clients
"concurrent", # Concurrent data structures
"multimodal", # Multi-modal processing
"observability", # Monitoring and metrics
"security", # Authentication and rate limiting
]Β§π License
This project is licensed under the MIT License.
Β§π€ Contributing
Contributions welcome! Please see our contributing guidelines for details.
Β§RRAG - Enterprise-Grade Rust RAG Framework
RRAG (Rust RAG) is a comprehensive, high-performance framework for building production-ready Retrieval-Augmented Generation (RAG) applications in Rust.
Designed for enterprise deployments requiring extreme performance, reliability, and observability, RRAG provides everything needed to build, deploy, and maintain sophisticated RAG systems at scale.
Β§π Key Features
- π₯ Native Performance: Zero-cost abstractions with compile-time optimizations
- π‘οΈ Memory Safe: Leverage Rustβs ownership system for bulletproof memory management
- β‘ Async First: Built on Tokio for high-concurrency workloads
- π― Type Safe: Compile-time guarantees prevent runtime errors
- π Pluggable: Modular architecture with swappable components
- π Streaming: Real-time token streaming with async iterators
- π Observable: Built-in metrics, tracing, and health checks
Β§ποΈ Architecture Overview
RRAG follows a modular, pipeline-based architecture that maximizes performance while maintaining flexibility:
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Documents βββββΆβ Processing βββββΆβ Vector Store β
β (Input) β β Pipeline β β (Storage) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β
βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Responses ββββββ Agent ββββββ Retriever β
β (Output) β β (rsllm) β β (Search) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββΒ§π Quick Start
Β§Basic RAG System
use rrag::prelude::*;
#[tokio::main]
async fn main() -> RragResult<()> {
// Create a RAG system
let rag = RragSystemBuilder::new()
.with_name("My RAG System")
.with_environment("development")
.build()
.await?;
// Add documents
let doc = Document::new("Rust is a systems programming language...")
.with_metadata("source", "documentation".into())
.with_content_hash();
rag.process_document(doc).await?;
// Search for relevant content
let results = rag.search("What is Rust?".to_string(), Some(5)).await?;
println!("Found {} results", results.total_results);
Ok(())
}Β§Advanced Agent with Tools
use rrag::prelude::*;
#[tokio::main]
async fn main() -> RragResult<()> {
// Create an agent with tools
let mut agent = AgentBuilder::new()
.with_model("gpt-4")
.with_temperature(0.7)
.with_streaming(true)
.build()
.await?;
// Register tools
agent.register_tool(Calculator::new())?;
agent.register_tool(HttpTool::new())?;
// Chat with memory
let memory = ConversationBufferMemory::new(100);
let response = agent.chat_with_memory(
"Calculate 15 * 23",
&memory
).await?;
println!("Agent: {}", response.text);
Ok(())
}Β§π¦ Feature Flags
RRAG supports multiple feature flags for flexible deployments:
default: Core functionality with HTTP and concurrency supportrsllm-client: Integration with rsllm for LLM operationshttp: HTTP client support for external servicesconcurrent: Advanced concurrency features with DashMapobservability: Metrics, monitoring, and alertingsecurity: Authentication, authorization, and security featuressecurity-full: Complete security suite with 2FA and WebAuthn
[dependencies]
rrag = { version = "0.1", features = ["rsllm-client", "observability", "security"] }Β§ποΈ Module Organization
RRAG is organized into focused modules, each handling specific aspects of RAG functionality:
Β§Core Modules
error: Comprehensive error handling with structured error typesdocument: Document processing, chunking, and metadata managementembeddings: Multi-provider embedding generation and managementstorage: Pluggable storage backends for documents and vectorsmemory: Conversation memory and context managementagent: LLM agents with tool calling and streaming supportpipeline: Composable processing pipelinessystem: High-level system orchestration and lifecycle management
Β§Advanced Modules
retrieval_core: Core retrieval interfaces and implementationsretrieval_enhanced: Advanced hybrid retrieval with BM25 and semantic searchreranking: Result reranking and relevance scoringevaluation: Framework for evaluating RAG system performancecaching: Intelligent caching strategies for performance optimizationgraph_retrieval: Knowledge graph-based retrieval and reasoningincremental: Incremental indexing for large-scale document updatesobservability: Comprehensive monitoring, metrics, and alertingtools: Built-in and extensible tool implementationsstreaming: Real-time streaming response handlingquery: Query processing and optimizationmultimodal: Multi-modal content processing support
Re-exportsΒ§
pub use agent::AgentBuilder;pub use agent::AgentConfig;pub use agent::AgentResponse;pub use agent::ModelConfig;pub use agent::RragAgent;pub use agent::ToolCall;pub use document::ChunkingStrategy;pub use document::Document;pub use document::DocumentChunk;pub use document::DocumentChunker;pub use document::Metadata;pub use embeddings::Embedding;pub use embeddings::EmbeddingBatch;pub use embeddings::EmbeddingProvider;pub use embeddings::EmbeddingRequest;pub use embeddings::EmbeddingService;pub use embeddings::LocalEmbeddingProvider;pub use embeddings::MockEmbeddingService;pub use embeddings::OpenAIEmbeddingProvider;pub use error::ErrorSeverity;pub use error::RragError;pub use error::RragResult;pub use memory::ConversationBufferMemory;pub use memory::ConversationMessage;pub use memory::ConversationSummaryMemory;pub use memory::ConversationTokenBufferMemory;pub use memory::Memory;pub use memory::MemoryService;pub use memory::MessageRole;pub use pipeline::DocumentChunkingStep;pub use pipeline::EmbeddingStep;pub use pipeline::Pipeline;pub use pipeline::PipelineConfig;pub use pipeline::PipelineContext;pub use pipeline::PipelineData;pub use pipeline::PipelineStep;pub use pipeline::RagPipelineBuilder;pub use pipeline::RetrievalStep;pub use pipeline::TextOperation;pub use pipeline::TextPreprocessingStep;pub use retrieval_core::InMemoryRetriever;pub use retrieval_core::RetrievalService;pub use retrieval_core::Retriever;pub use retrieval_core::SearchAlgorithm;pub use retrieval_core::SearchConfig;pub use retrieval_core::SearchQuery;pub use retrieval_core::SearchResult;pub use retrieval_enhanced::BM25Config;pub use retrieval_enhanced::BM25Retriever;pub use retrieval_enhanced::FusionStrategy;pub use retrieval_enhanced::HybridConfig;pub use retrieval_enhanced::HybridRetriever;pub use retrieval_enhanced::RankFusion;pub use retrieval_enhanced::ReciprocalRankFusion;pub use retrieval_enhanced::SemanticConfig;pub use retrieval_enhanced::SemanticRetriever;pub use retrieval_enhanced::TokenizerType;pub use retrieval_enhanced::WeightedFusion;pub use storage::FileStorage;pub use storage::InMemoryStorage;pub use storage::Storage;pub use storage::StorageEntry;pub use storage::StorageKey;pub use storage::StorageQuery;pub use storage::StorageService;pub use streaming::StreamToken;pub use streaming::StreamingResponse;pub use streaming::TokenStreamBuilder;pub use streaming::TokenType;pub use system::ChatResponse;pub use system::HealthCheckResult;pub use system::ProcessingResult;pub use system::RragSystem;pub use system::RragSystemBuilder;pub use system::RragSystemConfig;pub use system::SearchResponse;pub use system::SystemMetrics;pub use tools::HttpTool;httppub use tools::Calculator;pub use tools::EchoTool;pub use tools::Tool;pub use tools::ToolRegistry;pub use tools::ToolResult;pub use graph_retrieval::EdgeType;pub use graph_retrieval::Entity;pub use graph_retrieval::EntityExtractor;pub use graph_retrieval::EntityType;pub use graph_retrieval::ExpansionResult;pub use graph_retrieval::ExpansionStrategy;pub use graph_retrieval::GraphAlgorithms;pub use graph_retrieval::GraphBuildConfig;pub use graph_retrieval::GraphConfig;pub use graph_retrieval::GraphConfigBuilder;pub use graph_retrieval::GraphEdge;pub use graph_retrieval::GraphIndex;pub use graph_retrieval::GraphMetrics;pub use graph_retrieval::GraphNode;pub use graph_retrieval::GraphQuery;pub use graph_retrieval::GraphQueryResult;pub use graph_retrieval::GraphRetrievalBuilder;pub use graph_retrieval::GraphRetrievalConfig;pub use graph_retrieval::GraphRetriever;pub use graph_retrieval::GraphStorage;pub use graph_retrieval::KnowledgeGraph;pub use graph_retrieval::NodeType;pub use graph_retrieval::PageRankConfig;pub use graph_retrieval::PathFindingConfig;pub use graph_retrieval::QueryExpander;pub use graph_retrieval::RelationType;pub use graph_retrieval::Relationship;pub use graph_retrieval::TraversalConfig;pub use incremental::AlertConfig;pub use incremental::BatchConfig;pub use incremental::BatchExecutor;pub use incremental::BatchOperation;pub use incremental::BatchProcessingStats;pub use incremental::BatchProcessor;pub use incremental::BatchResult;pub use incremental::ChangeDetectionConfig;pub use incremental::ChangeDetector;pub use incremental::ChangeResult;pub use incremental::ChangeType;pub use incremental::ConflictResolution;pub use incremental::ConsistencyReport;pub use incremental::ContentDelta;pub use incremental::DocumentChange;pub use incremental::DocumentVersion;pub use incremental::EmbeddingUpdate;pub use incremental::HealthMetrics;pub use incremental::IncrementalIndexManager;pub use incremental::IncrementalIndexingService;pub use incremental::IncrementalMetrics;pub use incremental::IncrementalServiceBuilder;pub use incremental::IncrementalServiceConfig;pub use incremental::IndexManagerConfig;pub use incremental::IndexOperation;pub use incremental::IndexUpdate;pub use incremental::IndexUpdateStrategy;pub use incremental::IndexingStats;pub use incremental::IntegrityChecker;pub use incremental::IntegrityConfig;pub use incremental::IntegrityError;pub use incremental::MetricsCollector;pub use incremental::MonitoringConfig;pub use incremental::OperationLog;pub use incremental::PerformanceTracker;pub use incremental::QueueManager;pub use incremental::RecoveryResult;pub use incremental::RollbackConfig;pub use incremental::RollbackManager;pub use incremental::RollbackOperation;pub use incremental::RollbackPoint;pub use incremental::UpdateResult;pub use incremental::ValidationResult;pub use incremental::VectorBatch;pub use incremental::VectorOperation;pub use incremental::VectorUpdateConfig;pub use incremental::VectorUpdateManager;pub use incremental::VersionConflict;pub use incremental::VersionHistory;pub use incremental::VersionManager;pub use incremental::VersionResolution;pub use incremental::VersioningConfig;pub use observability::AlertCondition;pub use observability::AlertManager;pub use observability::AlertNotification;pub use observability::AlertRule;pub use observability::AlertSeverity;pub use observability::BottleneckAnalysis;pub use observability::ComponentStatus;pub use observability::DashboardConfig;pub use observability::DashboardServer;pub use observability::DataRetention;pub use observability::ExportFormat;pub use observability::ExportManager;pub use observability::HealthChecker;pub use observability::HealthReport;pub use observability::HistoricalAnalyzer;pub use observability::LogAggregator;pub use observability::LogEntry;pub use observability::LogFilter;pub use observability::LogLevel;pub use observability::LogQuery;pub use observability::Metric;pub use observability::MetricType;pub use observability::MetricValue;pub use observability::MetricsCollector as ObsMetricsCollector;pub use observability::MetricsExporter;pub use observability::MetricsRegistry;pub use observability::ObservabilityBuilder;pub use observability::ObservabilityConfig;pub use observability::ObservabilitySystem;pub use observability::PerformanceMonitor;pub use observability::PerformanceReport;pub use observability::ProfileData;pub use observability::Profiler;pub use observability::RealtimeMetrics;pub use observability::ReportGenerator;pub use observability::RetentionPolicy;pub use observability::SearchAnalyzer;pub use observability::SystemMonitor;pub use observability::UserActivityTracker;pub use observability::WebSocketManager;pub use rsllm;rsllm-client
ModulesΒ§
- agent
- RRAG Agent System
- caching
- Intelligent Caching Layer
- document
- RRAG Document Types
- embeddings
- RRAG Embeddings System
- error
- RRAG Error Types
- evaluation
- RRAG Evaluation Framework
- graph_
retrieval - Graph-Based Retrieval Module
- incremental
- Incremental Indexing System for RRAG
- memory
- RRAG Memory System
- multimodal
- Multi-Modal RAG Processing
- observability
- RRAG Observability System
- pipeline
- RRAG Pipeline System
- prelude
- Prelude module for convenient imports
- query
- Query Processing Module
- reranking
- Advanced Reranking Module
- retrieval_
core - RRAG Retrieval System
- retrieval_
enhanced - Enhanced Retrieval Module
- storage
- RRAG Storage System
- streaming
- RRAG Streaming System
- system
- RRAG System Integration
- tools
- RRAG Tools System
MacrosΒ§
- rrag_
tool - Macro for creating simple tools with less boilerplate
ConstantsΒ§
- DESCRIPTION
- Framework description
- LICENSE
- Framework license
- MSRV
- Minimum supported Rust version (MSRV)
- NAME
- Framework name identifier
- REPOSITORY
- Framework repository URL
- VERSION
- Framework constants and metadata