Fix get corpus is empty for Sebis trainer.
This commit is contained in:
parent
c6ea723976
commit
15af4c0797
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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<SebisIntent> sentences)
|
||||
private void ImportIntentUserSays(Intent intent, List<SebisIntent> sentences)
|
||||
{
|
||||
intent.UserSays = new List<IntentExpression>();
|
||||
|
||||
|
|
@ -113,6 +113,8 @@ namespace BotSharp.Core.Engines
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
intent.UserSays.Add(expression);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize dialog controller and get a platform instance
|
||||
/// </summary>
|
||||
/// <param name="platform"></param>
|
||||
public AgentController(IBotPlatform platform)
|
||||
{
|
||||
_platform = platform;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restore a agent from a uploaded zip file
|
||||
/// </summary>
|
||||
|
|
@ -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<Agent> Dump([FromRoute] String agentId)
|
||||
{
|
||||
var rasa = new RasaAi();
|
||||
var agent = rasa.LoadAgent(agentId);
|
||||
var agent = _platform.LoadAgent(agentId);
|
||||
|
||||
return Ok(agent);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue