Skip to main content

A modular Retrieval-Augmented Generation (RAG) pipeline for Python.

Project description

RAGpy is a lightweight, modular Retrieval-Augmented Generation (RAG) pipeline for Python. It provides a clear and testable architecture for document ingestion, chunking, embedding, retrieval, reranking, context compression, and grounded answer generation using Azure OpenAI and ChromaDB.

RAGpy is designed for developers who want a transparent, hackable RAG system without the complexity of large frameworks.

Features • Modular ingestion pipeline for text, PDF, and DOCX documents • Deterministic chunking and batching utilities for efficient embedding • Azure OpenAI embeddings and chat completions • ChromaDB vector database integration • LLM-based reranking for improved retrieval quality • Context compression to reduce token usage • Fully monkeypatch-friendly design for offline testing • Clean architecture suitable for extension and customization

Installation

From PyPI: pip install ragpy

Quickstart Example

from ragpy.RAGOrchestrator import IngestFile, GenerateAnswer from ragpy.VectorDatabase import OpenDatabase

OpenDatabase("AeroDB", "./vectorDB") IngestFile("engine_vibration.pdf", "AeroDB")

answer = GenerateAnswer("What causes engine vibration?", "AeroDB") print(answer)

How RAGpy Works

Ingestion

Load text, PDF, or DOCX using FileLoader

Chunk text using TextChunker

Batch chunks using ChunkBatcher

Generate embeddings with Azure OpenAI

Store vectors and metadata in ChromaDB

Retrieval

Embed the user query

Retrieve top-K candidates from the vector database

Reranking

Use an LLM-based reranker to reorder retrieved chunks by relevance

Compression

Summarize top chunks into a compact context block

Reduce token usage while preserving grounding

Answer Generation

Build a prompt using compressed context

Generate a grounded answer using Azure OpenAI

Project Structure

ragpy/ AzureOpenAIRelay.py RAGOrchestrator.py VectorDatabase.py Reranker.py ChunkCompressor.py loaders/ FileLoader.py TextChunker.py batching/ ChunkBatcher.py

tests/ docs/

Requirements

• Python 3.9+ • chromadb • numpy • tiktoken • pypdf • python-docx • openai (Azure OpenAI SDK)

Testing

RAGpy includes a full pytest suite. All Azure calls are monkeypatch-friendly, allowing offline testing with mock LLMs.

Run tests: pytest -q

Contributing

Contributions are welcome. Please open an issue or submit a pull request on GitHub.

Planned enhancements include: • Local embedding support (sentence-transformers) • Hybrid retrieval (vector + keyword) • Multimodal RAG (image + text) • Evaluation tools for relevance and faithfulness • Agentic RAG extensions

License

RAGpy is released under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ragpy_core-1.0.2.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ragpy_core-1.0.2-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file ragpy_core-1.0.2.tar.gz.

File metadata

  • Download URL: ragpy_core-1.0.2.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for ragpy_core-1.0.2.tar.gz
Algorithm Hash digest
SHA256 ce63021e5fdcbc19d6b8d6ac40a5b4c54a65cc1015ad03316e3cd75b20765520
MD5 af6d6a139b25dea8f40d8d1249bdf0c6
BLAKE2b-256 95b7ff076d8104bfde4dadb38f9045326912d2db2272f3e4f2ff33605964c5f9

See more details on using hashes here.

File details

Details for the file ragpy_core-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: ragpy_core-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for ragpy_core-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 410924e2302292a23a47ecfbed7478e007c08213faf2783f2a7d5b2392e0a34e
MD5 36b4c9d6ec2fd044164f3a5500c9f8ac
BLAKE2b-256 1fb848bb5bc242bf0a220749deef3f11aeaeffeb68bb1ecb36fb09d916017fcd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page