RAG Debugger SDK 🔍
One-line decorator to debug your RAG pipelines in real time.
Instrument any Python RAG pipeline with @rag_trace — captures inputs, outputs, timing, and errors for every stage (embed → retrieve → rerank → generate) and streams them to the RAG Debugger Dashboard.
Features
- 🔗 One decorator —
@rag_trace("retrieve")on your existing functions - ⚡ Non-blocking — async background worker, never slows your pipeline
- 🧵 Auto-correlation —
trace_id/query_idviaContextVar(no manual threading) - 🔒 PII scrubbing — emails, phone numbers, SSNs, API keys automatically redacted
- 🔌 Framework adapters — LangChain, LlamaIndex, and OpenAI out of the box
- 🛡️ Safe — errors in the SDK never crash your application
Installation
pip install rag-debugger
With framework adapters:
pip install rag-debugger[langchain] # LangChain
pip install rag-debugger[llamaindex] # LlamaIndex
pip install rag-debugger[openai] # OpenAI
pip install rag-debugger[all] # All adapters
Quick Start
from rag_debugger import init, rag_trace
# 1. Point to your RAG Debugger server
init(dashboard_url="http://localhost:7777")
# 2. Decorate your pipeline functions
@rag_trace("embed")
async def embed_query(query: str) -> list[float]:
return await my_embedder.embed(query)
@rag_trace("retrieve")
async def retrieve_chunks(vector: list[float], k: int = 10):
return await vector_store.query(vector, k)
@rag_trace("rerank")
async def rerank(query: str, chunks: list) -> list:
return await reranker.rerank(query, chunks)
@rag_trace("generate")
async def generate(query: str, context: str) -> str:
return await llm.complete(query, context)
# 3. Call your pipeline — traces appear in the dashboard
answer = await generate(query, context)
The decorator automatically:
- Generates
trace_idandquery_idper request - Captures function inputs and outputs
- Measures
duration_msfor each stage - Emits a
session_completesummary after the generate stage - Scrubs PII before sending
Framework Adapters
LangChain
from rag_debugger.adapters.langchain import RAGDebuggerCallback
handler = RAGDebuggerCallback()
chain.invoke({"query": "..."}, config={"callbacks": [handler]})
LlamaIndex
from rag_debugger.adapters.llamaindex import RAGDebuggerLlamaIndex
from llama_index.core.callbacks import CallbackManager
handler = RAGDebuggerLlamaIndex()
callback_manager = CallbackManager([handler])
index = VectorStoreIndex.from_documents(docs, callback_manager=callback_manager)
OpenAI
from rag_debugger.adapters.openai import RAGDebuggerOpenAI
client = RAGDebuggerOpenAI(openai.AsyncOpenAI())
embedding = await client.embed("What is RAG?")
response = await client.complete("Explain RAG")
Advanced Usage
Explicit Trace Control
from rag_debugger import new_trace, reset_context
# Group events under a custom trace
new_trace(trace_id="my-trace-123", query_id="q-001")
await embed_query("What is RAG?")
await retrieve_chunks(vector)
# Reset for the next request
reset_context()
Async Context Manager
import rag_debugger
async with rag_debugger.trace(trace_id="req-123") as t:
print(t.trace_id)
result = await my_rag_pipeline(query)
# Context is automatically restored after the block
Documentation
License
MIT — see LICENSE for details.
Metadata
Release files for rag-debugger 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| rag_debugger-1.1.1.tar.gz | 271.0 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rag_debugger-1.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 285.5 kB
Release files / rag_debugger-1.1.1.tar.gz
| Download URL | rag_debugger-1.1.1.tar.gz |
|---|---|
| Size | 271.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d0cb987234f9a364348d768ef7b0a01f560b8c20f2c1d9e54fe87acc001df3cd
|
|
BLAKE2b-256 checksum How to use checksums |
9ceb32b88d06cd3629635a0d3f45b0e40fbe301dd381d82195e310e41641e00e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 5, 2026.
Transparency logRelease files / rag_debugger-1.1.1-py3-none-any.whl
| Download URL | rag_debugger-1.1.1-py3-none-any.whl |
|---|---|
| Size | 14.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
122725b33bfc8708fefecdaac8ad57a5b08e359e34e19ad45c3079b2d68e4f56
|
|
BLAKE2b-256 checksum How to use checksums |
c7672ccd24cfa92fe068fa8c49b7e246da3a7754d8a05c139943fbb57ccbf596
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 5, 2026.
Transparency logSecurity for rag-debugger 1.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for rag_debugger-1.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.