Skip to content

cpgames/VSAssistantGPT

Repository files navigation

Turn ★ into ⭐ (top-right corner) if you like the project!

VS GPT Assistant

Visual Studio extension utilizing OpenAI GPT assistants.

Video

VS Marketplace Link

Setup

  1. Open Visual Studio
  2. Tools->Show VS Assistant
  3. In VS Assistant, go to Settings tab.
  4. Set your OpenAI API key.
  5. Set Python Dll path. E.g. C:\Users{username}\miniconda3\python39.dll
  6. Save settings image.

Uploading Project Resources (optional)

To better understand the project, VS assistant can use project's source files. They need to be uploaded manually.

  1. In VS Assistant, go to Resources tab.

  2. If resources are empty, click refresh image button.

  3. Resource view mimics your physical file structure on disk (not in solution).

  4. You can sync individual files or entire folders by clicking sync image button to the right of the item.

  5. Once synced, file name will appear in greem. Synced files will automatically be updated on the server when changes are made. image

  6. Synced folders automatically add/remove files to the server.

  7. While files are syncing it's not recommended to perform other operations in VSAssistant.

  8. To locate an active file, click locate image button

  9. You can also search by filename by using the textbox.

Creating Assistant

You can create as many assistants as you need to acompish different kinds of tasks.

  1. In VS Assistant, go to Assistants tab.
  2. Create new assistant by clicking the plus icon image.
  3. Configure assistant as needed. For best results, I recommend gpt-4o model. It is more expensive than gpt-3.5-turbo-0125, but produces much better results. gpt-3.5-turbo-0125 is also known for struggling with file_search tool.
  4. Assign a set of required tools to the assistant. E.g. if it needs to be able to read current text selection, add GetSelection tool, or if it needs to create new files, add CreateDocument tool, etc.
  5. You can see all tool information in here.
  6. Save assistant image.

Note: Adding more tools will increase assistant's capabilities, but may also confuse it when selecting the right tool for the job. Feel free to experiment.

Interacting with Assistant

  1. In VS Assistant, go to Chat tab.
  2. Select the assistant to interact with.
  3. Type a prompt and press Enter, or click Submit button image.
  4. To add multiple lines to your message, press Shift+Enter.
  5. Wait for assistant to finish responding (thinking... message will disappear).
  6. To start new conversation and erase current one, click on Refrershimage button.

Note: Prompt engineering is important to achieve better results. You can specify specific tools to call, or give hints as to the direction the assistant should take.

Interacting with Assistant in Editor Window

You can bring up a minimal chat window directly from the text editor, instead of using full VS Assistant window.

  1. Make sure assistant has at least GetSelection tool.
  2. Select text in editor.
  3. Click on robot glyph on the left. image
  4. You can move the window by dragging its title, or close it by clicking outside.

Creating Custom Tools

  1. In VS Assistant, go to Tools tab.
  2. Create new tool by clicking the plus icon image.
  3. Set tool name.
  4. Save tool image.
  5. You should see tool automatically open in your text editor with template code.
  6. Implement the call function, and add required arguments (if tool does not require arguments, you can safely delete this field).
  7. Use ToolsLogger if you need to debug the code, log is located in C:\Users\{username}\AppData\Local\cpGames\VSA\Logs
  8. Save python file.
  9. In the Tools tab, click Refresh image button to reload the toolset. This reloads all tool modules in case you've made changes to them without requiring to restart Visual Studio.

Note: If you would like to call any of built-in VSIX functions, refer to ToolAPI class, specifically functions of return type and parameters like these public static JObject HasSelection(Dictionary<string, dynamic> arguments) (they are at the bottom of the file). Refer to CreateReadme.py for examples.

Debugging Assistant Errors

All output is printed to Output window (View->Output->AssistantGPT). Additionally python tools output is logged in C:\Users\{username}\AppData\Local\cpGames\VSA\Logs.

About

Visual Studio extension utilizing OpenAI GPT assistants

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors