fix default platform settings bug.

This commit is contained in:
botsharp2018 2018-10-12 23:12:21 -05:00
parent 7f75d06d0a
commit c226aca91c
8 changed files with 41 additions and 7 deletions

View file

@ -81,7 +81,6 @@ If you feel that this project is helpful to you, please Star on the project, we
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="RestSharp" Version="106.4.2" />
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
</ItemGroup>

View file

@ -5,11 +5,11 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BotSharp.Core.Abstractions;
using BotSharp.Platform.Abstraction;
using BotSharp.Platform.Models;
using BotSharp.Platform.Models.MachineLearning;
using DotNetToolkit;
using EntityFrameworkCore.BootKit;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@ -22,9 +22,11 @@ namespace BotSharp.Core.Engines
private readonly Database dc;
private readonly string agentId;
private readonly IPlatformSettings settings;
public BotTrainer()
public BotTrainer(IPlatformSettings setting)
{
this.settings = setting;
}
public BotTrainer(string agentId, Database dc)
@ -41,7 +43,7 @@ namespace BotSharp.Core.Engines
var config = (IConfiguration)AppDomain.CurrentDomain.GetData("Configuration");
var assemblies = (string[])AppDomain.CurrentDomain.GetData("Assemblies");
var platform = config.GetSection($"platformModuleName").Value;
var engine = config.GetSection($"{platform}:botEngine").Value;
var engine = this.settings.BotEngine;
string providerName = config.GetSection($"{engine}:Provider").Value;
var provider = TypeHelper.GetInstance(providerName, assemblies) as INlpProvider;
provider.Configuration = config.GetSection(engine);

View file

@ -19,10 +19,12 @@ namespace BotSharp.Core
public IAgentStorage<TAgent> Storage { get; set; }
private readonly IAgentStorageFactory<TAgent> agentStorageFactory;
private readonly IPlatformSettings settings;
public PlatformBuilderBase(IAgentStorageFactory<TAgent> agentStorageFactory)
public PlatformBuilderBase(IAgentStorageFactory<TAgent> agentStorageFactory, IPlatformSettings settings)
{
this.agentStorageFactory = agentStorageFactory;
this.settings = settings;
}
public async Task<List<TAgent>> GetAllAgents()
@ -89,7 +91,7 @@ namespace BotSharp.Core
options.Model = "model_" + DateTime.UtcNow.ToString("yyyyMMdd");
}
var trainer = new BotTrainer();
var trainer = new BotTrainer(settings);
agent.Corpus = corpus;
var info = await trainer.Train(agent, options);

View file

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

View file

