Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:ANative Lab EvoAgentX RAGBaseClasses

From Leeroopedia
Knowledge Sources
Domains RAG, Abstractions
Last Updated 2026-10-21 00:00 GMT

Overview

Concrete abstract base classes defining the interfaces for RAG pipeline components: chunkers, embeddings, indexings, postprocessors, retrievers, readers, and query transforms.

Description

EvoAgentX defines a comprehensive set of abstract base classes for the RAG pipeline:

  • ChunkingStrategy & BaseChunker (`chunkers/base.py`) — `ChunkingStrategy` enum (SIMPLE, SEMANTIC, HIERARCHICAL). `BaseChunker` ABC with abstract `chunk` method converting Documents to Corpus of Chunks.
  • EmbeddingProvider & BaseEmbeddingWrapper (`embeddings/base.py`) — `EmbeddingProvider` enum (OPENAI, AZURE_OPENAI, HUGGINGFACE, OLLAMA, VOYAGE). `BaseEmbeddingWrapper` wraps LlamaIndex BaseEmbedding with API key management. `AzureOpenAIEmbeddingWrapper` extends this for Azure-hosted embeddings. `VoyageEmbeddingWrapper` supports text and image embeddings (PIL Image) for multimodal RAG.
  • IndexType & BaseIndexWrapper (`indexings/base.py`) — `IndexType` enum (VECTOR, GRAPH, SUMMARY, TREE). `BaseIndexWrapper` ABC with abstract `_create_storage_context`.
  • RerankerType & BasePostprocessor (`postprocessors/base.py`) — `RerankerType` enum (SIMPLE, BGE). `BasePostprocessor` ABC with abstract `postprocess` method.
  • RetrieverType & BaseRetrieverWrapper (`retrievers/base.py`) — `RetrieverType` enum (VECTOR, GRAPH). `BaseRetrieverWrapper` ABC defining the retriever interface.
  • BaseQueryTransform (`transforms/query/base.py`) — ABC with abstract `_run` method. `run()` converts string to Query, calls `_run` with metadata. Subclasses (HyDETransform) implement specific transformations.
  • MultimodalReader (`readers/multimodal_reader.py`) — Loads images from files/directories with path-based lazy loading. Supports various formats via PIL. Converts to `ImageDocument` for LlamaIndex compatibility.

Usage

  • Custom chunkers: Subclass `BaseChunker` to implement custom chunking strategies.
  • Custom embeddings: Subclass `BaseEmbeddingWrapper` to support new embedding providers.
  • Custom retrievers: Subclass `BaseRetrieverWrapper` for custom retrieval logic.
  • Multimodal RAG: Use `MultimodalReader` and `VoyageEmbeddingWrapper` for image+text RAG.

Code Reference

Source Location

Signature

class ChunkingStrategy(enum.Enum): SIMPLE, SEMANTIC, HIERARCHICAL
class BaseChunker(ABC):
    @abstractmethod
    def chunk(self, documents: List[Document]) -> Corpus

class EmbeddingProvider(enum.Enum): OPENAI, AZURE_OPENAI, HUGGINGFACE, OLLAMA, VOYAGE
class BaseEmbeddingWrapper(ABC): ...

class IndexType(enum.Enum): VECTOR, GRAPH, SUMMARY, TREE
class BaseIndexWrapper(ABC):
    @abstractmethod
    def _create_storage_context(self, ...): ...

class RerankerType(enum.Enum): SIMPLE, BGE
class BasePostprocessor(ABC):
    @abstractmethod
    def postprocess(self, query: Query, results: List) -> List: ...

class RetrieverType(enum.Enum): VECTOR, GRAPH
class BaseRetrieverWrapper(ABC): ...

class BaseQueryTransform(ABC):
    @abstractmethod
    def _run(self, query: Query, **kwargs) -> Query: ...
    def run(self, query: Union[str, Query], **kwargs) -> Query

class MultimodalReader:
    def read(self, file_paths: Union[str, List[str]], ...) -> List[ImageDocument]

Import

from evoagentx.rag.chunkers.base import BaseChunker, ChunkingStrategy
from evoagentx.rag.embeddings.base import BaseEmbeddingWrapper, EmbeddingProvider
from evoagentx.rag.embeddings.azure_openai_embedding import AzureOpenAIEmbeddingWrapper
from evoagentx.rag.embeddings.voyage import VoyageEmbeddingWrapper
from evoagentx.rag.indexings.base import BaseIndexWrapper, IndexType
from evoagentx.rag.postprocessors.base import BasePostprocessor, RerankerType
from evoagentx.rag.retrievers.base import BaseRetrieverWrapper, RetrieverType
from evoagentx.rag.transforms.query.base import BaseQueryTransform
from evoagentx.rag.readers.multimodal_reader import MultimodalReader

I/O Contract

Inputs

Name Type Required Description
documents List[Document] Yes (chunker) Documents to chunk
query Query Yes (retriever/transform) Query string or object
file_paths List[str] Yes (reader) Image file paths

Outputs

Name Type Description
chunk returns Corpus Corpus of Chunks
postprocess returns List Reranked results
run returns Query │ Transformed query

Usage Examples

Multimodal Reader

from evoagentx.rag.readers.multimodal_reader import MultimodalReader

reader = MultimodalReader()
documents = reader.read("images/")
# Returns ImageDocument list for LlamaIndex compatibility

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment