David-Kunz / gen.nvim

Neovim plugin to generate text using LLMs with customizable prompts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Suggestion: add choice of models to switch to

kapral18 opened this issue · comments

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,
  },
}

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

Hi @kapral18 ,

Thanks for the suggestion and code, I've implemented it in #44

Best regards,
David

Ha, you were faster 😄