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="http://localhost:8000")

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://api.traceroai.example", api_key="key_acme")

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: traceroai-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 8179c5cce285117f55c55bb107b3298a4a7834276c84282573f1fb6dfc2fa9f8
MD5 ad298bcaec434ba0954e0f9010daba61
BLAKE2b-256 b4427b9d1e9faaf7fbcbd74b004fe7f2b98a410aede701a4c47e2b95a6a7def4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: traceroai-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2f312177ac0470315df6e93ac1c7b9232bde00542281c0212ba9b5e9e277a9d1
MD5 01f1607023235097e43a40faae79cecf
BLAKE2b-256 6af4ab47258f31d94ad83f1c2f3ffb0eb33e3b9d40a7e8775e73aade0f4edd40

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