Despite being introduced only a few years ago, Large Language Models (LLMs) are already widely used by developers for code generation. However, their application in automating other Software Engineering activities remains largely unexplored. Thus, in this paper, we report the first results of a study in which we are exploring the use of ChatGPT to support API migration tasks, an important problem that demands manual effort and attention from developers. Specifically, in the paper, we share our initial results involving the use of ChatGPT to migrate a client application to use a newer version of SQLAlchemy, an ORM (Object Relational Mapping) library widely used in Python. We evaluate the use of three types of prompts (Zero-Shot, One-Shot, and Chain Of Thoughts) and show that the best results are achieved by the One-Shot prompt, followed by the Chain Of Thoughts. Particularly, with the One-Shot prompt we were able to successfully migrate all columns of our target application and upgrade its code to use new functionalities enabled by SQLAlchemy's latest version, such as Python's asyncio and typing modules, while preserving the original code behavior.
翻译:尽管大型语言模型(LLMs)问世仅数年,现已被开发者广泛用于代码生成。然而,其在自动化其他软件工程活动中的应用仍鲜有探索。因此,本文报告了一项研究的初步成果,该研究探索使用ChatGPT支持API迁移任务——这是一个需要开发者投入大量手动工作与关注的重要问题。具体而言,本文分享了使用ChatGPT将客户端应用程序迁移至使用新版SQLAlchemy(一种在Python中广泛使用的对象关系映射库)的初步结果。我们评估了三种提示类型(零样本、单样本和思维链)的使用效果,结果表明单样本提示取得最佳效果,思维链提示次之。特别地,通过单样本提示,我们成功迁移了目标应用程序的所有数据列,并将其代码升级至能够使用SQLAlchemy最新版本支持的新功能(如Python的asyncio和类型标注模块),同时保持了原始代码的行为特性。