Inspiration
Our inspiration for Squire was Microsoft's own smart code auto-completion tool GitHub Copilot. Copilot is a smart assistant that predicts what your next lines of code will be, based on what you have written previously. It can write code based on a prompt or purely based on the code already written. Since Copilot is currently in beta testing, we thought it would be a good idea to create our own smart assistant using GPT-2 that is open to the public.
What it does
Squire detects if a user is writing Python code, then analyzes what has previously been written, then suggests what it believes the user is about to write next using a Python trained GPT-2 model.
How we built it
Squire is written entirely in Typescript and uses VS Code's API to detect the current user's file, interact with the previously written code, and suggest possible auto-completed code. Squire takes previously written lines of code by the user and passes them to a GPT-2 model hosted on the AI model hosting website Hugging Face. After the model returns the suggested next lines of code, it is suggested to the user using auto-completion.
Challenges we ran into
We ran into multiple issues with getting VS Code to run our extension and calling the Hugging Face API for our model. VS Code would randomly no longer recognize our code, and we had to keep switching which computer was running the code locally. Since VS Code opens a separate window to test the extension, only the person who locally ran the code could test to see if the extension was working.
We also ran into struggles getting the Hugging Face API working. The API, when initially called, would return an error message saying the model had to boot up first. This would cause the extension to error, even when we didn't do anything with the response. Our solution to this was to run the extension, have it error, then close and run it again with the API now ready. This isn't a good solution, but we believe we could fix this with our own model.
Accomplishments that we're proud of
We are proud of getting Squire to work at all, after our struggles. We are proud of being able to make our first-ever VS Code extension. None of us had experience working with VS Code's API before, and some of us had never even touched Typescript before!
We are proud of how well we worked together when debugging the program. Each team member noticed bugs in the code that the others didn't notice, and by working as a team, we were able to get the code to work.
What we learned
We learned Typescript, the VS Code API, the Hugging Face API, and how GPT-2 works. We learned how to problem solve due to unexpected issues, and we learned how to work as a team and cover each other's weak points.
What's next for Squire
In the future, we hope to use a model trained ourselves, instead of a pre-trained model, to have better results returned. Using our own model would allow us to have more control over what code is returned. We would also like to use GPT-3 as the basis for our model. GPT-3 is the newest model in the GPT line of language prediction models and is a significant upgrade to GPT-2. If we were able to train using GPT-3, our tool would be much more powerful and could suggest longer segments of code. Finally, in the future, we want to be able to assist with more languages than just python. That would involve either training one large model or training several smaller models, and calling whichever model when appropriate.
Built With
- git
- gpt-2
- hugging-face
- javascript
- json
- node.js
- python
- typescript
- visual-studio-code


Log in or sign up for Devpost to join the conversation.