diff --git a/BotSharp.WebHost/BotSharp.WebHost.csproj b/BotSharp.WebHost/BotSharp.WebHost.csproj
index 451892f0..51fd3eda 100644
--- a/BotSharp.WebHost/BotSharp.WebHost.csproj
+++ b/BotSharp.WebHost/BotSharp.WebHost.csproj
@@ -63,12 +63,8 @@
-
-
-
-
-
-
+
+
@@ -78,6 +74,10 @@
+
+
+
+
PreserveNewest
diff --git a/BotSharp.WebHost/InitializationLoader.cs b/BotSharp.WebHost/InitializationLoader.cs
index 41400f3f..31d57780 100644
--- a/BotSharp.WebHost/InitializationLoader.cs
+++ b/BotSharp.WebHost/InitializationLoader.cs
@@ -1,6 +1,4 @@
-using BotSharp.Core.Abstractions;
-using DotNetToolkit;
-using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using System;
using System.Linq;
@@ -13,12 +11,12 @@ namespace BotSharp.WebHost
public IConfiguration Config { get; set; }
public void Load()
{
- var assemblies = (string[])AppDomain.CurrentDomain.GetData("Assemblies");
+ /*var assemblies = (string[])AppDomain.CurrentDomain.GetData("Assemblies");
var appsLoaders1 = TypeHelper.GetInstanceWithInterface(assemblies);
appsLoaders1.ForEach(loader =>
{
loader.Initialize(Config, Env);
- });
+ });*/
}
}
}
diff --git a/BotSharp.WebHost/Program.cs b/BotSharp.WebHost/Program.cs
index 57d70b4a..fea265cb 100644
--- a/BotSharp.WebHost/Program.cs
+++ b/BotSharp.WebHost/Program.cs
@@ -44,7 +44,7 @@ namespace BotSharp.WebHost
config.AddJsonFile(setting, optional: false, reloadOnChange: true);
});
})
- .UseUrls("http://0.0.0.0:3112")
+ .UseUrls("http://0.0.0.0:7500")
.UseStartup()
.Build();
}
diff --git a/BotSharp.WebHost/Settings/BotSharpNLU.json b/BotSharp.WebHost/Settings/BotSharpNLU.json
index fd756c84..e40068cf 100644
--- a/BotSharp.WebHost/Settings/BotSharpNLU.json
+++ b/BotSharp.WebHost/Settings/BotSharpNLU.json
@@ -14,7 +14,7 @@
},
"botSharpIntentClassifier": {
- "classifer": "SVMClassifier",
+ "classifer": "NaiveBayesClassifier",
"wordvecModel": "|App_Data|wordvec_enu.bin"
},
diff --git a/BotSharp.WebHost/Startup.cs b/BotSharp.WebHost/Startup.cs
index 073a138c..72578711 100644
--- a/BotSharp.WebHost/Startup.cs
+++ b/BotSharp.WebHost/Startup.cs
@@ -12,6 +12,7 @@ using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
+using System.Reflection;
using Console = Colorful.Console;
namespace BotSharp.WebHost
@@ -56,8 +57,9 @@ namespace BotSharp.WebHost
var info = Configuration.GetSection("Swagger").Get();
c.SwaggerDoc(info.Version, info);
- var filePath = Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, "BotSharp.RestApi.xml");
- c.IncludeXmlComments(filePath);
+ //var filePath = Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, "BotSharp.RestApi.xml");
+ //c.IncludeXmlComments(filePath);
+
c.OperationFilter();
});
@@ -124,6 +126,13 @@ namespace BotSharp.WebHost
loader.Config = Configuration;
loader.Load();*/
+ // load dll dynamic
+ /*Assembly library = Assembly.LoadFile(Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, "BotSharp.Platform.Articulate.dll"));
+ Type myClass = (from type in library.GetExportedTypes()
+ where typeof(IMyInterface).IsAssignableFrom(type)
+ select type)
+ .Single();*/
+
var platform = Configuration.GetValue("Platform");
var engine = Configuration.GetValue($"{platform}:BotEngine");
Formatter[] settings = new Formatter[]
diff --git a/BotSharp.sln b/BotSharp.sln
index 0b374476..0b7fa318 100644
--- a/BotSharp.sln
+++ b/BotSharp.sln
@@ -5,8 +5,6 @@ VisualStudioVersion = 15.0.27130.2010
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Core", "BotSharp.Core\BotSharp.Core.csproj", "{95780673-2A1A-4953-962F-C46CBFDD07FF}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.RestApi", "BotSharp.RestApi\BotSharp.RestApi.csproj", "{80DDAA05-69BC-49DD-96A4-37345E7A2E20}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.WebHost", "BotSharp.WebHost\BotSharp.WebHost.csproj", "{03DCA427-327A-4FC9-9A2F-57D17F16708C}"
ProjectSection(ProjectDependencies) = postProject
{C2FDC855-BD88-4041-B0FF-3AA8A1C11A22} = {C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}
@@ -26,7 +24,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Platform.Models",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Platform.Dialogflow", "..\botsharp-dialogflow\BotSharp.Platform.Dialogflow\BotSharp.Platform.Dialogflow.csproj", "{B865F070-9693-47C6-B901-40121F659C6F}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Platform.Articulate", "Platform.Articulate\Platform.Articulate.csproj", "{9B7D2034-55A0-4539-A7A5-FAA7117E16A6}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Platform.Articulate", "..\botsharp-articulate\BotSharp.Platform.Articulate\BotSharp.Platform.Articulate.csproj", "{17BAE152-DDCF-4605-8DCB-9F14D403002F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -44,14 +42,6 @@ Global
{95780673-2A1A-4953-962F-C46CBFDD07FF}.Release|Any CPU.Build.0 = Release|Any CPU
{95780673-2A1A-4953-962F-C46CBFDD07FF}.Release|x64.ActiveCfg = Release|x64
{95780673-2A1A-4953-962F-C46CBFDD07FF}.Release|x64.Build.0 = Release|x64
- {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.Debug|x64.ActiveCfg = Debug|x64
- {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.Debug|x64.Build.0 = Debug|x64
- {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.Release|Any CPU.Build.0 = Release|Any CPU
- {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.Release|x64.ActiveCfg = Release|x64
- {80DDAA05-69BC-49DD-96A4-37345E7A2E20}.Release|x64.Build.0 = Release|x64
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{03DCA427-327A-4FC9-9A2F-57D17F16708C}.Debug|x64.ActiveCfg = Debug|x64
@@ -108,14 +98,14 @@ Global
{B865F070-9693-47C6-B901-40121F659C6F}.Release|Any CPU.Build.0 = Release|Any CPU
{B865F070-9693-47C6-B901-40121F659C6F}.Release|x64.ActiveCfg = Release|Any CPU
{B865F070-9693-47C6-B901-40121F659C6F}.Release|x64.Build.0 = Release|Any CPU
- {9B7D2034-55A0-4539-A7A5-FAA7117E16A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {9B7D2034-55A0-4539-A7A5-FAA7117E16A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {9B7D2034-55A0-4539-A7A5-FAA7117E16A6}.Debug|x64.ActiveCfg = Debug|Any CPU
- {9B7D2034-55A0-4539-A7A5-FAA7117E16A6}.Debug|x64.Build.0 = Debug|Any CPU
- {9B7D2034-55A0-4539-A7A5-FAA7117E16A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {9B7D2034-55A0-4539-A7A5-FAA7117E16A6}.Release|Any CPU.Build.0 = Release|Any CPU
- {9B7D2034-55A0-4539-A7A5-FAA7117E16A6}.Release|x64.ActiveCfg = Release|Any CPU
- {9B7D2034-55A0-4539-A7A5-FAA7117E16A6}.Release|x64.Build.0 = Release|Any CPU
+ {17BAE152-DDCF-4605-8DCB-9F14D403002F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {17BAE152-DDCF-4605-8DCB-9F14D403002F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {17BAE152-DDCF-4605-8DCB-9F14D403002F}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {17BAE152-DDCF-4605-8DCB-9F14D403002F}.Debug|x64.Build.0 = Debug|Any CPU
+ {17BAE152-DDCF-4605-8DCB-9F14D403002F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {17BAE152-DDCF-4605-8DCB-9F14D403002F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {17BAE152-DDCF-4605-8DCB-9F14D403002F}.Release|x64.ActiveCfg = Release|Any CPU
+ {17BAE152-DDCF-4605-8DCB-9F14D403002F}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Platform.Articulate/ArticulateAi.cs b/Platform.Articulate/ArticulateAi.cs
deleted file mode 100644
index b0eaa3d4..00000000
--- a/Platform.Articulate/ArticulateAi.cs
+++ /dev/null
@@ -1,185 +0,0 @@
-using BotSharp.Core;
-using BotSharp.Core.Engines;
-using BotSharp.Models.NLP;
-using BotSharp.Platform.Abstraction;
-using BotSharp.Platform.Models;
-using BotSharp.Platform.Models.AiRequest;
-using BotSharp.Platform.Models.AiResponse;
-using BotSharp.Platform.Models.MachineLearning;
-using DotNetToolkit;
-using Platform.Articulate.Models;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Platform.Articulate
-{
- ///
- /// A platform for building conversational interfaces with intelligent agents (chatbots)
- /// http://spg.ai/projects/articulate
- /// This implementation takes over APIs of Articulate's 7500 port.
- ///
- public class ArticulateAi :
- PlatformBuilderBase,
- IPlatformBuilder
- where TAgent : AgentModel
- {
- public DialogRequestOptions RequestOptions { get; set; }
-
- public Tuple GetAgentByDomainId(String domainId)
- {
- var results = GetAllAgents();
-
- foreach (TAgent agent in results)
- {
- var domain = agent.Domains.FirstOrDefault(x => x.Id == domainId);
-
- if (domain != null)
- {
- return new Tuple(agent, domain);
- }
- }
-
- return null;
- }
-
- public Tuple GetAgentByIntentId(String intentId)
- {
- var results = GetAllAgents();
-
- foreach (TAgent agent in results)
- {
- foreach (DomainModel domain in agent.Domains)
- {
- var intent = domain.Intents.FirstOrDefault(x => x.Id == intentId);
- if (intent != null)
- {
- return new Tuple(agent, domain, intent);
- }
- }
- }
-
- return null;
- }
-
- public List GetReferencedIntentsByEntity(string entityId)
- {
- var intents = new List();
- var allAgents = GetAllAgents();
- foreach (TAgent agent in allAgents)
- {
- foreach (DomainModel domain in agent.Domains)
- {
- foreach (IntentModel intent in domain.Intents)
- {
- if(intent.Examples.Exists(x => x.Entities.Exists(y => y.EntityId == entityId)))
- {
- intents.Add(intent);
- }
- }
- }
- }
-
- return intents;
- }
-
- public TrainingCorpus ExtractorCorpus(TAgent agent)
- {
- var corpus = new TrainingCorpus();
- corpus.Entities = agent.Entities.Select(x => new TrainingEntity
- {
- Entity = x.EntityName,
- Values = x.Examples.Select(y => new TrainingEntitySynonym
- {
- Value = y.Value,
- Synonyms = y.Synonyms
- }).ToList()
- }).ToList();
-
- corpus.UserSays = new List>();
-
- foreach(DomainModel domain in agent.Domains)
- {
- foreach(IntentModel intent in domain.Intents)
- {
- foreach(IntentExampleModel example in intent.Examples)
- {
- var say = new TrainingIntentExpression()
- {
- Intent = intent.IntentName,
- Text = example.UserSays,
- Entities = example.Entities.Select(x => new TrainingIntentExpressionPart
- {
- Entity = x.Entity,
- Start = x.Start,
- Value = x.Value
- }).ToList()
- };
-
- corpus.UserSays.Add(say);
- }
- }
- }
-
- return corpus;
- }
-
- public override bool SaveAgent(TAgent agent)
- {
- agent.Status = "Changed";
- agent.LastTraining = DateTime.UtcNow;
- return base.SaveAgent(agent);
- }
-
- public async Task Train(TAgent agent, TrainingCorpus corpus)
- {
- string agentDir = Path.Combine(AppDomain.CurrentDomain.GetData("DataPath").ToString(), "Projects", agent.Id);
- var model = "model_" + DateTime.UtcNow.ToString("yyyyMMdd");
-
- var trainer = new BotTrainer();
- agent.Corpus = corpus;
-
- var trainOptions = new BotTrainOptions
- {
- AgentDir = agentDir,
- Model = model
- };
-
- var info = await trainer.Train(agent, trainOptions);
-
- return info;
- }
-
- public AiResponse TextRequest(AiRequest request)
- {
- var aiResponse = new AiResponse();
-
- // Load agent
- var projectPath = Path.Combine(AppDomain.CurrentDomain.GetData("DataPath").ToString(), "Projects", request.AgentId);
- var model = Directory.GetDirectories(projectPath).Where(x => x.Contains("model_")).Last().Split(Path.DirectorySeparatorChar).Last();
- var modelPath = Path.Combine(projectPath, model);
- request.AgentDir = projectPath;
- request.Model = model;
-
- var agent = GetAgentById(request.AgentId);
-
- var preditor = new BotPredictor();
- var doc = preditor.Predict(agent, request).Result;
-
- var parameters = new Dictionary();
- if (doc.Sentences[0].Entities == null)
- {
- doc.Sentences[0].Entities = new List();
- }
- doc.Sentences[0].Entities.ForEach(x => parameters[x.Entity] = x.Value);
-
- aiResponse.Intent = doc.Sentences[0].Intent.Label;
- aiResponse.Speech = aiResponse.Intent;
-
- return aiResponse;
- }
- }
-}
diff --git a/Platform.Articulate/Controllers/AgentController.cs b/Platform.Articulate/Controllers/AgentController.cs
deleted file mode 100644
index 282b4a58..00000000
--- a/Platform.Articulate/Controllers/AgentController.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-using BotSharp.Core;
-using BotSharp.Core.Engines;
-using BotSharp.Platform.Abstraction;
-using BotSharp.Platform.Models;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Configuration;
-using Newtonsoft.Json;
-using Platform.Articulate;
-using Platform.Articulate.Models;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Text.RegularExpressions;
-
-namespace Platform.Articulate.Controllers
-{
- [Route("[controller]")]
- public class AgentController : ControllerBase
- {
- private readonly IBotEngine _platform;
- private ArticulateAi builder;
-
- ///
- /// Initialize agent controller and get a platform instance
- ///
- ///
- public AgentController(IBotEngine platform, IConfiguration configuration)
- {
- _platform = platform;
- builder = new ArticulateAi();
- builder.PlatformConfig = configuration.GetSection("ArticulateAi");
- }
-
- [HttpPost]
- public AgentModel PostAgent()
- {
- AgentModel agent = null;
-
- using (var reader = new StreamReader(Request.Body))
- {
- string body = reader.ReadToEnd();
- agent = JsonConvert.DeserializeObject(body);
- }
-
- // convert to standard Agent structure
- agent.Id = new Random().Next(Int32.MaxValue).ToString();
- agent.Name = agent.AgentName;
- builder.SaveAgent(agent);
-
- return agent;
- }
-
- [HttpGet]
- public List GetAgent()
- {
- var results = builder.GetAllAgents();
- var agents = results.ToList();
-
- return agents;
- }
-
- [HttpGet("{agentId}")]
- public AgentModel GetAgentById([FromRoute] string agentId)
- {
- var agent = builder.GetAgentById(agentId);
-
- return agent;
- }
-
- [HttpGet("name/{agentName}")]
- public AgentModel GetAgentByName([FromRoute] string agentName)
- {
- var agent = builder.GetAgentByName(agentName);
-
- return agent;
- }
- }
-}
diff --git a/Platform.Articulate/Controllers/DomainController.cs b/Platform.Articulate/Controllers/DomainController.cs
deleted file mode 100644
index c04ae299..00000000
--- a/Platform.Articulate/Controllers/DomainController.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-using BotSharp.Core;
-using BotSharp.Platform.Models;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Configuration;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
-using Platform.Articulate.Models;
-using Platform.Articulate.ViewModels;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Text.RegularExpressions;
-
-namespace Platform.Articulate.Controllers
-{
- [Route("[controller]")]
- public class DomainController : ControllerBase
- {
- private readonly IConfiguration configuration;
- private ArticulateAi builder;
-
- public DomainController(IConfiguration configuration)
- {
- builder = new ArticulateAi();
- builder.PlatformConfig = configuration.GetSection("ArticulateAi");
- }
-
- [HttpGet("{domainId}")]
- public DomainModel GetDomain([FromRoute] int domainId)
- {
- string dataDir = Path.Combine(AppDomain.CurrentDomain.GetData("DataPath").ToString(), "Articulate");
-
- var dataPath = Directory.GetFiles(dataDir).FirstOrDefault(x => Regex.IsMatch(x, $"-domain-{domainId}.json"));
- string json = System.IO.File.ReadAllText(dataPath);
-
- var domain = JsonConvert.DeserializeObject(json);
-
- return domain;
- }
-
- [HttpPost]
- public DomainModel PostDomain()
- {
- DomainModel domain = null;
-
- using (var reader = new StreamReader(Request.Body))
- {
- string body = reader.ReadToEnd();
- domain = JsonConvert.DeserializeObject(body);
- }
-
- var agent = builder.GetAgentByName(domain.Agent);
- domain.Id = Guid.NewGuid().ToString();
- (agent as AgentModel).Domains.Add(domain);
- builder.SaveAgent(agent);
-
- return domain;
- }
-
- [HttpGet("/agent/{agentId}/domain")]
- public DomainPageViewModel GetAgentDomains([FromRoute] string agentId, [FromQuery] int start, [FromQuery] int limit)
- {
- var agent = builder.GetAgentById(agentId);
-
- return new DomainPageViewModel { Domains = agent.Domains, Total = agent.Domains.Count };
- }
- }
-}
diff --git a/Platform.Articulate/Controllers/EntityController.cs b/Platform.Articulate/Controllers/EntityController.cs
deleted file mode 100644
index 434db0e7..00000000
--- a/Platform.Articulate/Controllers/EntityController.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-using BotSharp.Core;
-using BotSharp.Platform.Models;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Configuration;
-using Newtonsoft.Json;
-using Platform.Articulate.Models;
-using Platform.Articulate.ViewModels;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-
-namespace Platform.Articulate.Controllers
-{
- [Route("[controller]")]
- public class EntityController : ControllerBase
- {
- private readonly IConfiguration configuration;
- private ArticulateAi builder;
-
- public EntityController(IConfiguration configuration)
- {
- builder = new ArticulateAi();
- builder.PlatformConfig = configuration.GetSection("ArticulateAi");
- }
-
- [HttpGet("{entityId}")]
- public EntityModel GetEntity([FromRoute] string entityId)
- {
- string dataDir = Path.Combine(AppDomain.CurrentDomain.GetData("DataPath").ToString(), "Articulate");
-
- string dataPath = Directory.GetFiles(dataDir).FirstOrDefault(x => x.EndsWith($"-entity-{entityId}.json"));
-
- string json = System.IO.File.ReadAllText(dataPath);
-
- var entity = JsonConvert.DeserializeObject(json);
-
- return entity;
- }
-
- [HttpGet("/agent/{agentId}/entity")]
- public EntityPageViewModel GetAgentEntities([FromRoute] string agentId, [FromQuery] int start, [FromQuery] int limit)
- {
- var agent = builder.GetAgentById(agentId);
- return new EntityPageViewModel { Entities = agent.Entities.Select(x => x as EntityModel).ToList(), Total = agent.Entities.Count };
- }
-
- [HttpPost]
- public EntityModel PostEntity()
- {
- EntityModel entity = null;
-
- using (var reader = new StreamReader(Request.Body))
- {
- string body = reader.ReadToEnd();
- entity = JsonConvert.DeserializeObject(body);
- }
-
- var agent = builder.GetAgentByName(entity.Agent);
- entity.Id = Guid.NewGuid().ToString();
- agent.Entities.Add(entity);
-
- builder.SaveAgent(agent);
-
- return entity;
- }
- }
-}
diff --git a/Platform.Articulate/Controllers/IntentController.cs b/Platform.Articulate/Controllers/IntentController.cs
deleted file mode 100644
index b007aa5b..00000000
--- a/Platform.Articulate/Controllers/IntentController.cs
+++ /dev/null
@@ -1,129 +0,0 @@
-using BotSharp.Core;
-using BotSharp.Platform.Models;
-using DotNetToolkit;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Configuration;
-using Newtonsoft.Json;
-using Platform.Articulate.Models;
-using Platform.Articulate.ViewModels;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-
-namespace Platform.Articulate.Controllers
-{
- [Route("[controller]")]
- public class IntentController : ControllerBase
- {
- private readonly IConfiguration configuration;
- private ArticulateAi builder;
-
- public IntentController(IConfiguration configuration)
- {
- builder = new ArticulateAi();
- builder.PlatformConfig = configuration.GetSection("ArticulateAi");
- }
-
- [HttpGet("{intentId}")]
- public IntentViewModel GetIntent([FromRoute] string intentId)
- {
- var agent = builder.GetAgentByIntentId(intentId);
-
- return agent.Item3.ToObject();
- }
-
- [HttpPost]
- public IntentViewModel PostIntent()
- {
- IntentViewModel intent = null;
-
- using (var reader = new StreamReader(Request.Body))
- {
- string body = reader.ReadToEnd();
- intent = JsonConvert.DeserializeObject(body);
- }
-
- var agent = builder.GetAgentByName(intent.Agent);
- intent.Id = Guid.NewGuid().ToString();
- var domain = agent.Domains.First(x => x.DomainName == intent.Domain);
- domain.Intents.Add(intent.ToObject());
- builder.SaveAgent(agent);
-
- return intent;
- }
-
- [HttpPut("{intentId}")]
- public IntentViewModel PutIntent([FromRoute] string intentId)
- {
- IntentViewModel intent = null;
-
- using (var reader = new StreamReader(Request.Body))
- {
- string body = reader.ReadToEnd();
- intent = JsonConvert.DeserializeObject(body);
- }
-
- var agent = builder.GetAgentByIntentId(intentId);
-
- var updateAgent = agent.Item1;
- var updateIntents = updateAgent.Domains.First(x => x.Id == agent.Item2.Id).Intents;
- var updateIntent = updateIntents.First(x => x.Id == agent.Item3.Id);
-
- updateIntent.IntentName = intent.IntentName;
- updateIntent.Examples = intent.Examples;
-
- builder.SaveAgent(updateAgent);
-
- return intent;
- }
-
- [HttpGet("{intentId}/webhook")]
- public void GetIntentWebhook([FromRoute] string intentId)
- {
-
- }
-
- [HttpGet("{intentId}/postFormat")]
- public void GetIntentPostFormat([FromRoute] string intentId)
- {
-
- }
-
- [HttpGet("/agent/{agentId}/intent")]
- public IntentPageViewModel GetAgentIntents([FromRoute] string agentId, [FromQuery] int start, [FromQuery] int limit)
- {
- var intents = new List();
-
- string dataDir = Path.Combine(AppDomain.CurrentDomain.GetData("DataPath").ToString(), "Articulate");
-
- var agentPaths = Directory.GetFiles(dataDir).Where(x => x.Contains($"agent-{agentId}-intent-")).ToList();
- for (int i = 0; i < agentPaths.Count; i++)
- {
- string json = System.IO.File.ReadAllText(agentPaths[i]);
-
- var intent = JsonConvert.DeserializeObject(json);
-
- intents.Add(intent);
- }
-
- return new IntentPageViewModel { Intents = intents, Total = intents.Count };
- }
-
- [HttpGet("/entity/{entityId}/intent")]
- public List GetReferencedIntentsByEntity([FromRoute] string entityId, [FromQuery] int start, [FromQuery] int limit)
- {
- return builder.GetReferencedIntentsByEntity(entityId).Select(x => x.ToObject()).ToList();
- }
-
- [HttpGet("/domain/{domainId}/intent")]
- public IntentPageViewModel GetReferencedIntentsByDomain([FromRoute] string domainId, [FromQuery] int start, [FromQuery] int limit)
- {
- var agent = builder.GetAgentByDomainId(domainId);
- var intents = agent.Item2.Intents.Select(x => x.ToObject()).ToList();
-
- return new IntentPageViewModel { Intents = intents, Total = intents.Count };
- }
- }
-}
diff --git a/Platform.Articulate/Controllers/ParseControllercs.cs b/Platform.Articulate/Controllers/ParseControllercs.cs
deleted file mode 100644
index cde60aeb..00000000
--- a/Platform.Articulate/Controllers/ParseControllercs.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using BotSharp.NLP;
-using BotSharp.Platform.Models.AiRequest;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Configuration;
-using Platform.Articulate.Models;
-using Platform.Articulate.ViewModels;
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.IO;
-using System.Linq;
-using System.Text;
-using Console = Colorful.Console;
-
-namespace Platform.Articulate.Controllers
-{
- [Route("[controller]")]
- public class ParseControllercs : ControllerBase
- {
- private readonly IConfiguration configuration;
- private ArticulateAi builder;
-
- public ParseControllercs(IConfiguration configuration)
- {
- builder = new ArticulateAi();
- builder.PlatformConfig = configuration.GetSection("ArticulateAi");
- }
-
- [HttpGet("/agent/{agentId}/converse")]
- public ActionResult ParseText([FromRoute] string agentId, [FromQuery] string text, [FromQuery] string sessionId)
- {
- var response = new ResponseViewModel();
-
- Console.WriteLine($"Got message from {Request.Host}: {text}", Color.Green);
-
- var aiResponse = builder.TextRequest(new AiRequest
- {
- AgentId = agentId,
- Text = text
- });
-
- response.TextResponse = aiResponse.Speech;
-
- return Ok(response);
- }
- }
-}
diff --git a/Platform.Articulate/Controllers/ScenarioController.cs b/Platform.Articulate/Controllers/ScenarioController.cs
deleted file mode 100644
index f3b0615e..00000000
--- a/Platform.Articulate/Controllers/ScenarioController.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-using BotSharp.Core;
-using DotNetToolkit;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Configuration;
-using Newtonsoft.Json;
-using Platform.Articulate.Models;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-
-namespace Platform.Articulate.Controllers
-{
- [Route("[controller]")]
- public class ScenarioController : ControllerBase
- {
- private readonly IConfiguration configuration;
- private ArticulateAi builder;
-
- public ScenarioController(IConfiguration configuration)
- {
- builder = new ArticulateAi();
- builder.PlatformConfig = configuration.GetSection("ArticulateAi");
- }
-
- [HttpGet("/intent/{intentId}/scenario")]
- public IntentScenarioViewModel GetIntentScenario([FromRoute] string intentId)
- {
- var agent = builder.GetAgentByIntentId(intentId);
-
- var view = agent.Item3.Scenario.ToObject();
-
- view.Agent = agent.Item1.AgentName;
- view.Domain = agent.Item2.DomainName;
- view.Intent = agent.Item3.IntentName;
-
- return view;
- }
-
- [HttpPost("/intent/{intentId}/scenario")]
- public IntentScenarioViewModel PostIntentScenario()
- {
- IntentScenarioViewModel scenario = null;
-
- using (var reader = new StreamReader(Request.Body))
- {
- string body = reader.ReadToEnd();
- scenario = JsonConvert.DeserializeObject(body);
- }
-
- scenario.Id = Guid.NewGuid().ToString();
-
- var agent = builder.GetAgentByName(scenario.Agent);
-
- var domain = agent.Domains.FirstOrDefault(x => x.DomainName == scenario.Domain);
- var intent = domain.Intents.FirstOrDefault(x => x.IntentName == scenario.Intent);
- intent.Scenario = scenario.ToObject();
-
- builder.SaveAgent(agent);
-
- return scenario;
- }
- }
-}
diff --git a/Platform.Articulate/Controllers/SettingsController.cs b/Platform.Articulate/Controllers/SettingsController.cs
deleted file mode 100644
index 41031e38..00000000
--- a/Platform.Articulate/Controllers/SettingsController.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Configuration;
-using Newtonsoft.Json;
-using Platform.Articulate.Models;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Text;
-
-namespace Platform.Articulate.Controllers
-{
- [Route("[controller]")]
- public class SettingsController : ControllerBase
- {
- [HttpGet]
- public SettingsModel GetSettings()
- {
- string dataPath = Path.Combine(AppDomain.CurrentDomain.GetData("DataPath").ToString(), "Articulate", "settings.json");
-
- string json = System.IO.File.ReadAllText(dataPath);
-
- var settings = JsonConvert.DeserializeObject(json);
-
- return settings;
- }
-
- [HttpGet("/agent/{agentId}/settings")]
- public SettingsModel GetSettingsByAgent([FromRoute] string agentId)
- {
- string dataPath = Path.Combine(AppDomain.CurrentDomain.GetData("DataPath").ToString(), "Articulate", "settings.json");
-
- string json = System.IO.File.ReadAllText(dataPath);
-
- var settings = JsonConvert.DeserializeObject(json);
-
- return settings;
- }
-
- [HttpPut("/agent/{agentId}/settings")]
- public SettingsModel PutSettingsByAgent([FromRoute] string agentId)
- {
- string dataPath = Path.Combine(AppDomain.CurrentDomain.GetData("DataPath").ToString(), "Articulate", "settings.json");
-
- string json = System.IO.File.ReadAllText(dataPath);
-
- var settings = JsonConvert.DeserializeObject(json);
-
- return settings;
- }
- }
-}
diff --git a/Platform.Articulate/Controllers/TrainController.cs b/Platform.Articulate/Controllers/TrainController.cs
deleted file mode 100644
index 534e38f9..00000000
--- a/Platform.Articulate/Controllers/TrainController.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using BotSharp.Core;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Configuration;
-using Platform.Articulate.Models;
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Platform.Articulate.Controllers
-{
- [Route("[controller]")]
- public class TrainController : ControllerBase
- {
- private readonly IConfiguration configuration;
- private ArticulateAi builder;
-
- public TrainController(IConfiguration configuration)
- {
- builder = new ArticulateAi();
- builder.PlatformConfig = configuration.GetSection("ArticulateAi");
- }
-
- [HttpGet("/agent/{agentId}/train")]
- public async Task TrainAgent([FromRoute] string agentId)
- {
- var agent = builder.GetAgentById(agentId);
-
- var corpus = builder.ExtractorCorpus(agent);
-
- await builder.Train(agent, corpus);
-
- agent.Status = "Ready";
-
- builder.SaveAgent(agent);
-
- return agent;
- }
- }
-}
diff --git a/Platform.Articulate/Models/AgentModel.cs b/Platform.Articulate/Models/AgentModel.cs
deleted file mode 100644
index 5a65f27a..00000000
--- a/Platform.Articulate/Models/AgentModel.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using BotSharp.Platform.Models;
-using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Platform.Articulate.Models
-{
- public class AgentModel : AgentBase
- {
- public AgentModel()
- {
- Domains = new List();
- Entities = new List();
- }
-
- public string Status { get; set; }
-
- public string Timezone { get; set; }
-
- public string AgentName { get; set; }
-
- public bool UseWebhook { get; set; }
-
- public bool UsePostFormat { get; set; }
-
- public bool ExtraTrainingData { get; set; }
-
- public List FallbackResponses { get; set; }
-
- public bool EnableModelsPerDomain { get; set; }
-
- public decimal DomainClassifierThreshold { get; set; }
-
- public List Domains { get; set; }
-
- public List Entities { get; set; }
-
- public DateTime LastTraining { get; set; }
- }
-}
diff --git a/Platform.Articulate/Models/DomainModel.cs b/Platform.Articulate/Models/DomainModel.cs
deleted file mode 100644
index cfb83dc5..00000000
--- a/Platform.Articulate/Models/DomainModel.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using BotSharp.Platform.Models;
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Platform.Articulate.Models
-{
- public class DomainModel
- {
- public DomainModel()
- {
- Intents = new List();
- }
-
- public string Id { get; set; }
-
- public string Agent { get; set; }
-
- public string DomainName { get; set; }
-
- public bool Enabled { get; set; }
-
- public bool ExtraTrainingData { get; set; }
-
- public decimal IntentThreshold { get; set; }
-
- public string Status { get; set; }
-
- public List Intents { get; set; }
- }
-}
diff --git a/Platform.Articulate/Models/EntityModel.cs b/Platform.Articulate/Models/EntityModel.cs
deleted file mode 100644
index fb063cc4..00000000
--- a/Platform.Articulate/Models/EntityModel.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using BotSharp.Platform.Abstraction;
-using BotSharp.Platform.Models;
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Platform.Articulate.Models
-{
- public class EntityModel : EntityBase
- {
- public string Regex { get; set; }
-
- public string Agent { get; set; }
-
- public string EntityName { get; set; }
-
- public string Type { get; set; }
-
- public string UiColor { get; set; }
-
- public List Examples { get; set; }
- }
-}
diff --git a/Platform.Articulate/Models/EntitySynonymModel.cs b/Platform.Articulate/Models/EntitySynonymModel.cs
deleted file mode 100644
index cc3f0b62..00000000
--- a/Platform.Articulate/Models/EntitySynonymModel.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Platform.Articulate.Models
-{
- public class EntitySynonymModel
- {
- public string Value { get; set; }
-
- public List Synonyms { get; set; }
- }
-}
diff --git a/Platform.Articulate/Models/IntentExampleModel.cs b/Platform.Articulate/Models/IntentExampleModel.cs
deleted file mode 100644
index d3cbf398..00000000
--- a/Platform.Articulate/Models/IntentExampleModel.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using BotSharp.Core.Engines;
-using BotSharp.Platform.Models;
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Platform.Articulate.Models
-{
- public class IntentExampleModel
- {
- public string UserSays { get; set; }
-
- public List Entities { get; set; }
- }
-
- public class ArticulateTrainingIntentExpressionPart : TrainingIntentExpressionPart
- {
- public string EntityId { get; set; }
- }
-}
diff --git a/Platform.Articulate/Models/IntentModel.cs b/Platform.Articulate/Models/IntentModel.cs
deleted file mode 100644
index 356c58f3..00000000
--- a/Platform.Articulate/Models/IntentModel.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using BotSharp.Platform.Models;
-using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Platform.Articulate.Models
-{
- public class IntentModel : IntentBase
- {
- public string IntentName { get; set; }
-
- public string Agent { get; set; }
-
- public string Domain { get; set; }
-
- public bool UsePostFormat { get; set; }
-
- public bool UseWebhook { get; set; }
-
- ///
- /// User says
- ///
- public List Examples { get; set; }
-
- ///
- /// Intent responses
- ///
- public ScenarioModel Scenario { get; set; }
- }
-}
diff --git a/Platform.Articulate/Models/LanguageModel.cs b/Platform.Articulate/Models/LanguageModel.cs
deleted file mode 100644
index 1e799e6f..00000000
--- a/Platform.Articulate/Models/LanguageModel.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Platform.Articulate.Models
-{
- public class LanguageModel
- {
- public string Text { get; set; }
-
- public string Value { get; set; }
- }
-}
diff --git a/Platform.Articulate/Models/PipelineModel.cs b/Platform.Articulate/Models/PipelineModel.cs
deleted file mode 100644
index 0078ef55..00000000
--- a/Platform.Articulate/Models/PipelineModel.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Platform.Articulate.Models
-{
- public class PipelineModel
- {
- public string Name { get; set; }
- }
-}
diff --git a/Platform.Articulate/Models/ScenarioModel.cs b/Platform.Articulate/Models/ScenarioModel.cs
deleted file mode 100644
index 4f92e704..00000000
--- a/Platform.Articulate/Models/ScenarioModel.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.Text;
-
-namespace Platform.Articulate.Models
-{
- public class ScenarioModel
- {
- ///
- /// Guid
- ///
- [StringLength(36)]
- public String Id { get; set; }
-
- public string ScenarioName { get; set; }
-
- public List IntentResponses { get; set; }
-
- public List Slots { get; set; }
- }
-}
diff --git a/Platform.Articulate/Models/SettingsModel.cs b/Platform.Articulate/Models/SettingsModel.cs
deleted file mode 100644
index e9a9911a..00000000
--- a/Platform.Articulate/Models/SettingsModel.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using Newtonsoft.Json.Linq;
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Platform.Articulate.Models
-{
- public class SettingsModel
- {
- public string DucklingURL { get; set; }
-
- public string UiLanguage { get; set; }
-
- public string DefaultAgentLanguage { get; set; }
-
- public string DefaultTimezone { get; set; }
-
- public List Timezones { get; set; }
-
- public List DomainClassifierPipeline { get; set; }
-
- public List IntentClassifierPipeline { get; set; }
-
- public List DucklingDimension { get; set; }
-
- public List EntityClassifierPipeline { get; set; }
-
- public List DefaultAgentFallbackResponses { get; set; }
-
- public string RasaURL { get; set; }
-
- public List SpacyPretrainedEntities { get; set; }
-
- public List AgentLanguages { get; set; }
-
- public List UiLanguages { get; set; }
- }
-}
diff --git a/Platform.Articulate/Models/SlotModel.cs b/Platform.Articulate/Models/SlotModel.cs
deleted file mode 100644
index 098b5e54..00000000
--- a/Platform.Articulate/Models/SlotModel.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Platform.Articulate.Models
-{
- public class SlotModel
- {
- public string Entity { get; set; }
-
- public bool IsList { get; set; }
-
- public bool IsRequired { get; set; }
-
- public string SlotName { get; set; }
-
- public List TextPrompts { get; set; }
- }
-}
diff --git a/Platform.Articulate/Platform.Articulate.csproj b/Platform.Articulate/Platform.Articulate.csproj
deleted file mode 100644
index ee89501a..00000000
--- a/Platform.Articulate/Platform.Articulate.csproj
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
- netstandard2.0
- Debug;Release;RASA;ARTICULATE
-
-
-
- TRACE
- false
-
-
-
- TRACE;DEBUG
- false
-
-
-
-
- TRACE;DEBUG
-
-
-
- false
- TRACE;DEBUG
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Platform.Articulate/ViewModels/DomainPageViewModel.cs b/Platform.Articulate/ViewModels/DomainPageViewModel.cs
deleted file mode 100644
index d5f51636..00000000
--- a/Platform.Articulate/ViewModels/DomainPageViewModel.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using Platform.Articulate.Models;
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Platform.Articulate.ViewModels
-{
- public class DomainPageViewModel
- {
- public List Domains { get; set; }
-
- public int Total { get; set; }
- }
-}
diff --git a/Platform.Articulate/ViewModels/EntityPageViewModel.cs b/Platform.Articulate/ViewModels/EntityPageViewModel.cs
deleted file mode 100644
index 09d75a8c..00000000
--- a/Platform.Articulate/ViewModels/EntityPageViewModel.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using Platform.Articulate.Models;
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Platform.Articulate.ViewModels
-{
- public class EntityPageViewModel
- {
- public List Entities { get; set; }
-
- public int Total { get; set; }
- }
-}
diff --git a/Platform.Articulate/ViewModels/IntentPageViewModel.cs b/Platform.Articulate/ViewModels/IntentPageViewModel.cs
deleted file mode 100644
index f78a4e25..00000000
--- a/Platform.Articulate/ViewModels/IntentPageViewModel.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using Platform.Articulate.Models;
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Platform.Articulate.ViewModels
-{
- public class IntentPageViewModel
- {
- public List Intents { get; set; }
-
- public int Total { get; set; }
- }
-}
diff --git a/Platform.Articulate/ViewModels/IntentScenarioViewModel.cs b/Platform.Articulate/ViewModels/IntentScenarioViewModel.cs
deleted file mode 100644
index b9dcf8a7..00000000
--- a/Platform.Articulate/ViewModels/IntentScenarioViewModel.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Platform.Articulate.Models
-{
- public class IntentScenarioViewModel : ScenarioModel
- {
- public string Domain { get; set; }
-
- public string Agent { get; set; }
-
- public string Intent { get; set; }
- }
-}
diff --git a/Platform.Articulate/ViewModels/IntentViewModel.cs b/Platform.Articulate/ViewModels/IntentViewModel.cs
deleted file mode 100644
index dee25d43..00000000
--- a/Platform.Articulate/ViewModels/IntentViewModel.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using BotSharp.Platform.Models;
-using Platform.Articulate.Models;
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Platform.Articulate.ViewModels
-{
- public class IntentViewModel : IntentBase
- {
- public string IntentName { get; set; }
-
- public string Agent { get; set; }
-
- public string Domain { get; set; }
-
- public bool UsePostFormat { get; set; }
-
- public bool UseWebhook { get; set; }
-
- public List Examples { get; set; }
- }
-}
diff --git a/Platform.Articulate/ViewModels/ResponseViewModel.cs b/Platform.Articulate/ViewModels/ResponseViewModel.cs
deleted file mode 100644
index 3b2da95d..00000000
--- a/Platform.Articulate/ViewModels/ResponseViewModel.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Platform.Articulate.ViewModels
-{
- public class ResponseViewModel
- {
- public string TextResponse { get; set; }
- }
-}