92 lines
3.4 KiB
Lua
92 lines
3.4 KiB
Lua
-- Configuration module for avante.nvim plugin with DeepSeek API support
|
|
-- Returns configuration only if THIRD_PARTY_AI_ASSISTANT environment variable is set
|
|
|
|
-- Check for the required environment variable containing the API key
|
|
-- If the key is not set, returns an empty table and the plugin won't load
|
|
local ai_enabled = os.getenv "THIRD_PARTY_AI_ASSISTANT"
|
|
if not ai_enabled or ai_enabled:lower() ~= "true" then return {} end
|
|
|
|
-- Main plugin configuration object
|
|
---@type LazyPluginSpec[]
|
|
return {
|
|
{
|
|
-- Plugin identifier in GitHub repository
|
|
"yetone/avante.nvim",
|
|
-- Plugin version for compatibility assurance
|
|
version = "0.0.27",
|
|
-- Plugin configuration options
|
|
-- Remove the type annotation if avante.Config is undefined
|
|
opts = {
|
|
provider = "deepseek_safe",
|
|
|
|
behaviour = {
|
|
auto_approve_tool_permissions = true,
|
|
},
|
|
|
|
vendors = {
|
|
deepseek_safe = {
|
|
__inherited_from = "openai",
|
|
api_key_name = "DEEPSEEK_API_KEY",
|
|
endpoint = "https://api.deepseek.com",
|
|
model = "deepseek-chat",
|
|
timeout = 120000,
|
|
max_tokens = 8192,
|
|
extra_request_body = {
|
|
temperature = 0,
|
|
max_tokens = 8192,
|
|
},
|
|
|
|
-- parse_curl_args = function(opts, code_opts)
|
|
-- local log_file = io.open("/tmp/avante_debug.log", "a")
|
|
--
|
|
-- -- Helper function to extract text from content
|
|
-- local function get_content_text(content)
|
|
-- if type(content) == "string" then
|
|
-- return content
|
|
-- elseif type(content) == "table" then
|
|
-- -- Content can be array of {type="text", text="..."}
|
|
-- if content.text then
|
|
-- return content.text
|
|
-- elseif content[1] and content[1].text then
|
|
-- return content[1].text
|
|
-- end
|
|
-- return vim.inspect(content) -- fallback
|
|
-- end
|
|
-- return ""
|
|
-- end
|
|
--
|
|
-- if log_file and code_opts.messages then
|
|
-- log_file:write "\n=== NEW REQUEST ===\n"
|
|
-- log_file:write(string.format("Total messages: %d\n", #code_opts.messages))
|
|
--
|
|
-- -- Check for duplicates
|
|
-- if #code_opts.messages >= 2 then
|
|
-- local last = code_opts.messages[#code_opts.messages]
|
|
-- local prev = code_opts.messages[#code_opts.messages - 1]
|
|
--
|
|
-- local last_text = get_content_text(last.content)
|
|
-- local prev_text = get_content_text(prev.content)
|
|
--
|
|
-- log_file:write(string.format("\nLast text: %s\n", last_text))
|
|
-- log_file:write(string.format("Prev text: %s\n", prev_text))
|
|
--
|
|
-- if last_text == prev_text and last_text ~= "" then
|
|
-- log_file:write "\n!!! DUPLICATE DETECTED !!!\n"
|
|
-- log_file:close()
|
|
-- vim.notify("Duplicate message detected! Aborting.", vim.log.levels.ERROR)
|
|
-- return nil
|
|
-- end
|
|
-- end
|
|
--
|
|
-- log_file:close()
|
|
-- end
|
|
--
|
|
-- local openai = require("avante.providers").openai
|
|
-- return openai.parse_curl_args(opts, code_opts)
|
|
-- end,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|