Python SDK for logging LLM traces to an analytics scoring API.
Project description
LLM Analytics Python SDK
Python SDK for collecting LLM app traces (chat, RAG, vision, structured output), standardizing them, and sending them to an Analytics Bank API for scoring.
Features
- Pydantic v2 strict payload models.
- Sync and async clients via
httpx. - Built-in scoring tags via
ScoringTag. - Automatic UUID generation for
trace_id.
Installation
pip install gaunt
For local development:
pip install -e ".[dev]"
Quickstart
from gaunt import Client, ScoringTag
client = Client(
api_key="sk_live_xxx",
base_url="https://analytics-bank.example.com",
)
result = client.log(
project_id="project_123",
inputs={
"messages": [
{"role": "system", "content": "You are a concise assistant."},
{"role": "user", "content": "What is RAG?"},
],
"rag_context": [
{"content": "RAG combines retrieval and generation.", "source_id": "doc-1"},
],
},
outputs={
"raw": "RAG uses retrieved knowledge to ground generations.",
},
expected={"topic": "rag"},
metadata={"env": "prod"},
scoring_tags=[
ScoringTag.RAG_FAITHFULNESS,
ScoringTag.ANSWER_CORRECTNESS,
],
)
print(result)
client.close()
Scoring Tags
ScoringTag.SCHEMA_VALIDITY->score:schema_validityScoringTag.RAG_FAITHFULNESS->score:rag_faithfulnessScoringTag.VISION_HALLUCINATION->score:vision_hallucinationScoringTag.TOXICITY->score:toxicityScoringTag.NUMERIC_SCORING->score:numeric_scoringScoringTag.ANSWER_CORRECTNESS->score:answer_correctness
Payload Shape
The SDK emits payloads in this form:
{
"project_id": "project_123",
"trace_id": "uuid...",
"inputs": {
"messages": [],
"images": [],
"rag_context": [],
"json_schema": {}
},
"outputs": {
"raw": "...",
"parsed": {}
},
"expected": {},
"metadata": {},
"config": {
"scoring_tags": ["score:rag_faithfulness", "score:schema_validity"]
}
}
Testing
pytest -q
Publishing
See docs/publishing.md for a release checklist and TestPyPI/PyPI upload commands.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gaunt-0.1.0.tar.gz.
File metadata
- Download URL: gaunt-0.1.0.tar.gz
- Upload date:
- Size: 45.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.12.8 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe3ddcd18fc6c2e5fc09acccf0ce569488df02cfc40a47ba2b4d3faa58bc3871
|
|
| MD5 |
03a34b17093949f69fc6e1bb86859973
|
|
| BLAKE2b-256 |
9c5d76f3b28b534be8d78ae75f43fa0cc41cf3fa94d33742281a7670fe8566c0
|
File details
Details for the file gaunt-0.1.0-py3-none-any.whl.
File metadata
- Download URL: gaunt-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.12.8 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c37f5278abd48aa12d68d96a38799cb72da534c9cef7887ee10fc30792f7958
|
|
| MD5 |
029ad9b9e578420d8440fd2588366276
|
|
| BLAKE2b-256 |
6048949a70120423ad5747690211144fe2c96d2e89dcfabf1f6e2ef461adb780
|