David-Kunz / gen.nvim

Neovim plugin to generate text using LLMs with customizable prompts
The Unlicense
1.15k stars 92 forks source link

Suggestion: add choice of models to switch to #43

Closed kapral18 closed 10 months ago

kapral18 commented 10 months ago

Not entirely sure where to put tho can be added in the main list of actions that is invoked with :Gen

or can be added to just README as a suggestion for people to use if they want to conveniently switch to different models for a given :Gen invocation. What do you think?

this is how I use it for myself:

local changeModel = function()
  -- take the first column of the output of ollama list after header row and trim whitespace
  -- so that systemlist returns a valid list of models
  local list = vim.fn.systemlist("ollama list | awk 'NR>1' | cut -f1 | tr -d ' '")

  vim.ui.select(list, { prompt = "Select a model: " }, function(selected)
    if selected == nil then
      return
    end

    require("gen").model = selected
    print("Model set to " .. selected)
  end)
end

return {
  "David-Kunz/gen.nvim",
  keys = {
    { "<leader>ai", ":Gen<CR>", mode = { "n", "v", "x" }, desc = "Local [AI]: Menu" },
    { "<leader>am", changeModel, mode = { "n" }, desc = "Local [AI]: Change Model" },
  },
  opts = {
    display_mode = "float",
    show_model = true,
    no_serve = true,
    debugCommand = true,
  },
}
kapral18 commented 10 months ago

@David-Kunz I see the commit, epic thank you!

David-Kunz commented 10 months ago

Hi @kapral18 ,

Thanks for the suggestion and code, I've implemented it in https://github.com/David-Kunz/gen.nvim/pull/44

Best regards, David

David-Kunz commented 10 months ago

Ha, you were faster 😄