Skip to main content

Python SDK for sending RAG traces to TraceroAI

Project description

TraceroAI Python SDK

Send RAG traces to TraceroAI — a RAG observability and evaluation platform. Instrument any RAG pipeline (LangChain, LlamaIndex, or your own) and every answer becomes a debuggable trace.

Install

pip install traceroai

Usage

Context manager (recommended)

Times the block and sends the trace automatically:

from traceroai import TraceroClient

client = TraceroClient(
    base_url="https://traceroai.onrender.com",
    api_key="your_project_key",
)

with client.trace("How long does a refund take?") as t:
    t.log_retrieval(chunks, strategy="hybrid", config={"final_top_k": 3})
    t.log_prompt(prompt_text, version="grounded_v1")
    t.log_generation(answer, model="gpt-4o-mini")

print(t.trace_id)

Decorator

For a function that returns (answer, chunks):

@client.traced(model="gpt-4o-mini", strategy="hybrid")
def answer(query: str):
    chunks = retrieve(query)
    return generate(query, chunks), chunks

answer("What is the maximum file upload size?")  # traced automatically

Low-level

client.log_trace(
    query={"original": question},
    retrieval={"strategy": "hybrid", "chunks": chunks},
    generation={"model": "gpt-4o-mini", "answer": answer},
)

Authentication (multi-tenant)

Pass your project API key; the server attributes traces to your project:

client = TraceroClient(base_url="https://traceroai.onrender.com", api_key="your_project_key")

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

traceroai-0.1.2.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

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

traceroai-0.1.2-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file traceroai-0.1.2.tar.gz.

File metadata

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

File hashes

Hashes for traceroai-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5b3876dae51e0ae8da5b7891c9d085a63c8de11a3c1379824528af2cf8776f7f
MD5 b59cf9aa6c80cb2463bce0a75b14d0fb
BLAKE2b-256 83a059977ff214ad3f570c3da992f16b7b6ceababa78f9aa084a544fb75b19bd

See more details on using hashes here.

File details

Details for the file traceroai-0.1.2-py3-none-any.whl.

File metadata

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

File hashes

Hashes for traceroai-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cd8b04146ab0004312510fa1f701afc8905abd72b908003f623d7a2ecf26744b
MD5 cdce7f9dba8719a118bccf3580ca8609
BLAKE2b-256 cc4e5f4d847f937ed7cbb0194bf3074aff34475f9e6b5e59afbf74fa876e6bad

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