chore(llm): cut-back support (#159)

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
Aaron Pham 2024-08-23 00:21:30 -04:00 committed by GitHub
parent 6475407d0d
commit c6d5073945
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 10 additions and 117 deletions

View File

@ -99,7 +99,7 @@ _See [config.lua#L9](./lua/avante/config.lua) for the full config_
```lua
{
---@alias Provider "openai" | "claude" | "azure" | "deepseek" | "groq" | "copilot" | [string]
---@alias Provider "openai" | "claude" | "azure" | "copilot" | [string]
provider = "claude",
claude = {
endpoint = "https://api.anthropic.com",
@ -155,6 +155,11 @@ _See [config.lua#L9](./lua/avante/config.lua) for the full config_
Given its early stage, `avante.nvim` currently supports the following basic functionalities:
> [!IMPORTANT]
>
> Avante will only support OpenAI (and its variants including copilot and azure), and Claude out-of-the-box due to its high code quality generation.
> For all OpenAI-compatible providers, see [wiki](https://github.com/yetone/avante.nvim/wiki) for more details.
> [!IMPORTANT]
>
> For most consistency between neovim session, it is recommended to set the environment variables in your shell file.
@ -177,18 +182,6 @@ Given its early stage, `avante.nvim` currently supports the following basic func
> ```sh
> export AZURE_OPENAI_API_KEY=your-api-key
> ```
>
> For DeepSeek
>
> ```sh
> export DEEPSEEK_API_KEY=you-api-key
> ```
>
> For Groq
>
> ```sh
> export GROQ_API_KEY=you-api-key
> ```
1. Open a code file in Neovim.
2. Use the `:AvanteAsk` command to query the AI about the code.

View File

@ -7,9 +7,9 @@ local M = {}
---@class avante.Config
M.defaults = {
debug = false,
---Currently, default supported providers include "claude", "openai", "azure", "deepseek", "groq", "gemini"
---Currently, default supported providers include "claude", "openai", "azure", "gemini"
---For custom provider, see README.md
---@alias Provider "openai" | "claude" | "azure" | "deepseek" | "groq" | "copilot" | "gemini" | string
---@alias Provider "openai" | "claude" | "azure" | "copilot" | "gemini" | string
provider = "claude",
---@type AvanteSupportedProvider
openai = {
@ -27,7 +27,7 @@ M.defaults = {
allow_insecure = false, -- Allow insecure server connections
timeout = 30000, -- Timeout in milliseconds
temperature = 0,
max_tokens = 8192,
max_tokens = 4096,
},
---@type AvanteAzureProvider
azure = {
@ -46,22 +46,6 @@ M.defaults = {
temperature = 0,
max_tokens = 4096,
},
---@type AvanteSupportedProvider
deepseek = {
endpoint = "https://api.deepseek.com",
model = "deepseek-coder",
temperature = 0,
max_tokens = 4096,
["local"] = false,
},
---@type AvanteSupportedProvider
groq = {
endpoint = "https://api.groq.com",
model = "llama-3.1-70b-versatile",
temperature = 0,
max_tokens = 4096,
["local"] = false,
},
---@type AvanteGeminiProvider
gemini = {
endpoint = "https://generativelanguage.googleapis.com/v1beta/models",

View File

@ -1,41 +0,0 @@
local Utils = require("avante.utils")
local Config = require("avante.config")
local P = require("avante.providers")
local O = require("avante.providers").openai
---@class AvanteProviderFunctor
local M = {}
M.api_key_name = "DEEPSEEK_API_KEY"
M.has = function()
return os.getenv(M.api_key_name) and true or false
end
M.parse_message = O.parse_message
M.parse_response = O.parse_response
M.parse_curl_args = function(provider, code_opts)
local base, body_opts = P.parse_config(provider)
local headers = {
["Content-Type"] = "application/json",
}
if not P.env.is_local("deepseek") then
headers["Authorization"] = "Bearer " .. os.getenv(base.api_key_name or M.api_key_name)
end
return {
url = Utils.trim(base.endpoint, { suffix = "/" }) .. "/chat/completions",
proxy = base.proxy,
insecure = base.allow_insecure,
headers = headers,
body = vim.tbl_deep_extend("force", {
model = base.model,
messages = M.parse_message(code_opts),
stream = true,
}, body_opts),
}
end
return M

View File

@ -1,41 +0,0 @@
local Utils = require("avante.utils")
local Config = require("avante.config")
local P = require("avante.providers")
local O = require("avante.providers").openai
---@class AvanteProviderFunctor
local M = {}
M.api_key_name = "GROQ_API_KEY"
M.has = function()
return os.getenv(M.api_key_name) and true or false
end
M.parse_message = O.parse_message
M.parse_response = O.parse_response
M.parse_curl_args = function(provider, code_opts)
local base, body_opts = P.parse_config(provider)
local headers = {
["Content-Type"] = "application/json",
}
if not P.env.is_local("groq") then
headers["Authorization"] = "Bearer " .. os.getenv(base.api_key_name or M.api_key_name)
end
return {
url = Utils.trim(base.endpoint, { suffix = "/" }) .. "/openai/v1/chat/completions",
proxy = base.proxy,
insecure = base.allow_insecure,
headers = headers,
body = vim.tbl_deep_extend("force", {
model = base.model,
messages = M.parse_message(code_opts),
stream = true,
}, body_opts),
}
end
return M

View File

@ -88,9 +88,7 @@ local Dressing = require("avante.ui.dressing")
---@field copilot AvanteProviderFunctor
---@field claude AvanteProviderFunctor
---@field azure AvanteProviderFunctor
---@field deepseek AvanteProviderFunctor
---@field gemini AvanteProviderFunctor
---@field groq AvanteProviderFunctor
local M = {}
setmetatable(M, {
@ -224,7 +222,7 @@ function M.refresh(provider)
require("avante.config").override({ provider = provider })
end
local default_providers = { "openai", "claude", "azure", "deepseek", "groq", "gemini", "copilot" }
local default_providers = { "openai", "claude", "azure", "gemini", "copilot" }
---@private
M.commands = function()