-
-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support for multiple providers #93
Conversation
Would be awesome to see this merged! |
Would love to see URL seems to be Models: https://docs.anthropic.com/claude/docs/models-overview |
testing this branch I get on startup:
because I dont use copilot and this file doesn't exist. Also maybe I configure it wrong but my agents have disappeared and instead I get the default as completion I suppose:
|
answering to myself, my agents got silently discarded because I had removed the model and/or prompt. |
@teto Matthieu, thanks for the review. What are you using without model and sys prompt? Could you provide me with the config you got discarded?
I'll disable all but OpenAI provider before merging this to main and people will have to explicitly enable others. I'm considering the unpack for agents, but it seems a bit unwieldy for cases when user wants to override just few defaults while keeping others. I've used array for agents, so that users wouldn't trip over map syntax for keys with special characters ( Anyway, the following will have to be improved before merging. -- remove invalid agents
for name, agent in pairs(M.agents) do
if type(agent) ~= "table" or not agent.model or not agent.system_prompt then
M.agents[name] = nil
end
end |
@teto were you able to figure out how to use gp.nvim with ollama for local whisper? |
@Robitx can we merge this ? I would like to contribute to gp.nvim a lot more but while I can deal with stacked PRs, this is a pretty fundamental change that makes it more anxious and I really need the feature xD |
@teto Looks like this project will no longer be maintained. Such a shame, as it is by far the best experience I have had with LLMs and nvim. |
+1 |
For anyone interested, I've been using this branch with Ollama for some time (couple of months?) and haven't encountered any error, the chat and code agents work well (with ollama), so maybe forking from here migh be good. |
When we provide a secret in the provider, do we need to set the OpenAI API key? |
@1orZero if you set secret in the openai provider, it populates openai_api_key automatically, so you don't have to |
Thank you for the quick reply! I tried setting two providers in the config without setting the openai_api_key, but this gives me an error during initialization. |
@1orZero could you send me relevant config snippet? |
This is my config I am using Lazyvim if vim.g.vscode then
return {}
end
local api_config = require("api_config.gp-config")
local agents = {
{
name = "ChatGPT4o",
disable = true,
},
{
name = "ChatGPT4",
disable = true,
},
{
name = "ChatGPT3-5",
disable = true,
},
{
name = "CodeGPT4o",
disable = true,
},
{
name = "CodeGPT4",
disable = true,
},
{
name = "CodeGPT3-5",
disable = true,
},
}
if api_config.azure.agents then
for _, v in ipairs(api_config.azure.agents) do
table.insert(agents, v)
end
end
if api_config.onechat.agents then
for _, v in ipairs(api_config.onechat.agents) do
table.insert(agents, v)
end
end
local config = {
-- openai_api_key = api_config.azure.secret,
provider = {
azure = api_config.azure,
openai = api_config.onechat,
},
agents = agents,
}
return {
"robitx/gp.nvim",
config = function()
require("gp").setup(config)
end,
}
api-config file : local system_prompt_chat = "You are a general AI assistant.\n\n"
.. "The user provided the additional info about how they would like you to respond:\n\n"
.. "- If you're unsure don't guess and say you don't know instead.\n"
.. "- Ask question if you need clarification to provide better answer.\n"
.. "- Think deeply and carefully from first principles step by step.\n"
.. "- Zoom out first to see the big picture and then zoom in to details.\n"
.. "- Use Socratic method to improve your thinking and coding skills.\n"
.. "- Don't elide any code from your output if the answer requires coding.\n"
.. "- Take a deep breath; You've got this!\n"
local system_prompt_code = "You are an AI working as a code editor.\n\n"
.. "Please AVOID COMMENTARY OUTSIDE OF THE SNIPPET RESPONSE.\n"
.. "START AND END YOUR ANSWER WITH:\n\n```"
local azure = {
endpoint = "https://internal-ai-usages-4.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2024-02-15-preview",
secret = "xxxxx",
agents = {
{
name = "ChatGPT4o (Azure)",
chat = true,
command = true,
model = { model = "gpt-4o", temperature = 0.3, top_p = 0.5 },
system_prompt = system_prompt_chat,
max_tokens = 4096,
provider = "openai",
},
},
}
local onechat = {
endpoint = "https://chatapi.onechats.top/v1/chat/completions",
secret = "xxxxx",
agents = {
{
name = "Claude 3.5 Sonnet (OneChat)",
chat = true,
command = true,
model = { model = "claude-3-5-sonnet-20240620", temperature = 0.3, top_p = 0.5 },
system_prompt = system_prompt_chat,
max_tokens = 4096,
provider = "openai",
},
},
}
return {
azure = azure,
onechat = onechat,
}
|
@1orZero I see two things, it seems you're setting
and the |
You're right! Thank you for reviewing my config. It's now working so well. Appreciate your effort! |
@Robitx related to this, to enable |
@gonzaloserrano starting with a clean config, where only openai is active, you can switch between agents via Depending on which window is active, either you'll cycle among code agents or chat agents. The last agent used is persisted on disk. The commands are mentioned in the readme but i guess it could be improved and made more visible https://github.com/Robitx/gp.nvim?tab=readme-ov-file#agent-commands The other side of this is that people keep asking for options to specify default agents: Which I'll probably have to do in some form. |
No description provided.