refine side car

This commit is contained in:
Jicheng Lu 2025-06-18 15:03:16 -05:00
parent ef95e640ac
commit 796388a8fc
4 changed files with 14 additions and 0 deletions

View file

@ -9,6 +9,7 @@ public interface IConversationSideCar
List<DialogElement> GetConversationDialogs(string conversationId);
void UpdateConversationBreakpoint(string conversationId, ConversationBreakpoint breakpoint);
ConversationBreakpoint? GetConversationBreakpoint(string conversationId);
void UpdateConversationStates(string conversationId, List<StateKeyValue> states);
Task<RoleDialogModel> SendMessage(string agentId, string text,
PostbackMessageModel? postback = null, List<MessageState>? states = null, List<DialogElement>? dialogs = null);
}

View file

@ -86,6 +86,17 @@ public class BotSharpConversationSideCar : IConversationSideCar
return top.LastOrDefault();
}
public void UpdateConversationStates(string conversationId, List<StateKeyValue> states)
{
if (contextStack.IsNullOrEmpty() || _conversationId != conversationId)
{
return;
}
var top = contextStack.Peek();
top.State = new ConversationState(states);
}
public async Task<RoleDialogModel> SendMessage(string agentId, string text,
PostbackMessageModel? postback = null, List<MessageState>? states = null, List<DialogElement>? dialogs = null)
{

View file

@ -307,6 +307,7 @@ public partial class FileRepository
return new ConversationState(states);
}
[SideCar]
public void UpdateConversationStates(string conversationId, List<StateKeyValue> states)
{
if (states.IsNullOrEmpty()) return;

View file

@ -266,6 +266,7 @@ public partial class MongoRepository
return new ConversationState(savedStates);
}
[SideCar]
public void UpdateConversationStates(string conversationId, List<StateKeyValue> states)
{
if (string.IsNullOrEmpty(conversationId) || states == null) return;