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.3.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.

hallutraceai-0.1.3-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hallutraceai-0.1.3.tar.gz
  • Upload date:
  • Size: 4.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.3.tar.gz
Algorithm Hash digest
SHA256 594565fc868f87fc218aec48b932d849522b721e3714063002c3203986415592
MD5 ef4d8461a233d2946424e86cf45c3554
BLAKE2b-256 9cfd4fe05baf962d169eb65c0f517c6e90ee326088c60f8b350842f3d6858506

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hallutraceai-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 01b98648a9f8bf79367093b4d3a8e11199d2f1c6da5e9c060ad38ba072d7a688
MD5 59973f2b6300054f1ad8290c00dfc391
BLAKE2b-256 e8e9d42a1967cee5dbfde099b8dd3ae4f07d26e29628be87d267e919455156d7

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