A Python logger for HoneyHive
Project description
HoneyHive Logger
A Python logger for HoneyHive that helps you track and monitor your AI applications.
Installation
pip install honeyhive-logger
Usage
from honeyhive_logger import start, log, update
# Start a new session
session_id = start(
api_key="your-api-key",
project="your-project"
)
# Log an event
event_id = log(
session_id=session_id,
event_name="model_inference",
event_type="model",
inputs={"prompt": "Hello world"},
outputs={"response": "Hi there!"}
)
# Update an event with additional data
update(
event_id=event_id, # Can also pass session_id to update a session
feedback={"rating": 5},
metrics={"latency": 100}
)
API Reference
start()
Starts a new session with HoneyHive.
Parameters:
api_key(str, optional): Your HoneyHive API key. Must be provided or set via HH_API_KEY env var.project(str, optional): The project name. Must be provided or set via HH_PROJECT env var.session_name(str, optional): Optional tag to filter sessions on "v1", "au1i249c" (commit hash), etc. Defaults to project name.source(str, optional): Environment where the code is running. Defaults to "dev" or HH_SOURCE env var.config(dict, optional): Configuration details for the session like experiment versions, model names, etc.inputs(dict, optional): Input parameters for the session.metadata(dict, optional): Additional metadata for the session.user_properties(dict, optional): User-defined properties for the session.session_id(str, optional): A valid UUIDv4 for the session to correlate with your logs. If not provided, one will be generated.server_url(str, optional): HoneyHive API server URL. Defaults to "https://api.honeyhive.ai" or HH_API_URL env var.verbose(bool, optional): Print detailed error messages for debugging. Defaults to False.
Returns:
str: The session ID (UUIDv4)
Example:
session_id = start(
api_key="your-api-key",
project="your-project",
session_name="v1",
source="prod",
config={
"model": "gpt-4",
"temperature": 0.7
}
)
log()
Logs an event to HoneyHive.
Parameters:
api_key(str, optional): Your HoneyHive API key. Must be provided or set via HH_API_KEY env var.project(str, optional): The project name. Must be provided or set via HH_PROJECT env var.source(str, optional): Environment where the code is running. Defaults to "dev" or HH_SOURCE env var.event_name(str): Name of the event being logged. Required.event_type(str, optional): Type of event - "model", "tool", or "chain". Defaults to "tool".config(dict, optional): Configuration details for the event like model name, vector index name, etc.inputs(dict, optional): Input parameters for the event.outputs(dict, optional): Output data from the event.metadata(dict, optional): Additional metadata for the event.session_id(str): The ID of the session to log the event under. If not provided, a session is automatically created.duration_ms(int, optional): Duration of the event in milliseconds. If not provided, will be set to 10.server_url(str, optional): HoneyHive API server URL. Defaults to "https://api.honeyhive.ai" or HH_API_URL env var.verbose(bool, optional): Print detailed error messages for debugging. Defaults to False.
Returns:
str: The event ID (UUIDv4)
Example:
event_id = log(
session_id="your-session-id",
event_name="model_inference",
event_type="model",
config={
"model": "gpt-4",
"temperature": 0.7
},
inputs={
"prompt": "Hello world"
},
outputs={
"response": "Hi there!"
}
)
update()
Updates an event or session with additional data.
Parameters:
api_key(str, optional): Your HoneyHive API key. Must be provided or set via HH_API_KEY env var.event_id(str): The ID to update. This can be either:- A session_id returned from start()
- An event_id returned from log()
metadata(dict, optional): Additional metadata for the event/session.feedback(dict, optional): User feedback for the event/session.metrics(dict, optional): Metrics computed for the event/session.config(dict, optional): Configuration used in the event/session.outputs(dict, optional): Output data from the event/session.user_properties(dict, optional): User-defined properties for the event/session.duration_ms(int, optional): Duration of the event in milliseconds.server_url(str, optional): HoneyHive API server URL. Defaults to "https://api.honeyhive.ai" or HH_API_URL env var.verbose(bool, optional): Print detailed error messages for debugging. Defaults to False.
Returns:
None
Example:
# Update a session
update(
event_id=session_id,
metadata={
"status": "completed"
}
)
# Update an event
update(
event_id=event_id,
feedback={
"rating": 5,
"comment": "Great response!"
},
metrics={
"latency": 100,
"tokens": 50
}
)
Error Handling
The logger will raise exceptions for:
- Invalid API keys
- Network errors
- Invalid parameters
- Server errors
Each error includes detailed information about what went wrong and how to fix it. For example:
- Missing required parameters
- Invalid event types
- API key or project not found
- Network connectivity issues
- Server-side errors
Documentation
For detailed documentation, please visit https://docs.honeyhive.ai
License
MIT License
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
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 honeyhive_logger-0.0.7.tar.gz.
File metadata
- Download URL: honeyhive_logger-0.0.7.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b37a9a5f64d895409310d24637e69186b2c6ae44e06409525229499edc0fe1b8
|
|
| MD5 |
5bc779c9e75cbc8971b02c4bb93b6649
|
|
| BLAKE2b-256 |
ab7fbce0848be51749f4fa22f36a84ac5c93fb60dc86778e61f9a07488b6880f
|
File details
Details for the file honeyhive_logger-0.0.7-py3-none-any.whl.
File metadata
- Download URL: honeyhive_logger-0.0.7-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a9a3cbe415158304a896c7cc968ccd139ebf02c53912cc660b2b98107a645f2
|
|
| MD5 |
980f1ece9984facd2ab9301fcf80cb69
|
|
| BLAKE2b-256 |
cad8bb90b8a63005d05f6cd8c96252ba707b6ee10ae5f2eca55f3720a4bed2b0
|