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. The SDK automatically loads the configuration and sends data to the API

Installation

Install the SDK via pip:

pip install hivetrace

Usage

from hivetrace import HivetraceSDK

Create a hivetrace_config.json with the contents:

{
  "hivetrace_url": "https://your-hivetrace-instance.com"
}

Specify the path to the config

hivetrace_config_path = "your/path/hivetrace_config.json"

Initialize the SDK

hivetrace = HivetraceSDK(hivetrace_config_path)

# Send a user prompt
response = hivetrace.monitor_user(
    application_id="123",
    message="The monitoring user prompt is sent here",
    additional_parameters={
        "user_id": "1"
    }
)

# Send a response from your LLM
response = hivetrace.monitor_llm(
    application_id="123",
    message="The monitoring llm response is sent here",
    additional_parameters={
        "agent_id": "2"
    }
)

API

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

Sends a user prompt to the Hivetrace

  • application_id - application identifier
  • message - user prompt
  • additional_parameters - dictionary of additional parameters (optional)

Response Example for monitor_user()

{
    "status": "processed",
    "total_user_monitoring_result": [
        {
            "is_toxic": true,
            "type_of_violation": "injection"
        }
    ]
}

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

Sends an LLM response to the Hivetrace

  • application_id - application identifier
  • message - LLM response
  • additional_parameters - dictionary of additional parameters (optional)

Response Example for monitor_llm()

{
    "status": "processed",
    "llm monitoring result": {
        "is_toxic": false,
        "type_of_violation": "safe"
    }
}

Additional Parameters

The additional_parameters argument is a flexible dictionary that allows passing extra metadata along with requests

Configuration

The SDK loads configuration from the client file. The allowed domain (hivetrace_url) is automatically retrieved from the configuration. If the domain is not specified, the SDK raises a HostNotFound error

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.0.2.tar.gz (3.0 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.0.2-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for hivetrace-1.0.2.tar.gz
Algorithm Hash digest
SHA256 5397c54111c76c63bf446bb4e39095d4e1c1f7a01761b5272302d9b40badcbfc
MD5 8bee6cd2ab2524799a975100708176fe
BLAKE2b-256 90a18d0110a5a208edfa82f24a1e1d49cf33189d3f227aa76d0072d37f262e9b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hivetrace-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.1 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.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f1812ea2369b81f67b9fbecdb0f4a8aaeb6281845402c49a748d03c93328e763
MD5 aa7653bd2e955e6cd827a92edaeb90fc
BLAKE2b-256 406ab3263bac94360c1f5d66356851a67910929d40f6fc2b7520d69ab5a02122

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