Skip to main content

docling_rag/
lib.rs

1//! `docling-rag`: a pluggable Retrieval-Augmented-Generation subsystem built on
2//! the [`docling.rs`](https://crates.io/crates/docling.rs) document converter.
3//!
4//! The pipeline is: **source → convert to Markdown → chunk → embed → vector store →
5//! retrieve → (optionally) synthesize an answer**. Every external dependency is a
6//! trait with swappable backends:
7//!
8//! - **Embedders** ([`embed`]): Ollama (default), Gemini, local ONNX, or a
9//!   deterministic hashing embedder for offline tests.
10//! - **Vector stores** ([`store`]): SQLite (default), PostgreSQL + pgvector, or
11//!   in-memory. Documents and chunks live in separate tables.
12//! - **Retrieval** ([`retrieve`]): dense vector, sparse BM25, Hybrid (RRF),
13//!   Multi-Query fusion, and HyDE.
14//! - **LLM** ([`llm`]): OpenRouter (default model DeepSeek-V3).
15//! - **Sources** ([`source`]): local folder (default), FTP, SFTP.
16//! - **Queues** ([`queue`]): in-process, RabbitMQ, Redis pub/sub.
17//!
18//! Configuration comes from the environment / a `.env` file via [`RagConfig`].
19//!
20//! ```no_run
21//! use docling_rag::{RagConfig, Pipeline, RetrievalMode};
22//!
23//! # async fn run() -> docling_rag::Result<()> {
24//! let cfg = RagConfig::from_env()?;
25//! let pipeline = Pipeline::from_config(&cfg).await?;
26//! pipeline.ingest_all().await?;
27//! let hits = pipeline.query(RetrievalMode::Hybrid, "how does chunking work?", 5).await?;
28//! for h in hits {
29//!     println!("{:.3}  {}", h.score, h.chunk.text);
30//! }
31//! # Ok(()) }
32//! ```
33
34pub mod api;
35pub mod chunk;
36pub mod config;
37pub mod embed;
38pub mod error;
39pub mod eval;
40pub mod llm;
41pub mod math;
42pub mod metrics;
43pub mod model;
44pub mod pipeline;
45pub mod queue;
46pub mod retrieve;
47pub mod source;
48pub mod store;
49
50pub use config::RagConfig;
51pub use error::{RagError, Result};
52pub use model::{Chunk, Document, RetrievalMode, Scored};
53pub use pipeline::{Answer, IngestOutcome, IngestReport, Pipeline};
54pub use retrieve::Retriever;