gp.nvim
gp.nvim copied to clipboard
WIP: display why I can't change the chat agent
for some reason, GpAgent refused to autocomplete ChatGPT. Looking at the code, it refused to set the chat agent under some conditions (Is this a new behavior ?). :GpAgent ChatGPT4o would return ChatGPT4o is not a valid agent for current buffer" which is not very helpful (why ? how can I fix this). I've refactored not_chat to remove the negation into is_chat with a return pattern used widely in luarock return success (boolean), err_msg .
So right now I can see why it refuses to change:
:GpAgent ChatGPT4o
false resolved file (/home/teto/gp.nvim/lua/gp/init.lua) not in chat dir (/home/teto/.local/share/nvim/gp/chats)
Press ENTER or type command to continue
I am still not sure why we want to prevent that
Agents are currently a bundle of model settings and a system prompt leading to some agents being good for chats, while others for code operations.
The bundling is there, because different LLMs (and different tasks) might have different needs. In general, it's better to have a lower temperature for coding (less hallucinations) and weaker models (like llama) might need a different/custom sys prompt to force it work properly.
In a chat buffer :GpAgent autocompletes only agents which have chat = true, configured, in any other buffer it completes code agents (command = true,).
{
name = "ChatGPT4o",
chat = true,
command = false,
-- string with model name or table with model name and parameters
model = { model = "gpt-4o", temperature = 1.1, top_p = 1 },
-- system prompt (use this to specify the persona/role of the AI)
system_prompt = require("gp.defaults").chat_system_prompt,
},
{
provider = "openai",
name = "CodeGPT4o",
chat = false,
command = true,
-- string with model name or table with model name and parameters
model = { model = "gpt-4o", temperature = 0.8, top_p = 1 },
-- system prompt (use this to specify the persona/role of the AI)
system_prompt = require("gp.defaults").code_system_prompt,
},