OSBot-Utils
A comprehensive Python utility toolkit providing Type-Safe primitives, decorators, caching layers, HTML/AST helpers, SQLite tooling, SSH execution, LLM request pipelines, tracing, and more — all designed to accelerate building robust, maintainable automation and integration code.
✨ Key Features
- 🛡️ Type-Safe First: Strongly typed primitives (
Safe_Str,Safe_Int,Safe_Float, etc.) with validation and sanitization - ⚡ Multi-layer Caching: In-memory, per-instance, pickle-on-disk, temp-file, and request/response caches
- 🗂️ Rich Utilities: Helpers for HTML parsing/rendering, AST inspection, SSH/SCP execution, SQLite schema management, and more
- 🧠 LLM Support: Structured request builders, OpenAI API integration, schema enforcement, and persistent cache
- 🔍 Tracing & Debugging: Full function call tracing with configurable depth, locals capture, and pretty output
- 🧪 Testing Utilities: Temp SQLite DBs, mockable caches, and easy test helpers
📦 Installation
pip install osbot-utils
From source:
pip install git+https://github.com/owasp-sbot/OSBot-Utils.git@dev
🚀 Quick Start
Using Type-Safe Primitives
from osbot_utils.type_safe.primitives.safe_str.Safe_Str import Safe_Str
class Username(Safe_Str):
max_length = 20
print(Username("alice")) # 'alice'
print(Username("invalid username!")) # 'invalid_username_'
Simple In-Memory Caching
from osbot_utils.decorators.methods.cache_on_self import cache_on_self
class DataFetcher:
@cache_on_self
def fetch(self, x):
print("Fetching…")
return x * 2
fetcher = DataFetcher()
fetcher.fetch(10) # Calls method
fetcher.fetch(10) # Returns cached result
HTML Parsing
from osbot_utils.helpers.html.transformers.Html__To__Html_Dict import html_to_dict
html_code = "<html><body><h1>Hello</h1></body></html>"
print(html_to_dict(html_code))
SQLite Dynamic Table
from osbot_utils.helpers.sqlite.Temp_Sqlite__Table import Temp_Sqlite__Table
with Temp_Sqlite__Table() as table:
table.row_schema = type("Row", (), {"name": str, "age": int})
table.create()
table.add_row_and_commit(name="Alice", age=30)
print(table.rows())
LLM Request Execution
from osbot_utils.helpers.llms.builders.LLM_Request__Builder__Open_AI import LLM_Request__Builder__Open_AI
from osbot_utils.helpers.llms.actions.LLM_Request__Execute import LLM_Request__Execute
builder = LLM_Request__Builder__Open_AI()
builder.set__model__gpt_4o().add_message__user("Say hi in JSON")
executor = LLM_Request__Execute(request_builder=builder)
response = executor.execute(builder.llm_request())
print(response.response_data)
🏗️ Architecture
OSBot-Utils is organized into core Type-Safe foundations with layered utilities for different domains:
┌──────────────────────────────────────────────┐
│ Your Code │
│ ┌───────────┐ ┌─────────────┐ ┌──────────┐ │
│ │ Type-Safe │ │ Decorators │ │ Helpers │ │
│ │ Primitives│ │ & Caching │ │ (HTML, │ │
│ │ │ │ │ │ AST, │ │
│ │ │ │ │ │ SQLite)│ │
│ └───────────┘ └─────────────┘ └──────────┘ │
└──────────────────────────┬───────────────────┘
│
┌──────────────────────────▼───────────────────┐
│ OSBot-Utils │
│ ┌────────────────────────────────────────┐ │
│ │ Type-Safe Core Classes │ │
│ │ Validation / Sanitization / Defaults │ │
│ └────────────────────────────────────────┘ │
│ ┌────────────────────────────────────────┐ │
│ │ Caching Layers & Decorators │ │
│ │ @cache, @cache_on_self, pickle, tmp │ │
│ └────────────────────────────────────────┘ │
│ ┌────────────────────────────────────────┐ │
│ │ Domain Helpers │ │
│ │ HTML, AST, SSH, LLMs, SQLite, Tracing │ │
│ └────────────────────────────────────────┘ │
└──────────────────────────────────────────────┘
📚 Key Modules
helpers/safe_*— Type-Safe primitives for validated strings, ints, floatsdecorators/methods— Caching, exception capture, timing, validationhelpers/html— HTML ↔ dict ↔ tag classeshelpers/ast— Python AST parsing, visiting, merginghelpers/sqlite— High-level SQLite APIs, schema generation, temp DBshelpers/ssh— SSH/SCP execution with cachinghelpers/llms— LLM request/response handling with cachinghelpers/trace— Function call tracing with configurable output
🎯 Benefits
For Developers
- Strong runtime type validation with Type-Safe classes
- Consistent patterns for caching and decorators
- Rich helper library to avoid reinventing the wheel
For Production
- Deterministic caching with persistence options
- Safe, validated data structures at integration boundaries
- Lightweight, dependency-minimal utilities
For Teams
- Standardized approach to cross-cutting concerns (logging, tracing, caching)
- Modular helpers to fit many contexts (CLI, web apps, serverless)
🤝 Contributing
Pull requests are welcome!
Check existing patterns in /helpers and /decorators for style guidance.
📄 License
Licensed under the Apache 2.0 License.
Metadata
Release files for osbot-utils 3.75.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| osbot_utils-3.75.0.tar.gz | 365.1 kB | Without provenance | Details for osbot_utils-3.75.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| osbot_utils-3.75.0-py3-none-any.whl | Python 3 | none | any | Details for osbot_utils-3.75.0-py3-none-any.whl |
Total release size: 1.0 MB
Release files / osbot_utils-3.75.0.tar.gz
| Download URL | osbot_utils-3.75.0.tar.gz |
|---|---|
| Size | 365.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cedbd44a6093a25e2ae1852edf822706163273819f4d4c91b31be2d7e7b61673
|
|
BLAKE2b-256 checksum How to use checksums |
1c970342d2c68ccfc74ab1f3285a8d1de847de13cadc9d9ae58bcfc64cbdbac8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / osbot_utils-3.75.0-py3-none-any.whl
| Download URL | osbot_utils-3.75.0-py3-none-any.whl |
|---|---|
| Size | 662.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
784d45c959be216210bb3de07cfc3c309644073a8c0fe656e71dbfb45a294968
|
|
BLAKE2b-256 checksum How to use checksums |
61df4960b491af1d8bc92f3bb9b04310a88698784f8feae976970b6e28d6e491
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Security for osbot-utils 3.75.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.