Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features/add agent task mongo #287

Merged
merged 5 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,12 @@ public enum AgentField
Sample,
LlmConfig
}

public enum AgentTaskField
{
All = 1,
Name,
Description,
Enabled,
Content
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ public class AgentTaskFilter
{
public Pagination Pager { get; set; } = new Pagination();
public string? AgentId { get; set; }
public bool? Enabled { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using BotSharp.Abstraction.Plugins.Models;
using BotSharp.Abstraction.Repositories.Filters;
using BotSharp.Abstraction.Repositories.Models;
using BotSharp.Abstraction.Tasks.Models;
using BotSharp.Abstraction.Users.Models;

namespace BotSharp.Abstraction.Repositories;
Expand Down Expand Up @@ -34,6 +35,14 @@ public interface IBotSharpRepository
string GetAgentTemplate(string agentId, string templateName);
#endregion

#region Agent Task
PagedItems<AgentTask> GetAgentTasks(AgentTaskFilter filter);
AgentTask? GetAgentTask(string agentId, string taskId);
void InsertAgentTask(AgentTask task);
void UpdateAgentTask(AgentTask task, AgentTaskField field);
bool DeleteAgentTask(string agentId, string taskId);
#endregion

#region Conversation
void CreateNewConversation(Conversation conversation);
bool DeleteConversation(string conversationId);
Expand All @@ -49,9 +58,7 @@ public interface IBotSharpRepository
List<Conversation> GetLastConversations();
bool TruncateConversation(string conversationId, string messageId);
#endregion
#region Statistics
void IncrementConversationCount();
#endregion

#region Execution Log
void AddExecutionLogs(string conversationId, List<string> logs);
List<string> GetExecutionLogs(string conversationId);
Expand All @@ -60,4 +67,8 @@ public interface IBotSharpRepository
#region LLM Completion Log
void SaveLlmCompletionLog(LlmCompletionLog log);
#endregion

#region Statistics
void IncrementConversationCount();
#endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,12 @@ namespace BotSharp.Abstraction.Tasks;
public interface IAgentTaskService
{
Task<PagedItems<AgentTask>> GetTasks(AgentTaskFilter filter);

Task<AgentTask?> GetTask(string agentId, string taskId);

Task CreateTask(AgentTask task);

Task UpdateTask(AgentTask task, AgentTaskField field);

Task<bool> DeleteTask(string agentId, string taskId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ public class AgentTask
public DateTime CreatedDateTime { get; set; }
public DateTime UpdatedDateTime { get; set; }

[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
public string AgentId { get; set; }

[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
public Agent Agent { get; set; }

public AgentTask()
{

}

public AgentTask(string id, string name, string? description = null)
{
Id = id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ public class Pagination
public class PagedItems<T>
{
public int Count { get; set; }
public IEnumerable<T> Items { get; set; }
public IEnumerable<T> Items { get; set; } = new List<T>();
}
43 changes: 35 additions & 8 deletions src/Infrastructure/BotSharp.Core/Repository/BotSharpDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using BotSharp.Abstraction.Repositories;
using BotSharp.Abstraction.Repositories.Filters;
using BotSharp.Abstraction.Repositories.Models;
using BotSharp.Abstraction.Tasks.Models;
using BotSharp.Abstraction.Users.Models;
using Microsoft.EntityFrameworkCore.Infrastructure;

Expand Down Expand Up @@ -119,6 +120,32 @@ public bool DeleteAgents()
}
#endregion

#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();
}

public void UpdateAgentTask(AgentTask task, AgentTaskField field)
{
throw new NotImplementedException();
}

public bool DeleteAgentTask(string agentId, string taskId)
{
throw new NotImplementedException();
}
#endregion

#region Conversation
public void CreateNewConversation(Conversation conversation)
Expand Down Expand Up @@ -184,13 +211,7 @@ public bool TruncateConversation(string conversationId, string messageId)
throw new NotImplementedException();
}
#endregion
#region Stats
public void IncrementConversationCount()
{
throw new NotImplementedException();
}
#endregion


#region User
public User? GetUserByEmail(string email)
=> throw new NotImplementedException();
Expand All @@ -205,7 +226,6 @@ public void CreateUser(User user)
=> throw new NotImplementedException();
#endregion


#region Execution Log
public void AddExecutionLogs(string conversationId, List<string> logs)
{
Expand All @@ -224,4 +244,11 @@ public void SaveLlmCompletionLog(LlmCompletionLog log)
throw new NotImplementedException();
}
#endregion

#region Stats
public void IncrementConversationCount()
{
throw new NotImplementedException();
}
#endregion
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using BotSharp.Abstraction.Agents.Models;
using BotSharp.Abstraction.Evaluations.Settings;
using BotSharp.Abstraction.Functions.Models;
using BotSharp.Abstraction.Repositories.Filters;
using BotSharp.Abstraction.Routing.Models;
using BotSharp.Abstraction.Routing.Settings;
using BotSharp.Abstraction.Tasks.Models;
using Microsoft.Extensions.Logging;
using System.IO;

namespace BotSharp.Core.Repository
Expand Down Expand Up @@ -326,12 +326,11 @@ public List<string> GetAgentResponses(string agentId, string prefix, string inte
var functions = FetchFunctions(dir);
var samples = FetchSamples(dir);
var templates = FetchTemplates(dir);
var tasks = FetchTasks(dir);
var responses = FetchResponses(dir);
return record.SetInstruction(instruction)
.SetFunctions(functions)
.SetSamples(samples)
.SetTemplates(templates)
.SetSamples(samples)
.SetResponses(responses);
}

Expand Down Expand Up @@ -406,6 +405,7 @@ public string GetAgentTemplate(string agentId, string templateName)
return string.Empty;
}


public void BulkInsertAgents(List<Agent> agents)
{
}
Expand Down
Loading