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.8.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.8-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for openrouter_exception_handler-0.1.8.tar.gz
Algorithm Hash digest
SHA256 8b82a7af3a2414e3942d02d07c4ce822f25f01296e7dd5291ce5134f06f7e3e6
MD5 8fb4fe32ddeee9f2dd9d8a8700972556
BLAKE2b-256 e0f0c53407f1b6b2b75a940960fa354d0df6cee57c46cf68efb03034d6f22366

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for openrouter_exception_handler-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 c8afc1063a0b4a57ca18c67f612097612536d3e2e461c50fc2a85b90668cd058
MD5 0515423a38e6153d196a27ff77a957fb
BLAKE2b-256 30fc49abc92bcdc72fa750df20a1451920bdbadbb3f13d5e2893d3dabbba1d34

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