diff --git a/BotSharp.Core/Engines/BotTrainer.cs b/BotSharp.Core/Engines/BotTrainer.cs index a7812a44..9065a3f2 100644 --- a/BotSharp.Core/Engines/BotTrainer.cs +++ b/BotSharp.Core/Engines/BotTrainer.cs @@ -19,13 +19,10 @@ namespace BotSharp.Core.Engines private string agentId; - private string config; - - public BotTrainer(string agentId, Database dc, string config = "BotSharpAi") + public BotTrainer(string agentId, Database dc) { this.dc = dc; this.agentId = agentId; - this.config = config; } public string Train(Agent agent) diff --git a/BotSharp.Core/Engines/Sebis/AgentImporterInSebis.cs b/BotSharp.Core/Engines/Sebis/AgentImporterInSebis.cs index 32afb413..25e86fe0 100644 --- a/BotSharp.Core/Engines/Sebis/AgentImporterInSebis.cs +++ b/BotSharp.Core/Engines/Sebis/AgentImporterInSebis.cs @@ -58,11 +58,11 @@ namespace BotSharp.Core.Engines agent.Intents = sentences.Select(x => x.Name).Distinct().Select(x => new Intent{Name = x}).ToList(); agent.Intents.ForEach(intent => { - ImportIntentUserSays(agent, intent, sentences); + ImportIntentUserSays(intent, sentences); }); } - private void ImportIntentUserSays(Agent agent, Intent intent, List sentences) + private void ImportIntentUserSays(Intent intent, List sentences) { intent.UserSays = new List(); @@ -113,6 +113,8 @@ namespace BotSharp.Core.Engines }); } } + + intent.UserSays.Add(expression); }); } diff --git a/BotSharp.RestApi/AgentController.cs b/BotSharp.RestApi/AgentController.cs index 153b8bb8..10f74cf8 100644 --- a/BotSharp.RestApi/AgentController.cs +++ b/BotSharp.RestApi/AgentController.cs @@ -2,8 +2,10 @@ using BotSharp.Core.Engines; using BotSharp.Core.Engines.BotSharp; using BotSharp.Core.Models; +using DotNetToolkit; using EntityFrameworkCore.BootKit; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; using Newtonsoft.Json; using System; using System.Collections.Generic; @@ -19,6 +21,17 @@ namespace BotSharp.RestApi [Route("v1/[controller]/[action]")] public class AgentController : ControllerBase { + private readonly IBotPlatform _platform; + + /// + /// Initialize dialog controller and get a platform instance + /// + /// + public AgentController(IBotPlatform platform) + { + _platform = platform; + } + /// /// Restore a agent from a uploaded zip file /// @@ -45,9 +58,8 @@ namespace BotSharp.RestApi [HttpGet("{agentId}")] public string Train([FromRoute] String agentId) { - var ai = new BotSharpAi(); - ai.LoadAgent("bff7605c-3db5-44dc-9ba7-1c9be2832318"); - ai.Train(); + _platform.LoadAgent(agentId); + _platform.Train(); return ""; } @@ -60,8 +72,7 @@ namespace BotSharp.RestApi [HttpGet("{agentId}")] public ActionResult Dump([FromRoute] String agentId) { - var rasa = new RasaAi(); - var agent = rasa.LoadAgent(agentId); + var agent = _platform.LoadAgent(agentId); return Ok(agent); }