Code generation stands as a powerful technique in modern software development, improving development efficiency, reducing errors, and fostering standardization and consistency. Recently, ChatGPT has exhibited immense potential in automatic code generation. However, existing researches on code generation lack guidance for practical software development process. In this study, we utilized ChatGPT to develop a web-based code generation platform consisting of key components: User Interface, Prompt Builder and Backend Service. Specifically, Prompt Builder dynamically generated comprehensive prompts to enhance model generation performance. We conducted experiments on 2 datasets, evaluating the generated code through 8 widely used metrics.The results demonstrate that (1) Our Prompt Builder is effective, resulting in a 65.06% improvement in EM, a 38.45% improvement in BLEU, a 15.70% improvement in CodeBLEU, and a 50.64% improvement in Pass@1. (2) In real development scenarios, 98.5% of test cases can be validated through manual validation, highlighting the genuine assistance provided by the ChatGPT-based code generation approach.
翻译:代码生成作为现代软件开发中的一项强大技术,能够提升开发效率、减少错误,并促进标准化与一致性。近期,ChatGPT在自动代码生成方面展现出巨大潜力。然而,现有代码生成研究缺乏对实际软件开发过程的指导。在本研究中,我们利用ChatGPT开发了一个基于Web的代码生成平台,该平台由用户界面、提示构建器与后端服务等关键组件构成。其中,提示构建器动态生成综合性提示,以增强模型生成性能。我们在2个数据集上开展实验,通过8个广泛使用的指标对生成的代码进行评估。结果表明:(1)我们的提示构建器效果显著,EM提升了65.06%,BLEU提升了38.45%,CodeBLEU提升了15.70%,Pass@1提升了50.64%。(2)在实际开发场景中,98.5%的测试用例可通过人工验证通过,这凸显了基于ChatGPT的代码生成方法所提供的实际辅助作用。