BotSharp/src/Infrastructure/BotSharp.OpenAPI/Controllers/RealtimeController.cs

33 lines
1.1 KiB
C#
Raw Normal View History

2025-02-03 04:02:36 +00:00
using BotSharp.Abstraction.Routing;
2025-07-15 21:52:13 +00:00
using BotSharp.Abstraction.Routing.Enums;
2025-02-03 04:02:36 +00:00
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<string> ExecuteFunction(string agentId, string functionName, [FromBody] JsonDocument args)
{
// var agentService = _services.GetRequiredService<IAgentService>();
// var agent = await agentService.LoadAgent(agentId);
var routing = _services.GetRequiredService<IRoutingService>();
// Call functions
var message = new RoleDialogModel(AgentRole.Function, "")
{
FunctionName = functionName,
FunctionArgs = JsonSerializer.Serialize(args)
};
2025-08-04 19:21:11 +00:00
await routing.InvokeFunction(functionName, message, options: new() { From = InvokeSource.Llm });
2025-02-03 04:02:36 +00:00
return message.Content;
}
}