-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Python SDK version 0.2 #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dewitt4
wants to merge
2
commits into
main
Choose a base branch
from
sdk-python-0-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -205,3 +205,5 @@ cython_debug/ | |
| marimo/_static/ | ||
| marimo/_lsp/ | ||
| __marimo__/ | ||
| CHANGELOG.md | ||
| MIGRATION_SUMMARY.md | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,202 @@ | ||
| # WhiteBoxAI Python SDK | ||
|
|
||
| Official Python SDK for integrating WhiteBoxAI monitoring into your ML applications. | ||
|
|
||
| ## Features | ||
|
|
||
| - 🚀 **Easy Integration** - Monitor models with just a few lines of code | ||
| - 📊 **Framework Support** - Native integrations for Scikit-learn, PyTorch, TensorFlow, XGBoost, and more | ||
| - 🎯 **Decorator-based Monitoring** - Zero-code-change monitoring with decorators | ||
| - ⚡ **Async/Sync Interfaces** - Support for both synchronous and asynchronous workflows | ||
| - 🔒 **Privacy-First** - Built-in PII detection and data masking | ||
| - 💾 **Local Caching** - TTL-based caching to reduce API calls | ||
| - 📈 **Drift Detection** - Automatic model and data drift monitoring | ||
| - 🎨 **Flexible Configuration** - Extensive configuration options and feature flags | ||
| - 🔍 **Git Integration** - Automatic Git context detection for model versioning | ||
| - 🤖 **Multi-Agent Support** - Monitor CrewAI and LangChain multi-agent workflows | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| pip install whiteboxai-sdk | ||
|
|
||
| # With specific framework support | ||
| pip install whiteboxai-sdk[sklearn] | ||
| pip install whiteboxai-sdk[pytorch] | ||
| pip install whiteboxai-sdk[langchain] | ||
| pip install whiteboxai-sdk[crewai] | ||
| pip install whiteboxai-sdk[all] # All integrations | ||
| ``` | ||
|
|
||
| ## Quick Start | ||
|
|
||
| ### Basic Usage | ||
|
|
||
| ```python | ||
| from whiteboxai import WhiteBoxAI, ModelMonitor | ||
|
|
||
| # Initialize client | ||
| client = WhiteBoxAI(api_key="your-api-key") | ||
|
|
||
| # Create monitor | ||
| monitor = ModelMonitor(client) | ||
|
|
||
| # Register model | ||
| model_id = monitor.register_model( | ||
| name="fraud_detection", | ||
| model_type="classification", | ||
| framework="sklearn" | ||
| ) | ||
|
|
||
| # Log predictions | ||
| monitor.log_prediction( | ||
| inputs={"amount": 100.0, "merchant": "store_123"}, | ||
| output={"fraud_probability": 0.15, "prediction": "legitimate"} | ||
| ) | ||
| ``` | ||
|
|
||
| ### Git Integration | ||
|
|
||
| ```python | ||
| from whiteboxai import WhiteBoxAI, detect_git_context | ||
|
|
||
| # Auto-detect Git context | ||
| git_context = detect_git_context() | ||
|
|
||
| # Initialize with Git context | ||
| client = WhiteBoxAI(api_key="your-api-key") | ||
| model_id = client.models.register( | ||
| name="my_model", | ||
| **git_context.to_dict() # Include Git metadata | ||
| ) | ||
| ``` | ||
|
|
||
| ### CrewAI Multi-Agent Monitoring | ||
|
|
||
| ```python | ||
| from whiteboxai.integrations import CrewAIMonitor | ||
| from crewai import Agent, Task, Crew | ||
|
|
||
| # Initialize monitor | ||
| monitor = CrewAIMonitor(api_key="your-api-key") | ||
|
|
||
| # Define your crew | ||
| crew = Crew(agents=[...], tasks=[...]) | ||
|
|
||
| # Start monitoring | ||
| workflow_id = monitor.start_monitoring( | ||
| crew=crew, | ||
| workflow_name="Research Workflow" | ||
| ) | ||
|
|
||
| # Execute crew | ||
| result = crew.kickoff() | ||
|
|
||
| # Complete monitoring | ||
| summary = monitor.complete_monitoring(outputs={"result": result}) | ||
| ``` | ||
|
|
||
| ### LangChain Multi-Agent Monitoring | ||
|
|
||
| ```python | ||
| from whiteboxai.integrations import LangGraphMultiAgentMonitor | ||
|
|
||
| # Create monitor | ||
| monitor = LangGraphMultiAgentMonitor( | ||
| client=client, | ||
| workflow_name="Multi-Agent Research" | ||
| ) | ||
|
|
||
| # Start monitoring | ||
| workflow_id = monitor.start_monitoring() | ||
|
|
||
| # Register agents | ||
| monitor.register_agent("supervisor", role="Coordinates agents") | ||
| monitor.register_agent("researcher", role="Gathers information") | ||
|
|
||
| # Execute with callbacks | ||
| result = agent_executor.run( | ||
| callbacks=monitor.get_callbacks("researcher") | ||
| ) | ||
|
|
||
| # Complete monitoring | ||
| summary = monitor.complete_monitoring(outputs={"result": result}) | ||
| ``` | ||
|
|
||
| ## Framework Integrations | ||
|
|
||
| ### Scikit-learn | ||
|
|
||
| ```python | ||
| from whiteboxai.integrations import SklearnMonitor | ||
| from sklearn.ensemble import RandomForestClassifier | ||
|
|
||
| # Wrap your model | ||
| monitor = SklearnMonitor(client=client, model_id=model_id) | ||
| model = RandomForestClassifier() | ||
| wrapped_model = monitor.wrap(model) | ||
|
|
||
| # Use as normal - monitoring happens automatically | ||
| wrapped_model.fit(X_train, y_train) | ||
| predictions = wrapped_model.predict(X_test) | ||
| ``` | ||
|
|
||
| ### PyTorch | ||
|
|
||
| ```python | ||
| from whiteboxai.integrations import TorchMonitor | ||
| import torch.nn as nn | ||
|
|
||
| # Monitor your model | ||
| monitor = TorchMonitor(client=client, model_id=model_id) | ||
| model = MyNeuralNetwork() | ||
| monitor.attach(model) | ||
|
|
||
| # Training is automatically monitored | ||
| for epoch in range(num_epochs): | ||
| train(model, train_loader) | ||
| ``` | ||
|
|
||
| ### TensorFlow/Keras | ||
|
|
||
| ```python | ||
| from whiteboxai.integrations import KerasMonitor | ||
|
|
||
| # Add callback | ||
| monitor = KerasMonitor(client=client, model_id=model_id) | ||
| model.fit( | ||
| X_train, y_train, | ||
| callbacks=[monitor.get_callback()], | ||
| epochs=10 | ||
| ) | ||
| ``` | ||
|
|
||
| ### LangChain | ||
|
|
||
| ```python | ||
| from whiteboxai.integrations import LangChainMonitor | ||
|
|
||
| # Monitor chain execution | ||
| monitor = LangChainMonitor(client=client) | ||
| callback = monitor.create_callback() | ||
|
|
||
| chain.run("question", callbacks=[callback]) | ||
| ``` | ||
|
|
||
| ## Documentation | ||
|
|
||
| - [Getting Started Guide](getting-started.md) - Detailed installation and setup | ||
| - [Integration Guides](integrations.md) - Framework-specific integration tutorials | ||
| - [Offline Mode](offline-mode.md) - Running without internet connectivity | ||
| - [Production Deployment](PRODUCTION_DEPLOYMENT.md) - Best practices for production | ||
| - [API Reference](api-reference.md) - Complete API documentation | ||
|
|
||
| ## Support | ||
|
|
||
| - **Documentation**: [Full Documentation](https://github.com/AgentaFlow/whitebox-python-sdk) | ||
| - **Issues**: [GitHub Issues](https://github.com/AgentaFlow/whitebox-python-sdk/issues) | ||
| - **Community**: [Discussions](https://github.com/AgentaFlow/whitebox-python-sdk/discussions) | ||
|
|
||
| ## License | ||
|
|
||
| MIT License - see [LICENSE](https://github.com/AgentaFlow/whitebox-python-sdk/blob/main/LICENSE) for details. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| site_name: WhiteBoxAI Python SDK | ||
| site_description: Official Python SDK for WhiteBoxAI - AI Observability & Explainability Platform | ||
| site_author: AgentaFlow | ||
| site_url: https://github.com/AgentaFlow/whitebox-python-sdk | ||
|
|
||
| repo_name: AgentaFlow/whitebox-python-sdk | ||
| repo_url: https://github.com/AgentaFlow/whitebox-python-sdk | ||
| edit_uri: edit/main/docs/ | ||
|
|
||
| theme: | ||
| name: material | ||
| palette: | ||
| # Palette toggle for light mode | ||
| - media: "(prefers-color-scheme: light)" | ||
| scheme: default | ||
| primary: indigo | ||
| accent: indigo | ||
| toggle: | ||
| icon: material/brightness-7 | ||
| name: Switch to dark mode | ||
| # Palette toggle for dark mode | ||
| - media: "(prefers-color-scheme: dark)" | ||
| scheme: slate | ||
| primary: indigo | ||
| accent: indigo | ||
| toggle: | ||
| icon: material/brightness-4 | ||
| name: Switch to light mode | ||
| features: | ||
| - navigation.tabs | ||
| - navigation.sections | ||
| - navigation.expand | ||
| - navigation.top | ||
| - search.suggest | ||
| - search.highlight | ||
| - content.code.copy | ||
| - content.code.annotate | ||
|
|
||
| plugins: | ||
| - search | ||
| - mkdocstrings: | ||
| handlers: | ||
| python: | ||
| paths: [src] | ||
| options: | ||
| docstring_style: google | ||
| show_source: true | ||
|
|
||
| markdown_extensions: | ||
| - pymdownx.highlight: | ||
| anchor_linenums: true | ||
| line_spans: __span | ||
| pygments_lang_class: true | ||
| - pymdownx.inlinehilite | ||
| - pymdownx.snippets | ||
| - pymdownx.superfences | ||
| - pymdownx.tabbed: | ||
| alternate_style: true | ||
| - admonition | ||
| - pymdownx.details | ||
| - pymdownx.emoji: | ||
| emoji_index: !!python/name:material.extensions.emoji.twemoji | ||
| emoji_generator: !!python/name:material.extensions.emoji.to_svg | ||
| - attr_list | ||
| - md_in_html | ||
| - toc: | ||
| permalink: true | ||
|
|
||
| nav: | ||
| - Home: index.md | ||
| - Getting Started: | ||
| - Installation: getting-started.md | ||
| - Offline Mode: offline-mode.md | ||
| - Integrations: | ||
| - Overview: integrations.md | ||
| - Scikit-learn: SKLEARN_INTEGRATION.md | ||
| - PyTorch: PYTORCH_INTEGRATION.md | ||
| - TensorFlow: TENSORFLOW_INTEGRATION.md | ||
| - Hugging Face: HUGGINGFACE_INTEGRATION.md | ||
| - LangChain: LANGCHAIN_INTEGRATION.md | ||
| - Deployment: | ||
| - Production: PRODUCTION_DEPLOYMENT.md | ||
| - API Reference: api-reference.md | ||
|
|
||
| extra: | ||
| social: | ||
| - icon: fontawesome/brands/github | ||
| link: https://github.com/AgentaFlow/whitebox-python-sdk | ||
| - icon: fontawesome/brands/python | ||
| link: https://pypi.org/project/whiteboxai-sdk/ | ||
|
|
||
| copyright: Copyright © 2026 AgentaFlow |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CHANGELOG.md claims to have fixed import errors from "explainai" to "whiteboxai" (line 37-38, 50), but many existing files still contain "from explainai" imports. The following files were not updated and will cause ImportErrors:
All these imports need to be changed from "explainai" to "whiteboxai" to match the claimed fix and prevent breaking existing functionality.