More modifications

This commit is contained in:
Samuele Lorefice
2025-01-23 16:11:18 +01:00
parent ac63019fe6
commit b309ef2c0e
3 changed files with 6 additions and 3 deletions

View File

@@ -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;
}