DEV Community

Cover image for Get Instant Error Solutions with GPT
MusabShakil
MusabShakil

Posted on

Get Instant Error Solutions with GPT

Recently I found myself using ChatGPT a lot, I was at a point where I even left Google and Stackoverflow (my two best coding friends). But ChatGPT has two problems:

  1. If I don't provide my source code as context to ChatGPT, it behaves like a large language model and provides some random answers from its brain, which mostly aren't useful and meaningful. So I've to make it pretend like "ChatGPT, you are now a software engineer" by writing some prompts curated by awesome people at awesome-chatgpt-prompts.

  2. Even if I provide my source code to ChatGPT, then write my query or code error which I want ChatGPT to solve, most of the time my source code is too big it just exceeds the ChatGPT input limit.

Solution πŸ’‘

After thinking about this problem I came up with a plan to build a VS Code extension which can directly extract source code from IDE, so I don't have to copy paste the code every time I've to ask ChatGPT for the answer of errors in my code, and I use vector database as an index to store embeddings for my source code, which basically do an approximately nearest neighbors similarity search to just pick those snippets from my code which are the causing the error, in this way I'm able to input only a small chunk of source code into the GPT model which performs well and provide accurate solution for the errors without exceeding the OpenAI GPT input limit.

I made the VS Code extension publicly available for free on GitHub. It's currently in Alpha stage, and I would appreciate your Pull Requests/Contributions to this open source tool. Before diving into the extension, let's understand why we need it.

What are the existing solutions? πŸ€”

Today's Gen AI dev tools, such as Copilot, are missing the mark. Yes, they help with code completion, but every developer knows that programming is really 20% coding and 80% debugging. I asked myself, how can LLMs help with the crucial, time-sensitive, frustrating, and just incredibly intense task of debugging?

Introducing πŸ‘‹

Quickfix AI, an extension for VS Code that provides you instant solutions for errors in your code within the code editor using AI.

With quickfix.ai, you can:

  • 🧠 Get instant solution for error in real-time
  • πŸ’‘ Increase your coding understanding and efficiency
  • ⏳ Save time and minimize frustration with clear code solutions
  • πŸ” Improve your coding skills with in-depth code analysis

Demo πŸ“½

Installation πŸ“¦

Quickfix AI is in its Alpha phase, if you would like to use and explore it at this stage, you can follow the steps below to set it up. However, if you prefer to wait for a more reliable version with an easy installation process through VS Code Marketplace, you can Join the Waitlist for the Stable release.

Prerequisite:

  • Python v3.10 + Poetry
  • Node v16 + Yarn

Setup:

  1. Clone Quickfix AI repo
  2. Build the vscode-extension make install-vscode-extension
  3. Build the backend make install-backend
  4. Update the environment variables in both folders, /vscode-extension/src/env.ts (you probably don't need to update this file if your backend will be running in the localhost or 127.0.0.1) and /backend/.env
  5. Run the backend make run-backend

How to Use Quickfix AI πŸ› 

  1. Open a workspace/folder in VS Code
  2. Open the Command Palette (press Ctrl + Shift + P or Cmd + Shift + P on Mac)
  3. Type "Quickfix AI" and select the command from the list
  4. Paste/enter your error or question.
  5. Wait for the response and the solution will be displayed in a "solution-by-quickfix-ai markdown" file in your VS Code editor

Enjoy the instant and comprehensive error solutions with Quickfix AI! πŸŽ‰

Top comments (0)