Files
OnlineShop/AppWithAzureQueueStorage/OnlineShop/OnlineShop.Web/ChatHistoryService.cs
T
2026-02-01 08:47:38 +00:00

31 lines
734 B
C#

using Microsoft.SemanticKernel.ChatCompletion;
namespace OnlineShop.Web;
public class ChatHistoryService : IChatHistoryService
{
private readonly Dictionary<string, ChatHistory> _chatHistories = new();
public void AddUserMessage(string connectionId, string message)
{
if (!_chatHistories.TryGetValue(connectionId, out ChatHistory? value))
{
value = [];
_chatHistories[connectionId] = value;
}
value.AddUserMessage(message);
}
public ChatHistory GetChatHistory(string connectionId)
{
return _chatHistories[connectionId];
}
public void RemoveHistory(string connectionId)
{
_chatHistories.Remove(connectionId);
}
}