Add colorful console log.
Fix response format.
This commit is contained in:
parent
d4dc07171f
commit
83d09ffb8d
|
|
@ -51,6 +51,7 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="BotSharp.NLP" Version="0.2.4" />
|
<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="DotNetToolkit" Version="1.6.0" />
|
||||||
<PackageReference Include="EntityFrameworkCore.BootKit" Version="1.9.1" />
|
<PackageReference Include="EntityFrameworkCore.BootKit" Version="1.9.1" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="2.1.1" />
|
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="2.1.1" />
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,10 @@ using DotNetToolkit;
|
||||||
using EntityFrameworkCore.BootKit;
|
using EntityFrameworkCore.BootKit;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Serialization;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
@ -38,6 +40,7 @@ namespace BotSharp.Core.Engines
|
||||||
{
|
{
|
||||||
var preditor = new BotPredictor();
|
var preditor = new BotPredictor();
|
||||||
var doc = preditor.Predict(agent, request).Result;
|
var doc = preditor.Predict(agent, request).Result;
|
||||||
|
|
||||||
var parameters = new Dictionary<String, Object>();
|
var parameters = new Dictionary<String, Object>();
|
||||||
if(doc.Sentences[0].Entities == null)
|
if(doc.Sentences[0].Entities == null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,12 @@ using Newtonsoft.Json.Linq;
|
||||||
using Newtonsoft.Json.Serialization;
|
using Newtonsoft.Json.Serialization;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Console = Colorful.Console;
|
||||||
|
|
||||||
namespace BotSharp.Core.Engines
|
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]));
|
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
|
Console.WriteLine(JsonConvert.SerializeObject(data, new JsonSerializerSettings
|
||||||
{
|
{
|
||||||
Formatting = Formatting.Indented,
|
Formatting = Formatting.Indented,
|
||||||
|
|
|
||||||
|
|
@ -29,12 +29,15 @@ namespace BotSharp.Core.Engines.Classifiers
|
||||||
|
|
||||||
File.Delete(predictFileName);
|
File.Delete(predictFileName);
|
||||||
|
|
||||||
doc.Sentences[0].Intent = new TextClassificationResult
|
if (!String.IsNullOrEmpty(output))
|
||||||
{
|
{
|
||||||
Classifier = "FasttextClassifier",
|
doc.Sentences[0].Intent = new TextClassificationResult
|
||||||
Label = output.Split(' ')[0].Split(new string[] { "__label__" }, StringSplitOptions.None)[1],
|
{
|
||||||
Confidence = decimal.Parse(output.Split(' ')[1])
|
Classifier = "FasttextClassifier",
|
||||||
};
|
Label = output.Split(' ')[0].Split(new string[] { "__label__" }, StringSplitOptions.None)[1],
|
||||||
|
Confidence = decimal.Parse(output.Split(' ')[1])
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,11 @@ using Microsoft.AspNetCore.Mvc;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using Console = Colorful.Console;
|
||||||
|
|
||||||
namespace BotSharp.RestApi.Rasa
|
namespace BotSharp.RestApi.Rasa
|
||||||
{
|
{
|
||||||
|
|
@ -47,6 +49,7 @@ namespace BotSharp.RestApi.Rasa
|
||||||
body = reader.ReadToEnd();
|
body = reader.ReadToEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"Got message from {Request.Host}: {body}", Color.Green);
|
||||||
if(request.Project ==null && !String.IsNullOrEmpty(body))
|
if(request.Project ==null && !String.IsNullOrEmpty(body))
|
||||||
{
|
{
|
||||||
request = JsonConvert.DeserializeObject<RasaRequestModel>(body);
|
request = JsonConvert.DeserializeObject<RasaRequestModel>(body);
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,10 @@
|
||||||
<None Remove="App_Data\BotSharp.db" />
|
<None Remove="App_Data\BotSharp.db" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="App_Data\Corpus\CoNLL\conll2000_chunking_train.txt" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.2" />
|
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
@ -72,8 +76,4 @@
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="3.0.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="3.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="App_Data\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue