1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
//! Trait-driven RAG framework with runtime hot-swapping.
//!
//! **Zero native dependencies in the default build.** `cargo build --release`
//! produces a pure-Rust binary that talks to a local Ollama server for models.
//! No C++ compiler, no `cmake`, no `protoc` required.
//!
//! # Architecture
//!
//! Every pipeline stage is a trait object — swap any agent at runtime
//! without losing your document index or conversation context:
//!
//! | Stage | Trait | Built-in backends |
//! |---|---|---|
//! | Chat | [`agents::Generator`] | Ollama, DeepSeek |
//! | Memory / Rewrite | [`agents::Generator`] | Ollama, DeepSeek |
//! | Ranking | [`store::Ranker`] | RRF fusion, weighted linear, MMR diversity, LLM re-rank |
//! | Embeddings | [`embed::Embedder`] | Ollama, Fastembed (CPU-only), No-op |
//! | Storage | [`store::VectorStore`] | Brute-force (MessagePack), LanceDB |
//! | Parsing | [`parsers::DocumentParser`] | PDF × 5 (vision-VLM behind the `vision-pdf` feature), EPUB, DOCX, HTML, Markdown |
//! | Chunking | [`chunker::Chunker`] | Markdown, token, chunkedrs (×4), text-splitter, cognigraph |
//! | Corpora | [`corpora::Corpus`] | Folder, curated URL list |
//!
//! Every stored chunk records which (corpus, parser, chunker, embedder)
//! pipeline produced it ([`PipelineProvenance`]) — the document corpus is
//! part of the store's per-document identity. Index several pipelines into
//! one store and switch between them at query time with
//! [`PipelineFilter`] / [`RagAgent::set_search_filter`].
//!
//! # Stability
//!
//! Two tiers, formalised with the 1.0.0 freeze:
//!
//! - **Tier 1 — stable**: the core traits ([`agents::Generator`],
//! [`embed::Embedder`], [`store::VectorStore`],
//! [`parsers::DocumentParser`], [`chunker::Chunker`],
//! [`corpora::Corpus`], [`store::Ranker`]), [`RagAgent`], the error
//! types ([`RagrigError`], [`Cancelled`]), and the `vector`, `store`,
//! `corpora`, `parsers`, `chunker`, `embed`, `agents`, and
//! `longterm_memory` surfaces. Frozen at 1.0.0: additive-only changes.
//! Every public enum is `#[non_exhaustive]` — new variants may arrive
//! in minor releases (new backends, parsers, error conditions), so
//! downstream matches must keep a wildcard arm; variants are never
//! removed or renamed.
//! - **Tier 2 — experimental**: [`session::AgentSession`], the
//! [`progress`] module ([`Progress`], [`Cancel`], [`CancellationToken`],
//! [`ProgressEvent`]), and the document-metadata feature — the
//! [`citation`] module ([`CitationFormatter`]) plus the semantics of
//! [`Document::meta`](crate::corpora::Document) and
//! [`ChunkMeta::document_meta`](crate::types::ChunkMeta) (the field
//! types are stable; key conventions and how the data is consumed are
//! not). Convenience layers and new seams over the core — they may
//! change in 1.x minor releases without counting as a semver break for
//! Tier 1 users.
//!
//! Promotion from Tier 2 to Tier 1 happens only in a minor release, after
//! at least one release of soak without changes; promotion is a
//! documentation change, not a code change.
//!
//! # Quick Start
//!
//! ```rust,no_run
//! use ragrig::{
//! ChunkConfig, FolderCorpus, MarkdownChunker,
//! embed::EmbedderSpec,
//! agents::ChatAgentSpec,
//! parsers::{DocumentParsers, build_parsers},
//! store::open_store,
//! vector::{ingest_corpus, search_similar},
//! };
//! use std::path::Path;
//!
//! # async fn example() -> anyhow::Result<()> {
//! // Build agents from spec enums — swap backends by changing the variant.
//! let embedder = EmbedderSpec::Ollama { model: "nomic-embed-text:latest".into(), request_timeout_secs: None }.build()?;
//! let chat = ChatAgentSpec::Ollama { model: "qwen3.5:9b".into(), params: Default::default(), request_timeout_secs: None }.build()?;
//!
//! // Open or create the vector store.
//! let folder = Path::new("./my_docs");
//! let store = open_store(folder).await?;
//!
//! // Parse PDFs/EPUBs/DOCXs and index them with the chunker of your choice.
//! // The corpus path is the single ingestion entry point: name a corpus, ingest it.
//! let parsers = DocumentParsers::new(build_parsers());
//! let cfg = ChunkConfig::default(); // 1024 tokens, 128 overlap
//! let corpus = FolderCorpus::named("my_docs", folder);
//! ingest_corpus(&corpus, &parsers, &MarkdownChunker, &*embedder, &cfg, &*store).await?;
//!
//! // Search and generate.
//! let results = search_similar(&*embedder, 5, 0.0, &*store, "quantum entanglement").await?;
//! chat.generate("Summarise the following:\n\n...").await?;
//! # Ok(())
//! # }
//! ```
//!
//! See the [repository README](https://github.com/schmettow/ragrig) for the
//! full guide, including the REPL, session persistence, and hot-swap commands.
//!
//! # Feature Flags
//!
//! | Flag | Default | Adds |
//! |---|---|---|
//! | `ollama-embed` | **on** | Embeddings via local Ollama server |
//! | `internal` | **on** | Pure-Rust brute-force vector store |
//! | `internal-embed` | off | Fastembed CPU-only embeddings (requires C compiler) |
//! | `lancedb` | off | LanceDB hybrid vector store (requires protoc, cmake) |
//! | `test-fixtures` | off | Embedded test fixtures for downstream crates |
//! | `kreuzberg` | off | Kreuzberg PDF parser (OCR, layout, DOCX) |
//! | `vision-pdf` | off | Vision-VLM PDF parser (hayro rasterisation + Ollama vision model; needs Rust 1.92) |
// --- Re-export all public types ---
pub use ;
pub use CognigraphChunker;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use FastembedEmbedder;
pub use ;
pub use KreuzbergParser;
pub use VisionPdfParser;
pub use ;
pub use FsSessionStore;
pub use ;
pub use ;
pub use ;
pub use Cancelled;
pub use RagrigError;
pub use FileIndexResult;
pub use ;
pub use ;
pub use ;
pub use AgentSession;
pub use ;