BotSharp/src/Infrastructure/BotSharp.Abstraction/Conversations/IConversationService.cs

62 lines
2.9 KiB
C#
Raw Normal View History

2024-02-15 20:43:36 +00:00
using BotSharp.Abstraction.Loggers.Models;
2023-12-04 23:42:46 +00:00
using BotSharp.Abstraction.Repositories.Filters;
2023-06-03 02:07:30 +00:00
namespace BotSharp.Abstraction.Conversations;
public interface IConversationService
{
2023-09-06 03:19:36 +00:00
IConversationStateService States { get; }
2023-10-30 16:48:18 +00:00
string ConversationId { get; }
2023-06-27 18:31:13 +00:00
Task<Conversation> NewConversation(Conversation conversation);
2024-10-07 21:35:39 +00:00
void SetConversationId(string conversationId, List<MessageState> states, bool isReadOnly = false);
2023-07-19 22:30:23 +00:00
Task<Conversation> GetConversation(string id);
2023-12-04 23:42:46 +00:00
Task<PagedItems<Conversation>> GetConversations(ConversationFilter filter);
Task<Conversation> UpdateConversationTitle(string id, string title);
2023-11-10 16:01:03 +00:00
Task<List<Conversation>> GetLastConversations();
2024-09-09 17:26:26 +00:00
Task<List<string>> GetIdleConversations(int batchSize, int messageLimit, int bufferHours, IEnumerable<string> excludeAgentIds);
Task<bool> DeleteConversations(IEnumerable<string> ids);
2024-05-06 22:31:52 +00:00
/// <summary>
/// Truncate conversation
/// </summary>
/// <param name="conversationId">Target conversation id</param>
/// <param name="messageId">Target message id to delete</param>
/// <param name="newMessageId">If not null, delete messages while input a new message; otherwise delete messages only</param>
/// <returns></returns>
Task<bool> TruncateConversation(string conversationId, string messageId, string? newMessageId = null);
2024-03-01 02:50:39 +00:00
Task<List<ContentLogOutputModel>> GetConversationContentLogs(string conversationId);
2024-02-15 20:43:36 +00:00
Task<List<ConversationStateLogModel>> GetConversationStateLogs(string conversationId);
2023-08-14 22:14:05 +00:00
/// <summary>
/// Send message to LLM
/// </summary>
/// <param name="agentId"></param>
/// <param name="lastDalog"></param>
2024-02-28 20:40:59 +00:00
/// <param name="onResponseReceived">Received the response from AI Agent</param>
2023-08-14 22:14:05 +00:00
/// <param name="onFunctionExecuting">This delegate is useful when you want to report progress on UI</param>
/// <param name="onFunctionExecuted">This delegate is useful when you want to report progress on UI</param>
2023-08-14 22:14:05 +00:00
/// <returns></returns>
2023-11-27 03:04:48 +00:00
Task<bool> SendMessage(string agentId,
2023-08-14 22:14:05 +00:00
RoleDialogModel lastDalog,
2024-03-16 14:43:00 +00:00
PostbackMessageModel? replyMessage,
Func<RoleDialogModel, Task> onResponseReceived);
2023-08-14 22:14:05 +00:00
2024-10-07 21:35:39 +00:00
List<RoleDialogModel> GetDialogHistory(int lastCount = 100, bool fromBreakpoint = true, IEnumerable<string>? excludeMessageTypes = null);
2023-06-27 18:31:13 +00:00
Task CleanHistory(string agentId);
2024-03-24 01:31:15 +00:00
/// <summary>
/// Use this feature when you want to hide some context from LLM.
/// </summary>
2024-03-24 13:56:21 +00:00
/// <param name="resetStates">Whether to reset all states</param>
2024-04-08 03:15:51 +00:00
/// <param name="reason">Append user init words</param>
2024-05-27 13:17:50 +00:00
/// <param name="excludedStates"></param>
2024-03-24 01:31:15 +00:00
/// <returns></returns>
2024-05-27 13:17:50 +00:00
Task UpdateBreakpoint(bool resetStates = false, string? reason = null, params string[] excludedStates);
2024-05-27 01:40:24 +00:00
2024-05-29 02:50:16 +00:00
Task<string> GetConversationSummary(IEnumerable<string> conversationId);
2024-06-19 23:04:47 +00:00
Task<Conversation> GetConversationRecordOrCreateNew(string agentId);
2024-06-25 03:46:13 +00:00
bool IsConversationMode();
2023-06-03 02:07:30 +00:00
}