Development of an automatic modification system for generated programs using ChatGPT

Jun Yoshida,Oh Sato,Hane Kondo,Hiroaki Hashiura,Atsuo Hazeyama
2024-07-16
Abstract:In recent years, the field of artificial intelligence has been rapidly developing. Among them, OpenAI's ChatGPT excels at natural language processing tasks and can also generate source code. However, the generated code often has problems with consistency and program rules. Therefore, in this research, we developed a system that tests the code generated by ChatGPT, automatically corrects it if it is inappropriate, and presents the appropriate code to the user. This study aims to address the challenge of reducing the manual effort required for the human feedback and modification process for generated code. When we ran the system, we were able to automatically modify the code as intended.
Software Engineering
What problem does this paper attempt to address?
The problem that this paper attempts to solve is: how to reduce the amount of human feedback and modification work required when generating code, especially for the consistency and program - rule problems that often occur in the code generated by ChatGPT. Specifically, the author points out that although OpenAI's ChatGPT performs well in natural - language - processing tasks and can generate source code, the generated code often has consistency problems and violates programming norms. These problems need to be identified and corrected one by one manually, which is not only time - consuming but also inefficient. For this reason, the research team has developed a system that can automatically test the code generated by ChatGPT, automatically correct it if inappropriate parts are found, and finally present the correct code to the user. In this way, this research aims to reduce the workload of programmers in manual inspection and correction after code generation and improve the quality and efficiency of code generation. The following is a brief process of this system: 1. The user inputs the content of the code to be generated. 2. The system requests ChatGPT to generate code and corresponding test code through API. 3. The system compiles the generated code and runs the test. 4. If an error is found, the code and error information are returned to ChatGPT for correction. 5. Repeat the above steps until there are no errors. 6. Finally, display the error - free code to the user. In addition, the system also sets limits on the number of iterations and execution time to prevent resource exhaustion. This innovative method provides new ideas and technical support for the development of automated programming tools.