-
Recently came back from a month long vacation and I noticed that I am no longer getting a picker to choose from the different choices of models. I am using multiple adapters (openai_compatible, ollama and a custom open-webui adapter). When I hit Using ollama as an example, I have this adapter config: locallama_ctx40_qwen_think = function()
return require('codecompanion.adapters').extend('ollama', {
formatted_name = 'locallama',
schema = {
model = { default = 'hf.co/unsloth/Qwen3-32B-GGUF:UD-Q6_K_XL' },
num_ctx = { default = 40960 },
temperature = { default = 0.6 },
top_k = { default = 40 },
top_p = { default = 0.95 },
},
})
end, After opening a new chat window and selecting this adapter, I see this in the debug window ( -- Adapter: "locallama"
-- Buffer: 8
-- Context: "codecompanion.lua" (1)
local settings = {
model = "hf.co/unsloth/Qwen3-32B-GGUF:UD-Q6_K_XL", -- "hf.co/unsloth/QwQ-32B-GGUF:UD-Q6_K_XL", "hf.co/unsloth/Qwen3-32B-GGUF:UD-Q5_K_XL", "hf.co/unsloth/QwQ-32B-GGUF:UD-Q5_K_XL", "hf.co/unsloth/Qwen3-30B-A3B-GGUF:UD-Q6_K_XL", "hf.co/unsloth/Qwen3-14B-GGUF:UD-Q6_K_XL", "hf.co/unsloth/GLM-4-32B-0414-GGUF:Q5_K_XL", "hf.co/unsloth/GLM-4-32B-0414-GGUF:Q6_K_XL", "hf.co/unsloth/Qwen2.5-Coder-32B-Instruct-GGUF:Q5_K_M", "hf.co/unsloth/Qwen2.5-Coder-32B-Instruct-GGUF:Q6_K", "hf.co/unsloth/Mistral-Small-3.1-24B-Instruct-2503-GGUF:UD-Q6_K_XL", "hf.co/unsloth/Qwen2.5-Coder-14B-Instruct-GGUF:Q6_K", "hf.co/unsloth/phi-4-GGUF:Q5_K_M", "hf.co/darkc0de/gemma-3-27b-it-abliterated-Q5_K_M-GGUF:latest", "hf.co/unsloth/gemma-3-27b-it-GGUF:UD-Q6_K_XL", "hf.co/unsloth/gemma-3-27b-it-GGUF:UD-Q5_K_XL",
temperature = 0.6,
num_ctx = 40960,
mirostat = 0,
mirostat_eta = 0.1,
mirostat_tau = 5,
repeat_last_n = 64,
repeat_penalty = 1.1,
seed = 0,
stop = nil,
num_predict = -1,
top_k = 40,
top_p = 0.95,
}
local messages =
{ {
content = "You are an AI programming assistant named \"CodeCompanion\". You are currently plugged in to the Neovim text editor on a user's machine.\n\nYour core tasks include:\n- Answering general programming questions.\n- Explaining how the code in a Neovim buffer works.\n- Reviewing the selected code in a Neovim buffer.\n- Generating unit tests for the selected code.\n- Proposing fixes for problems in the selected code.\n- Scaffolding code for a new workspace.\n- Finding relevant code to the user's query.\n- Proposing fixes for test failures.\n- Answering questions about Neovim.\n- Running tools.\n\nYou must:\n- Follow the user's requirements carefully and to the letter.\n- Keep your answers short and impersonal, especially if the user responds with context outside of your tasks.\n- Minimize other prose.\n- Use Markdown formatting in your answers.\n- Include the programming language name at the start of the Markdown code blocks, do not forget triple backticks around code blocks.\n- Avoid including line numbers in code blocks.\n- Avoid wrapping the whole response in triple backticks.\n- Only return code that's relevant to the task at hand. You may not need to return all of the code that the user has shared.\n- Use actual line breaks instead of '\\n' in your response to begin new lines.\n- Use '\\n' only when you want a literal backslash followed by a character 'n'.\n\nWhen given a task:\n1. Think step-by-step and describe your plan for what to build in pseudocode, written out in great detail, unless asked not to do so.\n2. Output the code in a single code block, being careful to only return relevant code.\n3. You should always generate short suggestions for the next user turns that are relevant to the conversation.\n4. You can only give one reply for each conversation turn.\n",
cycle = 1,
id = 967016408,
opts = {
tag = "from_config",
visible = false
},
role = "system"
} } where we can see in the comment on the settings.model line that all other available choices are indeed getting pulled from ollama.. but I'm not longer getting prompted to choose from a picker view. Why is that? I have tried:
Any help will be greatly appreciated :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
The code for that is at M.change_adapter = {
desc = "Change the adapter",
callback = function(chat)
if config.display.chat.show_settings then
return util.notify("Adapter can't be changed when `display.chat.show_settings = true`", vim.log.levels.WARN)
end
local function select_opts(prompt, conditional)
return {
prompt = prompt,
kind = "codecompanion.nvim",
format_item = function(item)
if conditional == item then
return "* " .. item
end
return " " .. item
end,
}
end
local adapters = vim.deepcopy(config.adapters)
local current_adapter = chat.adapter.name
local current_model = vim.deepcopy(chat.adapter.schema.model.default)
local adapters_list = vim
.iter(adapters)
:filter(function(adapter)
return adapter ~= "opts" and adapter ~= "non_llms" and adapter ~= current_adapter
end)
:map(function(adapter, _)
return adapter
end)
:totable()
table.sort(adapters_list)
table.insert(adapters_list, 1, current_adapter)
vim.ui.select(adapters_list, select_opts("Select Adapter", current_adapter), function(selected)
if not selected then
return
end
if current_adapter ~= selected then
chat.adapter = require("codecompanion.adapters").resolve(adapters[selected])
util.fire(
"ChatAdapter",
{ bufnr = chat.bufnr, adapter = require("codecompanion.adapters").make_safe(chat.adapter) }
)
chat.ui.adapter = chat.adapter
chat:apply_settings()
end
-- Update the system prompt
local system_prompt = config.opts.system_prompt
if type(system_prompt) == "function" then
if chat.messages[1] and chat.messages[1].role == "system" then
local opts = { adapter = chat.adapter, language = config.opts.language }
chat.messages[1].content = system_prompt(opts)
end
end
-- Select a model
local models = chat.adapter.schema.model.choices
if not config.adapters.opts.show_model_choices then
models = { chat.adapter.schema.model.default }
end
if type(models) == "function" then
models = models(chat.adapter)
end
if not models or vim.tbl_count(models) < 2 then
return
end
local new_model = chat.adapter.schema.model.default
if type(new_model) == "function" then
new_model = new_model(chat.adapter)
end
models = vim
.iter(models)
:map(function(model, value)
if type(model) == "string" then
return model
else
return value -- This is for the table entry case
end
end)
:filter(function(model)
return model ~= new_model
end)
:totable()
table.insert(models, 1, new_model)
vim.ui.select(models, select_opts("Select Model", new_model), function(selected)
if not selected then
return
end
if current_model ~= selected then
util.fire("ChatModel", { bufnr = chat.bufnr, model = selected })
end
chat:apply_model(selected)
chat:apply_settings()
end)
end)
end,
} |
Beta Was this translation helpful? Give feedback.
I found the change the led to this behavior change:
90e82ab Pedro Ferrari (2025-05-04 16:47):
feat(adapters): can automatically choose default model when switching adapters (#1369)
I modified my config to include the config to always show model choices: