Skip to main content

Python SDK for HalluTrace AI - LLM hallucination detection & tracing

Project description

HalluTrace AI - Python SDK

Detect hallucinations in your LLM applications with HalluTrace AI.

Installation

pip install hallutraceai

Quick Start

from hallutraceai import HalluTrace

ht = HalluTrace(api_key="sk_live_your_api_key")

# Send a trace
ht.trace(
    session_id="chat-123",
    message_id="msg-1",
    type="agent",
    input="What is the capital of France?",
    output="The capital of France is Paris.",
    system_prompt="You are a helpful assistant.",
    model_name="gpt-4",
)

Batch Tracing

ht.trace_batch([
    {
        "session_id": "chat-123",
        "messages": [
            {
                "message_id": "msg-1",
                "type": "agent",
                "input": "Hello",
                "output": "Hi! How can I help?",
                "model_name": "gpt-4",
            },
            {
                "message_id": "msg-2",
                "type": "tool",
                "input": "search: weather",
                "output": '{"temp": 72, "condition": "sunny"}',
            },
        ],
    }
])

Message Types

  • agent — LLM responses (evaluated for hallucinations)
  • tool — Tool/function call results (logged but not evaluated)

API Reference

HalluTrace(api_key, base_url=None, timeout=30.0)

Create a client instance.

ht.trace(session_id, message_id=None, type="agent", input="", output="", ...)

Send a single trace. Returns session and message info.

ht.trace_batch(traces)

Send multiple traces in one request.

Links

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

hallutraceai-0.1.2.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

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

hallutraceai-0.1.2-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file hallutraceai-0.1.2.tar.gz.

File metadata

  • Download URL: hallutraceai-0.1.2.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for hallutraceai-0.1.2.tar.gz
Algorithm Hash digest
SHA256 6b4a0710d3af20327c9bfedd33f4d92b7df5941fa0e33f9ac10b985219af747e
MD5 ad50ca34c02760d7f1b27e184646f635
BLAKE2b-256 f7800d8806be5e83f4f622f4205c2921b16c274cbb99de2ef12e452627bfd72a

See more details on using hashes here.

File details

Details for the file hallutraceai-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: hallutraceai-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for hallutraceai-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e871e02cda0fd18d7877658fdf2e87eb6e5604a6454ee0fb8dfca9e7823fbb15
MD5 13edbbc51d4f29710f71f1a6423d3b20
BLAKE2b-256 123d01c59e2ec268f25d8b80d21e26cacb100ddb0b07e8bee7309e9bb4165ca1

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