Metadata-Version: 2.4
Name: traceroai
Version: 0.1.2
Summary: Python SDK for sending RAG traces to TraceroAI
Project-URL: Homepage, https://github.com/chinmai-sd-123/TraceroAI
Project-URL: Repository, https://github.com/chinmai-sd-123/TraceroAI
Author: chinmai-sd-123
License: MIT
Keywords: evaluation,llm,observability,rag,tracing
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Requires-Dist: httpx>=0.27.0
Description-Content-Type: text/markdown

# TraceroAI Python SDK

Send RAG traces to [TraceroAI](https://github.com/chinmai-sd-123/TraceroAI) — a
RAG observability and evaluation platform. Instrument any RAG pipeline
(LangChain, LlamaIndex, or your own) and every answer becomes a debuggable trace.

## Install

```bash
pip install traceroai
```

## Usage

### Context manager (recommended)

Times the block and sends the trace automatically:

```python
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)`:

```python
@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

```python
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:

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