2023-09-01 20:12:17 +00:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using BotSharp.Plugin.RoutingSpeeder.Providers;
|
|
|
|
|
using BotSharp.Plugin.RoutingSpeeder.Providers.Models;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
|
|
|
|
namespace BotSharp.Plugin.RoutingSpeeder.Controllers;
|
|
|
|
|
|
|
|
|
|
[AllowAnonymous]
|
2023-09-01 21:02:53 +00:00
|
|
|
public class RoutingSpeederController : ControllerBase
|
2023-09-01 20:12:17 +00:00
|
|
|
{
|
|
|
|
|
private readonly IServiceProvider _service;
|
2023-09-01 21:02:53 +00:00
|
|
|
public RoutingSpeederController(IServiceProvider service)
|
2023-09-01 20:12:17 +00:00
|
|
|
{
|
|
|
|
|
_service = service;
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-01 21:02:53 +00:00
|
|
|
[HttpPost("/routingspeeder/classifier/train")]
|
2023-09-01 20:12:17 +00:00
|
|
|
public IActionResult TrainIntentClassifier(TrainingParams trainingParams)
|
|
|
|
|
{
|
|
|
|
|
var intentClassifier = _service.GetRequiredService<IntentClassifier>();
|
2023-09-01 21:02:53 +00:00
|
|
|
intentClassifier.InitClassifer(trainingParams.Inference);
|
2023-09-01 20:12:17 +00:00
|
|
|
intentClassifier.Train(trainingParams);
|
|
|
|
|
return Ok(intentClassifier.Labels);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|