using BotSharp.Abstraction.Repositories.Filters; namespace BotSharp.Abstraction.Conversations; public interface IConversationService { IConversationStateService States { get; } string ConversationId { get; } Task NewConversation(Conversation conversation); void SetConversationId(string conversationId, List states, bool isReadOnly = false); Task GetConversation(string id, bool isLoadStates = false); Task> GetConversations(ConversationFilter filter); Task UpdateConversationTitle(string id, string title); Task UpdateConversationTitleAlias(string id, string titleAlias); Task UpdateConversationTags(string conversationId, List toAddTags, List toDeleteTags); Task UpdateConversationMessage(string conversationId, UpdateMessageRequest request); Task> GetLastConversations(); Task> GetIdleConversations(int batchSize, int messageLimit, int bufferHours, IEnumerable excludeAgentIds); Task DeleteConversations(IEnumerable ids); /// /// Truncate conversation /// /// Target conversation id /// Target message id to delete /// If not null, delete messages while input a new message; otherwise delete messages only /// Task TruncateConversation(string conversationId, string messageId, string? newMessageId = null); /// /// Send message to LLM /// /// /// /// /// Received the response from AI Agent /// Task SendMessage(string agentId, RoleDialogModel message, PostbackMessageModel? replyMessage, Func onResponseReceived); Task StreamMessage(string agentId, RoleDialogModel lastDialog, PostbackMessageModel? replyMessage); List GetDialogHistory(int lastCount = 100, bool fromBreakpoint = true, IEnumerable? includeMessageTypes = null); Task CleanHistory(string agentId); /// /// Use this feature when you want to hide some context from LLM. /// /// Whether to reset all states /// Append user init words /// /// Task UpdateBreakpoint(bool resetStates = false, string? reason = null, params string[] excludedStates); Task GetConversationSummary(ConversationSummaryModel model); Task GetConversationRecordOrCreateNew(string agentId); bool IsConversationMode(); void SaveStates(); Task> GetConversationStateSearhKeys(ConversationStateKeysFilter filter); Task MigrateLatestStates(int batchSize = 100, int errorLimit = 10); }