From b309ef2c0e226c9bfc723ebe108fe4ad67c51ef4 Mon Sep 17 00:00:00 2001 From: Samuele Lorefice Date: Thu, 23 Jan 2025 16:11:18 +0100 Subject: [PATCH] More modifications --- TelegramBot/OpenAIAgent.cs | 7 +++++-- TelegramBot/Program.cs | 2 +- lmstudio.env | 0 3 files changed, 6 insertions(+), 3 deletions(-) delete mode 100644 lmstudio.env diff --git a/TelegramBot/OpenAIAgent.cs b/TelegramBot/OpenAIAgent.cs index 50d9664..4493d67 100644 --- a/TelegramBot/OpenAIAgent.cs +++ b/TelegramBot/OpenAIAgent.cs @@ -60,9 +60,11 @@ public class OpenAiAgent { break; case Actor.Krolik: chat.Add((new AssistantChatMessage(message), tokenLenght)); + GetChatHistory(chatId, Actor.Nemesis).Add((new UserChatMessage(message), tokenLenght)); break; case Actor.Nemesis: chat.Add((new AssistantChatMessage(message), tokenLenght)); + GetChatHistory(chatId, Actor.Krolik).Add((new UserChatMessage(message), tokenLenght)); break; case Actor.System: chat.Add((new SystemChatMessage(message), tokenLenght)); @@ -97,12 +99,13 @@ public class OpenAiAgent { } //Reverse the chat history to get the correct order chatHistory.Reverse(1, chatHistory.Count - 1); + //chatHistory.Add(new AssistantChatMessage($"{agent.Name}:")); var completion = chatClient.CompleteChat(chatHistory).Value.Content[0].Text; //Add the response to the chat history - ChatHistoryAppend(agent.Actor, chatId, completion); - + ChatHistoryAppend(agent.Actor, chatId, $"{agent.Name}: {completion}"); + //ChatHistoryAppend(agent.Actor, chatId, $"{completion}"); return completion; } diff --git a/TelegramBot/Program.cs b/TelegramBot/Program.cs index 43640f5..22f2319 100644 --- a/TelegramBot/Program.cs +++ b/TelegramBot/Program.cs @@ -117,7 +117,7 @@ async Task OnMessage(Message msg, Agent agent) { Message: {msg.Text} """); //Add the message to the chat history - oaiAgent.ChatHistoryAppend(Actor.User, chatid, text); + oaiAgent.ChatHistoryAppend(agent.Actor, chatid, text); //Check if the message contains the bot's username or a reply to a message sent by the bot or a private chat diff --git a/lmstudio.env b/lmstudio.env deleted file mode 100644 index e69de29..0000000