Automation browser error detection and screen detection with AI fallback and cache
Project description
Automation Error Detector
🚀 Automation Error Detector là một Python package giúp bạn phát hiện và phân loại lỗi màn hình trình duyệt trong automation, sử dụng OpenAI API chỉ một lần, sau đó cache kết quả để tái sử dụng mà không cần AI nữa.
Package được thiết kế theo DDD + Clean Architecture, cho phép bạn tự do lưu cache ở bất kỳ đâu (Redis, PostgreSQL, file, cloud, v.v.) thông qua callback.
✨ Features
- ✅ Phát hiện lỗi từ text trên màn hình trình duyệt
- 🤖 AI fallback (OpenAI) chỉ dùng khi cache miss
- ⚡ Cache thông minh bằng signature từ keywords
- 🔌 Pluggable cache callback (Redis, Postgres, JSON, custom)
- 🧱 Kiến trúc DDD + Clean Architecture
- 📦 Sẵn sàng publish & reuse qua PyPI
- 🧪 Dễ test, dễ mở rộng, production-ready
📦 Installation
pip install automation-error-detector
🔐 Environment Variables
| Name | Required | Description |
|---|---|---|
| OPENAI_API_KEY | ✅ | OpenAI API key |
| OPENAI_MODEL | ❌ | Model name (default: gpt-4.1-mini) |
| ERROR_CACHE_FILE | ❌ | Cache file path (JSON adapter) |
export OPENAI_API_KEY="sk-xxxx"
🚀 Quick Start
from application.use_cases.detect_error_use_case import DetectErrorUseCase
from infrastructure.ai.openai_client import OpenAIClient
from infrastructure.cache.json_cache_callback import JsonCacheCallback
cache = JsonCacheCallback()
ai = OpenAIClient()
use_case = DetectErrorUseCase(
cache_callback=cache,
ai_client=ai
)
screen_text = """
Your session has expired.
Please log in again.
"""
result = use_case.execute(screen_text)
print(result.to_dict())
🌐 OpenAI Proxy (Instance-based)
Package KHÔNG dùng HTTP_PROXY / HTTPS_PROXY của OS. Proxy được inject theo từng OpenAIClient instance.
HTTP / HTTPS Proxy
proxy = {
"https": "http://127.0.0.1:8080"
}
ai = OpenAIClient(proxy=proxy)
SOCKS5 Proxy
proxy = {
"socks": "socks5://127.0.0.1:1080"
}
ai = OpenAIClient(proxy=proxy)
🔌 Custom Cache Callback
Bạn có thể lưu cache ở bất kỳ đâu bằng cách implement callback.
from domain.services.cache_callback import CacheSaveCallback
class CacheSaveCallback:
def load(self, signature: str) -> dict | None:
pass
def save(self, signature: str, data: dict) -> None:
pass
⚙️ Configuration API
from config import AppConfig
AppConfig.openai_api_key
AppConfig.openai_model
AppConfig.cache_file
🔒 Security Notes
- Không hard-code API key
- Không commit
.env - Luôn dùng ENV variables
📄 License
MIT License
Project details
Release history Release notifications | RSS feed
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 automation_error_detector-1.3.6.tar.gz.
File metadata
- Download URL: automation_error_detector-1.3.6.tar.gz
- Upload date:
- Size: 13.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a69ca73e548f9be1f3a431ae89cdd527ef1e5f070fc8f2e9c0b8856e2fec49d8
|
|
| MD5 |
5b78e5f8d805b273a7fe1a656b40b4eb
|
|
| BLAKE2b-256 |
1c0d3350721832118b7b8a0bb483cf15dfef9d9656ee1fa5bd00731733c65e53
|
File details
Details for the file automation_error_detector-1.3.6-py3-none-any.whl.
File metadata
- Download URL: automation_error_detector-1.3.6-py3-none-any.whl
- Upload date:
- Size: 21.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57c1c1a465a81695699848f424e2091139350c26c8c52b9320dfc361eafc861c
|
|
| MD5 |
8355f25e9ec066e6e396b4ffe85b6b90
|
|
| BLAKE2b-256 |
b4a4db579a000c38a6bbec34f0005f6fa5273aacdb4c2e28a29c5c28e97b347f
|