Metadata-Version: 2.3
Name: code-ninja
Version: 0.1.20
Summary: Code-ninja is the error handler library and help to detect the error and after detect the error give the solution of error.
Author: Asad Maqbool
Author-email: Asad Maqbool <asadmaqbool639@gmail.com>
Requires-Dist: openai
Requires-Dist: dotenv
Requires-Dist: rich
Requires-Python: >=3.11
Description-Content-Type: text/markdown

# 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](#overview)
- [Installation](#installation)
- [Quickstart](#quickstart)
- [Decorator Usage](#decorator-usage)


---

## 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:

