Integrated with Articulate UI.

This commit is contained in:
Oceania2018 2018-08-30 21:59:36 -05:00
parent 47623056f7
commit 4d3350de18
6 changed files with 54 additions and 7 deletions

View file

@ -57,7 +57,7 @@ namespace BotSharp.Core.Engines
var settings = new PipeSettings var settings = new PipeSettings
{ {
ProjectDir = Path.Combine(options.AgentDir), ProjectDir = options.AgentDir,
AlgorithmDir = Path.Combine(AppDomain.CurrentDomain.GetData("ContentRootPath").ToString(), "Algorithms") AlgorithmDir = Path.Combine(AppDomain.CurrentDomain.GetData("ContentRootPath").ToString(), "Algorithms")
}; };

View file

@ -47,7 +47,7 @@ namespace BotSharp.RestApi.Rasa
body = reader.ReadToEnd(); body = reader.ReadToEnd();
} }
if(request ==null && !String.IsNullOrEmpty(body)) if(request.Project ==null && !String.IsNullOrEmpty(body))
{ {
request = JsonConvert.DeserializeObject<RasaRequestModel>(body); request = JsonConvert.DeserializeObject<RasaRequestModel>(body);
} }

View file

@ -36,6 +36,7 @@ namespace BotSharp.RestApi.Rasa
{ {
var status = new RasaStatusModel(); var status = new RasaStatusModel();
status.AvailableProjects = JObject.FromObject(new { }); status.AvailableProjects = JObject.FromObject(new { });
status.MaxTrainingProcesses = 1;
// scan dir, get all models // scan dir, get all models
var projectPath = Path.Combine(AppDomain.CurrentDomain.GetData("DataPath").ToString(), "Projects"); var projectPath = Path.Combine(AppDomain.CurrentDomain.GetData("DataPath").ToString(), "Projects");

View file

@ -10,6 +10,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace BotSharp.RestApi.Rasa namespace BotSharp.RestApi.Rasa
@ -48,8 +49,24 @@ namespace BotSharp.RestApi.Rasa
body = reader.ReadToEnd(); body = reader.ReadToEnd();
} }
var rasa_nlu_data = JsonConvert.DeserializeObject<RasaTrainRequestModel>(body); string lang = Regex.Match(body, @"language:.+")?.Value;
if (!String.IsNullOrEmpty(lang))
{
lang = lang.Substring(11, 2);
}
string data = Regex.Match(body, @"data:([\s\S]*)")?.Value;
if (String.IsNullOrEmpty(data))
{
data = body;
}
else
{
data = data.Substring(6);
}
var rasa_nlu_data = JsonConvert.DeserializeObject<RasaTrainRequestModel>(data);
rasa_nlu_data.Model = model; rasa_nlu_data.Model = model;
rasa_nlu_data.Project = project;
var trainResult = await Train(rasa_nlu_data, project); var trainResult = await Train(rasa_nlu_data, project);
return trainResult; return trainResult;
@ -73,6 +90,12 @@ namespace BotSharp.RestApi.Rasa
} }
// Save raw data to file, then parse it to Agent instance. // Save raw data to file, then parse it to Agent instance.
var metaFileName = Path.Combine(modelPath, "meta.json");
System.IO.File.WriteAllText(metaFileName, JsonConvert.SerializeObject(new AgentImportHeader
{
Name = project,
Platform = "Rasa"
}));
// in order to unify the process. // in order to unify the process.
var fileName = Path.Combine(modelPath, "corpus.json"); var fileName = Path.Combine(modelPath, "corpus.json");
@ -85,7 +108,11 @@ namespace BotSharp.RestApi.Rasa
var agent = _platform.LoadAgentFromFile(modelPath); var agent = _platform.LoadAgentFromFile(modelPath);
var info = await trainer.Train(agent, new BotTrainOptions { Model = request.Model }); var info = await trainer.Train(agent, new BotTrainOptions
{
AgentDir = projectPath,
Model = request.Model
});
return Ok(new { info = info.Model }); return Ok(new { info = info.Model });
} }

View file

@ -22,12 +22,22 @@ Some Features
* Support for multiple data request and response formats such as Rasa NLU and Dialogflow. * Support for multiple data request and response formats such as Rasa NLU and Dialogflow.
* Integrate with popular social platforms like Facebook Messenger, Slack and Telegram. * Integrate with popular social platforms like Facebook Messenger, Slack and Telegram.
Quick Started
-------------
You can use docker compose to run BotSharp quickly, make sure you've got `Docker`_ installed.
::
PS D:\BotSharp\> docker-compose -f docker-compose-articulateui.yml up
Point your web browser at http://localhost:3000 and enjoy BotSharp with Articulate-UI.
Documents Documents
--------- ---------
Read the docs: https://botsharp.readthedocs.io Read the docs: https://botsharp.readthedocs.io
Github Wiki: https://github.com/Oceania2018/BotSharp/wiki Github Wiki: https://github.com/Oceania2018/BotSharp/wiki
.. _Docker: https://www.docker.com
.. _Rasa UI: https://github.com/paschmann/rasa-ui .. _Rasa UI: https://github.com/paschmann/rasa-ui
.. _Articulate UI: https://spg.ai/projects/articulate .. _Articulate UI: https://spg.ai/projects/articulate

View file

@ -6,8 +6,17 @@ If you want to use the `RASA UI`_ as a front end, you can use the rasaui-specifi
Docker Composer Docker Composer
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^
Integrate with `Rasa UI`_, you can use docker compose to run. You can use docker compose to run, make sure you've got `Docker`_ installed.
Make sure you've got `Docker`_ installed.
1. Integrate with `Articulate UI`_
::
PS D:\BotSharp\> docker-compose -f docker-compose-articulateui.yml up
Point your web browser at http://localhost:3000 and enjoy Articulate-UI with BotSharp.
2. Integrate with `Rasa UI`_, you can use docker compose to run.
:: ::