Skip to main content

RAG in 3 lines. Auto-GraphRAG, auto-reranking, auto-streaming. No LangChain required.

Project description

RAGBox

PyPI version Python 3.11+ License: MIT CI

RAG that works in 3 lines. Not 50.


The Problem With LangChain

This is a LangChain RAG app:

from langchain.document_loaders import DirectoryLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.embeddings import OpenAIEmbeddings
from langchain.vectorstores import Chroma
from langchain.chat_models import ChatOpenAI
from langchain.chains import RetrievalQA
from langchain.prompts import PromptTemplate

loader = DirectoryLoader("./docs", glob="**/*.txt")
documents = loader.load()

splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=200)
chunks = splitter.split_documents(documents)

embeddings = OpenAIEmbeddings()
vectorstore = Chroma.from_documents(chunks, embeddings, persist_directory="./chroma")
vectorstore.persist()

llm = ChatOpenAI(model_name="gpt-4o", temperature=0)
retriever = vectorstore.as_retriever(search_kwargs={"k": 5})
prompt = PromptTemplate(
    input_variables=["context", "question"],
    template="Answer from context:\n{context}\n\nQuestion: {question}"
)

chain = RetrievalQA.from_chain_type(
    llm=llm,
    chain_type="stuff",
    retriever=retriever,
    chain_type_kwargs={"prompt": prompt}
)

result = chain({"query": "What is the vacation policy?"})
print(result["result"])

That's 30+ lines. And it doesn't include GraphRAG, reranking, or streaming.


This is RAGBox

from ragbox import RAGBox

rag = RAGBox("./docs")
print(rag.query("What is the vacation policy?"))

3 lines. Includes GraphRAG, reranking, streaming, and self-healing — out of the box.


Install

pip install ragbox-core

Set one API key:

export GROQ_API_KEY="gsk_..."   # free tier works
# OR
export OPENAI_API_KEY="sk-..."
# OR
export ANTHROPIC_API_KEY="sk-ant-..."

That's it. No config files. No boilerplate. Point it at a folder and ask questions.


What You Get For Free

Feature LangChain LlamaIndex RAGBox
Works in 3 lines
Auto-detects LLM provider
Built-in GraphRAG (Leiden)
Dual-Mode Retrieval (Fast Factual vs Deep Graph) manual manual ✅ auto
Cross-Encoder Reranking manual manual ✅ auto
Streaming (astream()) complex complex ✅ built-in
Self-healing watchdog
Cost estimation before indexing
Multi-query expansion manual manual ✅ auto
Default install size ~500MB ~300MB ~80MB

Real Examples

Ask questions about your company docs

from ragbox import RAGBox

rag = RAGBox("./company-docs")
print(rag.query("What's the oncall escalation policy?"))
print(rag.query("Who does Maria Santos report to?"))     # cross-doc GraphRAG
print(rag.query("What was Q4 revenue and who drove it?"))  # multi-hop

Stream answers token-by-token

import asyncio
from ragbox import RAGBox

async def main():
    rag = RAGBox("./docs")
    async for chunk in rag.astream("Summarize all findings"):
        print(chunk, end="", flush=True)

asyncio.run(main())

Chat with a codebase

from ragbox import RAGBox

rag = RAGBox("./my-python-project")  # auto-parses .py files with AST
print(rag.query("How does the auth middleware work?"))
print(rag.query("Which functions call the database?"))  # graph traversal

Estimate cost before indexing

from ragbox import RAGBox

rag = RAGBox("./large-docs")
estimate = rag.estimate_cost()
print(f"Indexing will cost ~${estimate.total_cost_usd:.4f}")
# Indexing will cost ~$0.0023

Docker — instant RAG server

docker run \
  -v ./docs:/data \
  -e OPENAI_API_KEY=$OPENAI_API_KEY \
  -p 8000:8000 \
  ragbox/ragbox

# Query via HTTP
curl -X POST http://localhost:8000/query \
  -H "Content-Type: application/json" \
  -d '{"question": "What is the vacation policy?"}'

How It Works

RAGBox wires up 7 components automatically — you never touch them:

Your Documents
     │
     ▼
Document Processor   ← auto-routes PDF / TXT / PPTX / Code
     │
     ├──▶ Chunking Engine  ← late chunking with context awareness
     │
     ├──▶ Vector Store     ← ChromaDB, auto-configured
     │
     └──▶ Knowledge Graph  ← Leiden/Louvain entity extraction
                                          │
Your Question ────────────────────────────▼
     │                          Agentic Orchestrator
     │                       (classifies: vector / graph / multi-query)
     │                                    │
     └────────────────────────────────────▼
                               Retrieval Fusion + Reranking
                                          │
                                     Your Answer

CLI

# Index your documents
ragbox init ./docs

# Ask a question
ragbox query "What is the vacation policy?" -d ./docs

When RAGBox Wins

RAGBox is not for everyone. Here's exactly when to use it:

Use RAGBox if:

  • You want a working RAG system today, not next week
  • You're tired of wiring together 10 LangChain components
  • You need cross-document reasoning (GraphRAG) without a PhD
  • You're building internal tools, demos, or MVPs

Don't use RAGBox if:

  • You need highly custom retrieval pipelines
  • You're building a commercial RAG product with specific SLAs
  • You want to control every single component manually

Benchmarks

See BENCHMARKS.md — reproducible comparisons against vanilla vector search.

RAGBox features Dual-Mode Retrieval:

  • Fast Path (Factual): Bypasses the graph and reranker for simple queries. ~1500ms latency.
  • Deep Path (GraphRAG): Activates multi-query, graph context, and cross-encoder reranking for complex queries.

RAGBox wins heavily on cross-document reasoning. For example, on the query: "What is the relationship between the deployment strategy and the SEV1 incident?":

  • Vanilla Vector: 0.802
  • RAGBox GraphRAG: 0.891 (+0.089 Delta)

Contributing

PRs welcome. See CONTRIBUTING.md.


License

MIT — use it for anything.

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

ragbox_core-2.1.0.tar.gz (40.6 kB view details)

Uploaded Source

Built Distribution

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

ragbox_core-2.1.0-py3-none-any.whl (48.0 kB view details)

Uploaded Python 3

File details

Details for the file ragbox_core-2.1.0.tar.gz.

File metadata

  • Download URL: ragbox_core-2.1.0.tar.gz
  • Upload date:
  • Size: 40.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.3 Linux/6.17.0-14-generic

File hashes

Hashes for ragbox_core-2.1.0.tar.gz
Algorithm Hash digest
SHA256 c273d490dfcb551353737613d9fafece1c9033b183356b2a03d2b8d4d734b93a
MD5 997376ddfa5e1962509dabcc30d31c24
BLAKE2b-256 fc11b8c9e5a0a0c628be5e2828335708a0a61aed7332c7034a50c062a51da66c

See more details on using hashes here.

File details

Details for the file ragbox_core-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: ragbox_core-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 48.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.3 Linux/6.17.0-14-generic

File hashes

Hashes for ragbox_core-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c9f84d181ec37c910475999c84453e032d188c62e151ef7ccf9b787db2d2aba4
MD5 119f1e4323447052ce78f90c74f1d9f0
BLAKE2b-256 bcb46b2d71340887cfb0699e3da6a41093c73e8256c3cce5b6f1d60ab52b1f63

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