Apply Large Language Models, such as GPT-4 and CodeLlama, for the purpose of generating Sui-Move smart contracts.
Through tailored Prompt Engineering, SuiGPT empowers GPT-4 to be proficient in the Move language, enabling it to generate corresponding Move code based on user instructions. It can be used through the GPTutor interface, and its API to get Prompt by user instruction is available on the Web. The website version is coming soon.
Click me to Download GPTutor and try SuiGPT in Visual Studio Code IDE
What Sui Technologies incorporated?
While GPT-4 is incredibly powerful, it lacks knowledge of Sui Move in its training data, resulting in its unfamiliarity with the syntax and writing style of Sui Move. However, we believe that by providing Sui-Move examples through prompts, GPT-4 can generate Sui-Move code accurately.
SuiGPT collect Move codes from the official Sui example codes, annotated them, and stored them in a database. When users want to create Move smart contract with SuiGPT. SuiGPT will provides relevant code snippets in prompts for GPT to reference. By doing so, SuiGPT can integrate various existing and executable Move contract functionalities, creating personalized new contracts for users.
During the Taipei Blockchain Week hackathon, we accomplished the following four parts:
All the above are open-source and available by Web API.
We use Sui-Move Analyzer to add type annotations to the Move code. Then, we utilize GPT-4 to annotate and summarize the code.
The annotation API is available at https://move-annotate-backend.gptutor.tools/api/docs. Moreover, the source code of database creation is available at GPTutor/sui-move-annotation.
Moreover, SuiGPT's Sui-Move annotation also supports the smart contract from the Bucket Protocol, allowing users to generate smart contract applications that call the Bucket Protocol endpoints using SuiGPT.
We collected 68 move files from Sui's official example code. After processing them through step one, we saved them in the ElasticSearch database, and the processed data can be downloaded here.
The source code of data processing and database creation is available at GPTutor/SuiGPT-backend.
By the users' input about what kinds of Move contract they want to write, query similar Move codes by ElasticSearch's "more like this" query. Then, pick the top 3 matched codes and assemble them to create a prompt for GPT-4 to reference.
The prompt creation API is available at https://backend.suigpt.gptutor.tools/api/docs, and it's source code is at GPTutor/SuiGPT-backend.
We integrated SuiGPT with GPTutor. GPTutor is a Visual Studio Code extension that enables users to use OpenAI's GPT models for code explanations, comments, and reviews. One of GPTutor's standout features is its open-source nature, which grants users the flexibility to customize their prompts. By dynamically querying prompts created by SuiGPT through the API into GPTutor, GPTutor is now able to compose Sui-Move according to users' instructions.
Furthermore, the API for generating prompts for SuiGPT is publicly available, so anyone can integrate SuiGPT into their AI coding services.