Skip to main content

Adapters Module

The Adapters module provides concrete implementations of knowledge base components including readers, vector stores, retrievers, and rerankers.

Import

Quick Example

Registering the built-in adapters

register_default_adapters() is the single explicit entry point for wiring the wrapper’s default readers, retrievers, and rerankers into the core-SDK registries.
Prior to PraisonAI 4.6.156, importing praisonai.adapters.readers / retrievers / rerankers implicitly registered the defaults. Import is now side-effect-free — call register_default_adapters() (or the per-family helper) once at startup to wire them in.
Behaviour
  • Idempotent and thread-safe — subsequent calls are no-ops.
  • Composite readers (DirectoryReader.load, GlobReader.load, AutoReader.load) auto-wire the built-in readers on first .load() call, so a reader-only workflow works without the explicit call. Retrievers and rerankers have no equivalent safety net — call register_default_adapters() if you look them up by name from the registry.
  • register_default_vector_stores() is intentionally not wrapped in — it probes chromadb / pinecone on disk and stays opt-in.
Per-family helpers (unchanged, still importable):

Native async in custom retrievers / rerankers

BasicRetriever.aretrieve() and its siblings — plus every reranker’s arerank() — offload the blocking body via asyncio.to_thread(...), so calling them from inside an event loop no longer freezes it. If you build a custom retriever or reranker on top of a natively-async provider (e.g. cohere.AsyncClient, an httpx AsyncClient), override the async def and await the native call directly — a to_thread hop over an already-async provider adds latency for no gain.

Features

  • Readers: Load documents from files, directories, URLs, and glob patterns
  • Vector Stores: Store and query document embeddings (ChromaDB, Pinecone)
  • Retrievers: Find relevant documents (Basic, Fusion, Recursive, AutoMerge)
  • Rerankers: Improve result relevance (LLM, CrossEncoder, Cohere)

Module Structure

Available Components

Readers

Vector Stores

Retrievers

Rerankers

Lazy Loading

All adapters use lazy loading to minimize import time:

Example: Full RAG Pipeline

CLI Integration

The adapters power the praisonai knowledge CLI commands: