using BotSharp.Abstraction.Routing; using BotSharp.Abstraction.Routing.Enums; namespace BotSharp.OpenAPI.Controllers; [Authorize] [ApiController] public class RealtimeController : ControllerBase { private readonly IServiceProvider _services; public RealtimeController(IServiceProvider services) { _services = services; } [HttpPost("/agent/{agentId}/function/{functionName}/execute")] public async Task ExecuteFunction(string agentId, string functionName, [FromBody] JsonDocument args) { // var agentService = _services.GetRequiredService(); // var agent = await agentService.LoadAgent(agentId); var routing = _services.GetRequiredService(); // Call functions var message = new RoleDialogModel(AgentRole.Function, "") { FunctionName = functionName, FunctionArgs = JsonSerializer.Serialize(args) }; await routing.InvokeFunction(functionName, message, options: new() { From = InvokeSource.Llm }); return message.Content; } }