Real-time debugging SDK for RAG pipelines
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rag_debugger-1.0.1.tar.gz.
File metadata
- Download URL: rag_debugger-1.0.1.tar.gz
- Upload date:
- Size: 268.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d706267726a2b7998f63eb9cda69ff8ddcc8fbf094a6566292df4555c55303d1
|
|
| MD5 |
d13b670d322e38e7646486daff5185eb
|
|
| BLAKE2b-256 |
b30cfdcacf62811aac9a5586e16300fae568680f5af2fc433028ddade02d2954
|
Provenance
The following attestation bundles were made for rag_debugger-1.0.1.tar.gz:
Publisher:
publish.yml on ChanduBobbili/rag-debugger
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rag_debugger-1.0.1.tar.gz -
Subject digest:
d706267726a2b7998f63eb9cda69ff8ddcc8fbf094a6566292df4555c55303d1 - Sigstore transparency entry: 996330227
- Sigstore integration time:
-
Permalink:
ChanduBobbili/rag-debugger@2ccaf285fc4fa87d706bf8330cc55c4a75d875e6 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/ChanduBobbili
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2ccaf285fc4fa87d706bf8330cc55c4a75d875e6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rag_debugger-1.0.1-py3-none-any.whl.
File metadata
- Download URL: rag_debugger-1.0.1-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5df9a4486f6ea0ff74e440ce6915b946858de26f588954e209de3e7ff8cbda0c
|
|
| MD5 |
83ac70b4007cc0269386e4b5b3f4d9cf
|
|
| BLAKE2b-256 |
9af686a21626d5da2459c17e11879efa55963f20ccdef249ae1938701eae2aa7
|
Provenance
The following attestation bundles were made for rag_debugger-1.0.1-py3-none-any.whl:
Publisher:
publish.yml on ChanduBobbili/rag-debugger
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rag_debugger-1.0.1-py3-none-any.whl -
Subject digest:
5df9a4486f6ea0ff74e440ce6915b946858de26f588954e209de3e7ff8cbda0c - Sigstore transparency entry: 996330249
- Sigstore integration time:
-
Permalink:
ChanduBobbili/rag-debugger@2ccaf285fc4fa87d706bf8330cc55c4a75d875e6 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/ChanduBobbili
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2ccaf285fc4fa87d706bf8330cc55c4a75d875e6 -
Trigger Event:
push
-
Statement type: