From b196627e8636e21b8572fc3ed2ca4af5cb68d4b6 Mon Sep 17 00:00:00 2001 From: Aaron Pham Date: Fri, 30 Aug 2024 13:39:36 -0400 Subject: [PATCH] chore(provider): use latest cohere models (#400) Update prompts to correct grammar concat with table.concat to avoid overhead Signed-off-by: Aaron Pham --- lua/avante/config.lua | 6 +++--- lua/avante/llm.lua | 6 +++--- lua/avante/providers/cohere.lua | 7 ++----- lua/avante/providers/openai.lua | 5 +---- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/lua/avante/config.lua b/lua/avante/config.lua index 456ce90..86875ce 100644 --- a/lua/avante/config.lua +++ b/lua/avante/config.lua @@ -62,10 +62,10 @@ M.defaults = { ---@type AvanteSupportedProvider cohere = { endpoint = "https://api.cohere.com/v1", - model = "command-r-plus", + model = "command-r-plus-08-2024", timeout = 30000, -- Timeout in milliseconds temperature = 0, - max_tokens = 3072, + max_tokens = 4096, ["local"] = false, }, ---To add support for custom provider, follow the format below @@ -233,7 +233,7 @@ M = setmetatable(M, { M.support_paste_image = function() local supported = Utils.has("img-clip.nvim") or Utils.has("img-clip") - if not supported and not M.options.silent_warning then + if not supported then Utils.warn("img-clip.nvim is not installed. Pasting image will be disabled.", { once = true }) end return supported diff --git a/lua/avante/llm.lua b/lua/avante/llm.lua index 758667f..bd38bc1 100644 --- a/lua/avante/llm.lua +++ b/lua/avante/llm.lua @@ -51,8 +51,8 @@ Replace lines: {{start_line}}-{{end_line}} - The content regarding line numbers MUST strictly follow the format "Replace lines: {{start_line}}-{{end_line}}". Do not be lazy! - The range {{start_line}}-{{end_line}} is INCLUSIVE. Both start_line and end_line are included in the replacement. - Count EVERY line, including empty lines and comments lines, comments. Do not be lazy! - - For single-line changes, use the same number for start and end lines. - - For multi-line changes, ensure the range covers ALL affected lines, from the very first to the very last. + - Use the same number for start and end lines for single-line changes. + - For multi-line changes, ensure the range covers ALL affected lines, from first to last. - Double-check that your line numbers align perfectly with the original code structure. 5. Final check: @@ -63,7 +63,7 @@ Replace lines: {{start_line}}-{{end_line}} - Double-check that your line numbers align perfectly with the original code structure. - DO NOT return the complete modified code with applied changes! -Remember: Accurate line numbers are CRITICAL. The range start_line to end_line must include ALL lines to be replaced, from the very first to the very last. Double-check every range before finalizing your response, paying special attention to the start_line to ensure it hasn't shifted down. Ensure that your line numbers perfectly match the original code structure without any overall shift. +Remember: Accurate line numbers are CRITICAL. The range start_line to end_line must include ALL lines to be replaced, from the very first to the very last. Double-check every range before finalizing your response, paying special attention to the start_line to ensure it hasn't shifted down. Ensure your line numbers match the original code structure without any overall shift. ]] local editing_mode_user_prompt_tpl = [[ diff --git a/lua/avante/providers/cohere.lua b/lua/avante/providers/cohere.lua index cd897e8..d9efcea 100644 --- a/lua/avante/providers/cohere.lua +++ b/lua/avante/providers/cohere.lua @@ -31,10 +31,7 @@ local M = {} M.api_key_name = "CO_API_KEY" M.parse_message = function(opts) - local user_prompt = "" - for _, user_prompt_ in ipairs(opts.user_prompts) do - user_prompt = user_prompt .. "\n\n" .. user_prompt_ - end + local user_prompt = table.concat(opts.user_prompts, "\n\n") return { preamble = opts.system_prompt, @@ -75,7 +72,7 @@ M.parse_curl_args = function(provider, code_opts) .. "." .. vim.version().patch, } - if not P.env.is_local("openai") then + if not P.env.is_local("cohere") then headers["Authorization"] = "Bearer " .. provider.parse_api_key() end diff --git a/lua/avante/providers/openai.lua b/lua/avante/providers/openai.lua index cd48b9a..8fc9699 100644 --- a/lua/avante/providers/openai.lua +++ b/lua/avante/providers/openai.lua @@ -28,10 +28,7 @@ local M = {} M.api_key_name = "OPENAI_API_KEY" M.parse_message = function(opts) - local user_prompt = "" - for _, user_prompt_ in ipairs(opts.user_prompts) do - user_prompt = user_prompt .. "\n\n" .. user_prompt_ - end + local user_prompt = table.concat(opts.user_prompts, "\n\n") ---@type string | OpenAIMessage[] local user_content