|
| 1 | +LLM Copilot Extension in VS Code |
| 2 | +---------------------------------- |
| 3 | + |
| 4 | +1. Introduction: |
| 5 | +---------------- |
| 6 | +Welcome to the documentation for the VS Code Copilot Extension, which I created. This |
| 7 | +extension was developed to enhance coding efficiency by integrating advanced language |
| 8 | +models like Llama 3.1, OpenAI’s GPT-3.5-turbo, and Gemini 1.5. These models offer powerful |
| 9 | +code generation, suggestion capabilities, and the ability to solve complex coding problems. The |
| 10 | +extension is designed with a user-friendly interface and can be easily integrated into your |
| 11 | +existing workflow. |
| 12 | + |
| 13 | +2. Prerequisites: |
| 14 | +----------------- |
| 15 | +Before using this extension, we need to ensure that we have the following installed on our |
| 16 | +system: |
| 17 | +- Visual Studio Code (version 1.92.0 or higher) |
| 18 | +- Node.js (for running the extension) |
| 19 | +- TypeScript (for compiling TypeScript files) |
| 20 | +Additionally, we need to make sure that we have access to API keys from Together.ai, Groq, |
| 21 | +OpenAI, or other supported providers to interact with the language models. |
| 22 | + |
| 23 | +3. Installation: |
| 24 | +------------------ |
| 25 | +- First we clone this repository |
| 26 | +- We then run “npm install” to install all necessary dependencies. |
| 27 | +- Thereafter , we use the command npm run compile to compile the TypeScript files. |
| 28 | +- Now to test the extension,we need to press F5 in VS Code to open a new window with |
| 29 | +the extension running or run the following command in terminal window : |
| 30 | +code --extensionDevelopmentPath=D:\Extension\extension\ ( according to our |
| 31 | +exact file location path) |
| 32 | + |
| 33 | +4. Overview of package.json |
| 34 | +---------------------------- |
| 35 | +The package.json file is crucial as it defines the extension’s metadata, dependencies, |
| 36 | +and commands. Key elements include: |
| 37 | +- Name and Version: The extension is named codesuggestion with version 0.0.1. |
| 38 | +- Engines: Specifies compatibility with VS Code version 1.92.0 or higher. |
| 39 | +- Contributes: Defines the command extension.openChat to open the chat interface. |
| 40 | +- Scripts: Includes commands for compiling TypeScript, linting, and testing. |
| 41 | +- Dependencies: Includes axios for API calls and development dependencies for |
| 42 | +TypeScript, linting, and testing. |
| 43 | + |
| 44 | +5. Setting Up the Command in extension.ts: |
| 45 | +------------------------------------------ |
| 46 | +The extension.ts file contains the core logic: |
| 47 | +- Imports: Includes necessary modules like vscode and axios. |
| 48 | +- Activate Function: The entry point when the extension is activated, where the |
| 49 | +command extension.openChat is registered. |
| 50 | +- Webview Setup: The command triggers a Webview panel that displays the chat |
| 51 | +interface, allowing users to interact with the AI. |
| 52 | + |
| 53 | +6. Making API Calls to AI Models: |
| 54 | +--------------------------------- |
| 55 | +The getCodeSnippet function is central to the extension’s operation: |
| 56 | +- Functionality: Sends a POST request to the selected AI model's API, passing the user’s |
| 57 | +query. |
| 58 | +- Response Handling: The response is processed and the code snippet is returned and displayed in the Webview. |
| 59 | + |
| 60 | +7. User Interface: |
| 61 | +------------------- |
| 62 | +The user interface is designed using HTML, CSS, and JavaScript: |
| 63 | +- Chat Interface: Users can input queries and select the desired AI model from a |
| 64 | +dropdown menu. |
| 65 | +- Response Display: The AI’s response is displayed in a code block format for easy |
| 66 | +copying and pasting. |
| 67 | + |
| 68 | +8. Features: |
| 69 | +------------ |
| 70 | + |
| 71 | +- Model Integration: Supports switching between Llama 3.1, GPT-3.5-turbo, and Gemini models. |
| 72 | +- Code Generation: Generates code snippets, solves LeetCode & DSA problems, and supports autocompletion |
| 73 | +- User-Friendly Interface: Simplified design for ease of use, allowing users to interact with the AI seamlessly |
| 74 | + |
| 75 | +Sample chat and prompt response demonstration: |
| 76 | +----------------------------------------- |
| 77 | + |
| 78 | + |
| 79 | +Personalized chat interface to match your needs : |
| 80 | +----------------------------------------- |
| 81 | + |
| 82 | + |
0 commit comments