Documentation

Everything you need to integrate and use RAGView

Quick Start

Get up and running with RAGView in under 5 minutes.

1. Installation

# Install via pip
pip install ragview

# Or via npm
npm install @ragview/sdk

2. Initialize RAGView

import ragview

# Initialize with your API key
ragview.init(api_key="your_api_key_here")

3. Add Tracing to Your RAG Pipeline

@ragview.trace()
def retrieve_and_generate(query):
    # Your retrieval logic
    chunks = vector_db.search(query, k=5)
    
    # Your generation logic
    response = llm.generate(query, context=chunks)
    
    return response

4. View Results

Visit your RAGView dashboard to see real-time diagnostics, pollution tracking, and performance metrics.

Python SDK Reference

ragview.init()

Initialize the RAGView client with your credentials.

ragview.init(
    api_key="your_api_key",
    project_name="my-rag-project",
    environment="production"
)

@ragview.trace()

Decorator to automatically capture retrieval and generation metrics.

@ragview.trace(
    capture_input=True,
    capture_output=True,
    track_chunks=True
)
def my_rag_function(query):
    pass

ragview.log_retrieval()

Manually log retrieval results for analysis.

ragview.log_retrieval(
    query="user question",
    chunks=[
        {"text": "chunk content", "score": 0.95},
        {"text": "another chunk", "score": 0.87}
    ],
    metadata={"retrieval_method": "hybrid"}
)

ragview.analyze_pollution()

Analyze context pollution for a given prompt.

result = ragview.analyze_pollution(
    query="user question",
    context="full context string"
)

print(result.pollution_score)
print(result.polluted_segments)

Node.js SDK Reference

Installation & Setup

const RAGView = require('@ragview/sdk');

const ragview = new RAGView({
  apiKey: 'your_api_key',
  projectName: 'my-rag-project'
});

Tracing Retrievals

async function retrieveAndGenerate(query) {
  const trace = ragview.startTrace();
  
  const chunks = await vectorDB.search(query, { k: 5 });
  trace.logRetrieval(query, chunks);
  
  const response = await llm.generate(query, chunks);
  trace.logGeneration(response);
  
  await trace.end();
  return response;
}

REST API

Authentication

All API requests require an API key in the Authorization header:

Authorization: Bearer your_api_key_here

POST /api/v1/trace

Submit a trace for analysis.

{
  "query": "user question",
  "chunks": [
    {
      "text": "chunk content",
      "score": 0.95,
      "metadata": {}
    }
  ],
  "response": "generated answer",
  "timestamp": "2026-03-22T10:30:00Z"
}

GET /api/v1/metrics

Retrieve aggregated metrics for your project.

GET /api/v1/metrics?start_date=2026-03-01&end_date=2026-03-22

POST /api/v1/analyze/pollution

Analyze context pollution for a given prompt.

{
  "query": "user question",
  "context": "full context string"
}

Best Practices

Optimizing Retrieval Quality

  • Start with K=10 and adjust based on decay curve analysis
  • Monitor precision@K to find the optimal cutoff point
  • Use hybrid search for better recall on diverse queries
  • Implement reranking when initial retrieval is noisy

Reducing Context Pollution

  • Set SNR thresholds and alert when exceeded
  • Filter chunks with similarity scores below 0.7
  • Use semantic deduplication to remove redundant chunks
  • Implement query expansion for better retrieval coverage

Monitoring in Production

  • Set up alerts for sudden drops in precision or recall
  • Review pollution heatmaps weekly to identify patterns
  • Run needle tests monthly to catch degradation early
  • A/B test retrieval changes before full rollout
Get Your API Key