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.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.4.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.4-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hivetrace-1.0.4.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.4.tar.gz
Algorithm Hash digest
SHA256 14ec3767b627859017655e699de7ad493f00e1bef9dd17fc5e96f35948c0a797
MD5 4b5ead25496c76702b0f46db36d08df7
BLAKE2b-256 a98715a03200ff63e34d2012f2c6d66a5f853188c2952b5e0e2db9c53fbad00f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hivetrace-1.0.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 77c63e1a00afc8209872b316b43354323da2e76440c234631efa504ca16737a8
MD5 3ada023a5f345e8a91d3ee5fde19dd18
BLAKE2b-256 77b299751d0ea30be62cd10ba5ead528e8fbfc8f3c7a80db8effdef6d32b7e5e

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