From 68a71f5e0da24bb795bd3fac5e5704469526cc2d Mon Sep 17 00:00:00 2001 From: Madpeter <57852827+Madpeterz@users.noreply.github.com> Date: Tue, 28 Jan 2025 22:55:28 +0000 Subject: [PATCH] adds custom name for the AI --- SecondBotEvents/Config/ChatGptConfig.cs | 6 ++++++ SecondBotEvents/Services/ChatGptService.cs | 11 ++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/SecondBotEvents/Config/ChatGptConfig.cs b/SecondBotEvents/Config/ChatGptConfig.cs index 2e83a80..b0c8e0b 100644 --- a/SecondBotEvents/Config/ChatGptConfig.cs +++ b/SecondBotEvents/Config/ChatGptConfig.cs @@ -27,6 +27,12 @@ namespace SecondBotEvents.Config settings.Add("ChatHistoryTimeout"); settings.Add("ShowDebug"); settings.Add("Provider"); + settings.Add("CustomName"); + } + + public string GetCustomName() + { + return ReadSettingAsString("CustomName", ""); } public bool GetShowDebug() diff --git a/SecondBotEvents/Services/ChatGptService.cs b/SecondBotEvents/Services/ChatGptService.cs index a19e42e..d47c2cc 100644 --- a/SecondBotEvents/Services/ChatGptService.cs +++ b/SecondBotEvents/Services/ChatGptService.cs @@ -288,19 +288,24 @@ namespace SecondBotEvents.Services } // trim history List> history = chatHistoryAI[user]; + string yourname = GetClient().Self.FirstName; + if(myConfig.GetCustomName() != "") + { + yourname = myConfig.GetCustomName(); + } if (history.Count() == 0) { if (avatarchat == true) { - history.Add(new KeyValuePair("system", "You are " + GetClient().Self.FirstName + ", "+myConfig.GetChatPrompt()+", you are talking to " + name + ".")); + history.Add(new KeyValuePair("system", "You are " + yourname + ", "+myConfig.GetChatPrompt()+", you are talking to " + name + ".")); } else if (groupchat == true) { - history.Add(new KeyValuePair("system", "You are " + GetClient().Self.FirstName + ", "+myConfig.GetChatPrompt()+", you are talking to a group of people.")); + history.Add(new KeyValuePair("system", "You are " + yourname + ", "+myConfig.GetChatPrompt()+", you are talking to a group of people.")); } else { - history.Add(new KeyValuePair("system", "You are " + GetClient().Self.FirstName + ", "+myConfig.GetChatPrompt()+", you are talking to people in a public place.")); + history.Add(new KeyValuePair("system", "You are " + yourname + ", "+myConfig.GetChatPrompt()+", you are talking to people in a public place.")); } } history.Add(new KeyValuePair("user", "" + name + " says " + message));