Skip to main content

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_validity
  • ScoringTag.RAG_FAITHFULNESS -> score:rag_faithfulness
  • ScoringTag.VISION_HALLUCINATION -> score:vision_hallucination
  • ScoringTag.TOXICITY -> score:toxicity
  • ScoringTag.NUMERIC_SCORING -> score:numeric_scoring
  • ScoringTag.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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gaunt-0.1.0.tar.gz (45.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gaunt-0.1.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

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

Hashes for gaunt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fe3ddcd18fc6c2e5fc09acccf0ce569488df02cfc40a47ba2b4d3faa58bc3871
MD5 03a34b17093949f69fc6e1bb86859973
BLAKE2b-256 9c5d76f3b28b534be8d78ae75f43fa0cc41cf3fa94d33742281a7670fe8566c0

See more details on using hashes here.

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

Hashes for gaunt-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8c37f5278abd48aa12d68d96a38799cb72da534c9cef7887ee10fc30792f7958
MD5 029ad9b9e578420d8440fd2588366276
BLAKE2b-256 6048949a70120423ad5747690211144fe2c96d2e89dcfabf1f6e2ef461adb780

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