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
//! # adk-rag
//!
//! Retrieval-Augmented Generation for ADK-Rust agents.
//!
//! This crate provides a modular, trait-based RAG system with pluggable
//! embedding providers, vector stores, chunking strategies, and rerankers.
//! A [`RagPipeline`](pipeline) orchestrates the full ingest-and-query workflow,
//! and a [`RagTool`](tool) exposes retrieval as an `adk_core::Tool` for
//! agentic use.
//!
//! ## Features
//!
//! All external backends are feature-gated. The default feature set includes
//! only core traits, the in-memory vector store, and chunking implementations.
//!
//! | Feature | What it enables |
//! |--------------|------------------------------------------|
//! | `gemini` | `GeminiEmbeddingProvider` via adk-gemini |
//! | `openai` | `OpenAIEmbeddingProvider` via reqwest |
//! | `qdrant` | `QdrantVectorStore` via qdrant-client |
//! | `lancedb` | `LanceDBVectorStore` via lancedb |
//! | `pgvector` | `PgVectorStore` via sqlx |
//! | `agent-retrieval` | `AgentRetrievalStore` via Agent Retrieval (Vector Search 2.0) |
//! | `vertex-rag` | Vertex AI RAG Engine client + retrieval tool |
//! | `onnx` | `OnnxEmbeddingProvider`: a sentence-transformer ONNX model run in process |
//! | `full` | `gemini`, `openai`, `qdrant`, `lancedb`, `pgvector` |
//!
//! ## Example
//!
//! The pipeline below runs offline with a toy embedder; swap in
//! `GeminiEmbeddingProvider` or `OpenAIEmbeddingProvider` for real embeddings.
//!
//! ```rust
//! use std::sync::Arc;
//!
//! use adk_rag::{
//! Document, EmbeddingProvider, InMemoryVectorStore, RagConfig, RagPipeline, RecursiveChunker,
//! Scope,
//! };
//! use async_trait::async_trait;
//!
//! struct LengthEmbedder;
//!
//! #[async_trait]
//! impl EmbeddingProvider for LengthEmbedder {
//! async fn embed(&self, text: &str) -> adk_rag::Result<Vec<f32>> {
//! Ok(vec![text.len() as f32, 1.0])
//! }
//!
//! fn dimensions(&self) -> usize {
//! 2
//! }
//! }
//!
//! # #[tokio::main]
//! # async fn main() -> adk_rag::Result<()> {
//! let pipeline = RagPipeline::builder()
//! .config(RagConfig::default())
//! .embedding_provider(Arc::new(LengthEmbedder))
//! .vector_store(Arc::new(InMemoryVectorStore::new()))
//! .chunker(Arc::new(RecursiveChunker::new(512, 100)))
//! .build()?;
//!
//! pipeline.create_collection("docs").await?;
//! let document = Document::new("intro", "Rust is a systems programming language.")
//! .with_source_uri("https://example.com/rust")
//! .with_title("About Rust");
//!
//! // Every read and write names a scope; an application with one tenant uses this one.
//! let rag = pipeline.scoped(Scope::single_tenant());
//! rag.ingest("docs", &document).await?;
//!
//! let results = rag.query("docs", "systems language").await?;
//! assert_eq!(results[0].chunk.document_id, "intro");
//! assert_eq!(results[0].chunk.source_uri.as_deref(), Some("https://example.com/rust"));
//! # Ok(())
//! # }
//! ```
pub use ;
pub use ;
pub use ;
pub use ;
pub use EmbeddingProvider;
pub use ;
pub use ;
pub use InMemoryVectorStore;
pub use ;
pub use ;
pub use Scope;
pub use ;
pub use RagTool;
pub use ;
pub use GeminiEmbeddingProvider;
pub use LanceDBVectorStore;
pub use ;
pub use OpenAIEmbeddingProvider;
pub use PgVectorStore;
pub use QdrantVectorStore;
pub use ;