2023-09-22 20:38:58 +00:00
|
|
|
using BotSharp.Abstraction.Functions.Models;
|
|
|
|
|
using BotSharp.Abstraction.Repositories;
|
|
|
|
|
using BotSharp.Abstraction.Routing;
|
2023-10-29 01:54:10 +00:00
|
|
|
using BotSharp.Abstraction.Routing.Models;
|
2023-09-22 20:38:58 +00:00
|
|
|
using BotSharp.Abstraction.Routing.Settings;
|
2023-10-29 01:54:10 +00:00
|
|
|
using BotSharp.Core.Planning;
|
2023-09-22 20:38:58 +00:00
|
|
|
|
|
|
|
|
namespace BotSharp.Core.Routing.Handlers;
|
|
|
|
|
|
2023-10-29 01:54:10 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// Retrieve information from specific agent
|
|
|
|
|
/// </summary>
|
2023-09-22 20:38:58 +00:00
|
|
|
public class RetrieveDataFromAgentRoutingHandler : RoutingHandlerBase, IRoutingHandler
|
|
|
|
|
{
|
|
|
|
|
public string Name => "retrieve_data_from_agent";
|
|
|
|
|
|
|
|
|
|
public string Description => "Retrieve data from appropriate agent.";
|
|
|
|
|
|
2023-10-28 20:59:26 +00:00
|
|
|
public List<ParameterPropertyDef> Parameters => new List<ParameterPropertyDef>
|
2023-09-22 20:38:58 +00:00
|
|
|
{
|
2023-10-28 20:59:26 +00:00
|
|
|
new ParameterPropertyDef("reason", "why retrieve data"),
|
2023-10-29 01:54:10 +00:00
|
|
|
new ParameterPropertyDef("question", "the question you will ask the agent to get the necessary data"),
|
|
|
|
|
new ParameterPropertyDef("next_action_agent", "agent that can handle the question"),
|
2023-10-28 20:59:26 +00:00
|
|
|
new ParameterPropertyDef("args", "required parameters extracted from question and hand over to the next agent")
|
|
|
|
|
{
|
|
|
|
|
Type = "object"
|
|
|
|
|
}
|
2023-09-22 20:38:58 +00:00
|
|
|
};
|
|
|
|
|
|
2023-10-28 20:59:26 +00:00
|
|
|
public List<string> Planers => new List<string>
|
|
|
|
|
{
|
2023-10-29 01:54:10 +00:00
|
|
|
nameof(ReasoningPlanner)
|
2023-10-28 20:59:26 +00:00
|
|
|
};
|
2023-09-22 20:38:58 +00:00
|
|
|
|
|
|
|
|
public RetrieveDataFromAgentRoutingHandler(IServiceProvider services, ILogger<RetrieveDataFromAgentRoutingHandler> logger, RoutingSettings settings)
|
|
|
|
|
: base(services, logger, settings)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-27 20:36:26 +00:00
|
|
|
public async Task<bool> Handle(IRoutingService routing, FunctionCallFromLlm inst, RoleDialogModel message)
|
2023-09-22 20:38:58 +00:00
|
|
|
{
|
2023-10-29 01:54:10 +00:00
|
|
|
var context = _services.GetRequiredService<RoutingContext>();
|
|
|
|
|
var ret = await routing.InvokeAgent(context.GetCurrentAgentId(), message);
|
2023-09-22 20:38:58 +00:00
|
|
|
|
2023-10-29 01:54:10 +00:00
|
|
|
return ret;
|
2023-09-22 20:38:58 +00:00
|
|
|
}
|
|
|
|
|
}
|