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

292 lines
7.7 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;
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-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)
2023-09-03 04:11:53 +00:00
{
throw new NotImplementedException();
}
2023-11-27 22:20:49 +00:00
public List<Agent> GetAgents(AgentFilter filter)
{
throw new NotImplementedException();
}
public List<Agent> GetAgentsByUser(string userId)
{
throw new NotImplementedException();
}
2023-09-15 22:08:59 +00:00
public void UpdateAgent(Agent agent, AgentField field)
2023-09-03 04:11:53 +00:00
{
throw new NotImplementedException();
}
2023-09-15 22:08:59 +00:00
public string GetAgentTemplate(string agentId, string templateName)
2023-09-03 04:11:53 +00:00
{
throw new NotImplementedException();
}
2023-09-15 22:08:59 +00:00
public List<string> GetAgentResponses(string agentId, string prefix, string intent)
2023-09-03 04:11:53 +00:00
{
throw new NotImplementedException();
}
2023-10-17 20:29:40 +00:00
public void BulkInsertAgents(List<Agent> agents)
{
throw new NotImplementedException();
}
public void BulkInsertUserAgents(List<UserAgent> userAgents)
{
throw new NotImplementedException();
}
public bool DeleteAgents()
{
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)
{
throw new NotImplementedException();
}
public AgentTask? GetAgentTask(string agentId, string taskId)
{
throw new NotImplementedException();
}
public void InsertAgentTask(AgentTask task)
{
throw new NotImplementedException();
}
2024-02-05 20:53:18 +00:00
public void BulkInsertAgentTasks(List<AgentTask> tasks)
{
throw new NotImplementedException();
}
2024-02-04 20:01:56 +00:00
public void UpdateAgentTask(AgentTask task, AgentTaskField field)
{
throw new NotImplementedException();
}
2024-02-04 05:42:13 +00:00
public bool DeleteAgentTask(string agentId, string taskId)
{
throw new NotImplementedException();
}
2024-02-05 20:53:18 +00:00
public bool DeleteAgentTasks()
{
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)
2023-09-03 04:54:22 +00:00
{
throw new NotImplementedException();
}
2023-09-03 19:32:12 +00:00
public bool DeleteConversations(IEnumerable<string> conversationIds)
2023-11-26 06:29:06 +00:00
{
throw new NotImplementedException();
}
2023-09-15 22:08:59 +00:00
public Conversation GetConversation(string conversationId)
2023-09-03 19:32:12 +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)
2023-09-07 22:04:34 +00:00
{
throw new NotImplementedException();
}
2023-11-10 16:01:03 +00:00
public List<Conversation> GetLastConversations()
{
throw new NotImplementedException();
}
2024-03-07 17:25:23 +00:00
public List<string> GetIdleConversations(int batchSize, int messageLimit, int bufferHours)
{
throw new NotImplementedException();
}
2023-11-22 00:16:45 +00:00
public List<DialogElement> GetConversationDialogs(string conversationId)
2023-09-07 22:04:34 +00:00
{
throw new NotImplementedException();
}
2023-12-20 20:12:40 +00:00
public void UpdateConversationDialogElements(string conversationId, List<DialogContentUpdateModel> updateElements)
{
throw new NotImplementedException();
}
2024-01-02 17:50:07 +00:00
public ConversationState GetConversationStates(string conversationId)
2023-09-03 22:43:50 +00:00
{
throw new NotImplementedException();
}
2023-11-22 00:16:45 +00:00
public void AppendConversationDialogs(string conversationId, List<DialogElement> dialogs)
2023-09-03 22:43:50 +00:00
{
throw new NotImplementedException();
}
public void UpdateConversationTitle(string conversationId, string title)
{
throw new NotImplementedException();
}
2024-01-02 17:40:08 +00:00
public void UpdateConversationStates(string conversationId, List<StateKeyValue> states)
2023-09-07 22:04:34 +00:00
{
throw 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)
{
throw new NotImplementedException();
}
2024-01-29 01:33:40 +00:00
2024-02-28 23:37:36 +00:00
public bool TruncateConversation(string conversationId, string messageId, bool cleanLog = false)
2024-01-29 01:33:40 +00:00
{
throw new NotImplementedException();
}
2023-11-29 16:21:03 +00:00
#endregion
2024-02-04 05:42:13 +00:00
2023-11-29 16:21:03 +00:00
#region User
2024-01-31 19:57:54 +00:00
public User? GetUserByEmail(string email)
=> throw new NotImplementedException();
2023-10-23 20:33:24 +00:00
2024-01-31 19:57:54 +00:00
public User? GetUserById(string id)
=> throw new NotImplementedException();
2023-09-15 22:08:59 +00:00
2024-01-31 19:57:54 +00:00
public User? GetUserByUserName(string userName)
=> throw new NotImplementedException();
public void CreateUser(User user)
=> throw new NotImplementedException();
2023-11-29 16:21:03 +00:00
#endregion
2023-09-03 22:43:50 +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
}