- Introduction
- Benefits of Integration with GitHub Copilot Chat
- Getting Started
- Extension Settings
- Model Selection
- Development
- Adding an Assistant in the OpenAI API Playground
- Contributing
- References
The Assistants Chat Extension (@assistant
) integrates the OpenAI Assistants API into GitHub Copilot Chat, allowing you to create custom assistants that understand your project's context and generate relevant code snippets. This repository provides a working extension and serves as an example for developers looking to build their own advanced GitHub Copilot Chat Extensions.
This extension uses OpenAI's Assistants API and Azure OpenAI Service, which allow you to build AI assistants tailored to your specific needs. By integrating API Assistant capabilities, the Assistants Chat Extension enables you to implement features like context-aware responses about project details, such as the latest version of a tool or library.
- Real-time Suggestions: Get context-aware code completions and suggestions in VS Code, making your coding experience smoother and more efficient.
- Bug Fixes and Guidance: Copilot Chat can identify bugs and suggest fixes based on your codebase and external resources.
- Uninterrupted Workflow: You can stay focused on building your project without constantly switching between tools.
- Personalized Suggestions: The assistant learns your coding style and preferences, making the suggestions more relevant and accurate for your specific needs.
Important
You must be using Visual Studio Code Insiders Edition for this to work.
-
Set up your OpenAI or Azure OpenAI API key:
- OpenAI:
- Create an OpenAI account: Visit OpenAI's website and sign up for an account if you don't have one.
- Obtain your API key: Once your account is set up, navigate to the API section to generate a new API key. Copy this key to use it in the next steps.
- Azure OpenAI:
- Create an Azure account: If you don't have an Azure account, sign up at Azure's website.
- Create an Azure OpenAI resource: Follow the Azure OpenAI documentation to create an Azure OpenAI resource and obtain the API key and endpoint.
- Add the API key to the extension settings in VS Code:
- Open Visual Studio Code Insiders.
- Go to the settings by clicking on the gear icon in the lower left corner and selecting "Settings".
- In the search bar, type "Assistants Chat Extension".
- Find the setting for
assistantsChatExtension.apiKey
(OpenAI) orassistantsChatExtension.azureOpenAIApiKey
andassistantsChatExtension.azureOpenAIEndpoint
(Azure OpenAI). - Paste your API key (and endpoint for Azure OpenAI) into the appropriate field(s) and save the settings.
- OpenAI:
-
Choose an Assistant:
- Open the Copilot Chat interface: Launch Visual Studio Code Insiders and ensure that the GitHub Copilot Chat extension is installed and active.
- Select an assistant:
- Use the command palette (
Ctrl+Shift+P
orCmd+Shift+P
on macOS) and type "AI Assistant: Select Assistant". - Browse through the list of your assistants. If you don't have one, you will be offered to create a new Beavis and Butthead assistant.
- Each assistant maintains its own thread, allowing for context retention and more meaningful interactions over time. This ensures continuity in conversations and follow-up questions, reducing the need to re-explain context or re-establish the current state of the project.
- Use the command palette (
-
Start Chatting:
- Initiate a conversation: Open the chat window within GitHub Copilot Chat.
- Ask questions and get guidance:
- Type your questions or prompts in natural language. For example, you can ask about specific code functionalities, request code snippets, or seek debugging help.
- The assistant will respond with relevant information, suggestions, or code snippets based on the context of your query.
The Assistants Chat Extension provides the following settings to customize your experience:
Setting | Description |
---|---|
assistantsChatExtension.apiKey |
Your OpenAI API key for accessing the language models. |
assistantsChatExtension.model |
The OpenAI language model to use for the chat extension. Default is gpt-3.5-turbo. |
assistantsChatExtension.apiProvider |
Select the API provider to use. 'auto' will choose based on available API keys. Options: 'auto', 'openai', 'azure'. |
assistantsChatExtension.azureOpenAIApiKey |
Your Azure OpenAI API key for accessing the language models. |
assistantsChatExtension.azureOpenAIEndpoint |
The endpoint URL for your Azure OpenAI resource. |
assistantsChatExtension.sendCodeContext |
Enable to send file context to OpenAI for enhanced responses. This setting allows you to control privacy by opting in or out of sending code context data. Default is enabled. |
To manage your privacy settings and control the data sent to OpenAI:
- Navigate to the Visual Studio Code settings.
- Search for "Assistants Chat Extension".
- Locate the
sendCodeContext
setting under the extension's options. - Toggle this setting to enable or disable sending code context, allowing you to enhance privacy or improve the relevancy of the responses based on your preferences.
Choosing the best combination of Copilot and Assistants API models depends on factors like task complexity, speed, and specific use cases:
- Copilot GPT-4 + Assistants API GPT-4o: Best for high complexity and consistency, but slower and costlier. Assistants API GPT-4o is fast, but Copilot GPT-4 is slower.
- Copilot GPT-4 + Assistants API GPT-3.5 Turbo: Balances performance and cost, with fast responses for less complex tasks.
- Copilot GPT-3.5-Turbo + Assistants API GPT-4o: Provides powerful custom assistant tasks with quick Copilot responses.
- Copilot GPT-3.5-Turbo + Assistants AI GPT-3.5-Turbo: Cost-effective and fast for basic tasks, but limited in handling complex scenarios.
For most users, Copilot GPT-4 + Assistants AI GPT-3.5-Turbo offers a good balance of cost, performance, and capability.
- Node.js: Ensure you have Node.js installed. You can download it from nodejs.org.
- Visual Studio Code Insiders: Install Visual Studio Code Insiders.
- GitHub Copilot Subscription: Ensure you have an active GitHub Copilot subscription.
-
Clone the repository:
git clone https://github.com/potatoqualitee/vscode-assistant-chat.git cd vscode-assistant-chat
-
Install dependencies:
npm install
-
Build the extension:
npm run compile
-
Launch the extension:
- Press
F5
in Visual Studio Code Insiders or go to the "Run" menu and select "Start Debugging".
- Press
You can add an API assistant one of two ways: automatically or using the OpenAI API Playground.
Just type @assistant hello
and if you don't have any assistants, you will be prompted to automatically create a Beavis and Butthead assistant. B&B were chosen because of their unique speaking style which makes it obvious that the assistant is working.
- Go to the OpenAI API Playground.
- Click on the "Assistants" tab in the left sidebar.
- Click on "New Assistant" to create a new assistant.
- Enter the necessary information, such as the name, instructions, and model (e.g.,
gpt-4
). - Save your newly created assistant.
- Use the assistant in your chat extension by selecting it with the "AI Assistant: Select Assistant" command in GitHub Copilot Chat.
Here's a screenshot for reference:
Contributions to the Assistants Chat Extension are welcome! If you encounter any issues, have suggestions for improvements, or would like to contribute new features, please open an issue or submit a pull request.
- About GitHub Copilot Extensions
- GitHub Marketplace
- VS Code Extension Samples - Chat Example
- Language Model API
- Prompt Builder
- Azure OpenAI Documentation
1.1.0 - Moved configuration to context.workspaceState instead of settings.json