chatpdb


Namechatpdb JSON
Version 0.1.14 PyPI version JSON
download
home_pageNone
SummaryA chatgpt enabled python debugger
upload_time2024-05-02 23:44:27
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseNone
keywords python chatgpt pdb ai chat debugger
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![image](https://img.shields.io/pypi/v/chatpdb.svg)](https://pypi.python.org/pypi/chatpdb)
[![image](https://img.shields.io/pypi/l/chatpdb.svg)](https://pypi.python.org/pypi/chatpdb)
[![image](https://img.shields.io/pypi/pyversions/chatpdb.svg)](https://pypi.python.org/pypi/chatpdb)
[![image](https://github.com/Never-Over/chatpdb/actions/workflows/ci.yml/badge.svg)](https://github.com/Never-Over/chatpdb/actions/workflows/ci.yml)
[![Checked with pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
# chatpdb

`chatpdb` is a drop-in replacement for [ipdb](https://github.com/gotcha/ipdb) or [pdb](https://docs.python.org/3/library/pdb.html) that lets you ask questions while debugging.

![](https://raw.githubusercontent.com/Never-Over/chatpdb/main/assets/chatpdb_demo.gif)

`chatpdb` meets you where you are - AI tooling that's only invoked when you need it.

## Installation
```bash
pip install chatpdb
```
Ensure that you have `OPENAI_API_KEY` set in your environment.
```bash
export OPENAI_API_KEY=...```

## Usage
In your code:
```python3
import chatpdb; chatpdb.set_trace()
```
Simply type `y` to receive a summary of the current code and stack trace.
```python3
> /Programming/test-chatpdb/lib.py(2)echo_platform()
      1 def echo_platform(platform: str):
----> 2     print("You are running on:" + platform)
      3
ipdb> y 
The exception occurred because the function `echo_platform` tries to concatenate the string "You are running on:" with the `platform` variable, which is `None`. [...]
```

Type `y "prompt"` to ask a question. 

```python3
> /Programming/test-chatpdb/lib.py(2)echo_platform()
      1 def echo_platform(platform: str):
----> 2     print("You are running on:" + platform)
      3
ipdb> y "Why is platform coming through as None?"
The variable `platform` is coming through as `None` because the environment variable `"PLATFORM"` is not set in your system's environment variables. [...]
```


## How does it work?
`chatpdb` uses the OpenAI API to generate responses to your questions. It uses the `gpt-4-turbo` model by default.

`chatpdb` will automatically include relevant context from the current frame and stack trace, as well as
exception information if one has been raised.


### Advanced Usage

Just like [ipdb](https://github.com/gotcha/ipdb) and [pdb](https://docs.python.org/3/library/pdb.html), `chatpdb` supports many different entrypoints.

Running code:
```python3
import chatpdb; chatpdb.run('print("hello")')
import chatpdb; chatpdb.runcall(lambda x: x + 1, 1)
```
As a decorator:
```python3

@chatpdb.cex
def sample_cex_function():
    raise # any exception within the decorated function will trigger chatpdb
```
As a context manager:
```python3
with chatpdb.launch_chatpdb_on_exception():
    raise # any exception within the with block will trigger chatpdb
```
On files:
```bash
python3 -m chatpdb file.py
```
post-mortem support:
```python3
chatpdb.pm()
```

See the documentation of [ipdb](https://github.com/gotcha/ipdb) or [pdb](https://docs.python.org/3/library/pdb.html) for the full api.

### Configuration
You can use more specific environment variables to configure an OpenAI key and preferred model
for chatpdb. The following environment variables are supported:
- `CHAT_PDB_OPENAI_API_KEY`: Your OpenAI API key
- `CHAT_PDB_OPENAI_MODEL`: The model to use for chatpdb. Default is 'gpt-4-turbo'

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "chatpdb",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "python, chatgpt, pdb, ai, chat, debugger",
    "author": null,
    "author_email": "Caelean Barnes <caeleanb@gmail.com>, Evan Doyle <evanmdoyle@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/51/c2/b4b30b0c4e44aa9bce59e3d75c4144f5c924d2bfa68ec3f6cab6ce005254/chatpdb-0.1.14.tar.gz",
    "platform": null,
    "description": "[![image](https://img.shields.io/pypi/v/chatpdb.svg)](https://pypi.python.org/pypi/chatpdb)\n[![image](https://img.shields.io/pypi/l/chatpdb.svg)](https://pypi.python.org/pypi/chatpdb)\n[![image](https://img.shields.io/pypi/pyversions/chatpdb.svg)](https://pypi.python.org/pypi/chatpdb)\n[![image](https://github.com/Never-Over/chatpdb/actions/workflows/ci.yml/badge.svg)](https://github.com/Never-Over/chatpdb/actions/workflows/ci.yml)\n[![Checked with pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n# chatpdb\n\n`chatpdb` is a drop-in replacement for [ipdb](https://github.com/gotcha/ipdb) or [pdb](https://docs.python.org/3/library/pdb.html) that lets you ask questions while debugging.\n\n![](https://raw.githubusercontent.com/Never-Over/chatpdb/main/assets/chatpdb_demo.gif)\n\n`chatpdb` meets you where you are - AI tooling that's only invoked when you need it.\n\n## Installation\n```bash\npip install chatpdb\n```\nEnsure that you have `OPENAI_API_KEY` set in your environment.\n```bash\nexport OPENAI_API_KEY=...```\n\n## Usage\nIn your code:\n```python3\nimport chatpdb; chatpdb.set_trace()\n```\nSimply type `y` to receive a summary of the current code and stack trace.\n```python3\n> /Programming/test-chatpdb/lib.py(2)echo_platform()\n      1 def echo_platform(platform: str):\n----> 2     print(\"You are running on:\" + platform)\n      3\nipdb> y \nThe exception occurred because the function `echo_platform` tries to concatenate the string \"You are running on:\" with the `platform` variable, which is `None`. [...]\n```\n\nType `y \"prompt\"` to ask a question. \n\n```python3\n> /Programming/test-chatpdb/lib.py(2)echo_platform()\n      1 def echo_platform(platform: str):\n----> 2     print(\"You are running on:\" + platform)\n      3\nipdb> y \"Why is platform coming through as None?\"\nThe variable `platform` is coming through as `None` because the environment variable `\"PLATFORM\"` is not set in your system's environment variables. [...]\n```\n\n\n## How does it work?\n`chatpdb` uses the OpenAI API to generate responses to your questions. It uses the `gpt-4-turbo` model by default.\n\n`chatpdb` will automatically include relevant context from the current frame and stack trace, as well as\nexception information if one has been raised.\n\n\n### Advanced Usage\n\nJust like [ipdb](https://github.com/gotcha/ipdb) and [pdb](https://docs.python.org/3/library/pdb.html), `chatpdb` supports many different entrypoints.\n\nRunning code:\n```python3\nimport chatpdb; chatpdb.run('print(\"hello\")')\nimport chatpdb; chatpdb.runcall(lambda x: x + 1, 1)\n```\nAs a decorator:\n```python3\n\n@chatpdb.cex\ndef sample_cex_function():\n    raise # any exception within the decorated function will trigger chatpdb\n```\nAs a context manager:\n```python3\nwith chatpdb.launch_chatpdb_on_exception():\n    raise # any exception within the with block will trigger chatpdb\n```\nOn files:\n```bash\npython3 -m chatpdb file.py\n```\npost-mortem support:\n```python3\nchatpdb.pm()\n```\n\nSee the documentation of [ipdb](https://github.com/gotcha/ipdb) or [pdb](https://docs.python.org/3/library/pdb.html) for the full api.\n\n### Configuration\nYou can use more specific environment variables to configure an OpenAI key and preferred model\nfor chatpdb. The following environment variables are supported:\n- `CHAT_PDB_OPENAI_API_KEY`: Your OpenAI API key\n- `CHAT_PDB_OPENAI_MODEL`: The model to use for chatpdb. Default is 'gpt-4-turbo'\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A chatgpt enabled python debugger",
    "version": "0.1.14",
    "project_urls": {
        "Homepage": "https://github.com/never-over/chatpdb",
        "Issues": "https://github.com/never-over/chatpdb/issues"
    },
    "split_keywords": [
        "python",
        " chatgpt",
        " pdb",
        " ai",
        " chat",
        " debugger"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4629fa76624edfbd7157802d9e1cb686c70711123e4d74242148a91eda827f08",
                "md5": "996fdab16aa4a8d167f7570b13191814",
                "sha256": "6efe7e13fe9e8ff43cb76e00c190454f79b34e66678e20d50f005d8c7363eb0a"
            },
            "downloads": -1,
            "filename": "chatpdb-0.1.14-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "996fdab16aa4a8d167f7570b13191814",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 29036,
            "upload_time": "2024-05-02T23:44:26",
            "upload_time_iso_8601": "2024-05-02T23:44:26.009549Z",
            "url": "https://files.pythonhosted.org/packages/46/29/fa76624edfbd7157802d9e1cb686c70711123e4d74242148a91eda827f08/chatpdb-0.1.14-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "51c2b4b30b0c4e44aa9bce59e3d75c4144f5c924d2bfa68ec3f6cab6ce005254",
                "md5": "0d4a76c1440a76b4b5fa848cd9585978",
                "sha256": "18769882737c878925c28215871cdda05af5b5631bf7d890c337ceeac41469b4"
            },
            "downloads": -1,
            "filename": "chatpdb-0.1.14.tar.gz",
            "has_sig": false,
            "md5_digest": "0d4a76c1440a76b4b5fa848cd9585978",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 26574,
            "upload_time": "2024-05-02T23:44:27",
            "upload_time_iso_8601": "2024-05-02T23:44:27.700699Z",
            "url": "https://files.pythonhosted.org/packages/51/c2/b4b30b0c4e44aa9bce59e3d75c4144f5c924d2bfa68ec3f6cab6ce005254/chatpdb-0.1.14.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-02 23:44:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "never-over",
    "github_project": "chatpdb",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "chatpdb"
}
        
Elapsed time: 0.73423s