JupyterDebug


NameJupyterDebug JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/et22/JupyterDebug
SummaryA package for debugging Jupyter notebooks using OpenAI.
upload_time2025-01-27 02:23:13
maintainerNone
docs_urlNone
authorEthan
requires_python>=3.6
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## 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:
1. `init()`: Initializes the package by prompting the user for their OpenAI API key and selecting a model.
2. `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:
```bash
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**:
```python
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-4o`
  - `o1`
  - `o1-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**:
```python
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 to `max_iter` times.

**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**:
```python
# Cell 1: Code with an error
x = 10
y = "20"
z = x + y  # This will raise a TypeError
```

```python
# Cell 2: Debug the error
jd.debug()
```

---

### Example Workflow
1. Install the package:
   ```bash
   pip install JupyterDebug
   ```

2. Initialize the package:
   ```python
   import JupyterDebug as jd
   jd.init()
   ```

3. Write and run code in a Jupyter notebook cell:
   ```python
   # Cell 1: Code with an error
   x = 10
   y = "20"
   z = x + y  # This will raise a TypeError
   ```

4. Debug the error in the next cell:
   ```python
   # Cell 2: Debug the error
   jd.debug(max_iter=2)
   ```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/et22/JupyterDebug",
    "name": "JupyterDebug",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "Ethan",
    "author_email": "your.email@example.com",
    "download_url": "https://files.pythonhosted.org/packages/bb/fd/2f1568785ee693ec5f4464f901b2f15eb06de099b800162843030acb849f/JupyterDebug-0.1.0.tar.gz",
    "platform": null,
    "description": "## Documentation for `JupyterDebug`\n\n### Package Overview\n`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:\n1. `init()`: Initializes the package by prompting the user for their OpenAI API key and selecting a model.\n2. `debug(max_iter=1)`: Automatically debugs the code in the previous cell by calling the selected language model iteratively to fix errors.\n\n---\n\n### Installation\nTo install `JupyterDebug`, use pip:\n```bash\npip install JupyterDebug\n```\n\n---\n\n### Usage\n\n#### 1. `init()`\nThe `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.\n\n**Syntax**:\n```python\nimport JupyterDebug as jd\njd.init()\n```\n\n**Behavior**:\n- Prompts the user to enter their OpenAI API key.\n- Asks the user to select a model from the following options:\n  - `gpt-4o-mini` (default)\n  - `gpt-4o`\n  - `o1`\n  - `o1-mini`\n- Stores the API key and model selection in environment variables for use in the `debug()` method.\n\n---\n\n#### 2. `debug(max_iter=1)`\nThe `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. \n\n**Syntax**:\n```python\njd.debug(max_iter=1)\n```\n\n**Parameters**:\n- `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 to `max_iter` times.\n\n**Behavior**:\n- Captures the code from the previous cell and the error trace.\n- Calls the selected language model to generate a fix for the code.\n- Replaces the code in the previous cell with the fixed version.\n- If `max_iter > 1`, the process is repeated until all errors are fixed or the maximum number of iterations is reached.\n\n**Example**:\n```python\n# Cell 1: Code with an error\nx = 10\ny = \"20\"\nz = x + y  # This will raise a TypeError\n```\n\n```python\n# Cell 2: Debug the error\njd.debug()\n```\n\n---\n\n### Example Workflow\n1. Install the package:\n   ```bash\n   pip install JupyterDebug\n   ```\n\n2. Initialize the package:\n   ```python\n   import JupyterDebug as jd\n   jd.init()\n   ```\n\n3. Write and run code in a Jupyter notebook cell:\n   ```python\n   # Cell 1: Code with an error\n   x = 10\n   y = \"20\"\n   z = x + y  # This will raise a TypeError\n   ```\n\n4. Debug the error in the next cell:\n   ```python\n   # Cell 2: Debug the error\n   jd.debug(max_iter=2)\n   ```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A package for debugging Jupyter notebooks using OpenAI.",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/et22/JupyterDebug"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f5fbc708e87a59687780980e43157800e674bee4c6354f8d4afb4cbe63ffaba2",
                "md5": "6609307d5fc35cb21a584bd5168fdc55",
                "sha256": "8c53ef7b99b7c9e5b3e1d428c7b4fb8752cf76b63a519107b51be546cc51aada"
            },
            "downloads": -1,
            "filename": "JupyterDebug-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6609307d5fc35cb21a584bd5168fdc55",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 6359,
            "upload_time": "2025-01-27T02:23:09",
            "upload_time_iso_8601": "2025-01-27T02:23:09.659201Z",
            "url": "https://files.pythonhosted.org/packages/f5/fb/c708e87a59687780980e43157800e674bee4c6354f8d4afb4cbe63ffaba2/JupyterDebug-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "bbfd2f1568785ee693ec5f4464f901b2f15eb06de099b800162843030acb849f",
                "md5": "c6288cdc936667a9cee3b90ada932f56",
                "sha256": "2190d105c35a3c73856751f86864f3f15dbd9379929fa2b3216c9fda3ed692e7"
            },
            "downloads": -1,
            "filename": "JupyterDebug-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "c6288cdc936667a9cee3b90ada932f56",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 5568,
            "upload_time": "2025-01-27T02:23:13",
            "upload_time_iso_8601": "2025-01-27T02:23:13.129282Z",
            "url": "https://files.pythonhosted.org/packages/bb/fd/2f1568785ee693ec5f4464f901b2f15eb06de099b800162843030acb849f/JupyterDebug-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-27 02:23:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "et22",
    "github_project": "JupyterDebug",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "jupyterdebug"
}
        
Elapsed time: 0.61726s