A package for debugging Jupyter notebooks using OpenAI.
Project description
Documentation for JupyterDebug
Package Overview
JupyterDebug is a Python package designed to help users debug Python code in Jupyter notebooks using OpenAI's language models. It provides two main methods:
init(): Initializes the package by prompting the user for their OpenAI API key and selecting a model.debug(max_iter=1): Automatically debugs the code in the previous cell by calling the selected language model iteratively to fix errors.
Installation
To install JupyterDebug, use pip:
pip install JupyterDebug
Usage
1. init()
The init() method initializes the package by prompting the user for their OpenAI API key and selecting a model. It must be called before using the debug() method.
Syntax:
import JupyterDebug as jd
jd.init()
Behavior:
- Prompts the user to enter their OpenAI API key.
- Asks the user to select a model from the following options:
gpt-4o-mini(default)gpt-4oo1o1-mini
- Stores the API key and model selection in environment variables for use in the
debug()method.
2. debug(max_iter=1)
The debug() method automatically debugs the code in the previous cell by calling the selected language model iteratively to fix errors. It should be called in a new cell immediately after the cell that generated the error.
Syntax:
jd.debug(max_iter=1)
Parameters:
max_iter(optional, default=1): The maximum number of times the language model is called to iteratively debug the code. If the first solution does not fix all errors, the method will retry up tomax_itertimes.
Behavior:
- Captures the code from the previous cell and the error trace.
- Calls the selected language model to generate a fix for the code.
- Replaces the code in the previous cell with the fixed version.
- If
max_iter > 1, the process is repeated until all errors are fixed or the maximum number of iterations is reached.
Example:
# Cell 1: Code with an error
x = 10
y = "20"
z = x + y # This will raise a TypeError
# Cell 2: Debug the error
jd.debug()
Example Workflow
-
Install the package:
pip install JupyterDebug
-
Initialize the package:
import JupyterDebug as jd jd.init()
-
Write and run code in a Jupyter notebook cell:
# Cell 1: Code with an error x = 10 y = "20" z = x + y # This will raise a TypeError
-
Debug the error in the next cell:
# Cell 2: Debug the error jd.debug(max_iter=2)
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 JupyterDebug-0.1.1.tar.gz.
File metadata
- Download URL: JupyterDebug-0.1.1.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e694b324d55bdab09ed5fe2dbf32b273597d1003ff5fbca820c0dd1598b105f4
|
|
| MD5 |
d8033ad39160ca9eb97b3d88ae535711
|
|
| BLAKE2b-256 |
468d43ea686b46715aabff3d76f93494b2b2f7faffd7ed47fce385ce747efd61
|
File details
Details for the file JupyterDebug-0.1.1-py3-none-any.whl.
File metadata
- Download URL: JupyterDebug-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
512528c2315f13854704a19e057cd60cb53a18d7f134e100b3b9d07b2093f0fd
|
|
| MD5 |
831f5ea963602d432a4461add4a48edd
|
|
| BLAKE2b-256 |
147d5b42f12d829eca3813df17d968ed14360d157750bf1318f064650c3d9d82
|