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.0.tar.gz (4.9 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.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: traceroai-0.1.0.tar.gz
  • Upload date:
  • Size: 4.9 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.0.tar.gz
Algorithm Hash digest
SHA256 6c919a8368b0282e88f91f50df93555d3ea9960d05b2f169939e0f029457cb56
MD5 309928564201370a6b391db5f8c79ec4
BLAKE2b-256 a7ba7a258b144a804dac49d66f2bb87b9ab55b079f1bf43f749974fc18f63ac2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: traceroai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.6 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d652e34be49d32cbcd4559b2f234a0de09e3848e8c4a17669383a82da5cef405
MD5 bdb78e3487e729115bbb9645c25ff7d9
BLAKE2b-256 917c67cc90a877f430b35b927028698c52179bb41b8e1022694894b39989c826

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