Add router name.
This commit is contained in:
parent
25ac948510
commit
8b135e8c32
|
|
@ -2,7 +2,7 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<LangVersion>10.0</LangVersion>
|
<LangVersion>10.0</LangVersion>
|
||||||
<OutputPath>..\..\..\packages</OutputPath>
|
<OutputPath>..\..\..\packages</OutputPath>
|
||||||
<BotSharpVersion>0.14.2</BotSharpVersion>
|
<BotSharpVersion>0.14.3</BotSharpVersion>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -7,6 +7,8 @@ public class RoutingSettings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string RouterId { get; set; } = string.Empty;
|
public string RouterId { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string RouteName { get; set; } = "Router";
|
||||||
|
|
||||||
public bool EnableReasoning { get; set; } = false;
|
public bool EnableReasoning { get; set; } = false;
|
||||||
|
|
||||||
public string Provider { get; set; } = string.Empty;
|
public string Provider { get; set; } = string.Empty;
|
||||||
|
|
|
||||||
|
|
@ -210,6 +210,7 @@ public class RoutingService : IRoutingService
|
||||||
var router = new Agent()
|
var router = new Agent()
|
||||||
{
|
{
|
||||||
Id = _settings.RouterId,
|
Id = _settings.RouterId,
|
||||||
|
Name = _settings.RouteName
|
||||||
};
|
};
|
||||||
var agents = db.Agents.Where(x => !x.Disabled && x.AllowRouting).ToArray();
|
var agents = db.Agents.Where(x => !x.Disabled && x.AllowRouting).ToArray();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
using BotSharp.Abstraction.Agents.Enums;
|
using BotSharp.Abstraction.Agents.Enums;
|
||||||
|
using BotSharp.Abstraction.Agents.Models;
|
||||||
using BotSharp.Abstraction.ApiAdapters;
|
using BotSharp.Abstraction.ApiAdapters;
|
||||||
|
using BotSharp.Abstraction.Routing;
|
||||||
|
using BotSharp.Abstraction.Routing.Settings;
|
||||||
using BotSharp.OpenAPI.ViewModels.Agents;
|
using BotSharp.OpenAPI.ViewModels.Agents;
|
||||||
|
|
||||||
namespace BotSharp.OpenAPI.Controllers;
|
namespace BotSharp.OpenAPI.Controllers;
|
||||||
|
|
@ -9,15 +12,23 @@ namespace BotSharp.OpenAPI.Controllers;
|
||||||
public class AgentController : ControllerBase, IApiAdapter
|
public class AgentController : ControllerBase, IApiAdapter
|
||||||
{
|
{
|
||||||
private readonly IAgentService _agentService;
|
private readonly IAgentService _agentService;
|
||||||
public AgentController(IAgentService agentService)
|
private readonly IServiceProvider _services;
|
||||||
|
|
||||||
|
public AgentController(IAgentService agentService, IServiceProvider services)
|
||||||
{
|
{
|
||||||
_agentService = agentService;
|
_agentService = agentService;
|
||||||
|
_services = services;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("/agents")]
|
[HttpGet("/agents")]
|
||||||
public async Task<List<AgentViewModel>> GetAgents()
|
public async Task<List<AgentViewModel>> GetAgents()
|
||||||
{
|
{
|
||||||
var agents = await _agentService.GetAgents();
|
var agents = await _agentService.GetAgents();
|
||||||
|
|
||||||
|
// Add the router as agent
|
||||||
|
var routing = _services.GetRequiredService<IRoutingService>();
|
||||||
|
agents.Add(routing.LoadRouter());
|
||||||
|
|
||||||
return agents.Select(x => AgentViewModel.FromAgent(x)).ToList();
|
return agents.Select(x => AgentViewModel.FromAgent(x)).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
"Router": {
|
"Router": {
|
||||||
"RouterId": "01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a",
|
"RouterId": "01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a",
|
||||||
|
"RouterName": "PizzaBot",
|
||||||
"EnableReasoning": false,
|
"EnableReasoning": false,
|
||||||
"Model": "gpt-3.5"
|
"Model": "gpt-3.5"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue