BotSharp/src/Infrastructure/BotSharp.Core/Repository/BotSharpDbContext.cs

228 lines
7.3 KiB
C#
Raw Normal View History

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;
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-10 04:53:22 +00:00
using Microsoft.EntityFrameworkCore.Infrastructure;
2023-06-11 23:46:02 +00:00
namespace BotSharp.Core.Repository;
2023-08-10 04:53:22 +00:00
public class BotSharpDbContext : Database, IBotSharpRepository
2023-06-11 23:46:02 +00:00
{
2023-09-07 22:04:34 +00:00
public IQueryable<User> Users => throw new NotImplementedException();
2023-08-10 04:53:22 +00:00
2023-09-07 22:04:34 +00:00
public IQueryable<Agent> Agents => throw new NotImplementedException();
2023-09-02 05:10:46 +00:00
2023-09-07 22:04:34 +00:00
public IQueryable<UserAgent> UserAgents => throw new NotImplementedException();
public IQueryable<Conversation> Conversations => throw new NotImplementedException();
2023-08-10 04:53:22 +00:00
public int Transaction<TTableInterface>(Action action)
{
DatabaseFacade database = base.GetMaster(typeof(TTableInterface)).Database;
int num = 0;
if (database.CurrentTransaction == null)
{
using (Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction dbContextTransaction = database.BeginTransaction())
{
try
{
action();
num = base.SaveChanges();
dbContextTransaction.Commit();
return num;
}
catch (Exception ex)
{
dbContextTransaction.Rollback();
if (ex.Message.Contains("See the inner exception for details"))
{
throw ex.InnerException;
}
throw ex;
}
}
}
try
{
action();
return base.SaveChanges();
}
catch (Exception ex2)
{
if (database.CurrentTransaction != null)
{
database.CurrentTransaction.Rollback();
}
if (ex2.Message.Contains("See the inner exception for details"))
{
throw ex2.InnerException;
}
throw ex2;
}
}
2023-09-03 04:11:53 +00:00
2024-01-12 22:20:22 +00:00
#region Plugin
public PluginConfig GetPluginConfig() => throw new NotImplementedException();
public void SavePluginConfig(PluginConfig config) => throw new NotImplementedException();
#endregion
2023-09-07 22:04:34 +00:00
2023-09-15 22:08:59 +00:00
#region Agent
public Agent GetAgent(string agentId)
2024-04-11 07:00:17 +00:00
=> throw new NotImplementedException();
2023-09-03 04:11:53 +00:00
2023-11-27 22:20:49 +00:00
public List<Agent> GetAgents(AgentFilter filter)
2024-04-11 07:00:17 +00:00
=> throw new NotImplementedException();
public List<Agent> GetAgentsByUser(string userId)
2024-04-11 07:00:17 +00:00
=> throw new NotImplementedException();
2023-09-15 22:08:59 +00:00
public void UpdateAgent(Agent agent, AgentField field)
2024-04-11 07:00:17 +00:00
=> throw new NotImplementedException();
2023-09-03 04:11:53 +00:00
2023-09-15 22:08:59 +00:00
public string GetAgentTemplate(string agentId, string templateName)
2024-04-11 07:00:17 +00:00
=> throw new NotImplementedException();
2023-09-03 04:11:53 +00:00
2024-05-09 22:06:03 +00:00
public bool PatchAgentTemplate(string agentId, AgentTemplate template)
=> throw new NotImplementedException();
2023-09-15 22:08:59 +00:00
public List<string> GetAgentResponses(string agentId, string prefix, string intent)
2024-04-11 07:00:17 +00:00
=> throw new NotImplementedException();
2023-10-17 20:29:40 +00:00
public void BulkInsertAgents(List<Agent> agents)
2024-04-11 07:00:17 +00:00
=> throw new NotImplementedException();
2023-10-17 20:29:40 +00:00
public void BulkInsertUserAgents(List<UserAgent> userAgents)
2024-04-11 07:00:17 +00:00
=> throw new NotImplementedException();
2023-10-17 20:29:40 +00:00
public bool DeleteAgents()
2024-04-11 07:00:17 +00:00
=> throw new NotImplementedException();
public bool DeleteAgent(string agentId)
=> throw new NotImplementedException();
2023-09-15 22:08:59 +00:00
#endregion
2023-09-03 04:54:22 +00:00
2024-02-04 05:42:13 +00:00
#region Agent Task
public PagedItems<AgentTask> GetAgentTasks(AgentTaskFilter filter)
2024-04-11 07:00:17 +00:00
=> throw new NotImplementedException();
2024-02-04 05:42:13 +00:00
public AgentTask? GetAgentTask(string agentId, string taskId)
2024-04-11 07:00:17 +00:00
=> throw new NotImplementedException();
2024-02-04 05:42:13 +00:00
public void InsertAgentTask(AgentTask task)
2024-04-11 07:00:17 +00:00
=> throw new NotImplementedException();
2024-02-04 05:42:13 +00:00
2024-02-05 20:53:18 +00:00
public void BulkInsertAgentTasks(List<AgentTask> tasks)
2024-04-11 07:00:17 +00:00
=> throw new NotImplementedException();
2024-02-05 20:53:18 +00:00
2024-02-04 20:01:56 +00:00
public void UpdateAgentTask(AgentTask task, AgentTaskField field)
2024-04-11 07:00:17 +00:00
=> throw new NotImplementedException();
2024-02-04 20:01:56 +00:00
2024-04-11 07:00:17 +00:00
public bool DeleteAgentTask(string agentId, List<string> taskIds)
=> throw new NotImplementedException();
2024-02-05 20:53:18 +00:00
public bool DeleteAgentTasks()
2024-04-11 07:00:17 +00:00
=> throw new NotImplementedException();
2024-02-04 05:42:13 +00:00
#endregion
2023-09-15 22:08:59 +00:00
#region Conversation
public void CreateNewConversation(Conversation conversation)
2024-03-24 01:31:15 +00:00
=> throw new NotImplementedException();
2023-09-03 19:32:12 +00:00
public bool DeleteConversations(IEnumerable<string> conversationIds)
2024-03-24 01:31:15 +00:00
=> throw new NotImplementedException();
2023-11-26 06:29:06 +00:00
2023-09-15 22:08:59 +00:00
public Conversation GetConversation(string conversationId)
2024-03-24 01:31:15 +00:00
=> throw new NotImplementedException();
2023-09-03 22:43:50 +00:00
2024-01-18 05:23:20 +00:00
public PagedItems<Conversation> GetConversations(ConversationFilter filter)
2024-03-24 01:31:15 +00:00
=> throw new NotImplementedException();
2023-09-07 22:04:34 +00:00
2023-11-10 16:01:03 +00:00
public List<Conversation> GetLastConversations()
2024-03-24 01:31:15 +00:00
=> throw new NotImplementedException();
2023-11-10 16:01:03 +00:00
2024-03-07 17:25:23 +00:00
public List<string> GetIdleConversations(int batchSize, int messageLimit, int bufferHours)
2024-03-24 01:31:15 +00:00
=> throw new NotImplementedException();
2023-11-22 00:16:45 +00:00
public List<DialogElement> GetConversationDialogs(string conversationId)
2024-03-24 01:31:15 +00:00
=> throw new NotImplementedException();
2023-09-07 22:04:34 +00:00
2024-01-02 17:50:07 +00:00
public ConversationState GetConversationStates(string conversationId)
2024-03-24 01:31:15 +00:00
=> throw new NotImplementedException();
2023-09-03 22:43:50 +00:00
2023-11-22 00:16:45 +00:00
public void AppendConversationDialogs(string conversationId, List<DialogElement> dialogs)
2024-03-24 01:31:15 +00:00
=> new NotImplementedException();
public void UpdateConversationTitle(string conversationId, string title)
2024-03-24 01:31:15 +00:00
=> new NotImplementedException();
2024-04-08 03:15:51 +00:00
public void UpdateConversationBreakpoint(string conversationId, ConversationBreakpoint breakpoint)
2024-03-24 01:31:15 +00:00
=> new NotImplementedException();
2024-03-26 17:10:34 +00:00
2024-04-08 03:15:51 +00:00
public ConversationBreakpoint? GetConversationBreakpoint(string conversationId)
2024-03-26 17:10:34 +00:00
=> throw new NotImplementedException();
2024-01-02 17:40:08 +00:00
public void UpdateConversationStates(string conversationId, List<StateKeyValue> states)
2024-03-24 01:31:15 +00:00
=> new NotImplementedException();
2023-10-23 20:33:24 +00:00
2023-11-15 18:35:24 +00:00
public void UpdateConversationStatus(string conversationId, string status)
2024-03-24 01:31:15 +00:00
=> new NotImplementedException();
2024-01-29 01:33:40 +00:00
2024-05-06 22:31:52 +00:00
public IEnumerable<string> TruncateConversation(string conversationId, string messageId, bool cleanLog = false)
2024-03-24 01:31:15 +00:00
=> throw new NotImplementedException();
2023-11-29 16:21:03 +00:00
#endregion
2024-03-24 01:31:15 +00:00
2023-11-29 16:21:03 +00:00
#region Execution Log
public void AddExecutionLogs(string conversationId, List<string> logs)
{
throw new NotImplementedException();
}
2023-11-29 16:21:03 +00:00
public List<string> GetExecutionLogs(string conversationId)
2023-09-03 22:43:50 +00:00
{
throw new NotImplementedException();
}
2023-09-15 22:08:59 +00:00
#endregion
2023-11-27 23:49:24 +00:00
#region LLM Completion Log
public void SaveLlmCompletionLog(LlmCompletionLog log)
{
throw new NotImplementedException();
}
#endregion
2024-02-04 05:42:13 +00:00
2024-02-15 20:43:36 +00:00
#region Conversation Content Log
2024-03-01 02:50:39 +00:00
public void SaveConversationContentLog(ContentLogOutputModel log)
2024-02-15 20:43:36 +00:00
{
throw new NotImplementedException();
}
2024-03-01 02:50:39 +00:00
public List<ContentLogOutputModel> GetConversationContentLogs(string conversationId)
2024-02-15 20:43:36 +00:00
{
throw new NotImplementedException();
}
#endregion
#region Conversation State Log
public void SaveConversationStateLog(ConversationStateLogModel log)
{
throw new NotImplementedException();
}
public List<ConversationStateLogModel> GetConversationStateLogs(string conversationId)
{
throw new NotImplementedException();
}
#endregion
2024-02-04 05:42:13 +00:00
#region Stats
public void IncrementConversationCount()
{
throw new NotImplementedException();
}
#endregion
2023-06-11 23:46:02 +00:00
}