Skip to content

Commit

Permalink
adds custom name for the AI
Browse files Browse the repository at this point in the history
  • Loading branch information
Madpeterz committed Jan 28, 2025
1 parent 4148d6d commit 68a71f5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 6 additions & 0 deletions SecondBotEvents/Config/ChatGptConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ protected override void MakeSettings()
settings.Add("ChatHistoryTimeout");
settings.Add("ShowDebug");
settings.Add("Provider");
settings.Add("CustomName");
}

public string GetCustomName()
{
return ReadSettingAsString("CustomName", "<!FIRSTNAME!>");
}

public bool GetShowDebug()
Expand Down
11 changes: 8 additions & 3 deletions SecondBotEvents/Services/ChatGptService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,19 +288,24 @@ protected async void GetAiReply(int ratelimiter, UUID replyTo, UUID user, string
}
// trim history
List<KeyValuePair<string, string>> history = chatHistoryAI[user];
string yourname = GetClient().Self.FirstName;
if(myConfig.GetCustomName() != "<!FIRSTNAME!>")
{
yourname = myConfig.GetCustomName();
}
if (history.Count() == 0)
{
if (avatarchat == true)
{
history.Add(new KeyValuePair<string, string>("system", "You are " + GetClient().Self.FirstName + ", "+myConfig.GetChatPrompt()+", you are talking to " + name + "."));
history.Add(new KeyValuePair<string, string>("system", "You are " + yourname + ", "+myConfig.GetChatPrompt()+", you are talking to " + name + "."));
}
else if (groupchat == true)
{
history.Add(new KeyValuePair<string, string>("system", "You are " + GetClient().Self.FirstName + ", "+myConfig.GetChatPrompt()+", you are talking to a group of people."));
history.Add(new KeyValuePair<string, string>("system", "You are " + yourname + ", "+myConfig.GetChatPrompt()+", you are talking to a group of people."));
}
else
{
history.Add(new KeyValuePair<string, string>("system", "You are " + GetClient().Self.FirstName + ", "+myConfig.GetChatPrompt()+", you are talking to people in a public place."));
history.Add(new KeyValuePair<string, string>("system", "You are " + yourname + ", "+myConfig.GetChatPrompt()+", you are talking to people in a public place."));
}
}
history.Add(new KeyValuePair<string, string>("user", "" + name + " says " + message));
Expand Down

0 comments on commit 68a71f5

Please sign in to comment.