Overview
Concrete tool for declaratively configuring all stages of a RAG pipeline: reading, chunking, embedding, indexing, and retrieval.
Description
The RAGConfig class aggregates five sub-configurations: ReaderConfig (file reading), ChunkerConfig (chunking strategy), EmbeddingConfig (embedding provider and model), IndexConfig (index type), and RetrievalConfig (retriever, reranker, top_k, similarity cutoff). Each sub-config is a Pydantic model with sensible defaults, allowing partial configuration.
Usage
- RAG pipeline setup: Pass a `RAGConfig` to `RAGEngine(config=...)` to configure all pipeline stages.
- Custom chunking: Set `chunker.strategy` to `"SIMPLE"`, `"SEMANTIC"`, or `"HIERARCHICAL"`.
- Embedding provider: Set `embedding.provider` to `"OPENAI"`, `"HUGGINGFACE"`, or `"OLLAMA"`.
- Multimodal: Set `modality="multimodal"` for image-based RAG.
Code Reference
Source Location
- Repository: EvoAgentX
- File: evoagentx/rag/rag_config.py (L13-69)
Signature
class ReaderConfig(BaseModule):
recursive: bool = False
exclude_hidden: bool = True
num_files_limit: Optional[int] = None
custom_metadata_function: Optional[Callable] = None
errors: str = "ignore"
encoding: str = "utf-8"
class ChunkerConfig(BaseModule):
strategy: str = ChunkingStrategy.SIMPLE # "SIMPLE", "SEMANTIC", "HIERARCHICAL"
chunk_size: int = 1024
chunk_overlap: int = 20
max_chunks: Optional[int] = None
class EmbeddingConfig(BaseModule):
provider: str = EmbeddingProvider.OPENAI # "OPENAI", "HUGGINGFACE", "OLLAMA"
model_name: str = "text-embedding-ada-002"
api_key: Optional[str] = None
dimensions: Optional[int] = None
class IndexConfig(BaseModule):
index_type: str = IndexType.VECTOR # "VECTOR", "GRAPH"
class RetrievalConfig(BaseModule):
retrivel_type: str = RetrieverType.VECTOR
postprocessor_type: str = RerankerType.SIMPLE
top_k: int = 5
similarity_cutoff: Optional[float] = 0.7
keyword_filters: Optional[List[str]] = None
metadata_filters: Optional[Dict[str, Any]] = None
class RAGConfig(BaseConfig):
modality: str = "text" # "text" or "multimodal"
num_workers: Optional[int] = None
reader: ReaderConfig = ReaderConfig()
chunker: ChunkerConfig = ChunkerConfig()
embedding: EmbeddingConfig = EmbeddingConfig()
index: IndexConfig = IndexConfig()
retrieval: RetrievalConfig = RetrievalConfig()
Import
from evoagentx.rag.rag_config import (
RAGConfig, ReaderConfig, ChunkerConfig,
EmbeddingConfig, IndexConfig, RetrievalConfig
)
I/O Contract
Inputs
| Name |
Type |
Required |
Description
|
| modality |
str |
No |
"text" or "multimodal" (default: "text")
|
| chunker |
ChunkerConfig |
No |
Chunking configuration
|
| embedding |
EmbeddingConfig |
No |
Embedding provider and model
|
| retrieval |
RetrievalConfig |
No |
Retrieval configuration
|
Outputs
| Name |
Type |
Description
|
| RAGConfig |
BaseConfig |
Config consumed by RAGEngine
|
Usage Examples
Custom RAG Configuration
from evoagentx.rag.rag_config import (
RAGConfig, ChunkerConfig, EmbeddingConfig, RetrievalConfig
)
config = RAGConfig(
modality="text",
chunker=ChunkerConfig(strategy="SEMANTIC", chunk_size=512, chunk_overlap=50),
embedding=EmbeddingConfig(
provider="OPENAI",
model_name="text-embedding-3-small",
api_key="sk-...",
),
retrieval=RetrievalConfig(top_k=10, similarity_cutoff=0.65),
)
Related Pages
Implements Principle
Requires Environment