From 8344d3ee3d8daf93c924d1592bedb71d934b0d5d Mon Sep 17 00:00:00 2001 From: yetone Date: Sat, 8 Mar 2025 12:51:49 +0800 Subject: [PATCH] feat: support customizing system_prompt in the configuration (#1527) --- lua/avante/config.lua | 1 + lua/avante/llm.lua | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lua/avante/config.lua b/lua/avante/config.lua index 08b2f69..967fb4d 100644 --- a/lua/avante/config.lua +++ b/lua/avante/config.lua @@ -34,6 +34,7 @@ M._defaults = { -- For most providers that we support we will determine this automatically. -- If you wish to use a given implementation, then you can override it here. tokenizer = "tiktoken", + system_prompt = nil, rag_service = { enabled = false, -- Enables the rag service, requires OPENAI_API_KEY to be set host_mount = os.getenv("HOME"), -- Host mount path for the rag service (docker will mount this path) diff --git a/lua/avante/llm.lua b/lua/avante/llm.lua index ff6636e..a7ad083 100644 --- a/lua/avante/llm.lua +++ b/lua/avante/llm.lua @@ -128,6 +128,10 @@ function M.generate_prompts(opts) local system_prompt = Path.prompts.render_mode(mode, template_opts) + if Config.system_prompt ~= nil and Config.system_prompt ~= "" and Config.system_prompt ~= "null" then + system_prompt = system_prompt .. "\n\n" .. Config.system_prompt + end + ---@type AvanteLLMMessage[] local messages = {}