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的代码生成平台,该平台包含三个关键组件:用户界面、提示构建器和后端服务。具体而言,提示构建器通过动态生成综合提示来增强模型生成性能。我们在两个数据集上进行了实验,并使用8个广泛应用的指标对生成的代码进行了评估。结果表明:(1)我们的提示构建器效果显著,使EM(精确匹配)提升65.06%,BLEU提升38.45%,CodeBLEU提升15.70%,Pass@1提升50.64%;(2)在实际开发场景中,98.5%的测试用例可通过人工验证,这突显了基于ChatGPT的代码生成方法所提供的实质性辅助。