Skip to main content

RAG Observability Platform - Trace, debug and understand your RAG pipelines

Project description

SourceMapR

PyPI version Python versions License Downloads

See what your RAG system actually saw.

SourceMapR provides evidence observability for RAG pipelines. Trace every LLM answer back to the exact document evidence that produced it, with complete evidence lineage.


Why SourceMapR?

Problem SourceMapR Solution
"Which chunks did the retriever return?" See every retrieved chunk with similarity scores
"What prompt was sent to the LLM?" Full prompt/response capture with token counts
"Why did the model hallucinate?" Click any chunk to view it in the original PDF
"Is my chunking strategy working?" Compare experiments side by side

Add RAG observability in two lines of code.


Document Support

Format Status Notes
PDF ✅ Supported Full support with chunk highlighting and source viewing
HTML 🧪 Experimental Basic rendering, chunk highlighting may not work
Other formats 🧪 Experimental Under development

Current Focus: SourceMapR is optimized for PDF documents. Support for HTML and other file types is experimental and under active development.


Quick Start

pip install sourcemapr
sourcemapr server

LlamaIndex

from sourcemapr import init_tracing, stop_tracing
init_tracing(endpoint="http://localhost:5000")

# Your existing LlamaIndex code — unchanged
from llama_index.core import SimpleDirectoryReader, VectorStoreIndex

documents = SimpleDirectoryReader("./papers").load_data()
index = VectorStoreIndex.from_documents(documents)

response = index.as_query_engine().query("What is attention?")
print(response)

stop_tracing()

LangChain

from sourcemapr import init_tracing, stop_tracing
init_tracing(endpoint="http://localhost:5000")

# Your existing LangChain code — unchanged
from langchain_community.document_loaders import PyPDFLoader
from langchain_text_splitters import RecursiveCharacterTextSplitter
from langchain_community.vectorstores import FAISS

loader = PyPDFLoader("./papers/attention.pdf")
documents = loader.load()

splitter = RecursiveCharacterTextSplitter(chunk_size=512)
chunks = splitter.split_documents(documents)

vectorstore = FAISS.from_documents(chunks, embeddings)
results = vectorstore.similarity_search("What is attention?")

stop_tracing()

Open http://localhost:5000 to see the full evidence lineage.


Supported Frameworks

Framework Documents Chunks Retrieval LLM Calls
LlamaIndex
LangChain
OpenAI

Pipeline Support

⚠️ Experimental: Pipeline tracing (e.g., langchain_pipeline_demo.py) is currently experimental and does not have stable support. Basic functionality works but may have limitations.

See Supported Features for details.


Features

  • Trace LLM Answers to Sources — Trace responses to exact chunks with similarity scores and rankings
  • PDF Chunk Viewer — Click any chunk to see it highlighted in the original PDF
  • Full LLM Tracing — Prompts, responses, tokens, latency for every query
  • Experiment Tracking — Organize runs and compare chunking strategies
  • Evidence Lineage — Complete trace from document load → parse → chunk → embed → retrieve → answer
  • Debug RAG Hallucinations — Verify grounding without guessing

CLI Commands

# Server management
sourcemapr server            # Start server (foreground)
sourcemapr server -b         # Start server in background
sourcemapr server -p 8080    # Start on custom port
sourcemapr stop              # Stop running server
sourcemapr restart           # Restart server
sourcemapr status            # Check if server is running

# Data management
sourcemapr clear             # Clear all trace data (with confirmation)
sourcemapr clear -y          # Clear without confirmation
sourcemapr init              # Initialize database
sourcemapr init --reset      # Delete and recreate database

# Info
sourcemapr version           # Show version

Examples

# LlamaIndex with PDFs
python examples/llamaindex_pdf_demo.py

# LangChain with PDFs
python examples/langchain_pdf_demo.py

See Examples for more.


Installation

From PyPI

pip install sourcemapr

From Source

git clone https://github.com/kamathhrishi/sourcemapr.git
cd sourcemapr && pip install -e .

Documentation


License

MIT


Built for developers who are tired of print-debugging RAG pipelines.

Website · GitHub

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

sourcemapr-0.1.1.tar.gz (701.5 kB view details)

Uploaded Source

Built Distribution

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

sourcemapr-0.1.1-py3-none-any.whl (710.3 kB view details)

Uploaded Python 3

File details

Details for the file sourcemapr-0.1.1.tar.gz.

File metadata

  • Download URL: sourcemapr-0.1.1.tar.gz
  • Upload date:
  • Size: 701.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for sourcemapr-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9a71e217a3cf21f5449053f158a4c8f85b2023827b865f11c14d4e2eb816bb85
MD5 2c73f2ce7ee369efca45f5c6a8ec042c
BLAKE2b-256 e4ad759c9610cfa93373f484da5c5c2a516762c558a0ef0a4d624b6adb4bcfdf

See more details on using hashes here.

File details

Details for the file sourcemapr-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: sourcemapr-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 710.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for sourcemapr-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3ea5b069b769dc380f35c09c9e1fe63e542d5a298f5ea549477dc8beafb2a85e
MD5 fdb96ddc8b3587747fad071bcb09dce2
BLAKE2b-256 0a3ba6af808c6486dbe51f20c2896ca1d2d29f0cae5ceb94fbd2d3a180a863c2

See more details on using hashes here.

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