@ -26,6 +26,8 @@ Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
DIALOGFLOW|Any CPU = DIALOGFLOW|Any CPU
DIALOGFLOW|x64 = DIALOGFLOW|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
@ -34,6 +36,10 @@ Global
{95780673-2A1A-4953-962F-C46CBFDD07FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{95780673-2A1A-4953-962F-C46CBFDD07FF}.Debug|x64.ActiveCfg = Debug|x64
{95780673-2A1A-4953-962F-C46CBFDD07FF}.Debug|x64.Build.0 = Debug|x64
{95780673-2A1A-4953-962F-C46CBFDD07FF}.DIALOGFLOW|Any CPU.ActiveCfg = DIALOGFLOW|Any CPU
{95780673-2A1A-4953-962F-C46CBFDD07FF}.DIALOGFLOW|Any CPU.Build.0 = DIALOGFLOW|Any CPU
{95780673-2A1A-4953-962F-C46CBFDD07FF}.DIALOGFLOW|x64.ActiveCfg = DIALOGFLOW|x64
{95780673-2A1A-4953-962F-C46CBFDD07FF}.DIALOGFLOW|x64.Build.0 = DIALOGFLOW|x64
{95780673-2A1A-4953-962F-C46CBFDD07FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{95780673-2A1A-4953-962F-C46CBFDD07FF}.Release|Any CPU.Build.0 = Release|Any CPU
{95780673-2A1A-4953-962F-C46CBFDD07FF}.Release|x64.ActiveCfg = Release|x64
@ -42,6 +48,10 @@ Global
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.Debug|x64.ActiveCfg = Debug|x64
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.Debug|x64.Build.0 = Debug|x64
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.DIALOGFLOW|Any CPU.ActiveCfg = Debug|Any CPU
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.DIALOGFLOW|Any CPU.Build.0 = Debug|Any CPU
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.DIALOGFLOW|x64.ActiveCfg = Debug|x64
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.DIALOGFLOW|x64.Build.0 = Debug|x64
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.Release|Any CPU.Build.0 = Release|Any CPU
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.Release|x64.ActiveCfg = Release|x64
@ -50,6 +60,10 @@ Global
{C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.Debug|x64.ActiveCfg = Debug|x64
{C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.Debug|x64.Build.0 = Debug|x64
{C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.DIALOGFLOW|Any CPU.ActiveCfg = DIALOGFLOW|Any CPU
{C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.DIALOGFLOW|Any CPU.Build.0 = DIALOGFLOW|Any CPU
{C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.DIALOGFLOW|x64.ActiveCfg = DIALOGFLOW|x64
{C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.DIALOGFLOW|x64.Build.0 = DIALOGFLOW|x64
{C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.Release|Any CPU.Build.0 = Release|Any CPU
{C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}.Release|x64.ActiveCfg = Release|x64
@ -58,6 +72,10 @@ Global
{8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.Debug|x64.ActiveCfg = Debug|x64
{8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.Debug|x64.Build.0 = Debug|x64
{8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.DIALOGFLOW|Any CPU.ActiveCfg = DIALOGFLOW|Any CPU
{8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.DIALOGFLOW|Any CPU.Build.0 = DIALOGFLOW|Any CPU
{8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.DIALOGFLOW|x64.ActiveCfg = DIALOGFLOW|x64
{8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.DIALOGFLOW|x64.Build.0 = DIALOGFLOW|x64
{8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.Release|Any CPU.Build.0 = Release|Any CPU
{8A1F6277-FFCB-4CCD-B798-876D8BE525A9}.Release|x64.ActiveCfg = Release|x64
@ -66,6 +84,10 @@ Global
{30F80E7D-951A-4E8F-9C3C-2C866528EABD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{30F80E7D-951A-4E8F-9C3C-2C866528EABD}.Debug|x64.ActiveCfg = Debug|x64
{30F80E7D-951A-4E8F-9C3C-2C866528EABD}.Debug|x64.Build.0 = Debug|x64
{30F80E7D-951A-4E8F-9C3C-2C866528EABD}.DIALOGFLOW|Any CPU.ActiveCfg = DIALOGFLOW|Any CPU
{30F80E7D-951A-4E8F-9C3C-2C866528EABD}.DIALOGFLOW|Any CPU.Build.0 = DIALOGFLOW|Any CPU
{30F80E7D-951A-4E8F-9C3C-2C866528EABD}.DIALOGFLOW|x64.ActiveCfg = DIALOGFLOW|x64
{30F80E7D-951A-4E8F-9C3C-2C866528EABD}.DIALOGFLOW|x64.Build.0 = DIALOGFLOW|x64
{30F80E7D-951A-4E8F-9C3C-2C866528EABD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{30F80E7D-951A-4E8F-9C3C-2C866528EABD}.Release|Any CPU.Build.0 = Release|Any CPU
{30F80E7D-951A-4E8F-9C3C-2C866528EABD}.Release|x64.ActiveCfg = Release|x64
@ -74,6 +96,10 @@ Global
{62F08F9F-16C2-4754-90B0-B604DC18AE23}.Debug|Any CPU.Build.0 = Debug|Any CPU
{62F08F9F-16C2-4754-90B0-B604DC18AE23}.Debug|x64.ActiveCfg = Debug|Any CPU
{62F08F9F-16C2-4754-90B0-B604DC18AE23}.Debug|x64.Build.0 = Debug|Any CPU
{62F08F9F-16C2-4754-90B0-B604DC18AE23}.DIALOGFLOW|Any CPU.ActiveCfg = Debug|Any CPU
{62F08F9F-16C2-4754-90B0-B604DC18AE23}.DIALOGFLOW|Any CPU.Build.0 = Debug|Any CPU
{62F08F9F-16C2-4754-90B0-B604DC18AE23}.DIALOGFLOW|x64.ActiveCfg = Debug|Any CPU
{62F08F9F-16C2-4754-90B0-B604DC18AE23}.DIALOGFLOW|x64.Build.0 = Debug|Any CPU
{62F08F9F-16C2-4754-90B0-B604DC18AE23}.Release|Any CPU.ActiveCfg = Release|Any CPU
{62F08F9F-16C2-4754-90B0-B604DC18AE23}.Release|Any CPU.Build.0 = Release|Any CPU
{62F08F9F-16C2-4754-90B0-B604DC18AE23}.Release|x64.ActiveCfg = Release|Any CPU
@ -82,6 +108,10 @@ Global
{C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.Debug|x64.ActiveCfg = Debug|Any CPU
{C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.Debug|x64.Build.0 = Debug|Any CPU
{C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.DIALOGFLOW|Any CPU.ActiveCfg = Debug|Any CPU
{C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.DIALOGFLOW|Any CPU.Build.0 = Debug|Any CPU
{C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.DIALOGFLOW|x64.ActiveCfg = Debug|Any CPU
{C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.DIALOGFLOW|x64.Build.0 = Debug|Any CPU
{C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.Release|Any CPU.Build.0 = Release|Any CPU
{C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}.Release|x64.ActiveCfg = Release|Any CPU