Giter Site home page Giter Site logo

plasma-umass / chatdbg Goto Github PK

View Code? Open in Web Editor NEW
710.0 24.0 38.0 2.74 MB

ChatDBG - AI-assisted debugging. Uses AI to answer 'why'

License: Apache License 2.0

Python 22.97% C++ 76.45% Rust 0.22% CMake 0.10% Batchfile 0.02% Jupyter Notebook 0.24%
debugger debugging-tools gpt-3 python lldb c-programming cpp-programming pdb

chatdbg's People

Contributors

artemmukhin avatar camelid avatar emeryberger avatar nicovank avatar pldi21 avatar ravenblood000 avatar stephenfreund avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chatdbg's Issues

Report better error message when user cannot access GPT-4, or not enough credits

When the user has no access to GPT-4, or when there is not enough money in the account, the HTTP requests succeeds but the JSON contains an error message, which causes soe KeyNotFoundError. Currently, we report this as if OPENAI_API_KEY was not defined, when it is.

@ravenblood000 and I ran into this because there is some issue with her account, actually took us quite a while debugging.

We should report better when such an issue occurs. I will look into it, maybe https://github.com/plasma-umass/cwhy also has the same issue.

Feature request for notebook support

I teach out of JupyterLab notebooks. Given time, I might be able to write a notebook extension that makes use of this. I'll let you know if I can get around to it.

Help in contributing

Hello developers,
Can you point me to good first steps towards learning the pre-reqs for this project (video tutorials, or books etc). I was always passionate about the idea of a smoother debugging workflow, but hardly have any idea as to how to 'hack into' a code-editor's debugger and make it work programmatically. Any help is much appreciated. Looking forward to making a small contribution to this amazing project! ๐Ÿ˜ Thank you!

Obscure error is reported when `OPENAI_API_KEY` is not set

Prerequisites

macOS 13.2.1

$ echo $OPENAI_API_KEY

$ python3 --version
Python 3.10.10

$ python3 -m pip install chatdbg

Steps to reproduce

$ python3 -m chatdbg -c continue testme.py

ZeroDivisionError: division by zero
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> ~/chatdbg/test/testme.py(4)tryme()
-> if x / i > 2:
(ChatDBG Pdb) why
EXCEPTION 'choices'

(ChatDBG Pdb)

It starts working after setting OPENAI_API_KEY

$ export OPENAI_API_KEY=<key>

$ python3 -m chatdbg -c continue testme.py

ZeroDivisionError: division by zero
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> ~/chatdbg/test/testme.py(4)tryme()
-> if x / i > 2:
(ChatDBG Pdb) why
The root cause of the error is that the code tries to divide by zero.
This occurs in the `tryme` function where `range(100)` includes the
value 0, and the code tries to divide by 0 on the line `if x / i >
2:`.

why fails with AttributeError: 'Traceback' object has no attribute 'positions'

I get this error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Cellar/[email protected]/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/homebrew/Cellar/[email protected]/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/juraj/tmp/models/lib/python3.10/site-packages/chatdbg/__main__.py", line 22, in <module>
    main()
  File "/Users/juraj/tmp/models/lib/python3.10/site-packages/chatdbg/__main__.py", line 20, in main
    chatdbg.main()
  File "/Users/juraj/tmp/models/lib/python3.10/site-packages/chatdbg/chatdbg.py", line 1789, in main
    pdb.interaction(None, t)
  File "/Users/juraj/tmp/models/lib/python3.10/site-packages/chatdbg/chatdbg.py", line 428, in interaction
    self._cmdloop()
  File "/Users/juraj/tmp/models/lib/python3.10/site-packages/chatdbg/chatdbg.py", line 393, in _cmdloop
    self.cmdloop()
  File "/opt/homebrew/Cellar/[email protected]/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/cmd.py", line 138, in cmdloop
    stop = self.onecmd(line)
  File "/Users/juraj/tmp/models/lib/python3.10/site-packages/chatdbg/chatdbg.py", line 493, in onecmd
    return cmd.Cmd.onecmd(self, line)
  File "/opt/homebrew/Cellar/[email protected]/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/cmd.py", line 217, in onecmd
    return func(arg)
  File "/Users/juraj/tmp/models/lib/python3.10/site-packages/chatdbg/chatdbg.py", line 996, in do_why
    asyncio.run(chatdbg_why.why(self, arg))
  File "/opt/homebrew/Cellar/[email protected]/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/opt/homebrew/Cellar/[email protected]/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/Users/juraj/tmp/models/lib/python3.10/site-packages/chatdbg/chatdbg_why.py", line 51, in why
    positions = inspect.getframeinfo(frame).positions
AttributeError: 'Traceback' object has no attribute 'positions'

Regardless of actual exception. I have OPENAPI_AI_KEY set up.

There is no "why" for this exception ๐Ÿ˜…

Output formatting incorrect

Expected to be cleanly formatted, but is not.

The root cause of this error is that the variable `x` is initialized
to 1.0, and then iteratively multiplied by `i` in the `for` loop in
the `fact` function. However, the loop starts from `i = 0.0`, which
means that `x` will always be multiplied by 0 in the first iteration,
resulting in `x` being 0.0. The subsequent `assert` statement checks
if `x` is not equal to 0.0, which will always fail.

