ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Open​AI completion

by yaroslavyaroslav ALL Trending

Sublime Text OpenAI completion plugin with GPT-4 support!

Details

Installs

  • Total 3K
  • Win 1K
  • Mac 1K
  • Linux 442
Feb 25 Feb 24 Feb 23 Feb 22 Feb 21 Feb 20 Feb 19 Feb 18 Feb 17 Feb 16 Feb 15 Feb 14 Feb 13 Feb 12 Feb 11 Feb 10 Feb 9 Feb 8 Feb 7 Feb 6 Feb 5 Feb 4 Feb 3 Feb 2 Feb 1 Jan 31 Jan 30 Jan 29 Jan 28 Jan 27 Jan 26 Jan 25 Jan 24 Jan 23 Jan 22 Jan 21 Jan 20 Jan 19 Jan 18 Jan 17 Jan 16 Jan 15 Jan 14 Jan 13 Jan 12 Jan 11
Windows 1 7 6 10 8 12 9 3 1 1 3 1 1 2 7 1 3 7 2 3 1 1 3 2 5 2 2 4 2 0 3 1 4 3 4 3 4 3 4 2 3 3 2 3 2 4
Mac 1 3 4 8 8 6 2 5 2 1 4 1 2 4 2 0 5 3 3 4 4 0 2 1 4 3 4 4 3 1 1 6 1 2 2 1 0 4 0 6 4 4 4 2 5 2
Linux 0 1 4 3 3 1 2 3 3 1 2 0 2 2 1 0 2 0 2 1 1 2 2 1 1 2 1 3 0 1 6 1 0 0 2 2 0 2 2 0 3 1 0 2 0 1

Readme

Source
raw.​githubusercontent.​com

Star on GitHub

OpenAI Sublime Text Plugin

Abstract

OpenAI Completion is a Sublime Text 4 plugin that uses the OpenAI natural language processing (NLP) model to provide an code assistant experience within the editor.

Features

  • Code manipulation (append, insert and edit) selected code with OpenAI models.
  • Selected text capture in addition to every message.
  • Chat mode support powered with ChatGPT models.
  • Markdown syntax with syntax highlight support (ChatGPT mode only).
  • Proxy support.
  • GPT-4 support.
  • Server Side Streaming (SSE) support (i.e. text starts presenting gradually right after user request)
  • Multiple assistant presets
  • Status bar badge with a currently selected assistant properties.

ChatGPT completion demo

Click to see screens

gif is speed up 1.5x

gif is speed up 1.5x

Requirements

  • Sublime Text 4
  • OpenAI API key (paid service)
  • Internet connection

Installation

  1. Install the Sublime Text Package Control plugin if you haven't done this before.
  2. Open the command palette and type Package Control: Install Package.
  3. Type OpenAI and press Enter.

Usage

ChatGPT usage

ChatGPT mode works the following way:

  1. Run the OpenAI: New Message command
  2. Right after that the plug-in will open the output panel and start printing the model response into it.
  3. Wait until the model stops transferring its answer (currently there's no way how to abort transmission or hide the output panel within that process).
  4. If you would like to fetch chat history to another window manually, you can do that by running the OpenAI: Refresh Chat command.
  5. When you're done or want to start all over you should run the OpenAI: Reset Chat History command, which deletes the chat cache.

Note You can bind both of the most usable commands OpenAI: New Message and OpenAI: Show output panel, to do that please follow Settings -> Package Control -> OpenAI completion -> Key Bindings.

Note As for now there's just a single history instance. I guess this limitation would disappear sometime.

Single shot completion usage

Warning The gpt-3.5-turbo model can still be unreliable in this regard, often generating wordy responses despite specific instructions. OpenAI had promised to address this issue by the end of the year. However, the gpt-4 model seems to handle commands more effectively.

  1. Configure your assistant for each text task you wish to perform (e.g., append, replace, insert, panel) in the plugin settings. You can refer to the default setup as an example.
  2. Launch the Sublime Text editor and select a block of code.
  3. Access the command palette and execute the “OpenAI: New Message” command.
  4. The plugin will transmit the selected code to the OpenAI servers using your API key. This action will prompt the generation of a suggested code modification based on your command (e.g., append, insert, or edit).
  5. The suggestion provided will make the necessary modifications to the selected code within the editor, following the command you issued.

Note A more detailed manual, including various assistant configuration examples, can be found within the plugin settings.

Other features

[Multi]Markdown syntax with syntax highlight support

ChatGPT output panel supports markdown syntax highlight. It should just work (if it's not please report an issue).

Although it's highly recommended to install the MultimarkdownEditing to apply syntax highlighting for code snippets provided by ChatGPT. OpenAI completion should just pick it up implicitly for the output panel content.

Proxy support

That's it. Now you can set up a proxy for this plugin. You can setup it up by overriding the proxy property in the OpenAI completion settings like follow:

"proxy": {
    "address": "127.0.0.1", // required
    "port": 9898, // required
    "username": "account",
    "password": "sOmEpAsSwOrD"
}

GPT-4 support

Note You have to have access to the GPT-4 model within your account, to use that feature.

It should just work, just set the chat_model setting to GPT-4.

Settings

The OpenAI Completion plugin has a settings file where you can set your OpenAI API key. This is required for the plugin to work. To set your API key, open the settings within Preferences -> Package Settings -> OpenAI -> Settings and paste your API key in the token property, as follows:

{
    "token": "sk-your-token",
}

Disclaimers

Note Please note that OpenAI is a paid service, and you will need to have an API key and sufficient credit to use this plugin.

Warning All selected code will be sent to the OpenAI servers for processing, so make sure you have all necessary permissions to do so.

This one was at 80% written by that thing itself including this readme. I was here mostly for debugging purposes, rather than designing and researching. This is pure magic, I swear.