Skip to main content

Hivetrace SDK for monitoring LLM applications

Project description

Hivetrace SDK

Description

Hivetrace SDK is designed for integration with the Hivetrace service, providing monitoring of user prompts and LLM responses.

Installation

Install the SDK via pip:

pip install hivetrace

Usage

from hivetrace.hivetrace import HivetraceSDK

Initialize the SDK

hivetrace = HivetraceSDK()

Send a user prompt

response = hivetrace.input(
    application_id="your-application-id", # get after registering the application in the UI
    message="User prompt here"
)

Send a response from your LLM

response = hivetrace.output(
    application_id="your-application-id", # get after registering the application in the UI
    message="LLM response here"
)

Example with additional parameters

response = hivetrace.input(
    application_id="your-application-id",
    message="User prompt here",
    additional_parameters={
        "session_id": "your-session-id",
        "user_id": "your-user-id",
        "agents": {
            "agent-1-id": {"name": "Agent 1", "description": "Agent description"},
            "agent-2-id": {"name": "Agent 2"},
            "agent-3-id": {}
        }
    }
)

API

input(application_id: str, message: str, additional_parameters: dict = None) -> dict

Sends a user prompt to Hivetrace.

  • application_id - Application identifier (must be a valid UUID, created in the UI)
  • message - User prompt
  • additional_parameters - Dictionary of additional parameters (optional)

Response Example for input()

{
    "status": "processed",
    "monitoring_result": {
        "is_toxic": false,
        "type_of_violation": "benign",
        "token_count": 9,
        "token_usage_warning": false,
        "token_usage_unbounded": false
    }
}

output(application_id: str, message: str, additional_parameters: dict = None) -> dict

Sends an LLM response to Hivetrace.

  • application_id - Application identifier (must be a valid UUID, created in the UI)
  • message - LLM response
  • additional_parameters - Dictionary of additional parameters (optional)

Response Example for output()

{
    "status": "processed",
    "monitoring_result": {
        "is_toxic": false,
        "type_of_violation": "safe",
        "token_count": 21,
        "token_usage_warning": false,
        "token_usage_unbounded": false
    }
}

Additional Parameters

The additional_parameters argument is an optional dictionary that allows passing extra metadata along with requests. It may include:

  • user_id (str, optional) – Unique user identifier (must be a valid UUID).
  • session_id (str, optional) – UUID representing a session.
  • agents (dict, optional) – Dictionary where keys are agent IDs (must be valid UUIDs) and values contain agent metadata:
    • name (str, optional) – Agent's name. If not provided, it will be automatically generated based on parts of its ID.
    • description (str, optional) – Description of the agent.

If user_id is not found in the system, it will be automatically created. Agents provided in the request will also be automatically registered in the system and can be viewed in the UI.

Configuration

The SDK loads configuration from environment variables. The allowed domain (HIVETRACE_URL) and access token (HIVETRACE_ACCESS_TOKEN) is automatically retrieved from the environment.

Configuration Sources

Hivetrace SDK can retrieve the configuration from the following sources:

  1. .env File: Place a .env file in your project directory containing:
    HIVETRACE_URL=https://your-hivetrace-instance.com
    HIVETRACE_ACCESS_TOKEN=your-access-token
    
    The SDK will automatically load this.

License

This project is licensed under the Apache License 2.0.

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

hivetrace-1.1.2.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

hivetrace-1.1.2-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file hivetrace-1.1.2.tar.gz.

File metadata

  • Download URL: hivetrace-1.1.2.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for hivetrace-1.1.2.tar.gz
Algorithm Hash digest
SHA256 c062845695fef80bca959c94c65b3a3423d07d045849addcd12d2c89727e7ebc
MD5 107cc69fc7ade5f170594f180223023b
BLAKE2b-256 f4d22d5d1702dcacb456862da0b7a7d2d5313c8473a5bb2120e5b04a5e21b915

See more details on using hashes here.

File details

Details for the file hivetrace-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: hivetrace-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for hivetrace-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cc0430da3c2e0ace7cd0295a1b2a754e1a0157e96e10ad660e7c8f82f508bda5
MD5 4084847e893c9f0afed49b1de5d23b5f
BLAKE2b-256 034c74ee53dda2fb9cdff49528d7695b0a2e2158aab2ff53da8abb5a891c4228

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