Skip to main content

Real-time debugging SDK for RAG pipelines

Project description

RAG Debugger SDK 🔍

PyPI - Version Python License: MIT

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-correlationtrace_id / query_id via ContextVar (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_id and query_id per request
  • Captures function inputs and outputs
  • Measures duration_ms for each stage
  • Emits a session_complete summary 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


Download files

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

Source Distribution

rag_debugger-1.0.1.tar.gz (268.6 kB view details)

Uploaded Source

Built Distribution

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

rag_debugger-1.0.1-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

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

Hashes for rag_debugger-1.0.1.tar.gz
Algorithm Hash digest
SHA256 d706267726a2b7998f63eb9cda69ff8ddcc8fbf094a6566292df4555c55303d1
MD5 d13b670d322e38e7646486daff5185eb
BLAKE2b-256 b30cfdcacf62811aac9a5586e16300fae568680f5af2fc433028ddade02d2954

See more details on using hashes here.

Provenance

The following attestation bundles were made for rag_debugger-1.0.1.tar.gz:

Publisher: publish.yml on ChanduBobbili/rag-debugger

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for rag_debugger-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5df9a4486f6ea0ff74e440ce6915b946858de26f588954e209de3e7ff8cbda0c
MD5 83ac70b4007cc0269386e4b5b3f4d9cf
BLAKE2b-256 9af686a21626d5da2459c17e11879efa55963f20ccdef249ae1938701eae2aa7

See more details on using hashes here.

Provenance

The following attestation bundles were made for rag_debugger-1.0.1-py3-none-any.whl:

Publisher: publish.yml on ChanduBobbili/rag-debugger

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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