Briefcase AI Python SDK
Python SDK for AI observability, replay, and decision tracking. This package provides high-performance Rust-powered tools for monitoring and debugging AI applications in Python.
Overview
This Python SDK provides a complete toolkit for AI observability, decision tracking, and replay functionality. Built on a high-performance Rust core with Python bindings via PyO3, it offers the speed of Rust with the convenience of Python.
Features
- High Performance - Rust core with minimal Python overhead
- Memory Efficient - Zero-copy operations where possible
- Type Safe - Full Python type hints and error handling
- Async Support - Async/await compatible operations
Installation
Install the Python SDK using pip:
Quick Start
# Initialize the SDK
# Track an OpenAI API call
# Create decision snapshot
=
# Add input
# Make API call (your existing code)
=
= ..
# Add output with confidence
# Estimate
# Save for analysis
=
=
return
# Use it
=
Advanced Usage Examples
1. Model Performance Monitoring
=
# Track multiple model variants
=
=
# Your model call here...
# decision.add_output(...)
2. Cost Tracking for AI Operations
# Initialize cost calculator
=
# Track costs for different models
=
= 0
=
+=
3. Drift Detection
# Monitor for changes in model outputs
=
# Sample outputs from the same prompt over time
=
=
4. Data Sanitization
# Remove sensitive information before logging
=
=
# Sanitize the input
=
# Use sanitized version in your AI tracking
=
5. Replay and Debugging
=
# Load a previous decision
=
=
# Create replay engine
=
# Replay the decision with same inputs
=
For Rust Developers
This crate is primarily used for building the Python extension. To use Briefcase AI in Rust, use the core library directly:
[]
= "2.0.4"
Building
This crate requires:
- Rust 1.70+
- Python 3.10+
- PyO3 dependencies
Build the Python extension:
Development
For development with maturin:
Then test in Python:
Dependencies
briefcase-core- Core Rust librarypyo3- Python FFI bindingstokio- Async runtime
License
MIT License - see LICENSE file for details.
Related Packages
briefcase-ai- Python package (end users)briefcase-core- Core Rust librarybriefcase-wasm- WebAssembly bindings