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.3.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.3-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: traceroai-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 fc2c81be065411df1d473ee5842d85019ee67e83bcfe7a7b30ee6eac3527e8a0
MD5 ebea1ca039fb82413cb9a827d4dce1f6
BLAKE2b-256 acf9fa7573714cd12f4e284271c7f5a16452f184a95585ac4e5b1dd99e692295

See more details on using hashes here.

File details

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

File metadata

  • Download URL: traceroai-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5c60b60b4ae1831849ed4f267cd31f5c4dca73b272981b435bc4c4a7ac7cb8be
MD5 bce98faa66ab9cf0ca2d6c90ae8ae6da
BLAKE2b-256 5230d83470ff280421e0a6f8675376bd8b8f99307d54ad135c3bf10d8b998448

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