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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for openrouter_exception_handler-0.1.6.tar.gz
Algorithm Hash digest
SHA256 0926c1b6b1990e0f8f2e44537af9e4e92841b2e21b4017d9ce547123dbe9949e
MD5 1494b9b1da999d075b497cec752b40b7
BLAKE2b-256 0bbf1ed4e7976bf109e2bf6924131969ad9b01c501cefc5ae4ea02eb69178294

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for openrouter_exception_handler-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 d97fd04f186f7d1ebd3928f356eb979ddad212243bb517d8b1f95143d82fb7e9
MD5 826719e335976232f5e4456d664e72e9
BLAKE2b-256 3c38b88524962d947c229d6a2529ede1e48dcc3ec79df39bd9033b6b2123fff2

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