Skip to main content

Plug-and-play AI/ML function call logging with replay and patching

Project description

AiBlackBox

AiBlackBox is a universal logging and auditing system for AI and machine learning models. It acts like a “flight recorder” for AI, capturing inputs, outputs, parameters, and metadata of all monitored functions, objects, or classes. Designed for transparency, reproducibility, and debugging, it ensures that AI models are traceable, auditable, and compliant with ethical standards.

Features

Automatic logging of AI model actions Capture all inputs, outputs, parameters, and metadata in real-time.

Function, object, class, and module patching Easily patch functions or entire modules to track behavior without modifying your original code.

Flexible backends Use in-memory logging for testing or connect to persistent storage backends for long-term auditing.

Serialization-safe Handles complex objects safely with customizable serializers.

Replay and audit Inspect recorded actions to debug, audit, or verify model behavior.

Supports AI frameworks out-of-the-box Designed to work with PyTorch, TensorFlow, scikit-learn, and other AI pipelines.

Installation

Install from PyPI:

pip install aiblackbox

For testing purposes, you can use TestPyPI:

pip install --index-url https://test.pypi.org/simple/ aiblackbox

Quick Start from aiblackbox import BlackBox

Initialize the BlackBox

bb = BlackBox()

Log a simple event

bb.log('prediction', {'input': [1,2,3], 'output': 0.95})

Replay logs

for entry in bb.replay(): print(entry)

Public API

The following functions and classes are available for advanced usage:

from aiblackbox import *

Function & object patching

patch_function patch_object patch_module patch_class apply_generic_patches auto_patch_ai_functions

Logging and backends

set_log_backend get_memory_backend LogBackend MemoryBackend

Serialization & safe logging

safe_serialize register_custom_serializer set_max_depth get_and_clear_fallback_logs

Unpatching

unpatch_object unpatch_all

Example: Patching a Function from aiblackbox import BlackBox, patch_function

def my_ai_model(x): return x**2

bb = BlackBox() patched_model = patch_function(my_ai_model, bb.log)

Call patched function

result = patched_model(5)

Replay logs

for entry in bb.replay(): print(entry)

Contributing

Contributions are welcome! Please fork the repository, create a feature branch, and submit a pull request.

License

Distributed under the MIT License. See LICENSE for details.

About

AI Ethics Institute — Our mission is to provide tools for AI transparency, auditability, and accountability, helping organizations build ethical AI systems.

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

aiblackbox-0.1.2.tar.gz (20.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiblackbox-0.1.2-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file aiblackbox-0.1.2.tar.gz.

File metadata

  • Download URL: aiblackbox-0.1.2.tar.gz
  • Upload date:
  • Size: 20.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for aiblackbox-0.1.2.tar.gz
Algorithm Hash digest
SHA256 6d2affbbfd3872a677424abbb0258372407e101a9488ff14eec01c04a63b5027
MD5 9ae18a719a0343ac88d022711e2a9868
BLAKE2b-256 97acbac946b3a89e7f5d89b4f7a45794ff62eb9e672e8bed3e92e93b063e2f24

See more details on using hashes here.

File details

Details for the file aiblackbox-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: aiblackbox-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for aiblackbox-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e243583c8c7b163590fab73e0040fdef14f5025e5eb57ee9ed7271e8a77f73f5
MD5 698aedc3310497ead4e0a10792a321ff
BLAKE2b-256 f3e82c643be8929615a576de34e804a57cea2b9a948233a6d68d70d8c8937bff

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