feat: enable diagnostics (#891)

This commit is contained in:
yetone
2024-11-23 21:49:33 +08:00
committed by GitHub
parent d14b2290d1
commit 9042f5f202
7 changed files with 102 additions and 20 deletions

View File

@@ -18,6 +18,8 @@ M.CANCEL_PATTERN = "AvanteLLMEscape"
local group = api.nvim_create_augroup("avante_llm", { clear = true })
---@param opts StreamOptions
---@param Provider AvanteProviderFunctor
M._stream = function(opts, Provider)
-- print opts
local mode = opts.mode or "planning"
@@ -52,6 +54,7 @@ M._stream = function(opts, Provider)
file_content = opts.file_content,
selected_code = opts.selected_code,
project_context = opts.project_context,
diagnostics = opts.diagnostics,
}
local system_prompt = Path.prompts.render_mode(mode, template_opts)
@@ -64,6 +67,11 @@ M._stream = function(opts, Provider)
if project_context ~= "" then table.insert(messages, { role = "user", content = project_context }) end
end
if opts.diagnostics ~= nil and opts.diagnostics ~= "" and opts.diagnostics ~= "null" then
local diagnostics = Path.prompts.render_file("_diagnostics.avanterules", template_opts)
if diagnostics ~= "" then table.insert(messages, { role = "user", content = diagnostics }) end
end
local code_context = Path.prompts.render_file("_context.avanterules", template_opts)
if code_context ~= "" then table.insert(messages, { role = "user", content = code_context }) end
@@ -334,6 +342,7 @@ end
---@field file_content string
---@field selected_code string | nil
---@field project_context string | nil
---@field diagnostics string | nil
---@field history_messages AvanteLLMMessage[]
---
---@class StreamOptions: TemplateOptions