mirror of
https://github.com/fiodarsazanavets/aspire-13-examples.git
synced 2026-06-20 12:23:14 +00:00
31 lines
734 B
C#
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);
|
|
}
|
|
}
|
|
|