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.2.tar.gz (3.3 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.2-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for openrouter_exception_handler-0.3.2.tar.gz
Algorithm Hash digest
SHA256 ff02a1a8d026477618f3a6823359071a4b96a07460cad8f88e247d2e70ff671d
MD5 1e346d65ab87abb5968eec6dea2b3251
BLAKE2b-256 32bdc22e45f9a8568a8727ac661c8955e68d77591555d11b6cbfc58dc714daee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for openrouter_exception_handler-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a3eb0babb83fd8ef301237f590de27668fffd8f03db79bc92b0c91d39b235f16
MD5 fced16cc29dccbe807a3b05cb0e2e948
BLAKE2b-256 1d88829d339b43ac4b9128212f4e1637e95eac568aff1f88108329c71a7892e4

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