krapjost / ChatGPT.nvim

Neovim plugin for interacting with OpenAI GPT-3 chatbot, providing an easy interface for exploring GPT-3 and NLP.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ChatGPT.nvim

GitHub Workflow Status Lua

ChatGPT is a Neovim plugin that allows you to interact with OpenAI's GPT-3 language model. With ChatGPT, you can ask questions and get answers from GPT-3 in real-time.

preview image

Installation

  • Make sure you have curl installed.
  • Set environment variable called $OPENAI_API_KEY which you can obtain here.
-- Packer
use({
  "jackMort/ChatGPT.nvim",
    config = function()
      require("chatgpt").setup({
        -- optional configuration
      })
    end,
    requires = {
      "MunifTanjim/nui.nvim",
      "nvim-lua/plenary.nvim",
      "nvim-telescope/telescope.nvim"
    }
})

Configuration

ChatGPT.nvim comes with the following defaults

{
  welcome_message = WELCOME_MESSAGE,
  loading_text = "loading",
  question_sign = "", -- you can use emoji if you want e.g. 🙂
  answer_sign = "ﮧ", -- 🤖
  max_line_length = 120,
  yank_register = "+",
  chat_layout = {
    relative = "editor",
    position = "50%",
    size = {
      height = "80%",
      width = "80%",
    },
  },
  settings_window = {
    border = {
      style = "rounded",
      text = {
        top = " Settings ",
      },
    },
  },
  chat_window = {
    filetype = "chatgpt",
    border = {
      highlight = "FloatBorder",
      style = "rounded",
      text = {
        top = " ChatGPT ",
      },
    },
  },
  chat_input = {
    prompt = "  ",
    border = {
      highlight = "FloatBorder",
      style = "rounded",
      text = {
        top_align = "center",
        top = " Prompt ",
      },
    },
  },
  openai_params = {
    model = "gpt-3.5-turbo",
    frequency_penalty = 0,
    presence_penalty = 0,
    max_tokens = 300,
    temperature = 0,
    top_p = 1,
    n = 1,
  },
  openai_edit_params = {
    model = "code-davinci-edit-001",
    temperature = 0,
    top_p = 1,
    n = 1,
  },
  keymaps = {
    close = { "<C-c>" },
    submit = "<C-Enter>",
    yank_last = "<C-y>",
    yank_last_code = "<C-k>",
    scroll_up = "<C-u>",
    scroll_down = "<C-d>",
    toggle_settings = "<C-o>",
    new_session = "<C-n>",
    cycle_windows = "<Tab>",
    -- in the Sessions pane
    select_session = "<Space>",
    rename_session = "r",
    delete_session = "d",
  },
}

Usage

Plugin exposes following commands:

  • ChatGPT command which opens interactive window.
  • ChatGPTActAs command which opens a prompt selection from Awesome ChatGPT Prompts to be used with the ChatGPT.

preview image

  • ChatGPTEditWithInstructions command which opens interactive window to edit selected text or whole window - demo video.

preview image

Available keybindings are:

  • <C-Enter> to submit.
  • <C-c> to close chat window.
  • <C-u> scroll up chat window.
  • <C-d> scroll down chat window.
  • <C-y> to copy/yank last answer.
  • <C-k> to copy/yank code from last answer.
  • <C-o> Toggle settings window.
  • <C-n> Start new session.
  • <Tab> Cycle over windows.
  • <C-i> [Edit Window] use response as input.

"Buy Me A Coffee"

About

Neovim plugin for interacting with OpenAI GPT-3 chatbot, providing an easy interface for exploring GPT-3 and NLP.


Languages

Language:Lua 100.0%