Remove IConversationSideCar dependency

This commit is contained in:
Haiping Chen 2025-02-20 09:33:47 -06:00
parent cd0fa0e222
commit 6bd2af4151

View file

@ -27,7 +27,6 @@ public class ConversationStateService : IConversationStateService, IDisposable
private readonly ILogger _logger;
private readonly IServiceProvider _services;
private readonly IBotSharpRepository _db;
private readonly IConversationSideCar _sidecar;
private string _conversationId;
/// <summary>
/// States in the current round of conversation
@ -41,12 +40,10 @@ public class ConversationStateService : IConversationStateService, IDisposable
public ConversationStateService(
IServiceProvider services,
IBotSharpRepository db,
IConversationSideCar sidecar,
ILogger<ConversationStateService> logger)
{
_services = services;
_db = db;
_sidecar = sidecar;
_logger = logger;
_curStates = new ConversationState();
_historyStates = new ConversationState();
@ -142,8 +139,9 @@ public class ConversationStateService : IConversationStateService, IDisposable
_conversationId = !isReadOnly ? conversationId : null;
Reset();
var sidecar = _services.GetService<IConversationSideCar>();
var endNodes = new Dictionary<string, string>();
if (_sidecar?.IsEnabled() == true)
if (sidecar?.IsEnabled() == true)
{
return endNodes;
}
@ -219,7 +217,8 @@ public class ConversationStateService : IConversationStateService, IDisposable
public void Save()
{
if (_conversationId == null || _sidecar?.IsEnabled() == true)
var sidecar = _services.GetService<IConversationSideCar>();
if (_conversationId == null || sidecar?.IsEnabled() == true)
{
Reset();
return;