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.1.1.tar.gz (271.0 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.1.1-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rag_debugger-1.1.1.tar.gz
  • Upload date:
  • Size: 271.0 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.1.1.tar.gz
Algorithm Hash digest
SHA256 d0cb987234f9a364348d768ef7b0a01f560b8c20f2c1d9e54fe87acc001df3cd
MD5 802b54c6209c89fc64983d98322e21fe
BLAKE2b-256 9ceb32b88d06cd3629635a0d3f45b0e40fbe301dd381d82195e310e41641e00e

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: rag_debugger-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.5 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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 122725b33bfc8708fefecdaac8ad57a5b08e359e34e19ad45c3079b2d68e4f56
MD5 8dca60c50e760453ef1e6819d1e43e12
BLAKE2b-256 c7672ccd24cfa92fe068fa8c49b7e246da3a7754d8a05c139943fbb57ccbf596

See more details on using hashes here.

Provenance

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