Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

automation_error_detector-1.3.2.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

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

automation_error_detector-1.3.2-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

File details

Details for the file automation_error_detector-1.3.2.tar.gz.

File metadata

File hashes

Hashes for automation_error_detector-1.3.2.tar.gz
Algorithm Hash digest
SHA256 3a6ca4b1c7593a43e89a4e4e577a8c044b22991fec67c66e6b9f85d03bbdb694
MD5 47a93dfe9c61bcc04a5bb114631cd64c
BLAKE2b-256 0531b7e98d31d4c0b05232d0510baf8c94f5c5c2d6f5c34ab470269ef659e6c1

See more details on using hashes here.

File details

Details for the file automation_error_detector-1.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for automation_error_detector-1.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 08ece1890cc0d316d2821a4d3afd0e8fb5d3db656400928164aae84233e4ea37
MD5 e5ef21bb345255b49230d05cd329b1ea
BLAKE2b-256 56b5b9a6e630978512bcfe3e37e7c6454d7eb55e6b392bddd2963c10398a06ae

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