RAGLens Python SDK
Observability and evaluation SDK for RAG (Retrieval-Augmented Generation) pipelines.
- Documentation & Walkthrough: Full Quickstart Guide
- Repository: github.com/saikirankalidindi/RAGLens
Installation
Requires Python 3.9+:
pip install raglens-sdk
Quickstart
from raglens import RAGLens, log_generation
# Reads RAGLENS_API_KEY and RAGLENS_BASE_URL from environment
client = RAGLens()
with client.trace("answer", input={"query": "What is RAG?"}) as trace:
with trace.span("llm", "generate") as span:
answer = "Retrieval-augmented generation"
log_generation(
span,
answer,
usage={"input_tokens": 12, "output_tokens": 4},
model="mock",
)
trace.set_output({"answer": answer})
Core Concepts
Traces and Spans
- Spans nest automatically within a trace using context-local state.
- Use
span.span()to declare an explicit parent. - Wrap the actual operation inside a span to capture accurate latency metrics.
- After delivery on context exit,
trace.idcontains the server-assigned ID. - Set
project_idand optionallyweb_urlon the client to automatically populatetrace.url.
Logging Helpers
RAGLens provides specialized logging helpers for common RAG steps:
log_retrieval(span, chunks=...): Records retrieved documents. Requireschunk_id,document_id,document_name,content, andscore.rankandretrieval_methodare populated automatically. Setselected=Truefor chunks that are passed into the context window.log_context(span, chunks=..., max_tokens=...): Records the assembled context window.log_prompt(span, prompt=...): Logs prompt templates or formatted prompts.log_generation(span, output=..., usage=..., model=...): Records LLM completion outputs and token usage metrics.
Tip: The helpers accept an existing span context. Matching
trace.log_*methods are also available to log instantaneous events.
Configuration
You can configure the client via environment variables or constructor arguments (constructor values override environment variables):
| Variable | Default | Description |
|---|---|---|
RAGLENS_BASE_URL |
http://localhost:8000 |
Ingestion API URL |
RAGLENS_API_KEY |
(None) | Your RAGLens API key |
RAGLENS_ENABLED |
true |
Set to false to disable delivery in testing/CI |
Delivery Behavior
- Delivery is synchronous on trace exit.
- HTTP timeout defaults to 2 seconds.
- Serialization and delivery failures produce warnings without crashing or replacing application exceptions. Application errors propagate normally.
Development
pip install -e '.[dev]'
pytest tests/
Metadata
Release files for raglens-sdk 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| raglens_sdk-0.1.1.tar.gz | 6.7 kB | Without provenance | Details for raglens_sdk-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| raglens_sdk-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for raglens_sdk-0.1.1-py3-none-any.whl |
Total release size: 13.4 kB
Release files / raglens_sdk-0.1.1.tar.gz
| Download URL | raglens_sdk-0.1.1.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c9cb9dae208a83572f75a44c3418597fd248e1308684a03c722874df34640bfe
|
|
BLAKE2b-256 checksum How to use checksums |
e9f23830a814c32bfe005c09e0f7941f0e78907466e91bd2636b934f14e47cf7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / raglens_sdk-0.1.1-py3-none-any.whl
| Download URL | raglens_sdk-0.1.1-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f048692b3229762bfd445d5ea3c9a942f7b54e322264288c41c67b71783e20f3
|
|
BLAKE2b-256 checksum How to use checksums |
69446cb6856e0c370a53d9308e3af6b233d882d6afa9bb8454493d770a772c6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for raglens-sdk 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.