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.send_in(
    application_id="123",
    message="The monitoring user prompt is sent here",
    additional_parameters={
        "user_id": "1"
    }
)

# Send a response from your LLM
response = hivetrace.send_out(
    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.5.tar.gz (3.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.0.5-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hivetrace-1.0.5.tar.gz
  • Upload date:
  • Size: 3.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.0.5.tar.gz
Algorithm Hash digest
SHA256 3ecc2936a66339b8585947ca7fdf556aae55043f05b43b2058262c76ff82e58c
MD5 cc8601ff9b9b1cb1dda1dddbb832d348
BLAKE2b-256 682c29b275fd4ee67e6d8dbc862c998b5e14008fb22e527d7131565478b22a26

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hivetrace-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 7.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.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 db86d7b0666dfad4913a1d8e4d3d6e2637f299446bd9bf23e1e9c0a008582de0
MD5 a32c882d0b6d7459b0c21e8b43aab931
BLAKE2b-256 273c8152613af93162cc6b8e29b202df8af9f7ab7d919e8ec52867358b40235b

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