Code-ninja is the error handler library and help to detect the error and after detect the error give the solution of error.
Project description
ErrorHandler-AI
Python error handler library with UV and Rich, provides AI-powered suggestions for fixing errors in user code. Uses OpenAI for error cause analysis and solution output. Styled suggestions are shown in the terminal using Rich.
Table of Contents
Overview
ErrorHandler-AI provides a decorator that lets you catch and explain Python errors in your functions automatically. If an error occurs, the library uses OpenAI to analyze the cause and suggest a fix and Correct code. Output is neatly formatted in your terminal using Rich panels for easy readability.
Main features:
- Catches Python errors in user code (decorator-based)
- AI-powered error cause and fix suggestions and Correct code.
- Rich terminal output with styled panels.
- Customizable with environment variables.
Installation
Install via pip:
pip install code-ninja==0.1.18
Set your OpenAI API key and other environment variables in a .env file:
API_KEY=your-api-key
BASE_URL=your-openai-base-url # optional
INSTRUCTION=Explain the error in more detail with examples. # optional
MODEL_NAME=Your-model # optional
Quickstart
Add the decorator to your function:
from code_ninja import catch
@catch
def divide(x, y):
return x / y
divide(10, 0)
When an error is raised, you'll see:
- Error type and info.
- AI-analyzed cause.
- AI fix suggestion.
- Correct code.
Decorator Usage
Use the @catch decorator to wrap any function you want to monitor for errors:
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 code_ninja-0.1.20.tar.gz.
File metadata
- Download URL: code_ninja-0.1.20.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49116c6a70721316a9f99dae2e09f43dfd3b9386a006a06ad6c97e1151637cca
|
|
| MD5 |
c24650d2f1fa696b0501dac623e945f5
|
|
| BLAKE2b-256 |
e0a6c0979c4fe403d130426952785e95657cdaa2bf5afb5307b58b8c7d508606
|
File details
Details for the file code_ninja-0.1.20-py3-none-any.whl.
File metadata
- Download URL: code_ninja-0.1.20-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00f421a53ef8e05ca062f0ba69132c1c71e164dd867ea2c22001654b6866edbd
|
|
| MD5 |
fde5c1340086035bc480e6fec60f2ce0
|
|
| BLAKE2b-256 |
d7ff5635028e35bccc5fe70e7df7ce8a3ea39304457d744f6631939085218be1
|