Add colorful console log.

Fix response format.
This commit is contained in:
Oceania2018 2018-08-31 12:52:52 -05:00
parent d4dc07171f
commit 83d09ffb8d
6 changed files with 22 additions and 9 deletions

View file

@ -51,6 +51,7 @@
<ItemGroup>
<PackageReference Include="BotSharp.NLP" Version="0.2.4" />
<PackageReference Include="Colorful.Console" Version="1.2.9" />
<PackageReference Include="DotNetToolkit" Version="1.6.0" />
<PackageReference Include="EntityFrameworkCore.BootKit" Version="1.9.1" />
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="2.1.1" />

View file

@ -9,8 +9,10 @@ using DotNetToolkit;
using EntityFrameworkCore.BootKit;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
@ -38,6 +40,7 @@ namespace BotSharp.Core.Engines
{
var preditor = new BotPredictor();
var doc = preditor.Predict(agent, request).Result;
var parameters = new Dictionary<String, Object>();
if(doc.Sentences[0].Entities == null)
{

View file

@ -8,10 +8,12 @@ using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Console = Colorful.Console;
namespace BotSharp.Core.Engines
{
@ -69,6 +71,7 @@ namespace BotSharp.Core.Engines
await pipe.Predict(agent, data, meta.Pipeline.FirstOrDefault(x => x.Name == pipelines[pipeIdx]));
}
Console.WriteLine($"Prediction result:", Color.Green);
Console.WriteLine(JsonConvert.SerializeObject(data, new JsonSerializerSettings
{
Formatting = Formatting.Indented,

View file

@ -29,12 +29,15 @@ namespace BotSharp.Core.Engines.Classifiers
File.Delete(predictFileName);
doc.Sentences[0].Intent = new TextClassificationResult
if (!String.IsNullOrEmpty(output))
{
Classifier = "FasttextClassifier",
Label = output.Split(' ')[0].Split(new string[] { "__label__" }, StringSplitOptions.None)[1],
Confidence = decimal.Parse(output.Split(' ')[1])
};
doc.Sentences[0].Intent = new TextClassificationResult
{
Classifier = "FasttextClassifier",
Label = output.Split(' ')[0].Split(new string[] { "__label__" }, StringSplitOptions.None)[1],
Confidence = decimal.Parse(output.Split(' ')[1])
};
}
return true;
}

View file

@ -6,9 +6,11 @@ using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using Console = Colorful.Console;
namespace BotSharp.RestApi.Rasa
{
@ -47,6 +49,7 @@ namespace BotSharp.RestApi.Rasa
body = reader.ReadToEnd();
}
Console.WriteLine($"Got message from {Request.Host}: {body}", Color.Green);
if(request.Project ==null && !String.IsNullOrEmpty(body))
{
request = JsonConvert.DeserializeObject<RasaRequestModel>(body);

View file

@ -53,6 +53,10 @@
<None Remove="App_Data\BotSharp.db" />
</ItemGroup>
<ItemGroup>
<Content Include="App_Data\Corpus\CoNLL\conll2000_chunking_train.txt" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.2" />
</ItemGroup>
@ -72,8 +76,4 @@
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="3.0.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
</ItemGroup>
</Project>