LLM Exceptions
LLM Exceptions is a Python package that enhances your debugging experience by automatically explaining stack traces for all exceptions. It leverages large language models to provide explanations and potential solutions for errors in your code. This tool is particularly useful for those who are beginners to python and apprehend the countless errors they face.
Features
- Automatic Error Analysis: Automatically captures stack traces from exceptions and provides detailed explanations and potential solutions.
- Easy Integration: Simple to set up in Jupyter Notebooks or Google Colab.
- Explained by LLMs: Uses large language models to generate accurate and helpful explanations.
Installation
You can install the package using pip:
pip install llm-exceptions
Setup
To use the package, you'll need to set the HF_TOKEN environment variable with your Hugging Face API token. This token is required to access the large language models. The default model is meta-llama/Meta-Llama-3-8B-Instruct.
You can set the environment variable in your terminal like this:
export HF_TOKEN='your_hugging_face_token'
Or, set it directly in your Python script or Jupyter Notebook:
import os
os.environ['HF_TOKEN'] = 'your_hugging_face_token'
Usage
To use LLM Exceptions in a Jupyter Notebook or Google Colab, load the extension with the following magic command:
%load_ext llm_exceptions
Once the extension is loaded, simply run your code as usual. If an exception occurs, LLM Exceptions will automatically analyze the stack trace and provide a detailed explanation along with potential solutions.
Example
-
Load the extension in your notebook:
%load_ext llm_exceptions
-
Run some code that produces an error:
def divide(a, b): return a / b divide(5, 0)
-
When the error occurs, LLM Exceptions will provide an explanation:
ZeroDivisionError: division by zeroLLM Explanation: The error
ZeroDivisionErroroccurs because you are attempting to divide a number by zero, which is mathematically undefined. To fix this error, ensure that the divisorbis not zero before performing the division.
Citations
If you use LLM Exceptions in your research or project, please consider citing it as follows:
@software{llm_exceptions,
author = {Davood Wadi},
title = {LLM Exceptions: Automatic Stack Trace Analysis and Solutions},
year = {2024},
url = {https://github.com/davoodwadi/llm_exceptions},
note = {Version 0.0.4}
}
License
This project is licensed under the Apache-2.0 license. See the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request or open an issue if you encounter any problems or have suggestions for improvements.
Acknowledgements
This package uses large language models provided by Hugging Face. Make sure to sign up on their platform to obtain the necessary API token.
Metadata
Release files for llm-exceptions 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| llm_exceptions-0.0.6.tar.gz | 9.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| llm_exceptions-0.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.4 kB
Release files / llm_exceptions-0.0.6.tar.gz
| Download URL | llm_exceptions-0.0.6.tar.gz |
|---|---|
| Size | 9.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8d9ff6e43086c944c21a12963acd8121a7ab7e24f3b1384441279b3c00d9d5ff
|
|
BLAKE2b-256 checksum How to use checksums |
556ae142ed312c078db62542ba34826f593bafcb41ca9f66b74fe094df047fdb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|
Release files / llm_exceptions-0.0.6-py3-none-any.whl
| Download URL | llm_exceptions-0.0.6-py3-none-any.whl |
|---|---|
| Size | 10.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ec3d257790ea68724f0ba4b82d183f37fb7fc1e5b8346f33a15240b7964f74ff
|
|
BLAKE2b-256 checksum How to use checksums |
b00979b5a9f389bde5496042bd3fb1d58b6bd22bf2f6d6e321574ea2b1439f97
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|