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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openrouter_exception_handler-0.3.7.tar.gz.
File metadata
- Download URL: openrouter_exception_handler-0.3.7.tar.gz
- Upload date:
- Size: 2.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ef9b14fd0c298c134ffcdea96787898f1068113575592f602880f06fc18357e
|
|
| MD5 |
1339603112136949d59e3ab56da7eed4
|
|
| BLAKE2b-256 |
d391a8bb6e7eee701dfb73412537085d0410bf9606a10cfa07f29f6e12714d58
|
File details
Details for the file openrouter_exception_handler-0.3.7-py3-none-any.whl.
File metadata
- Download URL: openrouter_exception_handler-0.3.7-py3-none-any.whl
- Upload date:
- Size: 2.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be41c370675bdf1edcfbcff04b4d4969c12e6494fff3f2c8770c6616d35e2b78
|
|
| MD5 |
957fc2ef33d7d8f72c89c266ad10adaf
|
|
| BLAKE2b-256 |
30d8ac301281a6397a69f392c6571fa2ca27ff9fc02eacfb5bf8fdfbb945a58f
|