Skip to content

A Visual Studio Code extension to support ChatGPT. The extension is pair-programmed with ChatGPT.

License

Notifications You must be signed in to change notification settings

Siddharth-cmd/vscode-chatgpt

 
 

Repository files navigation


Ask ChatGPT

ChatGPT conversations in Visual Studio Code

Badge for version for Visual Studio Code extension gencay.vscode-chatgpt

🚀🎉 Zero Configuration (Automated Authentication)

  • Zero-Config Autologin lets the extension grab the required tokens automatically using puppeteer.
  • 2 options to run ChatGPT assistant in your vs-code:
    1. Enable Autologin setting from vs-code settings page and let the extension log you in and grab required tokens. Described in Autologin Setup
    2. Manually login on a browser and grab required tokens for logging in. Described in Manual Setup

ChatGPT as your copilot to level up your developer experience

  • 🤖 Zero-Config. Automatically logs you in and grabs the required tokens on your behalf.
  • ➡️ Export all your conversation history at once in Markdown format.
  • 🔃 Option to clear and restart the conversation with ChatGPT.
  • 🍻 Optimized for dialogue! Have a conversation with ChatGPT with follow-ups.
  • 💯 Get help from ChatGPT within vs-code for implementing test cases, explaining it or finding bugs.
  • 📝 Create projects/files with one click using built-in actions in the conversation view.
  • ⚡ Built-in syntax highlighting for ChatGPT suggested code using the default code-font of your Visual Studio Code!
  • 🖼️ Icon is generated by dall-e-2.

Features

The extension comes with context menu commands, copy/move suggested code into editor with one-click, conversation window and customization options for OpenAI's ChatGPT prompts.

ChatGPT conversation window in vs-code

🆕 Export all your conversation history withs one click


🍻 Optimized for dialogue


Edit and resend a previous prompt


Copy or insert the code ChatGPT is suggesting right into your editor.


Ask free-form text questions that will be listed in the conversation window. The conversation is kept in cache until vs-code instance is closed.


Use defaults or customize your code prompts

  • ChatGPT: Add Tests: Write tests for you. Right click on a selected block of code, run command.
    • "default": "Implement tests for the following code",
    • "description": "The prompt prefix used for adding tests for the selected code"
  • ChatGPT: Find bugs: Analyze and find bugs in your code. Right click on a selected block of code, run command.
    • "default": "Find problems with the following code",
    • "description": "The prompt prefix used for finding problems for the selected code"
  • ChatGPT: Optimize: Add suggestions to your code to improve. Right click on a selected block of code, run command.
    • "default": "Optimize the following code",
    • "description": "The prompt prefix used for optimizing the selected code"
  • ChatGPT: Explain: Explain the selected code. Right click on a selected block of code, run command.
    • "default": "Explain the following code",
    • "description": "The prompt prefix used for explaining the selected code"

Other available commands

  • ChatGPT: Ask anything: Free-form text questions within conversation window.
  • ChatGPT: Clear session: Clears the current session. Useful in case of API errors.
  • ChatGPT: Clear conversation: Clears the conversation window and resets the thread to start a new conversation with ChatGPT
  • ChatGPT: Export conversation: Exports the whole conversation in Markdown for you to easily store and find the Q&A list.

Customization settings

  • Opt-in to use automation to authenticate OpenAI.
  • You can configure the commands to use any prompts for the selected code!
  • Opt-in to receive notification when ChatGPT sends you a message!

Autologin Setup

This option helps you grab the required tokens automatically, without needing to copy/paste tokens around 🚀.

  1. Make sure autologin setting is set to true (Default is true)

  2. Once you ask ChatGPT something, unless you already configured authentication, it'll open a Chrome window.

  3. Login to OpenAI as usual and solve captchas when prompted.

  4. The Chrome page will be closed automatically once we grab the required tokens.

NOTE: The default path will be used for Chrome on your operating system. You have the option to override it in the settings (If you override, make sure to escape \\ instead of \)

  • For reference here are the defaults:

    • Windows: C:\Program Files\Google\Chrome\Application\chrome.exe
    • MAC: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    • Linux: /usr/bin/google-chrome

Manual Setup

  1. Go to https://chat.openai.com and log in.
  2. Open your browser's developer tools
    • Hit F12 to open the developer tools in most browsers
    • Alternatively, right click on the browser window and select Inspect
  3. Go to Application -> Cookies -> https://chat.openai.com. You will need the following cookies:
    • __Secure-next-auth.session-token: The extension will use this to send prompts to ChatGPT
    • cf_clearance: CloudFlare clearance token. A security measure OpenAI put in place to block automated access.
  4. Go to Console and type in the following code to get your user-agent
    • navigator.userAgent: This is your browser's user-agent, needed for CloudFlare clearance. Enter the value of userAgent when prompted by the extension. Copy its value without single or double quotes.
  5. Now that you have all required session variables, run any command using the extension and you'll be asked to enter these values:
    • __Secure-next-auth.session-token: An encoded token starting with ey***
    • cf_clearance: An alpha-numeric token
    • userAgent

Troubleshooting

  • If the bot isn't responding, try clearing your cache by running the ChatGPT: Clear session command.
  • It's possible that openai systems may experience issues responding to your queries due to high-traffic from time to time.
  • If you get ChatGPTAPI error 429, it means that you are making Too Many Requests. Please wait and try again in a few moments. If it persists, restart your vs-code.
  • If you see ChatGPTAPI error terminated, your requests are being throttled. Please try again later.

Credits

About

A Visual Studio Code extension to support ChatGPT. The extension is pair-programmed with ChatGPT.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 47.7%
  • TypeScript 41.5%
  • CSS 10.8%