When writing a program, whether for beginners or professional developers, a lot of time will be spent debugging or fixing source code errors, that is, Debug.
This process is cumbersome and complicated, including bug recurrence and bug location. With an automated debug program, the efficiency of programming practice can be significantly improved.
Recently, a developer has created a debug artifact - Adrenaline - that can repair and explain problematic code in a few seconds.
Trial address: https://useadrenaline.com/
This tool is supported by OpenAI Codex, Codex It is the technical support behind the AI code completion tool GitHub Copilot jointly released by OpenAI and GitHub.
Since the completion function of Codex is based on GPT-3, Adrenaline also has a special Debug function: explaining bugs.
Currently, Adrenaline is open source, and the GitHub repository address is: https://github.com/shobrook/adrenaline
Please note that to use Adrenaline, users must provide their own OpenAI API key from the OpenAI console. This is to prevent API abuse.
To run locally, you need to clone the repository and run the following command:
$ npm install$ npm run start-local
Currently, Adrenaline supports Python, JavaScript, Java, Ruby, PHP, C, C, and Shell programming languages.
The debugging process is as follows: Adrenaline sends the code and error information to the OpenAI editing and inserting API (code-davinci-edit-001), which Code edits that may fix the error will be sent back. Suggested fixes appear online like a diff, with options to accept, reject, or modify each code change.
Adrenaline not only suggests fixes for bugs, but also explains them in plain English using GPT-3 (text-davinci-003) Error:
This error message means that the Granger causality test statistic cannot be calculated because the VAR (vector autoregressive) model has a perfect fit to the data. This means that the data is too predictable and the VAR model cannot find any meaningful relationships between the variables. To resolve this issue, you can try a different model or adjust the parameters of the VAR model.
If the code does not throw an exception but may still contain bugs, Adrenaline can also use OpenAI Codex to scan the code for issues and recommend fixes.
Right now, Adrenaline is just a simple Demo that only shows the possibility of AI-driven debugging. But in the author's vision, future Adrenaline will have richer functions.
On the project homepage, the author also introduced some ideas on how to improve Adrenaline:
1. Client-side intelligence (such as static code analysis ) can be used to build better prompts for GPT-3.
2. Adrenaline should not only explain the error, but also provide a ChatGPT style assistant to answer questions about the error.
3. Creating a VSCode extension that does this will eliminate the problem of copy-pasting code and error messages into your site.
Of course, ChatGPT may not be completely correct. Someone asked: How to deal with errors from ChatGPT?
The author said: "Adrenaline will not always correct your mistakes correctly, but it can at least give you a starting point."
The above is the detailed content of Paste the code and automatically find bugs. This debug tool automatically fixes it in just a few seconds. It also has GPT-3 to answer questions online.. For more information, please follow other related articles on the PHP Chinese website!