Metadata-Version: 2.1
Name: explainable-exceptions
Version: 0.0.2
Summary: A Python module to explain exceptions in execution-time using AOP
Home-page: https://github.com/ruescog/explainable-exceptions
Author: ruescog
Author-email: ruescog@unirioja.es
License: Apache Software License 2.0
Keywords: nbdev jupyter notebook python
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: License :: OSI Approved :: Apache Software License
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Provides-Extra: dev

explainable-exceptions
================

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

Artificial Intelligence is being used in several fields, including
computer engineering and programming.

During this work, we pretend to facilitate the process of programming as
much as possible adding the option to use a NLP (Natural Language
Processing) model to help the user to understand and solve the
exceptions that may appear while programming.

As simple as using a magic cell, the user will be able to send the
exception to the [huggingface chat](https://huggingface.co/chat/) and
obtain a possible solution to solve the exception. In this process, the
user must be logged in his huggingchat account. Credentials can be saved
to be requested only once.

After receiving the response, the user will be able to request another
response if the given one is not helpful enough.

## Install

To install `explainable_exceptions` you must use the following pip
command:

``` sh
pip install explainable_exceptions
```

## How to use

In order to use the magic cell, we need to import it from the `core` of
`explainable_exceptions`. The cell is called
[`explain`](https://ruescog.github.io/explainable-exceptions/core.html#explain).

After that, we can label cells using the magic cell command (%%). We can
provide a huggingchat user or we can just use the command (if there are
not credentials, then it will ask to generate them).

If an exception is raised inside a magic cell, it will be sent to the
huggingchat model to generate a possible solution. This response will be
shown by the jupyter standard output.

``` python
import random

from explainable_exceptions.core import explain
```

``` python
random.choice([])
```

    CRITICAL:root:Traceback (most recent call last):
      File "/home/ruescog/explainable-exceptions/explainable_exceptions/core.py", line 78, in explain
        exec(cell, globals(), local_ns)
      File "<string>", line 3, in <module>
      File "/grupoa/config/miniconda3/lib/python3.8/random.py", line 290, in choice
        raise IndexError('Cannot choose from an empty sequence') from None
    IndexError: Cannot choose from an empty sequence

    WARNING:root:Be careful, the following response has been generated automatically by a Natural Language Processing Model, so the answer may be incorrect or false.

## Huggingchat response [(online version)](https://huggingface.co/chat):

Hello! That error message suggests that you are trying to use the
`choice()` function from the `random` module on an empty list or
sequence. In order to fix the error, ensure that your code creates and
assigns a non-empty sequence for `random.choices()`. Here is an example
of how to create a simple randomized sequence using the `list`
constructor:

``` bash
import random
seq = [1, 2, 3]
random.shuffle(seq)
print("Shuffled sequence:")
for item in seq:
    print(item)
```

This should randomly shuffle the elements within the sequence and
generate output like this:

``` vbnet
Shuffled sequence:
2
3
1
```

Let me know if there’s something else I could assist you with!

------------------------------------------------------------------------


    Do you need another answer? (y/n) n

    IndexError: Cannot choose from an empty sequence