To fix this error, we need to initialize `x` to 1.0 instead of 0.0.
This can be done by changing the initialization of `i` in the `for`
loop to start from 1.0 instead of 0.0.

Fixed source code: ``` /* frame 0 */ /* frame 1 */ /* frame 2 */ /*
frame 3 */ /* frame 4 */ #include <assert.h> #include <iostream>

float fact(float n) {   auto x = 1.0;   for (auto i = 1.0; i < n; i++)
{     x *= i;   }   assert(x != 0.0);   ^-----------------------------
------------------------------------------------ /* frame 5 */   for
(auto i = 1.0; i < n; i++) {     x *= i;   }   assert(x != 0.0);
return x; }


int main()
{
  std::cout << fact(100) << std::endl;
  ^-----------------------------------------------------------------------------
      ```

With this fix, `x` will correctly accumulate the product of `i`
values, starting from 1 instead of 0, and the `assert` statement will
not fail.

ImportError: cannot import name '_ModuleTarget' from 'pdb'

@ravenblood000 and I ran into issues installing chatDBG. Culprit seems to be f330919, specifically this line. I suspect it works on your Python version but not other versions.

Reproduction.

% docker run -it ubuntu

% apt update
% apt install -y git python3 python3-pip
% git clone https://github.com/plasma-umass/ChatDBG.git
% cd ChatDBG
% python3 -m pip install --upgrade pip
% python3 -m pip install -e .
% python3 -m chatdbg

Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/ChatDBG/src/chatdbg/__main__.py", line 3, in <module>
    from . import chatdbg
  File "/ChatDBG/src/chatdbg/chatdbg.py", line 14, in <module>
    from pdb import Pdb, Restart, _ModuleTarget, _ScriptTarget
ImportError: cannot import name '_ModuleTarget' from 'pdb' (/usr/lib/python3.10/pdb.py)

Feature Request: `watch/inspect` command

Would you consider adding a command that inspects the current state of a program at the stopped breakpoint to answer questions such as "Is parameter 'a' equal to parameter 'b'?" This feature would utilize natural language, eliminating the need to declare a local watch with.

AttributeError: module 'lldb' has no attribute 'SBDebugger'

Could you help me with this issue?

env:
Linux fc10339df926 5.4.126-1.el7.elrepo.x86_64 #1 SMP Mon Jun 14 17:48:40 EDT 2021 x86_64 x86_64 x86_64 GNU/Linux

debugger: lldb 14.0.0

compiler: clang++15

python and pip:

Python 3.10.6
pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)

install command

apt update
apt-get install python3-pip -y
python3 -m pip install chatdbg
python3 -c 'import chatdbg; print(f"command script import {chatdbg.__path__[0]}/chatdbg_lldb.py")' >> ~/.lldbinit

~/.lldbinit

command script import /usr/local/lib/python3.10/dist-packages/chatdbg/chatdbg_lldb.py

usage:
I want to use LLDB to debug my unit test, and meet this error

lldb ./src/unit_tests_dbms

root@fc10339df926:/clickhouse/build_debug_# lldb ./src/unit_tests_dbms
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'lldb.embedded_interpreter'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'run_one_line' is not defined
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'run_one_line' is not defined
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'run_one_line' is not defined
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'run_one_line' is not defined
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'run_one_line' is not defined
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'run_one_line' is not defined
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'lldb' is not defined
error: module importing failed: Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.10/dist-packages/chatdbg/chatdbg_lldb.py", line 8, in <module>
    def __lldb_init_module(debugger: lldb.SBDebugger, internal_dict: dict) -> None:
AttributeError: module 'lldb' has no attribute 'SBDebugger'

EXCEPTION _send_to_openai.<locals>.send_to_openai() got an unexpected keyword argument 'stream'

Unable to execute this program. Can you help me?

(venv) ghost:testLLMDebugging hemanth$ chatdbg -c continue executeProgram.py
Traceback (most recent call last):
  File "/Users/hemanth/Documents/work/plv/testLLMDebugging/venv/lib/python3.11/site-packages/chatdbg/chatdbg.py", line 77, in main
    pdb._run(target)
  File "/Users/hemanth/Documents/work/plv/testLLMDebugging/venv/lib/python3.11/site-packages/chatdbg/pdb.py", line 1643, in _run
    self.run(target.code)
  File "/Users/hemanth/.pyenv/versions/3.11.4/lib/python3.11/bdb.py", line 600, in run
    exec(cmd, globals, locals)
  File "<string>", line 1, in <module>
  File "/Users/hemanth/Documents/work/plv/testLLMDebugging/executeProgram.py", line 9, in <module>
    print(tryme(100))
          ^^^^^^^^^^
  File "/Users/hemanth/Documents/work/plv/testLLMDebugging/executeProgram.py", line 4, in tryme
    if x / i > 2:
       ~~^~~
ZeroDivisionError: division by zero
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> /Users/hemanth/Documents/work/plv/testLLMDebugging/executeProgram.py(4)tryme()
-> if x / i > 2:
(ChatDBG Pdb) why
EXCEPTION _send_to_openai.<locals>.send_to_openai() got an unexpected keyword argument 'stream'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.