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.0.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.0-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file rag_debugger-1.0.0.tar.gz.

File metadata

  • Download URL: rag_debugger-1.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 4572f98dd0030c93f6aec7192b498b8b1a6dd3aaca9075e7b793b9e7125b6f20
MD5 8816acab6ec222ce50bff0687bebc8db
BLAKE2b-256 444f51dc35aa0ea566e1fe85dd2ef277cef98fd97f1b0276fa7b684af49b3a50

See more details on using hashes here.

Provenance

The following attestation bundles were made for rag_debugger-1.0.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: rag_debugger-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.6 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f539d65fef118473c7ca5dc6caa9292a71e6f844b623d62b7925dc4ea8be458e
MD5 b5ee1c134eb10736ea4320f27055ad9a
BLAKE2b-256 3dc8bb5f2f1967ceaf8c2ee9c12be8cad6b2120728248e6334773471b76498c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for rag_debugger-1.0.0-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