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 identifiermessage- user promptadditional_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 identifiermessage- LLM responseadditional_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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hivetrace-1.0.0.tar.gz.
File metadata
- Download URL: hivetrace-1.0.0.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f43dc5b75a2382939105728390baacb2e6a0a1de6275b64e4e5fb5bbc9304ca3
|
|
| MD5 |
13b5a5994bbce94e697527ff4a6c1b83
|
|
| BLAKE2b-256 |
74e35c2c74353c64d4bb662fe650421d864557d9c6b16b31fb7a05206ea6a4d8
|
File details
Details for the file hivetrace-1.0.0-py3-none-any.whl.
File metadata
- Download URL: hivetrace-1.0.0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb80aa31de3bc87ac48f5181024a41d7221e9a9e5ecc844a71274020e57457ad
|
|
| MD5 |
1d54f04dd66cb7e0ad04fc4fe425a317
|
|
| BLAKE2b-256 |
aadf1bb5ff417bc57a8d08aa5b6b304585a82384de1aeddadd82a5c1122226ce
|