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

Uploaded Python 3

File details

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

File metadata

  • Download URL: hivetrace-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 cf99f26ae0e645cbbc5273907f4218816d21974236792f4d858004034fda978e
MD5 83c58d78ffc2c117bfc8e62e33dc7386
BLAKE2b-256 a9a346be1cfd9803b2469c0439dbecf02a738aad2f5c091a3472446dbb40c9bb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hivetrace-1.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ee123627c2125bb4f7ae4805363036ac8d8b2891ad436df851f92d9395ed1a60
MD5 b80bed36a591f8888fc2aa1131ab77b0
BLAKE2b-256 8441c2ec199591713e619c93df2d80a175596b8ce695035055ef499c083eed28

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