From 990f56bef7045c0640b4557cfe6252b01b89cfc1 Mon Sep 17 00:00:00 2001 From: thiswillbeyourgithub <26625900+thiswillbeyourgithub@users.noreply.github.com> Date: Tue, 23 Apr 2024 13:51:43 +0200 Subject: [PATCH] feat: add config option to specify the default system prompt for chats --- lua/chatgpt/config.lua | 1 + lua/chatgpt/flows/chat/base.lua | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/chatgpt/config.lua b/lua/chatgpt/config.lua index 681a21cc..2f691ebe 100644 --- a/lua/chatgpt/config.lua +++ b/lua/chatgpt/config.lua @@ -25,6 +25,7 @@ function M.defaults() }, }, chat = { + default_system_prompt = nil, welcome_message = WELCOME_MESSAGE, loading_text = "Loading, please wait ...", question_sign = "", -- 🙂 diff --git a/lua/chatgpt/flows/chat/base.lua b/lua/chatgpt/flows/chat/base.lua index f37e1386..b17c9e48 100644 --- a/lua/chatgpt/flows/chat/base.lua +++ b/lua/chatgpt/flows/chat/base.lua @@ -69,7 +69,7 @@ function Chat:welcome() self.selectedIndex = 0 self:set_lines(0, -1, false, {}) self:set_cursor({ 1, 0 }) - self:set_system_message(nil, true) + self:set_system_message(Config.options.chat.default_system_prompt, true) if #self.session.conversation > 0 then for idx, item in ipairs(self.session.conversation) do @@ -134,8 +134,9 @@ function Chat:new_session() self.session = Session:new() self.session:save() - self.system_message = nil - self.system_role_panel:set_text({}) + self.system_message = Config.options.chat.default_system_prompt + self:set_system_message(self.system_message, true) + self.session:save() self:welcome() end