2024-02-15 20:43:36 +00:00
|
|
|
using BotSharp.Abstraction.Loggers.Models;
|
2024-01-12 22:20:22 +00:00
|
|
|
using BotSharp.Abstraction.Plugins.Models;
|
2023-11-27 22:20:49 +00:00
|
|
|
using BotSharp.Abstraction.Repositories.Filters;
|
2023-12-20 20:12:40 +00:00
|
|
|
using BotSharp.Abstraction.Repositories.Models;
|
2024-02-04 05:42:13 +00:00
|
|
|
using BotSharp.Abstraction.Tasks.Models;
|
2023-09-07 22:04:34 +00:00
|
|
|
using BotSharp.Abstraction.Users.Models;
|
2023-08-26 04:41:01 +00:00
|
|
|
|
|
|
|
|
namespace BotSharp.Abstraction.Repositories;
|
2023-08-10 04:53:22 +00:00
|
|
|
|
|
|
|
|
public interface IBotSharpRepository
|
|
|
|
|
{
|
|
|
|
|
int Transaction<TTableInterface>(Action action);
|
|
|
|
|
void Add<TTableInterface>(object entity);
|
2023-09-02 05:10:46 +00:00
|
|
|
|
2024-01-12 22:20:22 +00:00
|
|
|
#region Plugin
|
|
|
|
|
PluginConfig GetPluginConfig();
|
|
|
|
|
void SavePluginConfig(PluginConfig config);
|
|
|
|
|
#endregion
|
|
|
|
|
|
2023-09-15 20:19:44 +00:00
|
|
|
#region User
|
2023-10-17 20:29:40 +00:00
|
|
|
User? GetUserByEmail(string email);
|
2023-11-14 01:25:25 +00:00
|
|
|
User? GetUserById(string id);
|
2024-01-31 19:57:54 +00:00
|
|
|
User? GetUserByUserName(string userName);
|
2023-09-07 22:04:34 +00:00
|
|
|
void CreateUser(User user);
|
2023-09-15 20:19:44 +00:00
|
|
|
#endregion
|
2023-09-03 04:54:22 +00:00
|
|
|
|
2023-09-15 20:19:44 +00:00
|
|
|
#region Agent
|
|
|
|
|
void UpdateAgent(Agent agent, AgentField field);
|
2023-10-16 21:37:01 +00:00
|
|
|
Agent? GetAgent(string agentId);
|
2023-11-27 22:20:49 +00:00
|
|
|
List<Agent> GetAgents(AgentFilter filter);
|
2023-10-19 22:27:51 +00:00
|
|
|
List<Agent> GetAgentsByUser(string userId);
|
2023-10-17 20:29:40 +00:00
|
|
|
void BulkInsertAgents(List<Agent> agents);
|
|
|
|
|
void BulkInsertUserAgents(List<UserAgent> userAgents);
|
|
|
|
|
bool DeleteAgents();
|
2023-09-09 20:13:19 +00:00
|
|
|
List<string> GetAgentResponses(string agentId, string prefix, string intent);
|
2023-09-15 20:19:44 +00:00
|
|
|
string GetAgentTemplate(string agentId, string templateName);
|
|
|
|
|
#endregion
|
2023-09-03 22:43:50 +00:00
|
|
|
|
2024-02-04 05:42:13 +00:00
|
|
|
#region Agent Task
|
|
|
|
|
PagedItems<AgentTask> GetAgentTasks(AgentTaskFilter filter);
|
|
|
|
|
AgentTask? GetAgentTask(string agentId, string taskId);
|
|
|
|
|
void InsertAgentTask(AgentTask task);
|
2024-02-05 20:53:18 +00:00
|
|
|
void BulkInsertAgentTasks(List<AgentTask> tasks);
|
2024-02-04 20:01:56 +00:00
|
|
|
void UpdateAgentTask(AgentTask task, AgentTaskField field);
|
2024-02-04 05:42:13 +00:00
|
|
|
bool DeleteAgentTask(string agentId, string taskId);
|
2024-02-05 20:53:18 +00:00
|
|
|
bool DeleteAgentTasks();
|
2024-02-04 05:42:13 +00:00
|
|
|
#endregion
|
|
|
|
|
|
2023-09-15 20:19:44 +00:00
|
|
|
#region Conversation
|
2023-09-07 22:04:34 +00:00
|
|
|
void CreateNewConversation(Conversation conversation);
|
2023-11-26 06:29:06 +00:00
|
|
|
bool DeleteConversation(string conversationId);
|
2023-11-22 00:16:45 +00:00
|
|
|
List<DialogElement> GetConversationDialogs(string conversationId);
|
2023-12-20 20:12:40 +00:00
|
|
|
void UpdateConversationDialogElements(string conversationId, List<DialogContentUpdateModel> updateElements);
|
2023-11-22 00:16:45 +00:00
|
|
|
void AppendConversationDialogs(string conversationId, List<DialogElement> dialogs);
|
2024-01-02 17:50:07 +00:00
|
|
|
ConversationState GetConversationStates(string conversationId);
|
2024-01-02 17:40:08 +00:00
|
|
|
void UpdateConversationStates(string conversationId, List<StateKeyValue> states);
|
2023-11-15 18:35:24 +00:00
|
|
|
void UpdateConversationStatus(string conversationId, string status);
|
2023-09-07 22:04:34 +00:00
|
|
|
Conversation GetConversation(string conversationId);
|
2024-01-18 05:23:20 +00:00
|
|
|
PagedItems<Conversation> GetConversations(ConversationFilter filter);
|
2023-11-22 05:07:19 +00:00
|
|
|
void UpdateConversationTitle(string conversationId, string title);
|
2023-11-10 16:01:03 +00:00
|
|
|
List<Conversation> GetLastConversations();
|
2024-01-29 01:33:40 +00:00
|
|
|
bool TruncateConversation(string conversationId, string messageId);
|
2023-11-29 23:23:14 +00:00
|
|
|
#endregion
|
2024-02-04 05:42:13 +00:00
|
|
|
|
2023-11-29 23:23:14 +00:00
|
|
|
#region Execution Log
|
2023-11-29 16:21:03 +00:00
|
|
|
void AddExecutionLogs(string conversationId, List<string> logs);
|
|
|
|
|
List<string> GetExecutionLogs(string conversationId);
|
2023-09-15 20:19:44 +00:00
|
|
|
#endregion
|
2023-11-27 23:49:24 +00:00
|
|
|
|
|
|
|
|
#region LLM Completion Log
|
|
|
|
|
void SaveLlmCompletionLog(LlmCompletionLog log);
|
|
|
|
|
#endregion
|
2024-02-04 05:42:13 +00:00
|
|
|
|
2024-02-15 20:43:36 +00:00
|
|
|
#region Conversation Content Log
|
|
|
|
|
void SaveConversationContentLog(ConversationContentLogModel log);
|
|
|
|
|
List<ConversationContentLogModel> GetConversationContentLogs(string conversationId);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Conversation State Log
|
|
|
|
|
void SaveConversationStateLog(ConversationStateLogModel log);
|
|
|
|
|
List<ConversationStateLogModel> GetConversationStateLogs(string conversationId);
|
|
|
|
|
#endregion
|
|
|
|
|
|
2024-02-04 05:42:13 +00:00
|
|
|
#region Statistics
|
|
|
|
|
void IncrementConversationCount();
|
|
|
|
|
#endregion
|
2023-08-10 04:53:22 +00:00
|
|
|
}
|