Code Monkey home page Code Monkey logo

dingllm.nvim's Introduction

Azure setup

Create an Azure OpenAI service name thing and then go into the workspace and create a model, which has a deployment name. Now add the following to your bashrc.

export AZURE_OPENAI_API_KEY='<one of the keys for your azure openai API>'
export AZURE_OPENAI_API_BACKEND='https://<name of azure openai endpoint>.openai.azure.com/openai/deployments/<model deployment name>/chat/completions?api-version=2024-06-01'

Install lua to be the main language of neovim

If you're still on vimscript like I was, do the following.

Create ~/.config/nvim/init.lua and set it up in accordance with the structured setup in this page. Also have to install some stuff (look at the requirements).

Then, move the old init.vim to vimrc.vim and then add

local vimrc = vim.fn.stdpath("config") .. "/vimrc.vim"
vim.cmd.source(vimrc)

Now create ~/.config/nvim/lua/plugins/llm.lua and paste this into it

return {
  {
    'neilzxu/dingllm.nvim',
    dependencies = { 'nvim-lua/plenary.nvim' },
    config = function()
      local system_prompt =
        'You should replace the code that you are sent, only following the comments. Do not talk at all. Only output valid code. Do not provide any backticks that surround the code. Never ever output backticks like this ```. Any comment that is asking you for something should be removed after you satisfy them. Other comments should left alone. Do not output backticks'
      local helpful_prompt = 'You are a helpful assistant. What I have sent are my notes so far. You are very curt, yet helpful.'
      local dingllm = require 'dingllm'

      local function azure_openai_replace()
        dingllm.invoke_llm_and_stream_into_editor({
          url_name = 'AZURE_OPENAI_API_BACKEND',
          api_key_name = 'AZURE_OPENAI_API_KEY',
          system_prompt = system_prompt,
          replace = true,
        }, dingllm.make_azure_openai_spec_curl_args, dingllm.handle_openai_spec_data)
      end

      local function azure_openai_help()
        dingllm.invoke_llm_and_stream_into_editor({
          url_name = 'AZURE_OPENAI_API_BACKEND',
          api_key_name = 'AZURE_OPENAI_API_KEY',
          system_prompt = helpful_prompt,
          replace = false,
        }, dingllm.make_azure_openai_spec_curl_args, dingllm.handle_openai_spec_data)
      end
      -- Keymaps
      vim.keymap.set({ 'n', 'v' }, ',l', azure_openai_replace, { desc = 'llm azure_openai' })
      vim.keymap.set({ 'n', 'v' }, ',L', azure_openai_help, { desc = 'llm azure_openai_help' })
    end,
  },
}

Finally, add the following to init.lua

require("lazy").setup("plugins")

dingllm.nvim's People

Contributors

yacinemtb avatar neilzxu avatar makyfj avatar hayden-donnelly avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.