Skip to main content

A production-quality Retrieval Augmented Generation (RAG) Python Framework.

Project description

Rag-System

A production-quality Retrieval Augmented Generation (RAG) Python Framework.

Features

  • Multi-Format Ingestion: Recursively ingest and parse .pdf, .docx, .doc, .txt, .md, .csv, .xlsx, .xls, .json, .html, .htm, and .xml.
  • Hybrid Search: Combines ChromaDB vector similarity with native keyword filtering ($contains).
  • Flexible LLM Selection: Out-of-the-box support for Groq, OpenAI, Anthropic, Gemini, Ollama, and OpenRouter.
  • Session Memory: Persistent user facts serializer (memory.json) and token-budget-aware sliding conversation history window.
  • Advanced Document Filtering: Expand wildcard glob paths and folders to target retrieval down to specific files and page ranges.
  • Unified Developer Namespace: Exposes a clean, high-level user interface.

Installation

Install using pip:

pip install Rag-System

Quick Start

from Rag_System import RAG

# Initialize
rag = RAG(
    model="llama3-8b-8192",
    provider="groq",
    data_dir="data",
    auto_ingest=True,
    verbose=True
)

# Ask a question
response = rag.ask("Which departments have the lowest CAP1 MCA cutoffs?")
print(response.answer)

# Print citations
for citation in response.citations:
    print(f"- {citation.filename} (Page {citation.page_number}) similarity={citation.similarity:.4f}")

Configuration

Settings are parsed in the following priority order:

  1. Constructor arguments
  2. Environment variables from .env
  3. Defaults (Rag_System/constants.py)

Environment Settings (.env)

GROQ_API_KEY=gsk_...
OPENAI_API_KEY=sk-proj-...
ANTHROPIC_API_KEY=sk-ant-...
GEMINI_API_KEY=AIzaSy...
OLLAMA_BASE_URL=http://localhost:11434

API Reference

class RAG

Arguments:

  • model: Model name identifier.
  • embedding_model: Text embedding model name. Defaults to BAAI/bge-small-en-v1.5.
  • provider: Target LLM provider (groq, openai, anthropic, google, ollama, openrouter).
  • data_dir: File directory path to scan.
  • auto_ingest: If True, run index scans upon setup.
  • verbose: Toggle framework log outputs.

Methods:

  • ask(question, ...): Solves intent routing, runs retrival, and returns RAGResponse.
  • chat(message): Run interactive conversation storing chat history.
  • ingest(force_rebuild=False): Incremental document file indexing.
  • retrieve(query, **kwargs): Return candidate nodes with similarity scores.
  • search(query, **kwargs): Alias for retrieve.
  • summarize(query=...): Summarize indexed documents.
  • compare(query=...): Compare documents.
  • statistics(): Retrieve document counts and database counters.
  • list_documents(): Return list of uniquely indexed filenames.
  • delete_document(filename): Wipe document contents matching name.
  • update_document(filename): Reindex file.
  • clear_memory(): Reset conversation states.
  • add_memory(key, value): Remember user preference तथ्य.
  • reset_vectorstore(): Clean all collections.

CLI Usage

The package installs a rag subcommand group:

# Ingest documents
rag ingest --force-rebuild

# Query
rag ask "Which colleges offer MCA?" --files "data/pdfs/*.pdf"

# Stats
rag stats

# Documents list
rag documents

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

rag_system-1.0.1.tar.gz (47.1 kB view details)

Uploaded Source

Built Distribution

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

rag_system-1.0.1-py3-none-any.whl (67.7 kB view details)

Uploaded Python 3

File details

Details for the file rag_system-1.0.1.tar.gz.

File metadata

  • Download URL: rag_system-1.0.1.tar.gz
  • Upload date:
  • Size: 47.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for rag_system-1.0.1.tar.gz
Algorithm Hash digest
SHA256 650e8bbb699e706d402f12bc5b87f440044ef0a2cba33807b93a54672c5bea9b
MD5 8e8f01f455be7a3e41837ff5942b77e3
BLAKE2b-256 909a917d2dc42ef5badaa1023ce6a8cc0cf0d3e0484ab4440c024bbab2b2e845

See more details on using hashes here.

File details

Details for the file rag_system-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: rag_system-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 67.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for rag_system-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4e21c58d4ef799631629f8fb7e8d3be791145d03ef70fdc8016faf7ea5823e83
MD5 4d435ab3ef23ce90031d295735350d44
BLAKE2b-256 44586a81cf3133b293040d45711c8a6ef1d0c215b69e7165a60c0407aab06eab

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