Add OwnThink provider

This commit is contained in:
Oceania2018 2019-02-28 22:33:21 -06:00
parent cb9cf314d7
commit dd1bc2d8aa
11 changed files with 58 additions and 11 deletions

View file

@ -72,9 +72,9 @@ If you feel that this project is helpful to you, please Star on the project, we
</ItemGroup>
<ItemGroup>
<PackageReference Include="CherubNLP" Version="0.1.1" />
<PackageReference Include="CherubNLP" Version="0.2.0" />
<PackageReference Include="Colorful.Console" Version="1.2.9" />
<PackageReference Include="CSRedisCore" Version="3.0.39" />
<PackageReference Include="CSRedisCore" Version="3.0.40" />
<PackageReference Include="DotNetToolkit" Version="1.6.0" />
<PackageReference Include="EntityFrameworkCore.BootKit" Version="1.11.0" />
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="2.2.0" />
@ -82,7 +82,7 @@ If you feel that this project is helpful to you, please Star on the project, we
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="NumSharp" Version="0.7.3" />
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
<PackageReference Include="TensorFlow.NET" Version="0.4.0" />
<PackageReference Include="TensorFlow.NET" Version="0.4.1" />
</ItemGroup>
</Project>

View file

@ -9,6 +9,7 @@ using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace BotSharp.Core.Engines.BotSharp
{

View file

@ -95,6 +95,8 @@ namespace BotSharp.Core.Engines
for (int pipeIdx = 0; pipeIdx < pipelines.Count; pipeIdx++)
{
Console.WriteLine("");
Console.WriteLine($"Executing {pipeModel.Name}");
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
@ -109,7 +111,8 @@ namespace BotSharp.Core.Engines
Time = DateTime.UtcNow
};
meta.Pipeline.Add(pipeModel);
Console.WriteLine(JsonConvert.SerializeObject(pipeModel, Formatting.Indented));
await pipe.Train(agent, data, pipeModel);
stopwatch.Stop();

View file

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace BotSharp.Core.Engines.OwnThink
{
public class OwnThinkApi
{
}
}

View file

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace BotSharp.Core.Engines.OwnThink
{
public class OwnThinkChatResponse
{
public OwnThinkChatResponseData Data { get; set; }
public string Message { get; set; }
}
public class OwnThinkChatResponseData
{
public OwnThinkChatResponseDataInfo Info { get; set; }
public int Type { get; set; }
}
public class OwnThinkChatResponseDataInfo
{
public string Text { get; set; }
}
}

View file

@ -1,4 +1,5 @@
using BotSharp.Core.Engines;
using BotSharp.Core.Engines.OwnThink;
using BotSharp.Platform.Abstraction;
using BotSharp.Platform.Models;
using BotSharp.Platform.Models.AiRequest;
@ -219,8 +220,9 @@ namespace BotSharp.Core
{
var data = new
{
token = "openbot",
info = request.Text
appid = "openbot",
userid = "yener",
spoken = request.Text
};
using (var client = new HttpClient())
@ -229,12 +231,12 @@ namespace BotSharp.Core
"https://api.ownthink.com/bot",
new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json"));
var content = await response.Content.ReadAsStringAsync();
var result = JsonConvert.DeserializeObject<JObject>(content);
var result = JsonConvert.DeserializeObject<OwnThinkChatResponse>(content);
return new TextClassificationResult
{
Classifier = "ownthink",
Text = result["text"].ToString()
Text = result.Data.Info.Text
};
}
}

View file

@ -33,6 +33,7 @@
<Compile Remove="App_Data\AgentStorage\**" />
<Compile Remove="App_Data\Corpus\**" />
<Compile Remove="App_Data\Projects\**" />
<Compile Remove="App_Data\SessionStorage\**" />
<Compile Remove="PublishOutput\**" />
<Compile Remove="publish\**" />
<Content Remove="App_Data\AgentArchive\**" />
@ -40,6 +41,7 @@
<Content Remove="App_Data\Corpus\**" />
<Content Remove="App_Data\DbInitializer\**" />
<Content Remove="App_Data\Projects\**" />
<Content Remove="App_Data\SessionStorage\**" />
<Content Remove="App_Data\TrainingFiles\**" />
<Content Remove="PublishOutput\**" />
<Content Remove="publish\**" />
@ -47,6 +49,7 @@
<EmbeddedResource Remove="App_Data\AgentStorage\**" />
<EmbeddedResource Remove="App_Data\Corpus\**" />
<EmbeddedResource Remove="App_Data\Projects\**" />
<EmbeddedResource Remove="App_Data\SessionStorage\**" />
<EmbeddedResource Remove="PublishOutput\**" />
<EmbeddedResource Remove="publish\**" />
<None Remove="App_Data\AgentArchive\**" />
@ -54,6 +57,7 @@
<None Remove="App_Data\Corpus\**" />
<None Remove="App_Data\DbInitializer\**" />
<None Remove="App_Data\Projects\**" />
<None Remove="App_Data\SessionStorage\**" />
<None Remove="PublishOutput\**" />
<None Remove="publish\**" />
</ItemGroup>

View file

@ -15,7 +15,7 @@ by editing this MSBuild file. In order to learn more about this please visit htt
<ProjectGuid>03dca427-327a-4fc9-9a2f-57d17f16708c</ProjectGuid>
<publishUrl>publish\</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>
<SelfContained>false</SelfContained>
<_IsPortable>true</_IsPortable>
</PropertyGroup>

View file

@ -6,6 +6,6 @@ by editing this MSBuild file. In order to learn more about this please visit htt
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TimeStampOfAssociatedLegacyPublishXmlFile />
<_PublishTargetUrl>C:\Users\haipi\Documents\Projects\BotSharp\BotSharp.WebHost\publish\</_PublishTargetUrl>
<_PublishTargetUrl>D:\Projects\BotSharp\BotSharp.WebHost\publish\</_PublishTargetUrl>
</PropertyGroup>
</Project>

View file

@ -1,5 +1,6 @@
{
// if you want to override platform setting, please set corresponding value, otherwise you don't need this section.
// if you want to override platform setting, please set corresponding value,
// otherwise you don't need this section.
"dialogflowAi": {
"botEngine": "BotSharpNLU",
"agentStorage": "AgentStorageInFile",