More modifications
This commit is contained in:
@@ -60,9 +60,11 @@ public class OpenAiAgent {
|
|||||||
break;
|
break;
|
||||||
case Actor.Krolik:
|
case Actor.Krolik:
|
||||||
chat.Add((new AssistantChatMessage(message), tokenLenght));
|
chat.Add((new AssistantChatMessage(message), tokenLenght));
|
||||||
|
GetChatHistory(chatId, Actor.Nemesis).Add((new UserChatMessage(message), tokenLenght));
|
||||||
break;
|
break;
|
||||||
case Actor.Nemesis:
|
case Actor.Nemesis:
|
||||||
chat.Add((new AssistantChatMessage(message), tokenLenght));
|
chat.Add((new AssistantChatMessage(message), tokenLenght));
|
||||||
|
GetChatHistory(chatId, Actor.Krolik).Add((new UserChatMessage(message), tokenLenght));
|
||||||
break;
|
break;
|
||||||
case Actor.System:
|
case Actor.System:
|
||||||
chat.Add((new SystemChatMessage(message), tokenLenght));
|
chat.Add((new SystemChatMessage(message), tokenLenght));
|
||||||
@@ -97,12 +99,13 @@ public class OpenAiAgent {
|
|||||||
}
|
}
|
||||||
//Reverse the chat history to get the correct order
|
//Reverse the chat history to get the correct order
|
||||||
chatHistory.Reverse(1, chatHistory.Count - 1);
|
chatHistory.Reverse(1, chatHistory.Count - 1);
|
||||||
|
//chatHistory.Add(new AssistantChatMessage($"{agent.Name}:"));
|
||||||
|
|
||||||
var completion = chatClient.CompleteChat(chatHistory).Value.Content[0].Text;
|
var completion = chatClient.CompleteChat(chatHistory).Value.Content[0].Text;
|
||||||
|
|
||||||
//Add the response to the chat history
|
//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;
|
return completion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ async Task OnMessage(Message msg, Agent agent) {
|
|||||||
Message: {msg.Text}
|
Message: {msg.Text}
|
||||||
""");
|
""");
|
||||||
//Add the message to the chat history
|
//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
|
//Check if the message contains the bot's username or a reply to a message sent by the bot or a private chat
|
||||||
|
|||||||
Reference in New Issue
Block a user