Skip to main content

adk_rag/
lib.rs

1//! # adk-rag
2#![allow(clippy::result_large_err)]
3//!
4//! Retrieval-Augmented Generation for ADK-Rust agents.
5//!
6//! This crate provides a modular, trait-based RAG system with pluggable
7//! embedding providers, vector stores, chunking strategies, and rerankers.
8//! A [`RagPipeline`](pipeline) orchestrates the full ingest-and-query workflow,
9//! and a [`RagTool`](tool) exposes retrieval as an `adk_core::Tool` for
10//! agentic use.
11//!
12//! ## Features
13//!
14//! All external backends are feature-gated. The default feature set includes
15//! only core traits, the in-memory vector store, and chunking implementations.
16//!
17//! | Feature      | What it enables                          |
18//! |--------------|------------------------------------------|
19//! | `gemini`     | `GeminiEmbeddingProvider` via adk-gemini  |
20//! | `openai`     | `OpenAIEmbeddingProvider` via reqwest     |
21//! | `qdrant`     | `QdrantVectorStore` via qdrant-client     |
22//! | `lancedb`    | `LanceDBVectorStore` via lancedb          |
23//! | `pgvector`   | `PgVectorStore` via sqlx                  |
24//! | `agent-retrieval` | `AgentRetrievalStore` via Agent Retrieval (Vector Search 2.0) |
25//! | `surrealdb`  | `SurrealVectorStore` via surrealdb        |
26//! | `vertex-rag` | Vertex AI RAG Engine client + retrieval tool |
27//! | `full`       | All of the above except `vertex-rag` (external infrastructure) |
28
29pub mod chunking;
30pub mod config;
31pub mod document;
32pub mod embedding;
33pub mod error;
34pub mod inmemory;
35pub mod pipeline;
36pub mod reranker;
37pub mod tool;
38pub mod vectorstore;
39
40#[cfg(feature = "agent-retrieval")]
41pub mod agent_retrieval;
42#[cfg(feature = "gemini")]
43pub mod gemini;
44#[cfg(feature = "lancedb")]
45pub mod lancedb;
46#[cfg(feature = "openai")]
47pub mod openai;
48#[cfg(feature = "pgvector")]
49pub mod pgvector;
50#[cfg(feature = "qdrant")]
51pub mod qdrant;
52#[cfg(feature = "surrealdb")]
53pub mod surrealdb;
54#[cfg(feature = "vertex-rag")]
55pub mod vertex_rag;
56
57#[cfg(feature = "agent-retrieval")]
58pub use agent_retrieval::{AgentRetrievalConfig, AgentRetrievalStore};
59pub use chunking::{Chunker, FixedSizeChunker, MarkdownChunker, RecursiveChunker};
60pub use config::{RagConfig, RagConfigBuilder};
61pub use document::{Chunk, Document, SearchResult};
62pub use embedding::EmbeddingProvider;
63pub use error::{RagError, Result};
64pub use inmemory::InMemoryVectorStore;
65pub use pipeline::{RagPipeline, RagPipelineBuilder};
66pub use reranker::{NoOpReranker, Reranker};
67pub use tool::RagTool;
68pub use vectorstore::VectorStore;
69
70#[cfg(feature = "gemini")]
71pub use gemini::GeminiEmbeddingProvider;
72#[cfg(feature = "lancedb")]
73pub use lancedb::LanceDBVectorStore;
74#[cfg(feature = "openai")]
75pub use openai::OpenAIEmbeddingProvider;
76#[cfg(feature = "pgvector")]
77pub use pgvector::PgVectorStore;
78#[cfg(feature = "qdrant")]
79pub use qdrant::QdrantVectorStore;
80#[cfg(feature = "surrealdb")]
81pub use surrealdb::SurrealVectorStore;
82#[cfg(feature = "vertex-rag")]
83pub use vertex_rag::{
84    RetrieveContextsRequest, VertexAiRagRetrievalTool, VertexRagConfig, VertexRagEngineClient,
85};