diff --git a/docs/agent/intro.md b/docs/agent/intro.md
index 00484fe8..7e750ce3 100644
--- a/docs/agent/intro.md
+++ b/docs/agent/intro.md
@@ -2,7 +2,7 @@
An agent helps you process user sentences (unstructure data) into structure data that you can use to return an appropriate response.
-Agent is a collection that contains prompt words and function Json Schema definitions, few-shot examples and knowledge base data. You can create multiple different Agents to perform specific operations in specific domains. BotSharp has built-in maintenance for Agents, including creating, updating and deleting, importing and exporting. Agents are divided into task agents and routing (non-task) agents. Business domain agents belong to task agents, and routers belong to non-task agents.
+Agent is a collection that contains prompt words and function Json Schema definitions, few-shot examples and knowledge base data. You can create multiple different Agents to perform specific operations in specific domains. BotSharp has built-in maintenance for Agents, including creating, updating and deleting, importing and exporting. Agents are divided into `task agents`, `routing (non-task) agents`, `evaluating agents` and `static agents`. Business domain agents belong to task agents, and routers belong to non-task agents, static agents don't have capabilities to interact with external environment.
## My Agent
After creating the platform account, you can start to enter the steps of creating the Agent.
diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentField.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentField.cs
index 669ebaba..0fdeffe3 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentField.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentField.cs
@@ -7,7 +7,7 @@ public enum AgentField
Description,
IsPublic,
Disabled,
- AllowRouting,
+ Type,
Profiles,
RoutingRule,
Instruction,
diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentType.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentType.cs
new file mode 100644
index 00000000..17689407
--- /dev/null
+++ b/src/Infrastructure/BotSharp.Abstraction/Agents/Enums/AgentType.cs
@@ -0,0 +1,22 @@
+namespace BotSharp.Abstraction.Agents.Enums;
+
+public class AgentType
+{
+ ///
+ /// Routing Agent
+ ///
+ public const string Routing = "routing";
+
+ public const string Evaluating = "evaluating";
+
+ ///
+ /// Routable task agent with capability of interaction with external environment
+ ///
+ public const string Task = "task";
+
+ ///
+ /// Agent that cannot use external tools
+ ///
+ public const string Static = "static";
+}
+
diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs
index cb04e55e..a36ccc26 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Agents/Models/Agent.cs
@@ -9,6 +9,10 @@ public class Agent
public string Id { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
+ ///
+ /// Agent Type
+ ///
+ public string Type { get; set; } = AgentType.Task;
public DateTime CreatedDateTime { get; set; }
public DateTime UpdatedDateTime { get; set; }
@@ -58,9 +62,6 @@ public class Agent
public bool IsPublic { get; set; }
- [JsonIgnore]
- public bool IsRouter { get; set; }
-
[JsonIgnore]
public bool IsHost { get; set; }
@@ -70,11 +71,6 @@ public class Agent
[JsonIgnore]
public bool Installed => Plugin.Enabled;
- ///
- /// Allow to be routed
- ///
- public bool AllowRouting { get; set; }
-
///
/// Default is True, user will enable this by installing appropriate plugin.
///
@@ -108,6 +104,7 @@ public class Agent
Id = agent.Id,
Name = agent.Name,
Description = agent.Description,
+ Type = agent.Type,
Instruction = agent.Instruction,
Functions = agent.Functions,
Responses = agent.Responses,
@@ -115,7 +112,6 @@ public class Agent
Knowledges = agent.Knowledges,
IsPublic = agent.IsPublic,
Disabled = agent.Disabled,
- AllowRouting = agent.AllowRouting,
Profiles = agent.Profiles,
RoutingRules = agent.RoutingRules,
LlmConfig = agent.LlmConfig,
@@ -184,9 +180,9 @@ public class Agent
return this;
}
- public Agent SetAllowRouting(bool allowRouting)
+ public Agent SetAgentType(string type)
{
- AllowRouting = allowRouting;
+ Type = type;
return this;
}
diff --git a/src/Infrastructure/BotSharp.Abstraction/Repositories/Filters/AgentFilter.cs b/src/Infrastructure/BotSharp.Abstraction/Repositories/Filters/AgentFilter.cs
index 860a7dc9..fb2bfed2 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Repositories/Filters/AgentFilter.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Repositories/Filters/AgentFilter.cs
@@ -6,9 +6,7 @@ public class AgentFilter
public string? AgentName { get; set; }
public bool? Disabled { get; set; }
public bool? Installed { get; set; }
- public bool? AllowRouting { get; set; }
+ public string? Type { get; set; }
public bool? IsPublic { get; set; }
- public bool? IsRouter { get; set; }
- public bool? IsEvaluator { get; set; }
public List? AgentIds { get; set; }
}
diff --git a/src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingService.cs b/src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingService.cs
index c9f40fdc..f6a14ecb 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingService.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingService.cs
@@ -5,7 +5,14 @@ namespace BotSharp.Abstraction.Routing;
public interface IRoutingService
{
Agent Router { get; }
+
+ ///
+ /// Get routable agents
+ ///
+ /// router's profile
+ ///
RoutableAgent[] GetRoutableAgents(List profiles);
+
RoutingRule[] GetRulesByName(string name);
RoutingRule[] GetRulesByAgentId(string id);
List GetHandlers();
diff --git a/src/Infrastructure/BotSharp.Abstraction/Routing/Models/RoutingContext.cs b/src/Infrastructure/BotSharp.Abstraction/Routing/Models/RoutingContext.cs
index 9168b23f..085053e9 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Routing/Models/RoutingContext.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Routing/Models/RoutingContext.cs
@@ -1,12 +1,19 @@
+using BotSharp.Abstraction.Agents;
+using BotSharp.Abstraction.Repositories.Filters;
using BotSharp.Abstraction.Routing.Settings;
+using Microsoft.Extensions.DependencyInjection;
namespace BotSharp.Abstraction.Routing.Models;
public class RoutingContext
{
+ private readonly IServiceProvider _services;
private readonly RoutingSettings _setting;
- public RoutingContext(RoutingSettings setting)
+ private string[] _routerAgentIds;
+
+ public RoutingContext(IServiceProvider services, RoutingSettings setting)
{
+ _services = services;
_setting = setting;
}
@@ -22,7 +29,22 @@ public class RoutingContext
/// Agent that can handle user original goal.
///
public string OriginAgentId
- => _stack.Where(x => !_setting.AgentIds.Contains(x)).Last();
+ {
+ get
+ {
+ if (_routerAgentIds == null)
+ {
+ var agentService = _services.GetRequiredService();
+ _routerAgentIds = agentService.GetAgents(new AgentFilter
+ {
+ Type = AgentType.Routing
+ }).Result.Items
+ .Select(x => x.Id).ToArray();
+ }
+
+ return _stack.Where(x => !_routerAgentIds.Contains(x)).Last();
+ }
+ }
public bool IsEmpty => !_stack.Any();
public string GetCurrentAgentId()
diff --git a/src/Infrastructure/BotSharp.Abstraction/Routing/Settings/RoutingSettings.cs b/src/Infrastructure/BotSharp.Abstraction/Routing/Settings/RoutingSettings.cs
index eb7f099a..50cef510 100644
--- a/src/Infrastructure/BotSharp.Abstraction/Routing/Settings/RoutingSettings.cs
+++ b/src/Infrastructure/BotSharp.Abstraction/Routing/Settings/RoutingSettings.cs
@@ -2,10 +2,5 @@ namespace BotSharp.Abstraction.Routing.Settings;
public class RoutingSettings
{
- ///
- /// Router Agent Id
- ///
- public string[] AgentIds { get; set; } = new string[0];
-
public string Planner { get; set; } = string.Empty;
}
diff --git a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.CreateAgent.cs b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.CreateAgent.cs
index 772c21f9..ce74d7c4 100644
--- a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.CreateAgent.cs
+++ b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.CreateAgent.cs
@@ -33,7 +33,7 @@ public partial class AgentService
.SetDescription(foundAgent.Description)
.SetIsPublic(foundAgent.IsPublic)
.SetDisabled(foundAgent.Disabled)
- .SetAllowRouting(foundAgent.AllowRouting)
+ .SetAgentType(foundAgent.Type)
.SetProfiles(foundAgent.Profiles)
.SetRoutingRules(foundAgent.RoutingRules)
.SetInstruction(foundAgent.Instruction)
diff --git a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.GetAgents.cs b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.GetAgents.cs
index 7e7493d1..15be18f9 100644
--- a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.GetAgents.cs
+++ b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.GetAgents.cs
@@ -17,7 +17,6 @@ public partial class AgentService
var routeSetting = _services.GetRequiredService();
foreach (var agent in agents)
{
- agent.IsRouter = routeSetting.AgentIds.Contains(agent.Id);
agent.Plugin = GetPlugin(agent.Id);
}
@@ -58,9 +57,6 @@ public partial class AgentService
profile.LlmConfig.IsInherit = true;
}
- // Set IsRouter
- var routeSetting = _services.GetRequiredService();
- profile.IsRouter = routeSetting.AgentIds.Contains(profile.Id);
profile.Plugin = GetPlugin(profile.Id);
return profile;
diff --git a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs
index 459cace4..4577af6d 100644
--- a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs
+++ b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.UpdateAgent.cs
@@ -19,7 +19,7 @@ public partial class AgentService
record.Description = agent.Description ?? string.Empty;
record.IsPublic = agent.IsPublic;
record.Disabled = agent.Disabled;
- record.AllowRouting = agent.AllowRouting;
+ record.Type = agent.Type;
record.Profiles = agent.Profiles ?? new List();
record.RoutingRules = agent.RoutingRules ?? new List();
record.Instruction = agent.Instruction ?? string.Empty;
@@ -60,7 +60,7 @@ public partial class AgentService
.SetDescription(foundAgent.Description)
.SetIsPublic(foundAgent.IsPublic)
.SetDisabled(foundAgent.Disabled)
- .SetAllowRouting(foundAgent.AllowRouting)
+ .SetAgentType(foundAgent.Type)
.SetProfiles(foundAgent.Profiles)
.SetRoutingRules(foundAgent.RoutingRules)
.SetInstruction(foundAgent.Instruction)
diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs
index eb46d5ec..92b840d7 100644
--- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs
+++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs
@@ -59,7 +59,7 @@ public partial class ConversationService
var routing = _services.GetRequiredService();
var settings = _services.GetRequiredService();
- response = settings.AgentIds.Contains(agentId) ?
+ response = agent.Type == AgentType.Routing ?
await routing.InstructLoop(message) :
await routing.InstructDirect(agent, message);
diff --git a/src/Infrastructure/BotSharp.Core/Planning/NaivePlanner.cs b/src/Infrastructure/BotSharp.Core/Planning/NaivePlanner.cs
index a0d9f190..561471e2 100644
--- a/src/Infrastructure/BotSharp.Core/Planning/NaivePlanner.cs
+++ b/src/Infrastructure/BotSharp.Core/Planning/NaivePlanner.cs
@@ -126,7 +126,7 @@ public class NaivePlanner : IPlaner
var agentService = _services.GetRequiredService();
var agents = agentService.GetAgents(new AgentFilter
{
- AllowRouting = true
+ Type = AgentType.Task
}).Result.Items.ToList();
var malformed = false;
diff --git a/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Agent.cs b/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Agent.cs
index c72711ff..b2476921 100644
--- a/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Agent.cs
+++ b/src/Infrastructure/BotSharp.Core/Repository/FileRepository/FileRepository.Agent.cs
@@ -28,8 +28,8 @@ namespace BotSharp.Core.Repository
case AgentField.Disabled:
UpdateAgentDisabled(agent.Id, agent.Disabled);
break;
- case AgentField.AllowRouting:
- UpdateAgentAllowRouting(agent.Id, agent.AllowRouting);
+ case AgentField.Type:
+ UpdateAgentType(agent.Id, agent.Type);
break;
case AgentField.Profiles:
UpdateAgentProfiles(agent.Id, agent.Profiles);
@@ -112,12 +112,12 @@ namespace BotSharp.Core.Repository
File.WriteAllText(agentFile, json);
}
- private void UpdateAgentAllowRouting(string agentId, bool allowRouting)
+ private void UpdateAgentType(string agentId, string type)
{
var (agent, agentFile) = GetAgentFromFile(agentId);
if (agent == null) return;
- agent.AllowRouting = allowRouting;
+ agent.Type = type;
agent.UpdatedDateTime = DateTime.UtcNow;
var json = JsonSerializer.Serialize(agent, _options);
File.WriteAllText(agentFile, json);
@@ -260,7 +260,7 @@ namespace BotSharp.Core.Repository
agent.Description = inputAgent.Description;
agent.IsPublic = inputAgent.IsPublic;
agent.Disabled = inputAgent.Disabled;
- agent.AllowRouting = inputAgent.AllowRouting;
+ agent.Type = inputAgent.Type;
agent.Profiles = inputAgent.Profiles;
agent.RoutingRules = inputAgent.RoutingRules;
agent.LlmConfig = inputAgent.LlmConfig;
@@ -336,9 +336,9 @@ namespace BotSharp.Core.Repository
query = query.Where(x => x.Disabled == filter.Disabled);
}
- if (filter.AllowRouting.HasValue)
+ if (filter.Type != null)
{
- query = query.Where(x => x.AllowRouting == filter.AllowRouting);
+ query = query.Where(x => x.Type == filter.Type);
}
if (filter.IsPublic.HasValue)
@@ -346,22 +346,6 @@ namespace BotSharp.Core.Repository
query = query.Where(x => x.IsPublic == filter.IsPublic);
}
- if (filter.IsRouter.HasValue)
- {
- var route = _services.GetRequiredService();
- query = filter.IsRouter.Value ?
- query.Where(x => route.AgentIds.Contains(x.Id)) :
- query.Where(x => !route.AgentIds.Contains(x.Id));
- }
-
- if (filter.IsEvaluator.HasValue)
- {
- var evaluate = _services.GetRequiredService();
- query = filter.IsEvaluator.Value ?
- query.Where(x => x.Id == evaluate.AgentId) :
- query.Where(x => x.Id != evaluate.AgentId);
- }
-
if (filter.AgentIds != null)
{
query = query.Where(x => filter.AgentIds.Contains(x.Id));
diff --git a/src/Infrastructure/BotSharp.Core/Routing/Hooks/RoutingAgentHook.cs b/src/Infrastructure/BotSharp.Core/Routing/Hooks/RoutingAgentHook.cs
index 84de68b0..bd11a5aa 100644
--- a/src/Infrastructure/BotSharp.Core/Routing/Hooks/RoutingAgentHook.cs
+++ b/src/Infrastructure/BotSharp.Core/Routing/Hooks/RoutingAgentHook.cs
@@ -17,7 +17,7 @@ public class RoutingAgentHook : AgentHookBase
public override bool OnInstructionLoaded(string template, Dictionary dict)
{
- if (!_routingSetting.AgentIds.Contains(_agent.Id))
+ if (_agent.Type != AgentType.Routing)
{
return base.OnInstructionLoaded(template, dict);
}
diff --git a/src/Infrastructure/BotSharp.Core/Routing/RoutingService.cs b/src/Infrastructure/BotSharp.Core/Routing/RoutingService.cs
index 888a9eb5..d9cd266e 100644
--- a/src/Infrastructure/BotSharp.Core/Routing/RoutingService.cs
+++ b/src/Infrastructure/BotSharp.Core/Routing/RoutingService.cs
@@ -134,7 +134,7 @@ public partial class RoutingService : IRoutingService
var filter = new AgentFilter
{
Disabled = false,
- AllowRouting = true
+ Type = AgentType.Task
};
var agents = db.GetAgents(filter);
var records = agents.SelectMany(x =>
@@ -160,7 +160,7 @@ public partial class RoutingService : IRoutingService
var filter = new AgentFilter
{
Disabled = false,
- AllowRouting = true
+ Type = AgentType.Task
};
var agents = db.GetAgents(filter);
@@ -192,6 +192,12 @@ public partial class RoutingService : IRoutingService
x.Profiles.Exists(x1 => profiles.Exists(y => x1 == y)))
.ToArray();
}
+ else if (profiles == null || profiles.Count == 0)
+ {
+ routableAgents = routableAgents.Where(x => x.Profiles == null ||
+ x.Profiles.Count == 0)
+ .ToArray();
+ }
return routableAgents;
}
diff --git a/src/Infrastructure/BotSharp.Core/data/agents/01e2fc5c-2c89-4ec7-8470-7688608b496c/agent.json b/src/Infrastructure/BotSharp.Core/data/agents/01e2fc5c-2c89-4ec7-8470-7688608b496c/agent.json
index b701d67b..b17531f4 100644
--- a/src/Infrastructure/BotSharp.Core/data/agents/01e2fc5c-2c89-4ec7-8470-7688608b496c/agent.json
+++ b/src/Infrastructure/BotSharp.Core/data/agents/01e2fc5c-2c89-4ec7-8470-7688608b496c/agent.json
@@ -1,10 +1,12 @@
{
+ "id": "01e2fc5c-2c89-4ec7-8470-7688608b496c",
"name": "Chatbot",
"description": "AI chatbot that can do variaty of tasks",
+ "type": "task",
"createdDateTime": "2024-01-15T10:39:32Z",
"updatedDateTime": "2024-01-15T14:39:32Z",
- "id": "01e2fc5c-2c89-4ec7-8470-7688608b496c",
"iconUrl": "/images/users/bot.png",
"disabled": false,
- "isPublic": true
+ "isPublic": true,
+ "profiles": [ "standalone" ]
}
\ No newline at end of file
diff --git a/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/agent.json b/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/agent.json
index a92a4614..c8e4f4bd 100644
--- a/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/agent.json
+++ b/src/Infrastructure/BotSharp.Core/data/agents/01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a/agent.json
@@ -1,9 +1,10 @@
{
+ "id": "01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a",
"name": "AI Assistant",
"description": "AI assistant that can complete many different tasks",
+ "type": "routing",
"createdDateTime": "2023-08-18T10:39:32.2349685Z",
"updatedDateTime": "2023-08-18T14:39:32.2349686Z",
- "id": "01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a",
"iconUrl": "https://cdn.iconscout.com/icon/premium/png-256-thumb/route-1613278-1368497.png",
"disabled": false,
"isPublic": true
diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentCreationModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentCreationModel.cs
index fe6ce7e2..b5f8ea82 100644
--- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentCreationModel.cs
+++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentCreationModel.cs
@@ -8,6 +8,7 @@ public class AgentCreationModel
{
public string Name { get; set; }
public string Description { get; set; }
+ public string Type { get; set; } = AgentType.Task;
///
/// LLM default system instructions
@@ -57,7 +58,7 @@ public class AgentCreationModel
Responses = Responses,
Samples = Samples,
IsPublic = IsPublic,
- AllowRouting = AllowRouting,
+ Type = Type,
Disabled = Disabled,
Profiles = Profiles,
RoutingRules = RoutingRules?
diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentUpdateModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentUpdateModel.cs
index 56b6d968..0a461ea6 100644
--- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentUpdateModel.cs
+++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentUpdateModel.cs
@@ -9,7 +9,7 @@ public class AgentUpdateModel
{
public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
-
+ public string Type { get; set; } = AgentType.Task;
///
/// Instruction
///
@@ -62,7 +62,7 @@ public class AgentUpdateModel
Description = Description ?? string.Empty,
IsPublic = IsPublic,
Disabled = Disabled,
- AllowRouting = AllowRouting,
+ Type = Type,
Profiles = Profiles ?? new List(),
RoutingRules = RoutingRules?
.Select(x => RoutingRuleUpdateModel.ToDomainElement(x))?
diff --git a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentViewModel.cs b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentViewModel.cs
index 6a41a66b..e0d6c375 100644
--- a/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentViewModel.cs
+++ b/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Agents/AgentViewModel.cs
@@ -11,6 +11,7 @@ public class AgentViewModel
public string Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
+ public string Type { get; set; } = AgentType.Task;
public string Instruction { get; set; }
public List Templates { get; set; }
public List Functions { get; set; }
@@ -59,17 +60,16 @@ public class AgentViewModel
Id = agent.Id,
Name = agent.Name,
Description = agent.Description,
+ Type = agent.Type,
Instruction = agent.Instruction,
Templates = agent.Templates,
Functions = agent.Functions,
Responses = agent.Responses,
Samples = agent.Samples,
IsPublic= agent.IsPublic,
- IsRouter = agent.IsRouter,
IsHost = agent.IsHost,
Disabled = agent.Disabled,
IconUrl = agent.IconUrl,
- AllowRouting = agent.AllowRouting,
Profiles = agent.Profiles ?? new List(),
RoutingRules = agent.RoutingRules,
LlmConfig = agent.LlmConfig,
diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs
index b0f1d6e1..603f312e 100644
--- a/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs
+++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Collections/AgentDocument.cs
@@ -6,6 +6,7 @@ public class AgentDocument : MongoBase
{
public string Name { get; set; }
public string Description { get; set; }
+ public string Type { get; set; }
public string? IconUrl { get; set; }
public string Instruction { get; set; }
public List Templates { get; set; }
@@ -13,7 +14,6 @@ public class AgentDocument : MongoBase
public List Responses { get; set; }
public List Samples { get; set; }
public bool IsPublic { get; set; }
- public bool AllowRouting { get; set; }
public bool Disabled { get; set; }
public List Profiles { get; set; }
public List RoutingRules { get; set; }
diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Agent.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Agent.cs
index 36fc9ff9..9a0f0cee 100644
--- a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Agent.cs
+++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Agent.cs
@@ -29,8 +29,8 @@ public partial class MongoRepository
case AgentField.Disabled:
UpdateAgentDisabled(agent.Id, agent.Disabled);
break;
- case AgentField.AllowRouting:
- UpdateAgentAllowRouting(agent.Id, agent.AllowRouting);
+ case AgentField.Type:
+ UpdateAgentType(agent.Id, agent.Type);
break;
case AgentField.Profiles:
UpdateAgentProfiles(agent.Id, agent.Profiles);
@@ -109,11 +109,11 @@ public partial class MongoRepository
_dc.Agents.UpdateOne(filter, update);
}
- private void UpdateAgentAllowRouting(string agentId, bool allowRouting)
+ private void UpdateAgentType(string agentId, string type)
{
var filter = Builders.Filter.Eq(x => x.Id, agentId);
var update = Builders.Update
- .Set(x => x.AllowRouting, allowRouting)
+ .Set(x => x.Type, type)
.Set(x => x.UpdatedTime, DateTime.UtcNow);
_dc.Agents.UpdateOne(filter, update);
@@ -225,7 +225,7 @@ public partial class MongoRepository
.Set(x => x.Name, agent.Name)
.Set(x => x.Description, agent.Description)
.Set(x => x.Disabled, agent.Disabled)
- .Set(x => x.AllowRouting, agent.AllowRouting)
+ .Set(x => x.Type, agent.Type)
.Set(x => x.Profiles, agent.Profiles)
.Set(x => x.RoutingRules, agent.RoutingRules.Select(r => RoutingRuleMongoElement.ToMongoElement(r)).ToList())
.Set(x => x.Instruction, agent.Instruction)
@@ -267,7 +267,7 @@ public partial class MongoRepository
Samples = agent.Samples ?? new List(),
IsPublic = agent.IsPublic,
Disabled = agent.Disabled,
- AllowRouting = agent.AllowRouting,
+ Type = agent.Type,
Profiles = agent.Profiles,
RoutingRules = !agent.RoutingRules.IsNullOrEmpty() ? agent.RoutingRules
.Select(r => RoutingRuleMongoElement.ToDomainElement(agent.Id, agent.Name, r))
@@ -292,9 +292,9 @@ public partial class MongoRepository
filters.Add(builder.Eq(x => x.Disabled, filter.Disabled.Value));
}
- if (filter.AllowRouting.HasValue)
+ if (filter.Type != null)
{
- filters.Add(builder.Eq(x => x.AllowRouting, filter.AllowRouting.Value));
+ filters.Add(builder.Eq(x => x.Type, filter.Type));
}
if (filter.IsPublic.HasValue)
@@ -302,32 +302,6 @@ public partial class MongoRepository
filters.Add(builder.Eq(x => x.IsPublic, filter.IsPublic.Value));
}
- if (filter.IsRouter.HasValue)
- {
- var route = _services.GetRequiredService();
- if (filter.IsRouter.Value)
- {
- filters.Add(builder.In(x => x.Id, route.AgentIds));
- }
- else
- {
- filters.Add(builder.Nin(x => x.Id, route.AgentIds));
- }
- }
-
- if (filter.IsEvaluator.HasValue)
- {
- var evaluate = _services.GetRequiredService();
- if (filter.IsEvaluator.Value)
- {
- filters.Add(builder.Eq(x => x.Id, evaluate.AgentId));
- }
- else
- {
- filters.Add(builder.Ne(x => x.Id, evaluate.AgentId));
- }
- }
-
if (filter.AgentIds != null)
{
filters.Add(builder.In(x => x.Id, filter.AgentIds));
@@ -354,7 +328,7 @@ public partial class MongoRepository
Samples = x.Samples ?? new List(),
IsPublic = x.IsPublic,
Disabled = x.Disabled,
- AllowRouting = x.AllowRouting,
+ Type = x.Type,
Profiles = x.Profiles,
RoutingRules = !x.RoutingRules.IsNullOrEmpty() ? x.RoutingRules
.Select(r => RoutingRuleMongoElement.ToDomainElement(x.Id, x.Name, r))
@@ -418,7 +392,7 @@ public partial class MongoRepository
.ToList() ?? new List(),
Samples = x.Samples ?? new List(),
IsPublic = x.IsPublic,
- AllowRouting = x.AllowRouting,
+ Type = x.Type,
Disabled = x.Disabled,
Profiles = x.Profiles,
RoutingRules = x.RoutingRules?
diff --git a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Transaction.cs b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Transaction.cs
index 16b8080c..17e59c2e 100644
--- a/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Transaction.cs
+++ b/src/Plugins/BotSharp.Plugin.MongoStorage/Repository/MongoRepository.Transaction.cs
@@ -54,7 +54,7 @@ public partial class MongoRepository
.ToList() ?? new List(),
Samples = x.Samples ?? new List(),
IsPublic = x.IsPublic,
- AllowRouting = x.AllowRouting,
+ Type = x.Type,
Disabled = x.Disabled,
Profiles = x.Profiles,
RoutingRules = x.RoutingRules?
@@ -77,7 +77,7 @@ public partial class MongoRepository
.Set(x => x.Responses, agent.Responses)
.Set(x => x.Samples, agent.Samples)
.Set(x => x.IsPublic, agent.IsPublic)
- .Set(x => x.AllowRouting, agent.AllowRouting)
+ .Set(x => x.Type, agent.Type)
.Set(x => x.Disabled, agent.Disabled)
.Set(x => x.Profiles, agent.Profiles)
.Set(x => x.RoutingRules, agent.RoutingRules)
diff --git a/src/Plugins/BotSharp.Plugin.RoutingSpeeder/RoutingConversationHook.cs b/src/Plugins/BotSharp.Plugin.RoutingSpeeder/RoutingConversationHook.cs
index d3ed4bdf..8c6d826e 100644
--- a/src/Plugins/BotSharp.Plugin.RoutingSpeeder/RoutingConversationHook.cs
+++ b/src/Plugins/BotSharp.Plugin.RoutingSpeeder/RoutingConversationHook.cs
@@ -53,7 +53,7 @@ public class RoutingConversationHook: ConversationHookBase
public override async Task OnResponseGenerated(RoleDialogModel message)
{
var routerSettings = _services.GetRequiredService();
- bool saveFlag = !routerSettings.AgentIds.Contains(message.CurrentAgentId);
+ bool saveFlag = _agent.Type != AgentType.Routing;
if (saveFlag)
{
diff --git a/src/WebStarter/appsettings.json b/src/WebStarter/appsettings.json
index 66b92dc0..61ff3a19 100644
--- a/src/WebStarter/appsettings.json
+++ b/src/WebStarter/appsettings.json
@@ -60,9 +60,6 @@
],
"Router": {
- "AgentIds": [
- "01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a"
- ],
"Planner": "NaivePlanner"
},