feat: system_prompt can be a function (#1571)

This commit is contained in:
yetone
2025-03-12 19:57:17 +08:00
committed by GitHub
parent f9f92dc9d4
commit 8b37cfc306
2 changed files with 7 additions and 3 deletions

View File

@@ -128,8 +128,12 @@ 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
if Config.system_prompt ~= nil then
local custom_system_prompt = Config.system_prompt
if type(custom_system_prompt) == "function" then custom_system_prompt = custom_system_prompt() end
if custom_system_prompt ~= nil and custom_system_prompt ~= "" and custom_system_prompt ~= "null" then
system_prompt = system_prompt .. "\n\n" .. custom_system_prompt
end
end
---@type AvanteLLMMessage[]