Skip to main content

Handler for exceptions in Python with OpenRouter.ai

Project description

OpenRouter Exception Handler

A Python module distributed via pip that automatically handles exceptions using intelligent responses generated by OpenRouter.ai.

🚀 Installation

pip install openrouter_exception_handler

📌 Features

  • Automatically captures Python exceptions during execution.
  • Sends exception details to OpenRouter.ai.
  • Displays intelligent responses from OpenRouter.ai directly in your stdout.
  • Facilitates AI-assisted debugging, reducing the time needed for error diagnosis.

🔧 Quick Usage

Simply decorate your functions with @exception_handler:

from openrouter_exception_handler import exception_handler

@exception_handler
def divide(a, b):
    return a / b

divide(10, 0)  # Will trigger ZeroDivisionError

Example Output

❌ Exception captured:
Traceback (most recent call last):
  File "example.py", line 6, in wrapper
    return func(*args, **kwargs)
  File "example.py", line 10, in divide
    return a / b
ZeroDivisionError: division by zero

AI Response:
This exception occurs because you're trying to divide by zero. Validate your inputs before performing division to prevent this error.

🔑 Configuration

Define your OpenRouter.ai API key in the environment variable APIKEY_OPENROUTER:

export APIKEY_OPENROUTER="your_api_key_here"

📦 Installation

Install easily using pip:

pip install openrouter_exception_handler

📌 Requirements

  • Python >= 3.6
  • requests

📄 License

MIT

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

openrouter_exception_handler-0.3.0.tar.gz (2.2 kB view details)

Uploaded Source

Built Distribution

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

openrouter_exception_handler-0.3.0-py3-none-any.whl (2.0 kB view details)

Uploaded Python 3

File details

Details for the file openrouter_exception_handler-0.3.0.tar.gz.

File metadata

File hashes

Hashes for openrouter_exception_handler-0.3.0.tar.gz
Algorithm Hash digest
SHA256 72cf5c559c0e8ca0f7d93dc99631b0e0aa6c6a7ffaff5e9e688d230af23c0276
MD5 00813750cce2e1eeeee6199450084714
BLAKE2b-256 6951e8cf1ee7a3aafac0475cd2b36cd24597201f32e995a1ab17c205ff0e231f

See more details on using hashes here.

File details

Details for the file openrouter_exception_handler-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for openrouter_exception_handler-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a835574edc2d8466ce57d0ae155cd4d2dd8fb25f1dc53bb774b3efcc6c59983a
MD5 88894b3d6484e5af1d7d8574a66c9f67
BLAKE2b-256 ff15ca7705a177649396d5c293d77b3ceb0913d2375ea6fb95f0c0939d85b66d

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