refactor for dialogflow
This commit is contained in:
parent
89930b249f
commit
201a5f2ea0
|
|
@ -1,8 +1,5 @@
|
||||||
using BotSharp.Core.Agents;
|
using BotSharp.Core.Agents;
|
||||||
using BotSharp.Core.Engines;
|
using BotSharp.Core.Engines;
|
||||||
using BotSharp.Core.Engines.BotSharp;
|
|
||||||
using BotSharp.Core.Intents;
|
|
||||||
using BotSharp.Core.Models;
|
|
||||||
using EntityFrameworkCore.BootKit;
|
using EntityFrameworkCore.BootKit;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
|
@ -18,7 +15,7 @@ namespace BotSharp.Core.UnitTest
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class AgentTest : TestEssential
|
public class AgentTest : TestEssential
|
||||||
{
|
{
|
||||||
[TestMethod]
|
/*[TestMethod]
|
||||||
public void CreateAgentTest()
|
public void CreateAgentTest()
|
||||||
{
|
{
|
||||||
var agent = new Agent
|
var agent = new Agent
|
||||||
|
|
@ -62,6 +59,6 @@ namespace BotSharp.Core.UnitTest
|
||||||
var rasa = new RasaAi();
|
var rasa = new RasaAi();
|
||||||
rasa.LoadAgent(BOT_ID);
|
rasa.LoadAgent(BOT_ID);
|
||||||
rasa.Train();
|
rasa.Train();
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
using BotSharp.Core.Engines;
|
using BotSharp.Core.Engines;
|
||||||
using BotSharp.Core.Engines.BotSharp;
|
|
||||||
using BotSharp.Core.Models;
|
|
||||||
using BotSharp.Platform.Models;
|
using BotSharp.Platform.Models;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using System;
|
using System;
|
||||||
|
|
@ -15,9 +13,6 @@ namespace BotSharp.Core.UnitTest
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public async void TrainingTest()
|
public async void TrainingTest()
|
||||||
{
|
{
|
||||||
var ai = new BotSharpAi();
|
|
||||||
ai.LoadAgent(BOT_ID);
|
|
||||||
await ai.Train(new BotTrainOptions { });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,4 @@
|
||||||
using BotSharp.Core.Engines;
|
using BotSharp.NLP;
|
||||||
using BotSharp.Core.Engines.Dialogflow;
|
|
||||||
using BotSharp.Core.Models;
|
|
||||||
using BotSharp.NLP;
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
@ -16,7 +13,7 @@ namespace BotSharp.Core.UnitTest
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TextRequest()
|
public void TextRequest()
|
||||||
{
|
{
|
||||||
var ai = new ApiAi();
|
/*var ai = new ApiAi();
|
||||||
var agent = ai.LoadAgent(BOT_ID);
|
var agent = ai.LoadAgent(BOT_ID);
|
||||||
ai.AiConfig = new AIConfiguration(agent.ClientAccessToken, SupportedLanguage.English) { AgentId = BOT_ID };
|
ai.AiConfig = new AIConfiguration(agent.ClientAccessToken, SupportedLanguage.English) { AgentId = BOT_ID };
|
||||||
ai.AiConfig.SessionId = Guid.NewGuid().ToString();
|
ai.AiConfig.SessionId = Guid.NewGuid().ToString();
|
||||||
|
|
@ -46,7 +43,7 @@ namespace BotSharp.Core.UnitTest
|
||||||
Assert.AreEqual(response.Result.Contexts.First(x => x.Name == "music-player-control").Lifespan, 3);
|
Assert.AreEqual(response.Result.Contexts.First(x => x.Name == "music-player-control").Lifespan, 3);
|
||||||
Assert.AreEqual(response.Result.Contexts.First(x => x.Name == "play-music").Lifespan, 5);
|
Assert.AreEqual(response.Result.Contexts.First(x => x.Name == "play-music").Lifespan, 5);
|
||||||
Assert.AreEqual(response.Result.Parameters.First(x => x.Key == "song").Value, "Hard Times");
|
Assert.AreEqual(response.Result.Parameters.First(x => x.Key == "song").Value, "Hard Times");
|
||||||
Assert.AreEqual(response.Result.Parameters.First(x => x.Key == "artist").Value, "David Newman");
|
Assert.AreEqual(response.Result.Parameters.First(x => x.Key == "artist").Value, "David Newman");*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
using Bigtree.Algorithm.Extensions;
|
using Bigtree.Algorithm.Extensions;
|
||||||
using BotSharp.Core.Agents;
|
using BotSharp.Core.Agents;
|
||||||
using BotSharp.Core.Engines;
|
using BotSharp.Core.Engines;
|
||||||
using BotSharp.Core.Engines.BotSharp;
|
|
||||||
using BotSharp.Core.Models;
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
@ -15,7 +13,7 @@ namespace BotSharp.Core.UnitTest.Performance
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class Spotify : TestEssential
|
public class Spotify : TestEssential
|
||||||
{
|
{
|
||||||
private List<Tuple<AIRequest, string>> Samples;
|
//private List<Tuple<AIRequest, string>> Samples;
|
||||||
private IBotPlatform _platform;
|
private IBotPlatform _platform;
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
|
@ -26,7 +24,7 @@ namespace BotSharp.Core.UnitTest.Performance
|
||||||
|
|
||||||
var agent = LoadAgent();
|
var agent = LoadAgent();
|
||||||
|
|
||||||
for (int i = 0; i < Samples.Count; i++)
|
/*for (int i = 0; i < Samples.Count; i++)
|
||||||
{
|
{
|
||||||
var aIResponse = _platform.TextRequest(Samples[i].Item1);
|
var aIResponse = _platform.TextRequest(Samples[i].Item1);
|
||||||
if (aIResponse.Result.Metadata.IntentName == Samples[i].Item2)
|
if (aIResponse.Result.Metadata.IntentName == Samples[i].Item2)
|
||||||
|
|
@ -37,29 +35,23 @@ namespace BotSharp.Core.UnitTest.Performance
|
||||||
{
|
{
|
||||||
errors.Add(new Tuple<string, string>(Samples[i].Item2, Samples[i].Item1.Query[0]));
|
errors.Add(new Tuple<string, string>(Samples[i].Item2, Samples[i].Item1.Query[0]));
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
double accuracy = correct / (Samples.Count + 0.0);
|
//double accuracy = correct / (Samples.Count + 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Agent LoadAgent()
|
private Agent LoadAgent()
|
||||||
{
|
{
|
||||||
_platform = new BotSharpAi();
|
//_platform = new BotSharpAi();
|
||||||
|
|
||||||
// Load agent
|
// Load agent
|
||||||
var projectPath = Path.Combine(AppDomain.CurrentDomain.GetData("DataPath").ToString(), "Projects", "Spotify");
|
var projectPath = Path.Combine(AppDomain.CurrentDomain.GetData("DataPath").ToString(), "Projects", "Spotify");
|
||||||
string model = Directory.GetDirectories(projectPath).Where(x => x.Contains("model_")).Last().Split(Path.DirectorySeparatorChar).Last();
|
string model = Directory.GetDirectories(projectPath).Where(x => x.Contains("model_")).Last().Split(Path.DirectorySeparatorChar).Last();
|
||||||
var modelPath = Path.Combine(projectPath, model);
|
var modelPath = Path.Combine(projectPath, model);
|
||||||
var agent = _platform.LoadAgentFromFile(modelPath);
|
/*var agent = _platform.LoadAgentFromFile(modelPath);
|
||||||
|
|
||||||
// Init samples
|
// Init samples
|
||||||
Samples = new List<Tuple<AIRequest, string>>();
|
Samples = new List<Tuple<AIRequest, string>>();
|
||||||
/*agent.Corpus.UserSays = new List<TrainingIntentExpression<TrainingIntentExpressionPart>>
|
|
||||||
{
|
|
||||||
new TrainingIntentExpression<TrainingIntentExpressionPart>{ Intent = "music.play", Text = "play the 50 Great Beatles Songs playlist in Prime Music"},
|
|
||||||
new TrainingIntentExpression<TrainingIntentExpressionPart>{ Intent = "music.play", Text = "reproduce a the track Monster by Rihanna ft Eminem"},
|
|
||||||
new TrainingIntentExpression<TrainingIntentExpressionPart>{ Intent = "music_player_control.add_favorite", Text = "add this song to my favourites"}
|
|
||||||
};*/
|
|
||||||
agent.Corpus.UserSays.ForEach(intent =>
|
agent.Corpus.UserSays.ForEach(intent =>
|
||||||
{
|
{
|
||||||
Samples.Add(new Tuple<AIRequest, string>(new AIRequest
|
Samples.Add(new Tuple<AIRequest, string>(new AIRequest
|
||||||
|
|
@ -73,11 +65,11 @@ namespace BotSharp.Core.UnitTest.Performance
|
||||||
}, intent.Intent));
|
}, intent.Intent));
|
||||||
});
|
});
|
||||||
|
|
||||||
Samples.Shuffle();
|
Samples.Shuffle();*/
|
||||||
|
|
||||||
var samples = String.Join("\r\n", Samples.Select(x => $"__label__{x.Item2} {x.Item1.Query[0]}").ToList());
|
//var samples = String.Join("\r\n", Samples.Select(x => $"__label__{x.Item2} {x.Item1.Query[0]}").ToList());
|
||||||
|
|
||||||
return agent;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using BotSharp.Core.Agents;
|
using BotSharp.Core.Agents;
|
||||||
using BotSharp.Core.Models;
|
|
||||||
using BotSharp.Platform.Models;
|
using BotSharp.Platform.Models;
|
||||||
|
using BotSharp.Platform.Models.AiRequest;
|
||||||
|
using BotSharp.Platform.Models.AiResponse;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
@ -11,30 +12,7 @@ namespace BotSharp.Core.Engines
|
||||||
{
|
{
|
||||||
public interface IBotPlatform
|
public interface IBotPlatform
|
||||||
{
|
{
|
||||||
AIConfiguration AiConfig { get; set; }
|
AiResponse TextRequest(AiRequest request);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Load agent profile
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id">agentId, clientAccessToken, developerAccessToken</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Agent LoadAgent(string id);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Load agent from files.
|
|
||||||
/// There must contain a meta.json
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="dataDir"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Agent LoadAgentFromFile(string dataDir);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Save agent data to database
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
String SaveAgentToDb();
|
|
||||||
|
|
||||||
AIResponse TextRequest(AIRequest request);
|
|
||||||
|
|
||||||
Task Train(BotTrainOptions options);
|
Task Train(BotTrainOptions options);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using BotSharp.Core.Engines.NERs;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
|
|
@ -7,6 +6,6 @@ namespace BotSharp.Core.Abstractions
|
||||||
{
|
{
|
||||||
public interface INlpNer : INlpPipeline
|
public interface INlpNer : INlpPipeline
|
||||||
{
|
{
|
||||||
List<OntologyEnum> Ontologies { get; }
|
//List<OntologyEnum> Ontologies { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
using BotSharp.Core.Engines;
|
using BotSharp.Core.Engines;
|
||||||
using BotSharp.Core.Entities;
|
|
||||||
using BotSharp.Core.Intents;
|
|
||||||
using BotSharp.Platform.Models;
|
using BotSharp.Platform.Models;
|
||||||
using EntityFrameworkCore.BootKit;
|
using EntityFrameworkCore.BootKit;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
@ -46,11 +44,11 @@ namespace BotSharp.Core.Agents
|
||||||
public String DeveloperAccessToken { get; set; }
|
public String DeveloperAccessToken { get; set; }
|
||||||
|
|
||||||
[ForeignKey("AgentId")]
|
[ForeignKey("AgentId")]
|
||||||
public List<Intent> Intents { get; set; }
|
public List<Platform.Models.Intents.Intent> Intents { get; set; }
|
||||||
|
|
||||||
[ForeignKey("AgentId")]
|
/*[ForeignKey("AgentId")]
|
||||||
[JsonProperty("entity_types")]
|
[JsonProperty("entity_types")]
|
||||||
public List<EntityType> Entities { get; set; }
|
public List<EntityType> Entities { get; set; }*/
|
||||||
|
|
||||||
public String Birthday
|
public String Birthday
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,24 @@ If you feel that this project is helpful to you, please Star on the project, we
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Remove="Engines\NERs\**" />
|
||||||
|
<Compile Remove="Engines\QuickQA\**" />
|
||||||
|
<Compile Remove="Engines\Rasa\**" />
|
||||||
|
<Compile Remove="Engines\Sebis\**" />
|
||||||
|
<Compile Remove="Engines\SpaCy\**" />
|
||||||
|
<EmbeddedResource Remove="Engines\NERs\**" />
|
||||||
|
<EmbeddedResource Remove="Engines\QuickQA\**" />
|
||||||
|
<EmbeddedResource Remove="Engines\Rasa\**" />
|
||||||
|
<EmbeddedResource Remove="Engines\Sebis\**" />
|
||||||
|
<EmbeddedResource Remove="Engines\SpaCy\**" />
|
||||||
|
<None Remove="Engines\NERs\**" />
|
||||||
|
<None Remove="Engines\QuickQA\**" />
|
||||||
|
<None Remove="Engines\Rasa\**" />
|
||||||
|
<None Remove="Engines\Sebis\**" />
|
||||||
|
<None Remove="Engines\SpaCy\**" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Colorful.Console" Version="1.2.9" />
|
<PackageReference Include="Colorful.Console" Version="1.2.9" />
|
||||||
<PackageReference Include="CSRedisCore" Version="2.6.13" />
|
<PackageReference Include="CSRedisCore" Version="2.6.13" />
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,9 @@
|
||||||
using BotSharp.Core.Agents;
|
using BotSharp.Core.Agents;
|
||||||
using BotSharp.Core.Engines.QuickQA;
|
|
||||||
using BotSharp.Core.Engines.Rasa;
|
|
||||||
using BotSharp.Core.Entities;
|
|
||||||
using BotSharp.Core.Intents;
|
|
||||||
using BotSharp.Core.Models;
|
|
||||||
using BotSharp.Models.NLP;
|
using BotSharp.Models.NLP;
|
||||||
|
using BotSharp.Platform.Abstraction;
|
||||||
using BotSharp.Platform.Models;
|
using BotSharp.Platform.Models;
|
||||||
using BotSharp.Platform.Models.AiRequest;
|
using BotSharp.Platform.Models.AiRequest;
|
||||||
|
using BotSharp.Platform.Models.AiResponse;
|
||||||
using DotNetToolkit;
|
using DotNetToolkit;
|
||||||
using EntityFrameworkCore.BootKit;
|
using EntityFrameworkCore.BootKit;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
@ -29,8 +26,6 @@ namespace BotSharp.Core.Engines
|
||||||
{
|
{
|
||||||
protected Database dc;
|
protected Database dc;
|
||||||
|
|
||||||
public AIConfiguration AiConfig { get; set; }
|
|
||||||
|
|
||||||
protected Agent agent { get; set; }
|
protected Agent agent { get; set; }
|
||||||
|
|
||||||
public BotEngineBase()
|
public BotEngineBase()
|
||||||
|
|
@ -38,7 +33,7 @@ namespace BotSharp.Core.Engines
|
||||||
dc = new DefaultDataContextLoader().GetDefaultDc();
|
dc = new DefaultDataContextLoader().GetDefaultDc();
|
||||||
}
|
}
|
||||||
|
|
||||||
public AIResponse TextRequest(AIRequest request)
|
public AiResponse TextRequest(AiRequest request)
|
||||||
{
|
{
|
||||||
var preditor = new BotPredictor();
|
var preditor = new BotPredictor();
|
||||||
var doc = preditor.Predict(agent, new AiRequest
|
var doc = preditor.Predict(agent, new AiRequest
|
||||||
|
|
@ -46,7 +41,7 @@ namespace BotSharp.Core.Engines
|
||||||
AgentDir = request.AgentDir,
|
AgentDir = request.AgentDir,
|
||||||
Model = request.Model,
|
Model = request.Model,
|
||||||
SessionId = request.SessionId,
|
SessionId = request.SessionId,
|
||||||
Text = request.Query.First()
|
Text = request.Text
|
||||||
}).Result;
|
}).Result;
|
||||||
|
|
||||||
var parameters = new Dictionary<String, Object>();
|
var parameters = new Dictionary<String, Object>();
|
||||||
|
|
@ -56,9 +51,9 @@ namespace BotSharp.Core.Engines
|
||||||
}
|
}
|
||||||
doc.Sentences[0].Entities.ForEach(x => parameters[x.Entity] = x.Value);
|
doc.Sentences[0].Entities.ForEach(x => parameters[x.Entity] = x.Value);
|
||||||
|
|
||||||
return new AIResponse
|
return new AiResponse
|
||||||
{
|
{
|
||||||
Lang = request.Language,
|
/*Lang = request.Language,
|
||||||
Timestamp = DateTime.UtcNow,
|
Timestamp = DateTime.UtcNow,
|
||||||
SessionId = request.SessionId,
|
SessionId = request.SessionId,
|
||||||
Status = new AIResponseStatus(),
|
Status = new AIResponseStatus(),
|
||||||
|
|
@ -76,99 +71,10 @@ namespace BotSharp.Core.Engines
|
||||||
{
|
{
|
||||||
IntentName = doc.Sentences[0].Intent?.Label
|
IntentName = doc.Sentences[0].Intent?.Label
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public Agent LoadAgent(string id)
|
|
||||||
{
|
|
||||||
if (agent == null)
|
|
||||||
{
|
|
||||||
agent = dc.Table<Agent>()
|
|
||||||
.Include(x => x.Intents).ThenInclude(x => x.Contexts)
|
|
||||||
.Include(x => x.Entities).ThenInclude(x => x.Entries).ThenInclude(x => x.Synonyms)
|
|
||||||
.Include(x => x.MlConfig)
|
|
||||||
.FirstOrDefault(x => x.Id == id ||
|
|
||||||
x.ClientAccessToken == id ||
|
|
||||||
x.DeveloperAccessToken == id);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return agent;
|
|
||||||
}
|
|
||||||
|
|
||||||
return agent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Agent LoadAgentFromFile(string dataDir)
|
|
||||||
{
|
|
||||||
var meta = LoadMeta(dataDir);
|
|
||||||
IAgentImporter importer = null;
|
|
||||||
|
|
||||||
switch (meta.Platform)
|
|
||||||
{
|
|
||||||
case PlatformType.Dialogflow:
|
|
||||||
importer = new AgentImporterInDialogflow();
|
|
||||||
break;
|
|
||||||
case PlatformType.Rasa:
|
|
||||||
importer = new AgentImporterInRasa();
|
|
||||||
break;
|
|
||||||
case PlatformType.Sebis:
|
|
||||||
importer = new AgentImporterInSebis();
|
|
||||||
break;
|
|
||||||
case PlatformType.QuickQA:
|
|
||||||
importer = new AgentImporterInQuickQA();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
importer.AgentDir = dataDir;
|
|
||||||
|
|
||||||
// Load agent summary
|
|
||||||
agent = importer.LoadAgent(meta);
|
|
||||||
|
|
||||||
// Load user custom entities
|
|
||||||
importer.LoadCustomEntities(agent);
|
|
||||||
|
|
||||||
// Load agent intents
|
|
||||||
importer.LoadIntents(agent);
|
|
||||||
|
|
||||||
// Load system buildin entities
|
|
||||||
importer.LoadBuildinEntities(agent);
|
|
||||||
|
|
||||||
// Generate corpus
|
|
||||||
importer.AssembleTrainData(agent);
|
|
||||||
|
|
||||||
return agent;
|
|
||||||
}
|
|
||||||
|
|
||||||
private AgentImportHeader LoadMeta(string dataDir)
|
|
||||||
{
|
|
||||||
// load meta
|
|
||||||
string metaJson = File.ReadAllText(Path.Combine(dataDir, "meta.json"));
|
|
||||||
|
|
||||||
return JsonConvert.DeserializeObject<AgentImportHeader>(metaJson);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String SaveAgentToDb()
|
|
||||||
{
|
|
||||||
dc.DbTran(() =>
|
|
||||||
{
|
|
||||||
var existedAgent = dc.Table<Agent>().FirstOrDefault(x => x.Id == agent.Id || x.Name == agent.Name);
|
|
||||||
if (existedAgent == null)
|
|
||||||
{
|
|
||||||
dc.Table<Agent>().Add(agent);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
agent.Id = existedAgent.Id;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return agent.Id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TrainingCorpus GetIntentExpressions(Agent agent)
|
public TrainingCorpus GetIntentExpressions(Agent agent)
|
||||||
{
|
{
|
||||||
TrainingCorpus corpus = new TrainingCorpus()
|
TrainingCorpus corpus = new TrainingCorpus()
|
||||||
|
|
@ -177,7 +83,7 @@ namespace BotSharp.Core.Engines
|
||||||
Entities = new List<TrainingEntity>()
|
Entities = new List<TrainingEntity>()
|
||||||
};
|
};
|
||||||
|
|
||||||
var expressParts = new List<IntentExpressionPart>();
|
//var expressParts = new List<IntentExpressionPart>();
|
||||||
|
|
||||||
var intents = agent.Intents;
|
var intents = agent.Intents;
|
||||||
|
|
||||||
|
|
@ -247,7 +153,7 @@ namespace BotSharp.Core.Engines
|
||||||
Entities = new List<TrainingEntity>()
|
Entities = new List<TrainingEntity>()
|
||||||
};
|
};
|
||||||
|
|
||||||
var expressParts = new List<IntentExpressionPart>();
|
/*var expressParts = new List<IntentExpressionPart>();
|
||||||
|
|
||||||
var intents = dc.Table<Intent>()
|
var intents = dc.Table<Intent>()
|
||||||
.Include(x => x.Contexts)
|
.Include(x => x.Contexts)
|
||||||
|
|
@ -284,7 +190,7 @@ namespace BotSharp.Core.Engines
|
||||||
say.Entities.Add(part);
|
say.Entities.Add(part);
|
||||||
|
|
||||||
// assemble entity synonmus
|
// assemble entity synonmus
|
||||||
/*if (!trainingData.Entities.Any(y => y.EntityType == x.Alias && y.EntityValue == x.Text))
|
if (!trainingData.Entities.Any(y => y.EntityType == x.Alias && y.EntityValue == x.Text))
|
||||||
{
|
{
|
||||||
var allSynonyms = (from e in dc.Table<EntityType>()
|
var allSynonyms = (from e in dc.Table<EntityType>()
|
||||||
join ee in dc.Table<EntityEntry>() on e.Id equals ee.EntityId
|
join ee in dc.Table<EntityEntry>() on e.Id equals ee.EntityId
|
||||||
|
|
@ -300,7 +206,7 @@ namespace BotSharp.Core.Engines
|
||||||
};
|
};
|
||||||
|
|
||||||
trainingData.Entities.Add(te);
|
trainingData.Entities.Add(te);
|
||||||
}*/
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
corpus.UserSays.Add(say);
|
corpus.UserSays.Add(say);
|
||||||
|
|
@ -308,7 +214,7 @@ namespace BotSharp.Core.Engines
|
||||||
});
|
});
|
||||||
|
|
||||||
// remove Default Fallback Intent
|
// remove Default Fallback Intent
|
||||||
corpus.UserSays = corpus.UserSays.Where(x => x.Intent != "Default Fallback Intent").ToList();
|
corpus.UserSays = corpus.UserSays.Where(x => x.Intent != "Default Fallback Intent").ToList();*/
|
||||||
|
|
||||||
return corpus;
|
return corpus;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
using BotSharp.Core.Abstractions;
|
using BotSharp.Core.Abstractions;
|
||||||
using BotSharp.Core.Agents;
|
using BotSharp.Core.Agents;
|
||||||
using BotSharp.Core.Models;
|
|
||||||
using BotSharp.Platform.Models.AiRequest;
|
using BotSharp.Platform.Models.AiRequest;
|
||||||
using DotNetToolkit;
|
using DotNetToolkit;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BotSharp.Core.Models;
|
using BotSharp.Core.Agents;
|
||||||
using BotSharp.Platform.Models;
|
using BotSharp.Platform.Models;
|
||||||
|
|
||||||
namespace BotSharp.Core.Engines.BotSharp
|
namespace BotSharp.Core.Engines.BotSharp
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
using BotSharp.Core.Abstractions;
|
using BotSharp.Core.Abstractions;
|
||||||
using BotSharp.Core.Agents;
|
using BotSharp.Core.Agents;
|
||||||
using BotSharp.Core.Intents;
|
|
||||||
using BotSharp.NLP;
|
using BotSharp.NLP;
|
||||||
using BotSharp.NLP.Tokenize;
|
using BotSharp.NLP.Tokenize;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BotSharp.Core.Abstractions;
|
using BotSharp.Core.Abstractions;
|
||||||
using BotSharp.Core.Agents;
|
using BotSharp.Core.Agents;
|
||||||
using BotSharp.Core.Intents;
|
|
||||||
using BotSharp.Platform.Models;
|
using BotSharp.Platform.Models;
|
||||||
using DotNetToolkit;
|
using DotNetToolkit;
|
||||||
using EntityFrameworkCore.BootKit;
|
using EntityFrameworkCore.BootKit;
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,13 @@ using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using BotSharp.Core.Agents;
|
using BotSharp.Core.Agents;
|
||||||
using BotSharp.Core.Intents;
|
using BotSharp.Core.Intents;
|
||||||
|
using BotSharp.Platform.Abstraction;
|
||||||
|
using BotSharp.Platform.Models;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace BotSharp.Core.Engines.QuickQA
|
namespace BotSharp.Core.Engines.QuickQA
|
||||||
{
|
{
|
||||||
public class AgentImporterInQuickQA : IAgentImporter
|
public class AgentImporterInQuickQA<TAgent> : IAgentImporter<TAgent>
|
||||||
{
|
{
|
||||||
public string AgentDir { get; set; }
|
public string AgentDir { get; set; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,14 @@ using BotSharp.Core.Agents;
|
||||||
using BotSharp.Core.Entities;
|
using BotSharp.Core.Entities;
|
||||||
using BotSharp.Core.Intents;
|
using BotSharp.Core.Intents;
|
||||||
using BotSharp.Core.Models;
|
using BotSharp.Core.Models;
|
||||||
|
using BotSharp.Platform.Abstraction;
|
||||||
using BotSharp.Platform.Models;
|
using BotSharp.Platform.Models;
|
||||||
using DotNetToolkit;
|
using DotNetToolkit;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace BotSharp.Core.Engines.Rasa
|
namespace BotSharp.Core.Engines.Rasa
|
||||||
{
|
{
|
||||||
public class AgentImporterInRasa : IAgentImporter
|
public class AgentImporterInRasa<TAgent> : IAgentImporter<TAgent>
|
||||||
{
|
{
|
||||||
public string AgentDir { get; set; }
|
public string AgentDir { get; set; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ using BotSharp.Core.Agents;
|
||||||
using BotSharp.Core.Entities;
|
using BotSharp.Core.Entities;
|
||||||
using BotSharp.Core.Intents;
|
using BotSharp.Core.Intents;
|
||||||
using BotSharp.Core.Models;
|
using BotSharp.Core.Models;
|
||||||
|
using BotSharp.Platform.Abstraction;
|
||||||
using BotSharp.Platform.Models;
|
using BotSharp.Platform.Models;
|
||||||
using DotNetToolkit;
|
using DotNetToolkit;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
@ -18,7 +19,7 @@ namespace BotSharp.Core.Engines
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Import Sebis NLU benchmark corpus
|
/// Import Sebis NLU benchmark corpus
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class AgentImporterInSebis : IAgentImporter
|
public class AgentImporterInSebis<TAgent> : IAgentImporter<TAgent>
|
||||||
{
|
{
|
||||||
public string AgentDir { get; set; }
|
public string AgentDir { get; set; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BotSharp.Core.Abstractions;
|
using BotSharp.Core.Abstractions;
|
||||||
using BotSharp.Core.Agents;
|
using BotSharp.Core.Agents;
|
||||||
using BotSharp.Core.Models;
|
|
||||||
using BotSharp.Models.NLP;
|
using BotSharp.Models.NLP;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
using BotSharp.Core.Agents;
|
|
||||||
using EntityFrameworkCore.BootKit;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace BotSharp.Core.Entities
|
|
||||||
{
|
|
||||||
public static class EntityEntryDriver
|
|
||||||
{
|
|
||||||
public static void CreateEntity(this Agent agent, Database dc, EntityType entity)
|
|
||||||
{
|
|
||||||
dc.Table<EntityType>().Add(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void DeleteEntity(this Agent agent, Database dc, string entityId)
|
|
||||||
{
|
|
||||||
var entity = dc.Table<EntityType>().Find(entityId);
|
|
||||||
dc.Table<EntityType>().Remove(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void UpdateEntity(this Agent agent, Database dc, EntityType entity)
|
|
||||||
{
|
|
||||||
var oldEntity = dc.Table<EntityType>().Find(entity.Id);
|
|
||||||
oldEntity.Name = entity.Name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
using BotSharp.Core.Agents;
|
|
||||||
using EntityFrameworkCore.BootKit;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace BotSharp.Core.Entities
|
|
||||||
{
|
|
||||||
public static class EntityTypeDriver
|
|
||||||
{
|
|
||||||
public static string CreateEntityType(this Agent agent, Database dc, EntityType entityType)
|
|
||||||
{
|
|
||||||
if (dc.Table<EntityType>().Any(x => x.Name == entityType.Name && x.AgentId == agent.Id)) return agent.Id;
|
|
||||||
|
|
||||||
dc.Table<EntityType>().Add(entityType);
|
|
||||||
|
|
||||||
return entityType.Id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void UpdateEntityType(this Agent agent, Database dc, String entityTypeId, EntityType entityType)
|
|
||||||
{
|
|
||||||
var existedEntityType = dc.Table<EntityType>().Find(entityTypeId);
|
|
||||||
if (entityType == null) return;
|
|
||||||
|
|
||||||
existedEntityType.Name = entityType.Name;
|
|
||||||
existedEntityType.Description = entityType.Description;
|
|
||||||
existedEntityType.Color = entityType.Color;
|
|
||||||
existedEntityType.IsEnum = entityType.IsEnum;
|
|
||||||
existedEntityType.UpdatedTime = DateTime.UtcNow;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void DeleteEntityType(this Agent agent, Database dc, String entityTypeId)
|
|
||||||
{
|
|
||||||
var entityType = dc.Table<EntityType>().FirstOrDefault(x => x.Id == entityTypeId);
|
|
||||||
if (entityType == null) return;
|
|
||||||
|
|
||||||
dc.Table<EntityType>().Remove(entityType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
using EntityFrameworkCore.BootKit;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace BotSharp.Core.Entities
|
|
||||||
{
|
|
||||||
public static class EntrySynonymDriver
|
|
||||||
{
|
|
||||||
public static void CreateEntitySynonym(this EntityType agent, Database dc, EntrySynonym entity)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
using BotSharp.Core.Agents;
|
|
||||||
using BotSharp.Core.Engines;
|
|
||||||
using EntityFrameworkCore.BootKit;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace BotSharp.Core.Intents
|
|
||||||
{
|
|
||||||
public static class IntentDriver
|
|
||||||
{
|
|
||||||
public static Intent GetIntent(this IBotPlatform bot, Database dc, string intentId)
|
|
||||||
{
|
|
||||||
var intent = dc.Table<Intent>()
|
|
||||||
.Include(x => x.Contexts)
|
|
||||||
.Include(x => x.Responses).ThenInclude(x => x.Contexts)
|
|
||||||
.Include(x => x.Responses).ThenInclude(x => x.Parameters).ThenInclude(x => x.Prompts)
|
|
||||||
.Include(x => x.Responses).ThenInclude(x => x.Messages)
|
|
||||||
.Include(x => x.UserSays).ThenInclude(x => x.Data)
|
|
||||||
.FirstOrDefault(x => x.Id == intentId);
|
|
||||||
|
|
||||||
// order parts by time
|
|
||||||
intent.UserSays.ForEach(x => x.Data = x.Data.OrderBy(d => d.UpdatedTime).ToList());
|
|
||||||
|
|
||||||
return intent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String CreateIntent(this Agent agent, Database dc, Intent intent)
|
|
||||||
{
|
|
||||||
if (dc.Table<Intent>().Any(x => x.Id == intent.Id)) return intent.Id;
|
|
||||||
|
|
||||||
dc.Table<Intent>().Add(intent);
|
|
||||||
|
|
||||||
return intent.Id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +1,12 @@
|
||||||
using BotSharp.Platform.Abstraction;
|
using BotSharp.Core.Engines;
|
||||||
|
using BotSharp.Platform.Abstraction;
|
||||||
using BotSharp.Platform.Models;
|
using BotSharp.Platform.Models;
|
||||||
using DotNetToolkit;
|
using DotNetToolkit;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
|
|
@ -23,6 +26,38 @@ namespace BotSharp.Core
|
||||||
return Storage.Query();
|
return Storage.Query();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TAgent LoadAgentFromFile<TImporter>(string dataDir) where TImporter : IAgentImporter<TAgent>, new()
|
||||||
|
{
|
||||||
|
var meta = LoadMeta(dataDir);
|
||||||
|
var importer = new TImporter();
|
||||||
|
|
||||||
|
importer.AgentDir = dataDir;
|
||||||
|
|
||||||
|
// Load agent summary
|
||||||
|
var agent = importer.LoadAgent(meta);
|
||||||
|
|
||||||
|
// Load user custom entities
|
||||||
|
importer.LoadCustomEntities(agent);
|
||||||
|
|
||||||
|
// Load agent intents
|
||||||
|
importer.LoadIntents(agent);
|
||||||
|
|
||||||
|
// Load system buildin entities
|
||||||
|
importer.LoadBuildinEntities(agent);
|
||||||
|
|
||||||
|
// Generate corpus
|
||||||
|
importer.AssembleTrainData(agent);
|
||||||
|
|
||||||
|
return default(TAgent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private AgentImportHeader LoadMeta(string dataDir)
|
||||||
|
{
|
||||||
|
// load meta
|
||||||
|
string metaJson = File.ReadAllText(Path.Combine(dataDir, "meta.json"));
|
||||||
|
|
||||||
|
return JsonConvert.DeserializeObject<AgentImportHeader>(metaJson);
|
||||||
|
}
|
||||||
|
|
||||||
public TAgent GetAgentById(string agentId)
|
public TAgent GetAgentById(string agentId)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
using BotSharp.Core.Agents;
|
using BotSharp.Platform.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Engines
|
namespace BotSharp.Platform.Abstraction
|
||||||
{
|
{
|
||||||
public interface IAgentImporter
|
public interface IAgentImporter<TAgent>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// data dir
|
/// data dir
|
||||||
|
|
@ -16,30 +16,30 @@ namespace BotSharp.Core.Engines
|
||||||
/// Load agent summary
|
/// Load agent summary
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Agent LoadAgent(AgentImportHeader agentHeader);
|
TAgent LoadAgent(AgentImportHeader agentHeader);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Load user customized entity type which defined in dictionary
|
/// Load user customized entity type which defined in dictionary
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="agent"></param>
|
/// <param name="agent"></param>
|
||||||
void LoadCustomEntities(Agent agent);
|
void LoadCustomEntities(TAgent agent);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Load user customized intents
|
/// Load user customized intents
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="agent"></param>
|
/// <param name="agent"></param>
|
||||||
void LoadIntents(Agent agent);
|
void LoadIntents(TAgent agent);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add entities that labeled in intent.UserSays into user customized entity dictionary
|
/// Add entities that labeled in intent.UserSays into user customized entity dictionary
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="agent"></param>
|
/// <param name="agent"></param>
|
||||||
void LoadBuildinEntities(Agent agent);
|
void LoadBuildinEntities(TAgent agent);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// generate training data
|
/// generate training data
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="agent"></param>
|
/// <param name="agent"></param>
|
||||||
void AssembleTrainData(Agent agent);
|
void AssembleTrainData(TAgent agent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -31,6 +31,14 @@ namespace BotSharp.Platform.Abstraction
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
TrainingCorpus ExtractorCorpus(TAgent agent);
|
TrainingCorpus ExtractorCorpus(TAgent agent);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Load agent from files.
|
||||||
|
/// There must contain a meta.json
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dataDir"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
TAgent LoadAgentFromFile<TImporter>(string dataDir) where TImporter : IAgentImporter<TAgent>, new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Models
|
namespace BotSharp.Platform.Models
|
||||||
{
|
{
|
||||||
public enum AIResponseMessageType
|
public enum AIResponseMessageType
|
||||||
{
|
{
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
using BotSharp.Core.Agents;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Engines
|
namespace BotSharp.Platform.Models
|
||||||
{
|
{
|
||||||
public class AgentImportHeader
|
public class AgentImportHeader
|
||||||
{
|
{
|
||||||
|
|
@ -1,15 +1,19 @@
|
||||||
using EntityFrameworkCore.BootKit;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Agents
|
namespace BotSharp.Platform.Models
|
||||||
{
|
{
|
||||||
[Table("Bot_AgentIntegration")]
|
public class AgentIntegration
|
||||||
public class AgentIntegration : DbRecord, IDbRecord
|
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Guid
|
||||||
|
/// </summary>
|
||||||
|
[StringLength(36)]
|
||||||
|
public String Id { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
[StringLength(36)]
|
[StringLength(36)]
|
||||||
public String AgentId { get; set; }
|
public String AgentId { get; set; }
|
||||||
|
|
@ -1,14 +1,12 @@
|
||||||
using EntityFrameworkCore.BootKit;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Intents
|
namespace BotSharp.Platform.Models.AiResponse
|
||||||
{
|
{
|
||||||
[Table("Bot_ResponseParameterPrompt")]
|
public class ResponseParameterPrompt
|
||||||
public class ResponseParameterPrompt : DbRecord, IDbRecord
|
|
||||||
{
|
{
|
||||||
[Required]
|
[Required]
|
||||||
[StringLength(36)]
|
[StringLength(36)]
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
using DotNetToolkit;
|
using System;
|
||||||
using EntityFrameworkCore.BootKit;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Intents
|
namespace BotSharp.Platform.Models.Intents
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Intent Table
|
/// Intent Table
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Table("Bot_Intent")]
|
public class Intent
|
||||||
public class Intent : DbRecord, IDbRecord
|
|
||||||
{
|
{
|
||||||
[Required]
|
[Required]
|
||||||
[StringLength(36)]
|
[StringLength(36)]
|
||||||
|
|
@ -39,9 +36,10 @@ namespace BotSharp.Core.Intents
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Contexts == null || Contexts.Count == 0
|
return string.Empty;
|
||||||
|
/*return Contexts == null || Contexts.Count == 0
|
||||||
? Guid.Empty.ToString("N")
|
? Guid.Empty.ToString("N")
|
||||||
: $"{String.Join(",", Contexts.OrderBy(x => x.Name).Select(x => x.Name))}".GetMd5Hash();
|
: $"{String.Join(",", Contexts.OrderBy(x => x.Name).Select(x => x.Name))}".GetMd5Hash();*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1,14 +1,12 @@
|
||||||
using EntityFrameworkCore.BootKit;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Intents
|
namespace BotSharp.Platform.Models.Intents
|
||||||
{
|
{
|
||||||
[Table("Bot_IntentEvent")]
|
public class IntentEvent
|
||||||
public class IntentEvent : DbRecord, IDbRecord
|
|
||||||
{
|
{
|
||||||
[Required]
|
[Required]
|
||||||
[StringLength(36)]
|
[StringLength(36)]
|
||||||
|
|
@ -1,16 +1,13 @@
|
||||||
using EntityFrameworkCore.BootKit;
|
using System;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Intents
|
namespace BotSharp.Platform.Models.Intents
|
||||||
{
|
{
|
||||||
[Table("Bot_IntentExpression")]
|
public class IntentExpression
|
||||||
public class IntentExpression : DbRecord, IDbRecord
|
|
||||||
{
|
{
|
||||||
public IntentExpression()
|
public IntentExpression()
|
||||||
{
|
{
|
||||||
|
|
@ -23,10 +20,5 @@ namespace BotSharp.Core.Intents
|
||||||
|
|
||||||
[ForeignKey("ExpressionId")]
|
[ForeignKey("ExpressionId")]
|
||||||
public List<IntentExpressionPart> Data { get; set; }
|
public List<IntentExpressionPart> Data { get; set; }
|
||||||
|
|
||||||
public bool IsExist(Database dc)
|
|
||||||
{
|
|
||||||
return dc.Table<IntentExpression>().Any(x => x.IntentId == IntentId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,14 +1,12 @@
|
||||||
using EntityFrameworkCore.BootKit;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Intents
|
namespace BotSharp.Platform.Models.Intents
|
||||||
{
|
{
|
||||||
[Table("Bot_IntentExpressionPart")]
|
public class IntentExpressionPart
|
||||||
public class IntentExpressionPart : DbRecord, IDbRecord
|
|
||||||
{
|
{
|
||||||
[Required]
|
[Required]
|
||||||
[StringLength(36)]
|
[StringLength(36)]
|
||||||
|
|
@ -27,5 +25,7 @@ namespace BotSharp.Core.Intents
|
||||||
public int Start { get; set; }
|
public int Start { get; set; }
|
||||||
|
|
||||||
public Boolean UserDefined { get; set; }
|
public Boolean UserDefined { get; set; }
|
||||||
|
|
||||||
|
public DateTime UpdatedTime { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,14 +1,12 @@
|
||||||
using EntityFrameworkCore.BootKit;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Intents
|
namespace BotSharp.Platform.Models.Intents
|
||||||
{
|
{
|
||||||
[Table("Bot_IntentInputContext")]
|
public class IntentInputContext
|
||||||
public class IntentInputContext : DbRecord, IDbRecord
|
|
||||||
{
|
{
|
||||||
[Required]
|
[Required]
|
||||||
[StringLength(36)]
|
[StringLength(36)]
|
||||||
|
|
@ -1,15 +1,19 @@
|
||||||
using EntityFrameworkCore.BootKit;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Intents
|
namespace BotSharp.Platform.Models.Intents
|
||||||
{
|
{
|
||||||
[Table("Bot_IntentResponse")]
|
public class IntentResponse
|
||||||
public class IntentResponse : DbRecord, IDbRecord
|
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Guid
|
||||||
|
/// </summary>
|
||||||
|
[StringLength(36)]
|
||||||
|
public String Id { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
[StringLength(36)]
|
[StringLength(36)]
|
||||||
public String IntentId { get; set; }
|
public String IntentId { get; set; }
|
||||||
|
|
@ -1,14 +1,12 @@
|
||||||
using EntityFrameworkCore.BootKit;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Intents
|
namespace BotSharp.Platform.Models.Intents
|
||||||
{
|
{
|
||||||
[Table("Bot_IntentResponseContext")]
|
public class IntentResponseContext
|
||||||
public class IntentResponseContext : DbRecord, IDbRecord
|
|
||||||
{
|
{
|
||||||
[Required]
|
[Required]
|
||||||
[StringLength(36)]
|
[StringLength(36)]
|
||||||
|
|
@ -1,17 +1,12 @@
|
||||||
using BotSharp.Core.Models;
|
using System;
|
||||||
using EntityFrameworkCore.BootKit;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Intents
|
namespace BotSharp.Platform.Models.Intents
|
||||||
{
|
{
|
||||||
[Table("Bot_IntentResponseMessage")]
|
public class IntentResponseMessage
|
||||||
public class IntentResponseMessage : DbRecord, IDbRecord
|
|
||||||
{
|
{
|
||||||
[Required]
|
[Required]
|
||||||
[StringLength(36)]
|
[StringLength(36)]
|
||||||
|
|
@ -39,6 +34,8 @@ namespace BotSharp.Core.Intents
|
||||||
public String CardJson { get; set; }
|
public String CardJson { get; set; }
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public JObject Payload { get; set; }
|
public Object Payload { get; set; }
|
||||||
|
|
||||||
|
public DateTime UpdatedTime { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,14 +1,13 @@
|
||||||
using EntityFrameworkCore.BootKit;
|
using BotSharp.Platform.Models.AiResponse;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Intents
|
namespace BotSharp.Platform.Models.Intents
|
||||||
{
|
{
|
||||||
[Table("Bot_IntentResponseParameter")]
|
public class IntentResponseParameter
|
||||||
public class IntentResponseParameter : DbRecord, IDbRecord
|
|
||||||
{
|
{
|
||||||
[Required]
|
[Required]
|
||||||
[StringLength(36)]
|
[StringLength(36)]
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Engines
|
namespace BotSharp.Platform.Models
|
||||||
{
|
{
|
||||||
public enum PlatformType
|
public enum PlatformType
|
||||||
{
|
{
|
||||||
|
|
@ -73,8 +73,11 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Remove="Authentication\**" />
|
<Compile Remove="Authentication\**" />
|
||||||
|
<Compile Remove="Rasa\**" />
|
||||||
<EmbeddedResource Remove="Authentication\**" />
|
<EmbeddedResource Remove="Authentication\**" />
|
||||||
|
<EmbeddedResource Remove="Rasa\**" />
|
||||||
<None Remove="Authentication\**" />
|
<None Remove="Authentication\**" />
|
||||||
|
<None Remove="Rasa\**" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
using BotSharp.Core.Agents;
|
using BotSharp.Core.Agents;
|
||||||
using BotSharp.Core.Engines;
|
using BotSharp.Core.Engines;
|
||||||
using BotSharp.Core.Engines.Dialogflow;
|
|
||||||
using BotSharp.Core.Models;
|
|
||||||
using BotSharp.NLP;
|
using BotSharp.NLP;
|
||||||
|
using BotSharp.Platform.Models;
|
||||||
using BotSharp.RestApi.Integrations.FacebookMessenger;
|
using BotSharp.RestApi.Integrations.FacebookMessenger;
|
||||||
using DotNetToolkit;
|
using DotNetToolkit;
|
||||||
using EntityFrameworkCore.BootKit;
|
using EntityFrameworkCore.BootKit;
|
||||||
|
|
@ -79,7 +78,7 @@ namespace BotSharp.RestApi.Integrations
|
||||||
{
|
{
|
||||||
Console.WriteLine($"OnTextMessaged: {message.Message.Text}");
|
Console.WriteLine($"OnTextMessaged: {message.Message.Text}");
|
||||||
|
|
||||||
var ai = new ApiAi();
|
/*var ai = new ApiAi();
|
||||||
var agent = ai.LoadAgent(agentId);
|
var agent = ai.LoadAgent(agentId);
|
||||||
ai.AiConfig = new AIConfiguration(agent.ClientAccessToken, SupportedLanguage.English) { AgentId = agentId };
|
ai.AiConfig = new AIConfiguration(agent.ClientAccessToken, SupportedLanguage.English) { AgentId = agentId };
|
||||||
ai.AiConfig.SessionId = message.Sender.Id;
|
ai.AiConfig.SessionId = message.Sender.Id;
|
||||||
|
|
@ -95,7 +94,7 @@ namespace BotSharp.RestApi.Integrations
|
||||||
{
|
{
|
||||||
Text = String.IsNullOrEmpty(aiResponse.Result.Fulfillment.Speech) ? aiResponse.Result.Action : aiResponse.Result.Fulfillment.Speech
|
Text = String.IsNullOrEmpty(aiResponse.Result.Fulfillment.Speech) ? aiResponse.Result.Action : aiResponse.Result.Fulfillment.Speech
|
||||||
}
|
}
|
||||||
});
|
});*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SendTextMessage(string accessToken, WebhookMessage<WebhookTextMessage> body)
|
private void SendTextMessage(string accessToken, WebhookMessage<WebhookTextMessage> body)
|
||||||
|
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace BotSharp.RestApi
|
|
||||||
{
|
|
||||||
[Route("v1/[controller]/[action]")]
|
|
||||||
public class IntentController : ControllerBase
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -83,6 +83,9 @@
|
||||||
<Content Update="Settings\app.json">
|
<Content Update="Settings\app.json">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Update="Settings\DialogflowAi.json">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Update="Settings\ArticulateAi.json">
|
<Content Update="Settings\ArticulateAi.json">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|
|
||||||
36
BotSharp.WebHost/Settings/DialogflowAi.json
Normal file
36
BotSharp.WebHost/Settings/DialogflowAi.json
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
{
|
||||||
|
"DialogflowAi": {
|
||||||
|
"Lang": "en",
|
||||||
|
|
||||||
|
"AgentStorage": "AgentStorageInRedis",
|
||||||
|
|
||||||
|
"Provider": "BotSharpProvider",
|
||||||
|
"BotSharpProvider": {
|
||||||
|
},
|
||||||
|
|
||||||
|
"Pipe": "BotSharpTokenizer, BotSharpTagger, BotSharpCRFNer, BotSharpIntentClassifier",
|
||||||
|
|
||||||
|
"BotSharpTokenizer": {
|
||||||
|
"tokenizer": "TreebankTokenizer"
|
||||||
|
},
|
||||||
|
|
||||||
|
"BotSharpIntentClassifier": {
|
||||||
|
"classifer": "NaiveBayesClassifier"
|
||||||
|
},
|
||||||
|
|
||||||
|
"BotSharpTagger": {
|
||||||
|
"tagger": "NGramTagger"
|
||||||
|
},
|
||||||
|
|
||||||
|
"BotSharpCRFNer": {
|
||||||
|
"template": "|App_Data|CRFLite/template.en"
|
||||||
|
},
|
||||||
|
|
||||||
|
"WitAiEntityRecognizer": {
|
||||||
|
"url": "https://api.wit.ai",
|
||||||
|
"resource": "message",
|
||||||
|
"serverAccessToken": "SERVER_ACCESS_TOKEN",
|
||||||
|
"version": "20180811"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -11,7 +11,7 @@ namespace BotSharp.WebHost
|
||||||
{
|
{
|
||||||
public void Apply(Operation operation, OperationFilterContext context)
|
public void Apply(Operation operation, OperationFilterContext context)
|
||||||
{
|
{
|
||||||
if (operation.OperationId == "V1AgentRestorePost")
|
if (operation.OperationId == "V1AgentImportPost")
|
||||||
{
|
{
|
||||||
operation.Parameters.Clear();
|
operation.Parameters.Clear();
|
||||||
|
|
||||||
|
|
|
||||||
23
BotSharp.sln
23
BotSharp.sln
|
|
@ -10,7 +10,6 @@ EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.WebHost", "BotSharp.WebHost\BotSharp.WebHost.csproj", "{03DCA427-327A-4FC9-9A2F-57D17F16708C}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.WebHost", "BotSharp.WebHost\BotSharp.WebHost.csproj", "{03DCA427-327A-4FC9-9A2F-57D17F16708C}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
{C2FDC855-BD88-4041-B0FF-3AA8A1C11A22} = {C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}
|
{C2FDC855-BD88-4041-B0FF-3AA8A1C11A22} = {C2FDC855-BD88-4041-B0FF-3AA8A1C11A22}
|
||||||
{75B02A7C-EDB3-4082-9C1F-471773E760C3} = {75B02A7C-EDB3-4082-9C1F-471773E760C3}
|
|
||||||
{184F8B93-68C2-4849-9625-4023C4360990} = {184F8B93-68C2-4849-9625-4023C4360990}
|
{184F8B93-68C2-4849-9625-4023C4360990} = {184F8B93-68C2-4849-9625-4023C4360990}
|
||||||
{62F08F9F-16C2-4754-90B0-B604DC18AE23} = {62F08F9F-16C2-4754-90B0-B604DC18AE23}
|
{62F08F9F-16C2-4754-90B0-B604DC18AE23} = {62F08F9F-16C2-4754-90B0-B604DC18AE23}
|
||||||
{C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72} = {C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}
|
{C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72} = {C4F2EAE5-F2C7-4F52-9DB2-7E76D7080C72}
|
||||||
|
|
@ -20,8 +19,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.NLP", "BotSharp.NL
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Voice", "BotSharp.Voice\BotSharp.Voice.csproj", "{184F8B93-68C2-4849-9625-4023C4360990}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Voice", "BotSharp.Voice\BotSharp.Voice.csproj", "{184F8B93-68C2-4849-9625-4023C4360990}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Vision", "BotSharp.Vision\BotSharp.Vision.csproj", "{75B02A7C-EDB3-4082-9C1F-471773E760C3}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Voice.UnitTest", "BotSharp.Voice.UnitTest\BotSharp.Voice.UnitTest.csproj", "{3F0CAAD4-564B-43FF-90BF-26AC47C9D677}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Voice.UnitTest", "BotSharp.Voice.UnitTest\BotSharp.Voice.UnitTest.csproj", "{3F0CAAD4-564B-43FF-90BF-26AC47C9D677}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.NLP.UnitTest", "BotSharp.NLP.UnitTest\BotSharp.NLP.UnitTest.csproj", "{8A1F6277-FFCB-4CCD-B798-876D8BE525A9}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.NLP.UnitTest", "BotSharp.NLP.UnitTest\BotSharp.NLP.UnitTest.csproj", "{8A1F6277-FFCB-4CCD-B798-876D8BE525A9}"
|
||||||
|
|
@ -150,26 +147,6 @@ Global
|
||||||
{184F8B93-68C2-4849-9625-4023C4360990}.Release|Any CPU.Build.0 = Release|Any CPU
|
{184F8B93-68C2-4849-9625-4023C4360990}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{184F8B93-68C2-4849-9625-4023C4360990}.Release|x64.ActiveCfg = Release|Any CPU
|
{184F8B93-68C2-4849-9625-4023C4360990}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
{184F8B93-68C2-4849-9625-4023C4360990}.Release|x64.Build.0 = Release|Any CPU
|
{184F8B93-68C2-4849-9625-4023C4360990}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{75B02A7C-EDB3-4082-9C1F-471773E760C3}.ARTICULATE|Any CPU.ActiveCfg = ARTICULATE|Any CPU
|
|
||||||
{75B02A7C-EDB3-4082-9C1F-471773E760C3}.ARTICULATE|Any CPU.Build.0 = ARTICULATE|Any CPU
|
|
||||||
{75B02A7C-EDB3-4082-9C1F-471773E760C3}.ARTICULATE|x64.ActiveCfg = ARTICULATE|Any CPU
|
|
||||||
{75B02A7C-EDB3-4082-9C1F-471773E760C3}.ARTICULATE|x64.Build.0 = ARTICULATE|Any CPU
|
|
||||||
{75B02A7C-EDB3-4082-9C1F-471773E760C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{75B02A7C-EDB3-4082-9C1F-471773E760C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{75B02A7C-EDB3-4082-9C1F-471773E760C3}.Debug|x64.ActiveCfg = Debug|Any CPU
|
|
||||||
{75B02A7C-EDB3-4082-9C1F-471773E760C3}.Debug|x64.Build.0 = Debug|Any CPU
|
|
||||||
{75B02A7C-EDB3-4082-9C1F-471773E760C3}.DIALOGFLOW|Any CPU.ActiveCfg = DIALOGFLOW|Any CPU
|
|
||||||
{75B02A7C-EDB3-4082-9C1F-471773E760C3}.DIALOGFLOW|Any CPU.Build.0 = DIALOGFLOW|Any CPU
|
|
||||||
{75B02A7C-EDB3-4082-9C1F-471773E760C3}.DIALOGFLOW|x64.ActiveCfg = DIALOGFLOW|Any CPU
|
|
||||||
{75B02A7C-EDB3-4082-9C1F-471773E760C3}.DIALOGFLOW|x64.Build.0 = DIALOGFLOW|Any CPU
|
|
||||||
{75B02A7C-EDB3-4082-9C1F-471773E760C3}.RASA|Any CPU.ActiveCfg = RASA|Any CPU
|
|
||||||
{75B02A7C-EDB3-4082-9C1F-471773E760C3}.RASA|Any CPU.Build.0 = RASA|Any CPU
|
|
||||||
{75B02A7C-EDB3-4082-9C1F-471773E760C3}.RASA|x64.ActiveCfg = RASA|Any CPU
|
|
||||||
{75B02A7C-EDB3-4082-9C1F-471773E760C3}.RASA|x64.Build.0 = RASA|Any CPU
|
|
||||||
{75B02A7C-EDB3-4082-9C1F-471773E760C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{75B02A7C-EDB3-4082-9C1F-471773E760C3}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{75B02A7C-EDB3-4082-9C1F-471773E760C3}.Release|x64.ActiveCfg = Release|Any CPU
|
|
||||||
{75B02A7C-EDB3-4082-9C1F-471773E760C3}.Release|x64.Build.0 = Release|Any CPU
|
|
||||||
{3F0CAAD4-564B-43FF-90BF-26AC47C9D677}.ARTICULATE|Any CPU.ActiveCfg = ARTICULATE|Any CPU
|
{3F0CAAD4-564B-43FF-90BF-26AC47C9D677}.ARTICULATE|Any CPU.ActiveCfg = ARTICULATE|Any CPU
|
||||||
{3F0CAAD4-564B-43FF-90BF-26AC47C9D677}.ARTICULATE|Any CPU.Build.0 = ARTICULATE|Any CPU
|
{3F0CAAD4-564B-43FF-90BF-26AC47C9D677}.ARTICULATE|Any CPU.Build.0 = ARTICULATE|Any CPU
|
||||||
{3F0CAAD4-564B-43FF-90BF-26AC47C9D677}.ARTICULATE|x64.ActiveCfg = ARTICULATE|Any CPU
|
{3F0CAAD4-564B-43FF-90BF-26AC47C9D677}.ARTICULATE|x64.ActiveCfg = ARTICULATE|Any CPU
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
using BotSharp.Core;
|
using BotSharp.Core;
|
||||||
using BotSharp.Core.Agents;
|
using BotSharp.Core.Agents;
|
||||||
using BotSharp.Core.Engines;
|
using BotSharp.Core.Engines;
|
||||||
using BotSharp.Core.Entities;
|
|
||||||
using BotSharp.Core.Intents;
|
|
||||||
using BotSharp.Core.Models;
|
|
||||||
using BotSharp.Models.NLP;
|
using BotSharp.Models.NLP;
|
||||||
using BotSharp.Platform.Abstraction;
|
using BotSharp.Platform.Abstraction;
|
||||||
using BotSharp.Platform.Models;
|
using BotSharp.Platform.Models;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using BotSharp.Core.Models;
|
using BotSharp.NLP;
|
||||||
using BotSharp.NLP;
|
|
||||||
using BotSharp.Platform.Models.AiRequest;
|
using BotSharp.Platform.Models.AiRequest;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
|
||||||
|
|
@ -3,22 +3,22 @@ using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using BotSharp.Core.Adapters.Dialogflow;
|
|
||||||
using BotSharp.Core.Agents;
|
using BotSharp.Core.Agents;
|
||||||
using BotSharp.Core.Entities;
|
using BotSharp.Platform.Abstraction;
|
||||||
using BotSharp.Core.Intents;
|
|
||||||
using BotSharp.Core.Models;
|
|
||||||
using BotSharp.Platform.Models;
|
using BotSharp.Platform.Models;
|
||||||
|
using BotSharp.Platform.Models.AiResponse;
|
||||||
|
using BotSharp.Platform.Models.Intents;
|
||||||
using DotNetToolkit;
|
using DotNetToolkit;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using Platform.Dialogflow.Models;
|
||||||
|
|
||||||
namespace BotSharp.Core.Engines
|
namespace Platform.Dialogflow
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Import agent from Dialogflow
|
/// Import agent from Dialogflow
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class AgentImporterInDialogflow : IAgentImporter
|
public class AgentImporterInDialogflow<TAgent> : IAgentImporter<TAgent> where TAgent : AgentModel
|
||||||
{
|
{
|
||||||
public string AgentDir { get; set; }
|
public string AgentDir { get; set; }
|
||||||
|
|
||||||
|
|
@ -28,7 +28,7 @@ namespace BotSharp.Core.Engines
|
||||||
/// <param name="agentName"></param>
|
/// <param name="agentName"></param>
|
||||||
/// <param name="agentDir"></param>
|
/// <param name="agentDir"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Agent LoadAgent(AgentImportHeader agentHeader)
|
public TAgent LoadAgent(AgentImportHeader agentHeader)
|
||||||
{
|
{
|
||||||
// load agent profile
|
// load agent profile
|
||||||
string data = File.ReadAllText(Path.Combine(AgentDir, "agent.json"));
|
string data = File.ReadAllText(Path.Combine(AgentDir, "agent.json"));
|
||||||
|
|
@ -36,8 +36,8 @@ namespace BotSharp.Core.Engines
|
||||||
agent.Name = agentHeader.Name;
|
agent.Name = agentHeader.Name;
|
||||||
agent.Id = agentHeader.Id;
|
agent.Id = agentHeader.Id;
|
||||||
|
|
||||||
var result = agent.ToObject<Agent>();
|
var result = agent.ToObject<TAgent>();
|
||||||
result.ClientAccessToken = agentHeader.ClientAccessToken;
|
/*result.ClientAccessToken = agentHeader.ClientAccessToken;
|
||||||
result.DeveloperAccessToken = agentHeader.DeveloperAccessToken;
|
result.DeveloperAccessToken = agentHeader.DeveloperAccessToken;
|
||||||
|
|
||||||
result.MlConfig = agent.ToObject<AgentMlConfig>();
|
result.MlConfig = agent.ToObject<AgentMlConfig>();
|
||||||
|
|
@ -47,14 +47,14 @@ namespace BotSharp.Core.Engines
|
||||||
{
|
{
|
||||||
agentHeader.Integrations.ForEach(x => x.AgentId = agent.Id);
|
agentHeader.Integrations.ForEach(x => x.AgentId = agent.Id);
|
||||||
result.Integrations = agentHeader.Integrations;
|
result.Integrations = agentHeader.Integrations;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadCustomEntities(Agent agent)
|
public void LoadCustomEntities(TAgent agent)
|
||||||
{
|
{
|
||||||
agent.Entities = new List<EntityType>();
|
//agent.Entities = new List<EntityType>();
|
||||||
string entityDir = Path.Combine(AgentDir, "entities");
|
string entityDir = Path.Combine(AgentDir, "entities");
|
||||||
if (!Directory.Exists(entityDir)) return;
|
if (!Directory.Exists(entityDir)) return;
|
||||||
|
|
||||||
|
|
@ -82,14 +82,14 @@ namespace BotSharp.Core.Engines
|
||||||
}
|
}
|
||||||
|
|
||||||
var entityType = entity.ToObject<EntityType>();
|
var entityType = entity.ToObject<EntityType>();
|
||||||
agent.Entities.Add(entityType);
|
//agent.Entities.Add(entityType);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadIntents(Agent agent)
|
public void LoadIntents(TAgent agent)
|
||||||
{
|
{
|
||||||
agent.Intents = new List<Intent>();
|
//agent.Intents = new List<Intent>();
|
||||||
string intentDir = Path.Combine(AgentDir, "intents");
|
string intentDir = Path.Combine(AgentDir, "intents");
|
||||||
if (!Directory.Exists(intentDir)) return;
|
if (!Directory.Exists(intentDir)) return;
|
||||||
|
|
||||||
|
|
@ -109,12 +109,12 @@ namespace BotSharp.Core.Engines
|
||||||
|
|
||||||
var intent = JsonConvert.DeserializeObject<DialogflowIntent>(intentJson);
|
var intent = JsonConvert.DeserializeObject<DialogflowIntent>(intentJson);
|
||||||
var newIntent = ImportIntentUserSays(agent, intent, fileName);
|
var newIntent = ImportIntentUserSays(agent, intent, fileName);
|
||||||
agent.Intents.Add(newIntent);
|
//agent.Intents.Add(newIntent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private Intent ImportIntentUserSays(Agent agent, DialogflowIntent intent, string fileName)
|
private Intent ImportIntentUserSays(TAgent agent, DialogflowIntent intent, string fileName)
|
||||||
{
|
{
|
||||||
// void id confict
|
// void id confict
|
||||||
intent.Id = Guid.NewGuid().ToString();
|
intent.Id = Guid.NewGuid().ToString();
|
||||||
|
|
@ -169,7 +169,7 @@ namespace BotSharp.Core.Engines
|
||||||
return newIntent;
|
return newIntent;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Intent ImportIntentResponse(Agent agent, DialogflowIntent intent)
|
private Intent ImportIntentResponse(TAgent agent, DialogflowIntent intent)
|
||||||
{
|
{
|
||||||
var newIntent = intent.ToObject<Intent>();
|
var newIntent = intent.ToObject<Intent>();
|
||||||
|
|
||||||
|
|
@ -237,9 +237,9 @@ namespace BotSharp.Core.Engines
|
||||||
return newIntent;
|
return newIntent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadBuildinEntities(Agent agent)
|
public void LoadBuildinEntities(TAgent agent)
|
||||||
{
|
{
|
||||||
agent.Intents.ForEach(intent =>
|
/*agent.Intents.ForEach(intent =>
|
||||||
{
|
{
|
||||||
if (intent.UserSays != null)
|
if (intent.UserSays != null)
|
||||||
{
|
{
|
||||||
|
|
@ -254,26 +254,26 @@ namespace BotSharp.Core.Engines
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadBuildinEntityTypePerUserSay(Agent agent, IntentExpressionPart data)
|
private void LoadBuildinEntityTypePerUserSay(TAgent agent, IntentExpressionPart data)
|
||||||
{
|
{
|
||||||
var existedEntityType = agent.Entities.FirstOrDefault(x => x.Name == data.Meta);
|
var existedEntityType = agent.Entities.FirstOrDefault(x => x.Name == data.Meta);
|
||||||
|
|
||||||
if (existedEntityType == null)
|
if (existedEntityType == null)
|
||||||
{
|
{
|
||||||
existedEntityType = new EntityType
|
/*existedEntityType = new EntityType
|
||||||
{
|
{
|
||||||
Name = data.Meta,
|
Name = data.Meta,
|
||||||
Entries = new List<EntityEntry>(),
|
Entries = new List<EntityEntry>(),
|
||||||
IsOverridable = true
|
IsOverridable = true
|
||||||
};
|
};*/
|
||||||
|
|
||||||
agent.Entities.Add(existedEntityType);
|
agent.Entities.Add(existedEntityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
var entries = existedEntityType.Entries.Select(x => x.Value.ToLower()).ToList();
|
/*var entries = existedEntityType.Entries.Select(x => x.Value.ToLower()).ToList();
|
||||||
if (!entries.Contains(data.Text.ToLower()))
|
if (!entries.Contains(data.Text.ToLower()))
|
||||||
{
|
{
|
||||||
existedEntityType.Entries.Add(new EntityEntry
|
existedEntityType.Entries.Add(new EntityEntry
|
||||||
|
|
@ -287,13 +287,13 @@ namespace BotSharp.Core.Engines
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AssembleTrainData(Agent agent)
|
public void AssembleTrainData(TAgent agent)
|
||||||
{
|
{
|
||||||
// convert agent to training corpus
|
// convert agent to training corpus
|
||||||
agent.Corpus = new TrainingCorpus
|
/*agent.Corpus = new TrainingCorpus
|
||||||
{
|
{
|
||||||
Entities = new List<TrainingEntity>(),
|
Entities = new List<TrainingEntity>(),
|
||||||
UserSays = new List<TrainingIntentExpression<TrainingIntentExpressionPart>>()
|
UserSays = new List<TrainingIntentExpression<TrainingIntentExpressionPart>>()
|
||||||
|
|
@ -316,7 +316,7 @@ namespace BotSharp.Core.Engines
|
||||||
.ToList()
|
.ToList()
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using BotSharp.Core.Models;
|
using Platform.Dialogflow.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
@ -6,7 +6,7 @@ using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Engines.Dialogflow
|
namespace BotSharp.Core.Engines.Dialogflow
|
||||||
{
|
{
|
||||||
public class ApiAi : ApiAiBase, IBotPlatform
|
public class ApiAi : ApiAiBase
|
||||||
{
|
{
|
||||||
private AIDataService dataService;
|
private AIDataService dataService;
|
||||||
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace BotSharp.Core.Engines.Dialogflow
|
||||||
|
|
||||||
if(dataService == null)
|
if(dataService == null)
|
||||||
{
|
{
|
||||||
dataService = new AIDataService(AiConfig);
|
// dataService = new AIDataService(AiConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
return dataService.Request(request);
|
return dataService.Request(request);
|
||||||
|
|
@ -4,7 +4,7 @@ using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Engines.Dialogflow
|
namespace BotSharp.Core.Engines.Dialogflow
|
||||||
{
|
{
|
||||||
public class ApiAiBase : BotEngineBase
|
public class ApiAiBase
|
||||||
{
|
{
|
||||||
protected float[] TrimSilence(float[] samples)
|
protected float[] TrimSilence(float[] samples)
|
||||||
{
|
{
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
using BotSharp.Core.Agents;
|
using BotSharp.Core.Agents;
|
||||||
using BotSharp.Core.Engines;
|
using BotSharp.Core.Engines;
|
||||||
using BotSharp.Core.Engines.BotSharp;
|
|
||||||
using BotSharp.Core.Models;
|
|
||||||
using DotNetToolkit;
|
using DotNetToolkit;
|
||||||
using EntityFrameworkCore.BootKit;
|
using EntityFrameworkCore.BootKit;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Platform.Dialogflow.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
@ -16,53 +15,34 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BotSharp.RestApi
|
namespace Platform.Dialogflow.Controllers
|
||||||
{
|
{
|
||||||
|
#if DIALOGFLOW
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Agent
|
/// Agent
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("v1/[controller]/[action]")]
|
[Route("v1/[controller]")]
|
||||||
public class AgentController : ControllerBase
|
public class AgentController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly IBotPlatform _platform;
|
private DialogflowAi<AgentModel> builder;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initialize dialog controller and get a platform instance
|
/// Initialize dialog controller and get a platform instance
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="platform"></param>
|
/// <param name="platform"></param>
|
||||||
public AgentController(IBotPlatform platform)
|
public AgentController(IConfiguration configuration)
|
||||||
{
|
{
|
||||||
_platform = platform;
|
builder = new DialogflowAi<AgentModel>();
|
||||||
}
|
builder.PlatformConfig = configuration.GetSection("DialogflowAi");
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
public ActionResult<List<Agent>> AllAgents()
|
|
||||||
{
|
|
||||||
List<Agent> agents = new List<Agent>();
|
|
||||||
|
|
||||||
string agentDir = Path.Combine(AppDomain.CurrentDomain.GetData("DataPath").ToString(), "Projects");
|
|
||||||
|
|
||||||
var names = Directory.EnumerateDirectories(agentDir).Select(x => x.Split(Path.DirectorySeparatorChar).Last()).ToList();
|
|
||||||
|
|
||||||
names.ForEach(name =>
|
|
||||||
{
|
|
||||||
agents.Add(new Agent
|
|
||||||
{
|
|
||||||
Name = name
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
return agents;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Restore a agent from a uploaded zip file
|
/// Import a agent from a uploaded zip file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="file"></param>
|
/// <param name="file"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost("import")]
|
||||||
public async Task<ActionResult> Restore(IFormFile uploadedFile)
|
public async Task<ActionResult> Import(IFormFile uploadedFile)
|
||||||
{
|
{
|
||||||
if (uploadedFile == null || uploadedFile.Length == 0)
|
if (uploadedFile == null || uploadedFile.Length == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -77,7 +57,8 @@ namespace BotSharp.RestApi
|
||||||
await uploadedFile.CopyToAsync(stream);
|
await uploadedFile.CopyToAsync(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
string dest = Path.Combine(AppDomain.CurrentDomain.GetData("DataPath").ToString(), "Projects", uploadedFile.FileName.Split('.').First(), "model_" + DateTime.UtcNow.ToString("MMddyyyyHHmm"));
|
string dest = Path.Combine(AppDomain.CurrentDomain.GetData("DataPath").ToString(), "Projects", uploadedFile.FileName.Split('.').First(), "tmp");
|
||||||
|
System.IO.Directory.Delete(dest, true);
|
||||||
|
|
||||||
Console.WriteLine($"Extract zip file to {dest}");
|
Console.WriteLine($"Extract zip file to {dest}");
|
||||||
ZipFile.ExtractToDirectory(filePath, dest);
|
ZipFile.ExtractToDirectory(filePath, dest);
|
||||||
|
|
@ -85,11 +66,7 @@ namespace BotSharp.RestApi
|
||||||
System.IO.File.Delete(filePath);
|
System.IO.File.Delete(filePath);
|
||||||
|
|
||||||
Console.WriteLine($"LoadAgentFromFile {dest}");
|
Console.WriteLine($"LoadAgentFromFile {dest}");
|
||||||
var agent = _platform.LoadAgentFromFile(dest);
|
var agent = builder.LoadAgentFromFile<AgentImporterInDialogflow<AgentModel>>(dest);
|
||||||
|
|
||||||
#if DIALOGFLOW
|
|
||||||
_platform.SaveAgentToDb();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return Ok(agent.Id);
|
return Ok(agent.Id);
|
||||||
}
|
}
|
||||||
|
|
@ -102,9 +79,8 @@ namespace BotSharp.RestApi
|
||||||
[HttpGet("{agentId}")]
|
[HttpGet("{agentId}")]
|
||||||
public ActionResult<Agent> Dump([FromRoute] String agentId)
|
public ActionResult<Agent> Dump([FromRoute] String agentId)
|
||||||
{
|
{
|
||||||
var agent = _platform.LoadAgent(agentId);
|
return Ok();
|
||||||
|
|
||||||
return Ok(agent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
using BotSharp.Core.Adapters.Dialogflow;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Platform.Dialogflow.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
using BotSharp.Core.Engines;
|
using BotSharp.Core.Engines;
|
||||||
using BotSharp.Core.Models;
|
|
||||||
using BotSharp.NLP;
|
using BotSharp.NLP;
|
||||||
|
using BotSharp.Platform.Models;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Platform.Dialogflow.Models;
|
||||||
using Platform.Dialogflow.ViewModels;
|
using Platform.Dialogflow.ViewModels;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
@ -44,8 +45,8 @@ namespace Platform.Dialogflow.Controllers
|
||||||
public ActionResult<AIResponse> Query(QueryModel request)
|
public ActionResult<AIResponse> Query(QueryModel request)
|
||||||
{
|
{
|
||||||
String clientAccessToken = (User.Identity as ClaimsIdentity).Claims.FirstOrDefault(x => x.Type == "UserId")?.Value;
|
String clientAccessToken = (User.Identity as ClaimsIdentity).Claims.FirstOrDefault(x => x.Type == "UserId")?.Value;
|
||||||
_platform.AiConfig = new AIConfiguration(clientAccessToken, SupportedLanguage.English);
|
//_platform.AiConfig = new AIConfiguration(clientAccessToken, SupportedLanguage.English);
|
||||||
_platform.AiConfig.SessionId = request.SessionId;
|
//_platform.AiConfig.SessionId = request.SessionId;
|
||||||
|
|
||||||
// find a model according to clientAccessToken
|
// find a model according to clientAccessToken
|
||||||
string projectPath = String.Empty;
|
string projectPath = String.Empty;
|
||||||
|
|
@ -85,9 +86,9 @@ namespace Platform.Dialogflow.Controllers
|
||||||
|
|
||||||
Console.WriteLine($"LoadAgentFromFile {dataDir}");
|
Console.WriteLine($"LoadAgentFromFile {dataDir}");
|
||||||
|
|
||||||
_platform.LoadAgentFromFile(dataDir);
|
//_platform.LoadAgentFromFile(dataDir);
|
||||||
|
|
||||||
var aIResponse = _platform.TextRequest(new AIRequest
|
/*var aIResponse = _platform.TextRequest(new AIRequest
|
||||||
{
|
{
|
||||||
Timezone = request.Timezone,
|
Timezone = request.Timezone,
|
||||||
Contexts = request?.Contexts?.Select(x => new AIContext { Name = x })?.ToList(),
|
Contexts = request?.Contexts?.Select(x => new AIContext { Name = x })?.ToList(),
|
||||||
|
|
@ -95,9 +96,9 @@ namespace Platform.Dialogflow.Controllers
|
||||||
Query = new String[] { request.Query },
|
Query = new String[] { request.Query },
|
||||||
AgentDir = projectPath,
|
AgentDir = projectPath,
|
||||||
Model = model
|
Model = model
|
||||||
});
|
});*/
|
||||||
|
|
||||||
return aIResponse;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
using BotSharp.Core.Agents;
|
using BotSharp.Core.Agents;
|
||||||
using BotSharp.Core.Engines;
|
using BotSharp.Core.Engines;
|
||||||
using BotSharp.Core.Engines.Rasa;
|
|
||||||
using BotSharp.Platform.Models;
|
using BotSharp.Platform.Models;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
@ -47,7 +46,7 @@ namespace Platform.Dialogflow.Controllers
|
||||||
|
|
||||||
Console.WriteLine($"LoadAgentFromFile {dataDir}");
|
Console.WriteLine($"LoadAgentFromFile {dataDir}");
|
||||||
|
|
||||||
var agent = _platform.LoadAgentFromFile(dataDir);
|
/*var agent = _platform.LoadAgentFromFile(dataDir);
|
||||||
|
|
||||||
var info = await trainer.Train(agent, new BotTrainOptions
|
var info = await trainer.Train(agent, new BotTrainOptions
|
||||||
{
|
{
|
||||||
|
|
@ -55,7 +54,9 @@ namespace Platform.Dialogflow.Controllers
|
||||||
Model = model
|
Model = model
|
||||||
});
|
});
|
||||||
|
|
||||||
return Ok(new { info = info });
|
return Ok(new { info = info });*/
|
||||||
|
|
||||||
|
return Ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Models
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
public class AIConfiguration
|
public class AIConfiguration
|
||||||
{
|
{
|
||||||
|
|
@ -3,7 +3,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Models
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
[JsonObject]
|
[JsonObject]
|
||||||
public class AIContext
|
public class AIContext
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using BotSharp.Core.Engines.Dialogflow.Http;
|
using BotSharp.Core.Engines.Dialogflow;
|
||||||
using BotSharp.Core.Models;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Serialization;
|
using Newtonsoft.Json.Serialization;
|
||||||
using System;
|
using System;
|
||||||
|
|
@ -9,7 +8,7 @@ using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Engines.Dialogflow
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
public class AIDataService
|
public class AIDataService
|
||||||
{
|
{
|
||||||
|
|
@ -3,7 +3,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Models
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
public class AIRequest : QuestionMetadata
|
public class AIRequest : QuestionMetadata
|
||||||
{
|
{
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Models
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
public class AIResponse
|
public class AIResponse
|
||||||
{
|
{
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Models
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
public class AIResponseCustomPayload : AIResponseMessageBase
|
public class AIResponseCustomPayload : AIResponseMessageBase
|
||||||
{
|
{
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Models
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
public class AIResponseFulfillment
|
public class AIResponseFulfillment
|
||||||
{
|
{
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
using System;
|
using BotSharp.Platform.Models;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Models
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
public class AIResponseMessageBase
|
public class AIResponseMessageBase
|
||||||
{
|
{
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Models
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
public class AIResponseMetadata
|
public class AIResponseMetadata
|
||||||
{
|
{
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using BotSharp.Core.Intents;
|
using BotSharp.Models.NLP;
|
||||||
using BotSharp.Models.NLP;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using System;
|
using System;
|
||||||
|
|
@ -8,7 +7,7 @@ using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Models
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
public class AIResponseResult
|
public class AIResponseResult
|
||||||
{
|
{
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Models
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
public class AIResponseStatus
|
public class AIResponseStatus
|
||||||
{
|
{
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
using BotSharp.Core.Models;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Engines.Dialogflow
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
public class AIServiceException : Exception
|
public class AIServiceException : Exception
|
||||||
{
|
{
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
using BotSharp.Platform.Models;
|
using BotSharp.Core.Agents;
|
||||||
|
using BotSharp.Platform.Models;
|
||||||
|
using BotSharp.Platform.Models.Intents;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Platform.Dialogflow.Models
|
namespace Platform.Dialogflow.Models
|
||||||
|
|
@ -10,29 +13,56 @@ namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
public AgentModel()
|
public AgentModel()
|
||||||
{
|
{
|
||||||
Entities = new List<EntityModel>();
|
CreatedDate = DateTime.UtcNow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Status { get; set; }
|
[Required]
|
||||||
|
[MaxLength(64)]
|
||||||
|
public String Name { get; set; }
|
||||||
|
|
||||||
public string Timezone { get; set; }
|
[MaxLength(256)]
|
||||||
|
public String Description { get; set; }
|
||||||
|
|
||||||
public string AgentName { get; set; }
|
public Boolean Published { get; set; }
|
||||||
|
|
||||||
public bool UseWebhook { get; set; }
|
[Required]
|
||||||
|
[MaxLength(5)]
|
||||||
|
public String Language { get; set; }
|
||||||
|
|
||||||
public bool UsePostFormat { get; set; }
|
/// <summary>
|
||||||
|
/// Only access text/ audio rquest
|
||||||
|
/// </summary>
|
||||||
|
[StringLength(32)]
|
||||||
|
public String ClientAccessToken { get; set; }
|
||||||
|
|
||||||
public bool ExtraTrainingData { get; set; }
|
/// <summary>
|
||||||
|
/// Developer can access more APIs
|
||||||
|
/// </summary>
|
||||||
|
[StringLength(32)]
|
||||||
|
public String DeveloperAccessToken { get; set; }
|
||||||
|
|
||||||
public List<String> FallbackResponses { get; set; }
|
public List<Intent> Intents { get; set; }
|
||||||
|
|
||||||
public bool EnableModelsPerDomain { get; set; }
|
[JsonProperty("entity_types")]
|
||||||
|
public List<EntityType> Entities { get; set; }
|
||||||
|
|
||||||
public decimal DomainClassifierThreshold { get; set; }
|
public String Birthday
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return CreatedDate.ToShortDateString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<EntityModel> Entities { get; set; }
|
[Required]
|
||||||
|
public DateTime CreatedDate { get; set; }
|
||||||
|
|
||||||
public DateTime LastTraining { get; set; }
|
public Boolean IsSkillSet { get; set; }
|
||||||
|
|
||||||
|
public AgentMlConfig MlConfig { get; set; }
|
||||||
|
|
||||||
|
public TrainingCorpus Corpus { get; set; }
|
||||||
|
|
||||||
|
public List<AgentIntegration> Integrations { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Adapters.Dialogflow
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
public class DialogflowAgent
|
public class DialogflowAgent
|
||||||
{
|
{
|
||||||
|
|
@ -10,7 +10,7 @@ using BotSharp.Platform.Models.AiRequest;
|
||||||
using BotSharp.Platform.Models.AiResponse;
|
using BotSharp.Platform.Models.AiResponse;
|
||||||
using Platform.Dialogflow.Models;
|
using Platform.Dialogflow.Models;
|
||||||
|
|
||||||
namespace Platform.Dialogflow
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
public class DialogflowAi<TAgent> :
|
public class DialogflowAi<TAgent> :
|
||||||
PlatformBuilderBase<TAgent>,
|
PlatformBuilderBase<TAgent>,
|
||||||
|
|
@ -3,7 +3,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Adapters.Dialogflow
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
[JsonObject]
|
[JsonObject]
|
||||||
public class DialogflowEntity
|
public class DialogflowEntity
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
using BotSharp.Core.Entities;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Adapters.Dialogflow
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
[JsonObject]
|
[JsonObject]
|
||||||
public class DialogflowEntityEntry
|
public class DialogflowEntityEntry
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
using BotSharp.Core.Intents;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Adapters.Dialogflow
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
public class DialogflowIntent
|
public class DialogflowIntent
|
||||||
{
|
{
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Adapters.Dialogflow
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
public class DialogflowIntentEvent
|
public class DialogflowIntentEvent
|
||||||
{
|
{
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Adapters.Dialogflow
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
public class DialogflowIntentExpression
|
public class DialogflowIntentExpression
|
||||||
{
|
{
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Adapters.Dialogflow
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
public class DialogflowIntentExpressionPart
|
public class DialogflowIntentExpressionPart
|
||||||
{
|
{
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
using BotSharp.Core.Intents;
|
using System;
|
||||||
using BotSharp.Core.Models;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Adapters.Dialogflow
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
public class DialogflowIntentResponse
|
public class DialogflowIntentResponse
|
||||||
{
|
{
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
using BotSharp.Core.Models;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Adapters.Dialogflow
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
public class DialogflowIntentResponseMessage : AIResponseMessageBase
|
public class DialogflowIntentResponseMessage : AIResponseMessageBase
|
||||||
{
|
{
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Adapters.Dialogflow
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
public class DialogflowIntentResponseParameter
|
public class DialogflowIntentResponseParameter
|
||||||
{
|
{
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Adapters.Dialogflow
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
public class DialogflowIntentResponseParameterPrompt
|
public class DialogflowIntentResponseParameterPrompt
|
||||||
{
|
{
|
||||||
|
|
@ -5,11 +5,16 @@ using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Entities
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
[Table("Bot_EntityEntry")]
|
public class EntityEntry
|
||||||
public class EntityEntry : DbRecord, IDbRecord
|
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Guid
|
||||||
|
/// </summary>
|
||||||
|
[StringLength(36)]
|
||||||
|
public String Id { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
[StringLength(36)]
|
[StringLength(36)]
|
||||||
public String EntityId { get; set; }
|
public String EntityId { get; set; }
|
||||||
|
|
@ -5,11 +5,16 @@ using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Entities
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
[Table("Bot_EntityType")]
|
public class EntityType
|
||||||
public class EntityType : DbRecord, IDbRecord
|
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Guid
|
||||||
|
/// </summary>
|
||||||
|
[StringLength(36)]
|
||||||
|
public String Id { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
[StringLength(36)]
|
[StringLength(36)]
|
||||||
public String AgentId { get; set; }
|
public String AgentId { get; set; }
|
||||||
|
|
@ -5,11 +5,16 @@ using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Entities
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
[Table("Bot_EntityEntrySynonym")]
|
public class EntrySynonym
|
||||||
public class EntrySynonym : DbRecord, IDbRecord
|
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Guid
|
||||||
|
/// </summary>
|
||||||
|
[StringLength(36)]
|
||||||
|
public String Id { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
[StringLength(36)]
|
[StringLength(36)]
|
||||||
public String EntityEntryId { get; set; }
|
public String EntityEntryId { get; set; }
|
||||||
|
|
@ -3,7 +3,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Models
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
[JsonObject]
|
[JsonObject]
|
||||||
public class OriginalRequest
|
public class OriginalRequest
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
using BotSharp.Core.Entities;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Models
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
[JsonObject]
|
[JsonObject]
|
||||||
public class QuestionMetadata
|
public class QuestionMetadata
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
using BotSharp.Core.Entities;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Models
|
namespace Platform.Dialogflow.Models
|
||||||
{
|
{
|
||||||
public class RequestExtras
|
public class RequestExtras
|
||||||
{
|
{
|
||||||
|
|
@ -4,7 +4,7 @@ using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace BotSharp.Core.Engines.Dialogflow.Http
|
namespace BotSharp.Core.Engines.Dialogflow
|
||||||
{
|
{
|
||||||
public class MultipartHttpClient
|
public class MultipartHttpClient
|
||||||
{
|
{
|
||||||
Loading…
Reference in a new issue