add invoke function in routing service

This commit is contained in:
Jicheng Lu 2023-12-06 21:06:09 -06:00
parent ed96ff0fb9
commit fabbd8bcef
2 changed files with 15 additions and 0 deletions

View file

@ -11,6 +11,7 @@ public interface IRoutingService
List<RoutingHandlerDef> GetHandlers();
void ResetRecursiveCounter();
Task<bool> InvokeAgent(string agentId, List<RoleDialogModel> dialogs);
Task<bool> InvokeFunction(string name, RoleDialogModel message);
Task<RoleDialogModel> InstructLoop(RoleDialogModel message);
/// <summary>

View file

@ -0,0 +1,14 @@
using BotSharp.Abstraction.Functions;
namespace BotSharp.Core.Routing;
public partial class RoutingService
{
public async Task<bool> InvokeFunction(string name, RoleDialogModel message)
{
var function = _services.GetServices<IFunctionCallback>().FirstOrDefault(x => x.Name == name);
if (function == null) return false;
return await function.Execute(message);
}
}