commit
8f05afa0f1
11
.editorconfig
Normal file
11
.editorconfig
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
# All files
|
||||
[*]
|
||||
indent_style = space
|
||||
charset = utf-8
|
||||
# prevent linux/windows problem
|
||||
end_of_line = lf
|
||||
|
||||
# Xml files
|
||||
[*.{xml,csproj}]
|
||||
indent_size = 2
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<TargetFramework>$(DefaultTargetFramework)</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
@ -9,8 +9,8 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
|
||||
<PackageReference Include="RestSharp" Version="106.6.10" />
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
<PackageReference Include="RestSharp" Version="106.11.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using BotSharp.Core.Modules;
|
||||
using BotSharp.Core.Modules;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
|
@ -14,7 +14,7 @@ namespace BotSharp.Channel.FacebookMessenger
|
|||
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env/*, IOptions<SenparcSetting> senparcSetting, IOptions<SenparcWeixinSetting> senparcWeixinSetting*/)
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env/*, IOptions<SenparcSetting> senparcSetting, IOptions<SenparcWeixinSetting> senparcWeixinSetting*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,17 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<TargetFramework>$(DefaultTargetFramework)</TargetFramework>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<Authors>Haiping Chen</Authors>
|
||||
<RepositoryUrl>https://github.com/Oceania2018/botsharp-channel-weixin</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<PackageProjectUrl>https://github.com/Oceania2018/botsharp-channel-weixin</PackageProjectUrl>
|
||||
<Copyright>Apache 2.0</Copyright>
|
||||
<PackageTags>botsharp, wechat, wexin, chatbot</PackageTags>
|
||||
<AssemblyVersion>0.1.1.0</AssemblyVersion>
|
||||
<FileVersion>0.1.1.0</FileVersion>
|
||||
<Version>0.1.1</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
@ -19,8 +20,8 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
|
||||
<PackageReference Include="Senparc.Weixin.MP.MVC" Version="7.2.16" />
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
<PackageReference Include="Senparc.Weixin.MP.MVC" Version="7.5.510" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
using BotSharp.Channel.Weixin.Models;
|
||||
using BotSharp.Channel.Weixin.Models;
|
||||
using BotSharp.Platform.Abstractions;
|
||||
using BotSharp.Platform.Dialogflow.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Senparc.CO2NET.AspNet.HttpUtility;
|
||||
using Senparc.CO2NET.HttpUtility;
|
||||
using Senparc.Weixin.MP;
|
||||
using Senparc.Weixin.MP.Entities.Request;
|
||||
|
|
@ -93,7 +94,7 @@ namespace BotSharp.Channel.Weixin.Controllers
|
|||
messageHandler.RequestDocument.Save(Path.Combine(logPath, string.Format("{0}_Request_{1}_{2}.txt", _getRandomFileName(),
|
||||
messageHandler.RequestMessage.FromUserName,
|
||||
messageHandler.RequestMessage.MsgType)));
|
||||
if (messageHandler.UsingEcryptMessage)
|
||||
if (messageHandler.UsingEncryptMessage)
|
||||
{
|
||||
messageHandler.EcryptRequestDocument.Save(Path.Combine(logPath, string.Format("{0}_Request_Ecrypt_{1}_{2}.txt", _getRandomFileName(),
|
||||
messageHandler.RequestMessage.FromUserName,
|
||||
|
|
@ -119,7 +120,7 @@ namespace BotSharp.Channel.Weixin.Controllers
|
|||
messageHandler.ResponseMessage.MsgType)));
|
||||
}
|
||||
|
||||
if (messageHandler.UsingEcryptMessage && messageHandler.FinalResponseDocument != null)
|
||||
if (messageHandler.UsingEncryptMessage && messageHandler.FinalResponseDocument != null)
|
||||
{
|
||||
//记录加密后的响应信息
|
||||
messageHandler.FinalResponseDocument.Save(Path.Combine(logPath, string.Format("{0}_Response_Final_{1}_{2}.txt", _getRandomFileName(),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/*----------------------------------------------------------------
|
||||
/*----------------------------------------------------------------
|
||||
Copyright (C) 2018 Senparc
|
||||
|
||||
文件名:CustomMessageContext.cs
|
||||
|
|
@ -12,18 +12,23 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
using Senparc.NeuChar;
|
||||
using Senparc.NeuChar.Context;
|
||||
using Senparc.NeuChar.Entities;
|
||||
using Senparc.Weixin.MP.MessageContexts;
|
||||
|
||||
namespace BotSharp.Channel.Weixin.Models
|
||||
{
|
||||
public class CustomMessageContext : MessageContext<IRequestMessageBase, IResponseMessageBase>
|
||||
public class CustomMessageContext : DefaultMpMessageContext
|
||||
{
|
||||
public CustomMessageContext()
|
||||
{
|
||||
{
|
||||
base.MessageContextRemoved += CustomMessageContext_MessageContextRemoved;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 当上下文过期,被移除时触发的时间
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/*----------------------------------------------------------------
|
||||
/*----------------------------------------------------------------
|
||||
Copyright (C) 2018 Senparc
|
||||
|
||||
文件名:CustomMessageHandler.cs
|
||||
|
|
@ -112,20 +112,22 @@ namespace BotSharp.Channel.Weixin.Models
|
|||
};
|
||||
}
|
||||
|
||||
public override void OnExecuting()
|
||||
public override async Task OnExecutingAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var CurrentMessageContext = await GetCurrentMessageContext();
|
||||
//测试MessageContext.StorageData
|
||||
if (CurrentMessageContext.StorageData == null)
|
||||
{
|
||||
CurrentMessageContext.StorageData = 0;
|
||||
}
|
||||
base.OnExecuting();
|
||||
await base.OnExecutingAsync(cancellationToken);
|
||||
}
|
||||
|
||||
public override void OnExecuted()
|
||||
public override async Task OnExecutedAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
base.OnExecuted();
|
||||
var CurrentMessageContext = await GetCurrentMessageContext();
|
||||
CurrentMessageContext.StorageData = ((int)CurrentMessageContext.StorageData) + 1;
|
||||
await base.OnExecutedAsync(cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using BotSharp.Core.Modules;
|
||||
using BotSharp.Core.Modules;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
|
@ -17,7 +17,7 @@ namespace BotSharp.Channel.Weixin
|
|||
.AddSenparcWeixinServices(config);
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env/*, IOptions<SenparcSetting> senparcSetting, IOptions<SenparcWeixinSetting> senparcWeixinSetting*/)
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env/*, IOptions<SenparcSetting> senparcSetting, IOptions<SenparcWeixinSetting> senparcWeixinSetting*/)
|
||||
{
|
||||
|
||||
//https://github.com/Senparc/Senparc.CO2NET/blob/master/Sample/Senparc.CO2NET.Sample.netcore/Startup.cs
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<TargetFramework>$(DefaultTargetFramework)</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
|
||||
|
|
@ -11,11 +11,11 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="$(MvcVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="$(MvcVersion)" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
|
@ -9,6 +10,6 @@ namespace BotSharp.Core.Abstractions
|
|||
public interface IInitializationLoader
|
||||
{
|
||||
int Priority { get; }
|
||||
void Initialize(IConfiguration config, IHostingEnvironment env);
|
||||
void Initialize(IConfiguration config, IWebHostEnvironment env);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>$(DefaultTargetFramework)</TargetFramework>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Version>0.4.0</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Label="Globals">
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
|
|
@ -10,22 +16,20 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Authors>Haiping Chen</Authors>
|
||||
<Company>SciSharp STACK</Company>
|
||||
<Product>AI Bot Platform Builder</Product>
|
||||
<Description>Open source AI Bot platform builder which is written in C# runs on .Net Core and is enterprise oriented. Integrated with multiple bot engines besides BotSharp bot engine. Modulized pipeline design make NLP tasks plugin easily. Abstract platform and NLP task, migrate existed chatbot from a platform into another platform perfectly through dump and restore.
|
||||
<Description>
|
||||
Open source AI Bot platform builder which is written in C# runs on .Net Core and is enterprise oriented. Integrated with multiple bot engines besides BotSharp bot engine. Modulized pipeline design make NLP tasks plugin easily. Abstract platform and NLP task, migrate existed chatbot from a platform into another platform perfectly through dump and restore.
|
||||
|
||||
If you feel that this project is helpful to you, please Star on the project, we will be very grateful.</Description>
|
||||
If you feel that this project is helpful to you, please Star on the project, we will be very grateful.
|
||||
</Description>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<RepositoryUrl>https://github.com/SciSharp/BotSharp</RepositoryUrl>
|
||||
<PackageTags>NLU, Chatbot, Bot, AI Bot, Artificial Intelligence</PackageTags>
|
||||
<Version>0.4.0</Version>
|
||||
<PackageReleaseNotes>Support dialogue status tracking.</PackageReleaseNotes>
|
||||
<Copyright>Since 2018 Haiping Chen</Copyright>
|
||||
<PackageProjectUrl>https://github.com/SciSharp/BotSharp</PackageProjectUrl>
|
||||
<AssemblyVersion>0.4.0.0</AssemblyVersion>
|
||||
<PackageIconUrl>https://raw.githubusercontent.com/SciSharp/BotSharp/master/docs/static/logos/BotSharp.png</PackageIconUrl>
|
||||
<PackageLicenseUrl>https://raw.githubusercontent.com/SciSharp/BotSharp/master/LICENSE</PackageLicenseUrl>
|
||||
</PropertyGroup>
|
||||
|
|
@ -61,17 +65,19 @@ If you feel that this project is helpful to you, please Star on the project, we
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CherubNLP" Version="0.2.0" />
|
||||
<PackageReference Include="Colorful.Console" Version="1.2.9" />
|
||||
<PackageReference Include="CSRedisCore" Version="3.1.5" />
|
||||
<PackageReference Include="Ding.Core" Version="1.0.0-preview-20190906-01" />
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CherubNLP" Version="0.3.0" />
|
||||
<PackageReference Include="Colorful.Console" Version="1.2.11" />
|
||||
<PackageReference Include="CSRedisCore" Version="3.6.5" />
|
||||
<PackageReference Include="Ding.Core" Version="1.1.8" />
|
||||
<PackageReference Include="DotNetToolkit" Version="1.7.0" />
|
||||
<PackageReference Include="EntityFrameworkCore.BootKit" Version="1.14.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
|
||||
<PackageReference Include="NumSharp" Version="0.20.1" />
|
||||
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
|
||||
<PackageReference Include="TensorFlow.NET" Version="0.11.2" />
|
||||
<PackageReference Include="EntityFrameworkCore.BootKit" Version="2.4.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="NumSharp" Version="0.20.5" />
|
||||
<PackageReference Include="TensorFlow.NET" Version="0.15.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using BotSharp.Platform.Models;
|
||||
using BotSharp.Platform.Models;
|
||||
using BotSharp.Platform.Models.AiRequest;
|
||||
using BotSharp.Platform.Models.AiResponse;
|
||||
using BotSharp.Platform.Models.Entities;
|
||||
|
|
@ -27,7 +27,7 @@ namespace BotSharp.Core.Engines
|
|||
Dc = new DefaultDataContextLoader().GetDefaultDc();
|
||||
}
|
||||
|
||||
public async Task<AiResponse> TextRequest(AiRequest request)
|
||||
public Task<AiResponse> TextRequest(AiRequest request)
|
||||
{
|
||||
var preditor = new BotPredictor();
|
||||
var doc = preditor.Predict(Agent, new AiRequest
|
||||
|
|
@ -44,8 +44,7 @@ namespace BotSharp.Core.Engines
|
|||
doc.Sentences[0].Entities = new List<NlpEntity>();
|
||||
}
|
||||
doc.Sentences[0].Entities.ForEach(x => parameters[x.Entity] = x.Value);
|
||||
|
||||
return new AiResponse
|
||||
return Task.FromResult(new AiResponse
|
||||
{
|
||||
/*Lang = request.Language,
|
||||
Timestamp = DateTime.UtcNow,
|
||||
|
|
@ -66,7 +65,7 @@ namespace BotSharp.Core.Engines
|
|||
IntentName = doc.Sentences[0].Intent?.Label
|
||||
}
|
||||
}*/
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/*public TrainingCorpus GetIntentExpressions(AgentBase agent)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using BotSharp.Core.Abstractions;
|
||||
using BotSharp.Core.Abstractions;
|
||||
using DotNetToolkit;
|
||||
using EntityFrameworkCore.BootKit;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
|
|
@ -14,7 +14,7 @@ namespace BotSharp.Core.Engines
|
|||
{
|
||||
public int Priority => 1;
|
||||
|
||||
public void Initialize(IConfiguration config, IHostingEnvironment env)
|
||||
public void Initialize(IConfiguration config, IWebHostEnvironment env)
|
||||
{
|
||||
var dc = new DefaultDataContextLoader().GetDefaultDc();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
|
@ -28,6 +28,6 @@ namespace BotSharp.Core.Modules
|
|||
/// <param name="app">
|
||||
/// Instance of <see cref="IApplicationBuilder"/>.
|
||||
/// </param>
|
||||
void Configure(IApplicationBuilder app, IHostingEnvironment env);
|
||||
void Configure(IApplicationBuilder app, IWebHostEnvironment env);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
|
@ -93,7 +93,7 @@ namespace BotSharp.Core.Modules
|
|||
/// <param name="app">
|
||||
/// Instance of <see cref="IApplicationBuilder"/>.
|
||||
/// </param>
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
foreach (IModule module in this._modules)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<TargetFramework>$(DefaultTargetFramework)</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using BotSharp.Core;
|
||||
using BotSharp.Core;
|
||||
using BotSharp.Core.AgentStorage;
|
||||
using BotSharp.Core.Modules;
|
||||
using BotSharp.Platform.Articulate.Models;
|
||||
|
|
@ -20,7 +20,7 @@ namespace BotSharp.Platform.Articulate
|
|||
PlatformConfigServiceRegister.Register<PlatformSettings>("articulateAi", services, config);
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,14 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<TargetFramework>$(DefaultTargetFramework)</TargetFramework>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Version>0.2.2</Version>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<Authors>Haiping Chen</Authors>
|
||||
<Description>BotSharp platform emulator which is compatible with Google Dialogflow.</Description>
|
||||
<PackageProjectUrl>https://github.com/Oceania2018/botsharp-dialogflow</PackageProjectUrl>
|
||||
|
|
@ -18,7 +23,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
<PackageReference Include="Turing.NET" Version="1.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using BotSharp.Platform.Dialogflow.Models;
|
||||
using BotSharp.Platform.Dialogflow.Models;
|
||||
using BotSharp.Platform.Dialogflow.ViewModels;
|
||||
using BotSharp.Platform.Models.Agents;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
|
@ -31,7 +31,7 @@ namespace BotSharp.Platform.Dialogflow.Controllers
|
|||
/// <summary>
|
||||
/// Import a agent from a uploaded zip file
|
||||
/// </summary>
|
||||
/// <param name="file"></param>
|
||||
/// <param name="uploadedFile">Upload Zip File, meta.json is the extra data for customized function.</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("import")]
|
||||
[ProducesResponseType(typeof(ImportedAgentViewModel), 200)]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using BotSharp.Core;
|
||||
using BotSharp.Core;
|
||||
using BotSharp.Core.AgentStorage;
|
||||
using BotSharp.Core.ContextStorage;
|
||||
using BotSharp.Core.Modules;
|
||||
|
|
@ -26,7 +26,7 @@ namespace BotSharp.Platform.Dialogflow
|
|||
ContextStorageServiceRegister.Register<AIContext>(services);
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<TargetFramework>$(DefaultTargetFramework)</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using BotSharp.Core;
|
||||
using BotSharp.Core;
|
||||
using BotSharp.Core.AgentStorage;
|
||||
using BotSharp.Core.Modules;
|
||||
using BotSharp.Platform.Rasa.Models;
|
||||
|
|
@ -21,7 +21,7 @@ namespace BotSharp.Platform.Rasa
|
|||
PlatformConfigServiceRegister.Register<PlatformSettings>("rasaAi", services, config);
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,30 +1,29 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<RuntimeIdentifiers>Portable;win10-x64;centos.7-x64</RuntimeIdentifiers>
|
||||
<TargetFramework>$(DefaultTargetFramework)</TargetFramework>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<Configurations>Debug;Release;</Configurations>
|
||||
<UserSecretsId>4ee89154-9131-4e6b-8fd5-d4f04a8d77c4</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||
<DefineConstants>$(DefineConstants);TRACE;DEBUG</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RASA|AnyCPU'">
|
||||
<DefineConstants>DEBUG;TRACE;RASA</DefineConstants>
|
||||
<DefineConstants>$(DefineConstants);RASA</DefineConstants>
|
||||
<OutputPath>bin\RASA</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DIALOGFLOW|AnyCPU'">
|
||||
<Optimize>false</Optimize>
|
||||
<DefineConstants>DEBUG;TRACE;NETCOREAPP;NETCOREAPP2_1</DefineConstants>
|
||||
<DefineConstants>$(DefineConstants);</DefineConstants>
|
||||
<OutputPath></OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ARTICULATE|AnyCPU'">
|
||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||
<DefineConstants>$(DefineConstants);TRACE;DEBUG</DefineConstants>
|
||||
<Optimize>false</Optimize>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
@ -72,19 +71,11 @@
|
|||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DotNetToolkit" Version="1.7.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.PlatformAbstractions" Version="1.1.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="4.0.1" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="4.0.1" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="4.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="$(MvcVersion)" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.5.1" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="5.5.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
|
@ -10,42 +11,49 @@ namespace BotSharp.WebHost
|
|||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
BuildWebHost(args).Run();
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
public static IWebHost BuildWebHost(string[] args) =>
|
||||
Microsoft.AspNetCore.WebHost.CreateDefaultBuilder(args)
|
||||
.ConfigureAppConfiguration((hostingContext, config) =>
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args)
|
||||
{
|
||||
return Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHostDefaults(webHost =>
|
||||
{
|
||||
var env = hostingContext.HostingEnvironment;
|
||||
string dir = Path.GetFullPath(env.ContentRootPath);
|
||||
string settingsFolder = Path.Combine(dir, "Settings");
|
||||
|
||||
// locate setting folder
|
||||
if (!Directory.Exists(settingsFolder))
|
||||
webHost
|
||||
.ConfigureAppConfiguration((hostingContext, config) =>
|
||||
{
|
||||
dir = Path.GetFullPath(env.ContentRootPath + "/..");
|
||||
}
|
||||
var env = hostingContext.HostingEnvironment;
|
||||
string dir = Path.GetFullPath(env.ContentRootPath);
|
||||
string settingsFolder = Path.Combine(dir, "Settings");
|
||||
|
||||
settingsFolder = Path.Combine(dir, "Settings");
|
||||
// locate setting folder
|
||||
if (!Directory.Exists(settingsFolder))
|
||||
{
|
||||
dir = Path.GetFullPath(env.ContentRootPath + "/..");
|
||||
}
|
||||
|
||||
if (!Directory.Exists(settingsFolder))
|
||||
{
|
||||
dir = Path.GetFullPath(env.ContentRootPath + "/bin");
|
||||
}
|
||||
settingsFolder = Path.Combine(dir, "Settings");
|
||||
|
||||
settingsFolder = Path.Combine(dir, "Settings");
|
||||
if (!Directory.Exists(settingsFolder))
|
||||
{
|
||||
dir = Path.GetFullPath(env.ContentRootPath + "/bin");
|
||||
}
|
||||
|
||||
Console.WriteLine($"Read settings from {settingsFolder}");
|
||||
settingsFolder = Path.Combine(dir, "Settings");
|
||||
|
||||
var settings = Directory.GetFiles(settingsFolder, "*.json");
|
||||
settings.ToList().ForEach(setting =>
|
||||
{
|
||||
config.AddJsonFile(setting, optional: false, reloadOnChange: true);
|
||||
});
|
||||
})
|
||||
.UseUrls("http://0.0.0.0:3112")
|
||||
.UseStartup<Startup>()
|
||||
.Build();
|
||||
Console.WriteLine($"Read settings from {settingsFolder}");
|
||||
|
||||
var settings = Directory.GetFiles(settingsFolder, "*.json");
|
||||
settings.ToList().ForEach(setting =>
|
||||
{
|
||||
config.AddJsonFile(setting, optional: false, reloadOnChange: true);
|
||||
});
|
||||
})
|
||||
.UseUrls("http://0.0.0.0:3112")
|
||||
.UseStartup<Startup>();
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,19 @@
|
|||
{
|
||||
{
|
||||
"Logging": {
|
||||
"IncludeScopes": false,
|
||||
"Debug": {
|
||||
"LogLevel": {
|
||||
"Default": "Warning"
|
||||
}
|
||||
},
|
||||
"Console": {
|
||||
"LogLevel": {
|
||||
"Default": "Warning"
|
||||
}
|
||||
}
|
||||
//"IncludeScopes": false,
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}//,
|
||||
//"Debug": {
|
||||
// "LogLevel": {
|
||||
// "Default": "Warning"
|
||||
// }
|
||||
//},
|
||||
//"Console": {
|
||||
// "LogLevel": {
|
||||
// "Default": "Warning"
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,24 @@
|
|||
using BotSharp.Core.Modules;
|
||||
using BotSharp.Core.Modules;
|
||||
using DotNetToolkit.JwtHelper;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Swashbuckle.AspNetCore.Swagger;
|
||||
using Swashbuckle.AspNetCore.SwaggerUI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace BotSharp.WebHost
|
||||
{
|
||||
public partial class Startup
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
|
|
@ -41,14 +44,15 @@ namespace BotSharp.WebHost
|
|||
});
|
||||
services.AddJwtAuth(Configuration);
|
||||
|
||||
var mvcBuilder = services.AddMvc(options =>
|
||||
{
|
||||
options.RespectBrowserAcceptHeader = true;
|
||||
}).AddJsonOptions(options =>
|
||||
{
|
||||
options.SerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
|
||||
options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
|
||||
});
|
||||
services.AddMvc(options =>
|
||||
{
|
||||
options.RespectBrowserAcceptHeader = true;
|
||||
})
|
||||
.AddNewtonsoftJson(options =>
|
||||
{
|
||||
options.SerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
|
||||
options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
|
||||
});
|
||||
|
||||
//PlatformModuleAssembyLoader.LoadAssemblies(Configuration, assembly => mvcBuilder.AddApplicationPart(assembly));
|
||||
|
||||
|
|
@ -56,26 +60,38 @@ namespace BotSharp.WebHost
|
|||
|
||||
services.AddSwaggerGen(c =>
|
||||
{
|
||||
c.AddSecurityDefinition("Bearer", new ApiKeyScheme()
|
||||
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme()
|
||||
{
|
||||
In = "header",
|
||||
In = ParameterLocation.Header,
|
||||
Description = "Please insert JWT with Bearer schema. Example: \"Authorization: Bearer {token}\"",
|
||||
Name = "Authorization",
|
||||
Type = "apiKey"
|
||||
Type = SecuritySchemeType.ApiKey,
|
||||
Scheme = "Bearer"
|
||||
});
|
||||
c.AddSecurityRequirement(new OpenApiSecurityRequirement
|
||||
{
|
||||
{ new OpenApiSecurityScheme(){
|
||||
Reference = new OpenApiReference{Type = ReferenceType.SecurityScheme ,Id = "Bearer"}
|
||||
}, new List<string>(0) }
|
||||
});
|
||||
|
||||
c.AddSecurityRequirement(new Dictionary<string, IEnumerable<string>> {
|
||||
{ "Bearer", Enumerable.Empty<string>() },
|
||||
});
|
||||
|
||||
var info = Configuration.GetSection("Swagger").Get<Info>();
|
||||
var info = Configuration.GetSection("Swagger").Get<OpenApiInfo>();
|
||||
c.SwaggerDoc(info.Version, info);
|
||||
|
||||
//var filePath = Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, "BotSharp.RestApi.xml");
|
||||
//c.IncludeXmlComments(filePath);
|
||||
var filePath = Path.Combine(AppContext.BaseDirectory, "BotSharp.RestApi.xml");
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
c.IncludeXmlComments(filePath);
|
||||
}
|
||||
|
||||
var xmlPath = Path.Combine(AppContext.BaseDirectory, "BotSharp.Platform.Dialogflow.xml");
|
||||
if (File.Exists(xmlPath))
|
||||
{
|
||||
c.IncludeXmlComments(xmlPath);
|
||||
}
|
||||
|
||||
c.OperationFilter<SwaggerFileUploadOperation>();
|
||||
});
|
||||
}).AddSwaggerGenNewtonsoftSupport();
|
||||
|
||||
// register platform dependency
|
||||
/*services.AddTransient<IBotEngine>((provider) =>
|
||||
|
|
@ -84,7 +100,7 @@ namespace BotSharp.WebHost
|
|||
});*/
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
|
|
@ -95,11 +111,11 @@ namespace BotSharp.WebHost
|
|||
|
||||
app.UseDefaultFiles();
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseRouting();
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(c =>
|
||||
{
|
||||
var info = Configuration.GetSection("Swagger").Get<Info>();
|
||||
var info = Configuration.GetSection("Swagger").Get<OpenApiInfo>();
|
||||
|
||||
c.SupportedSubmitMethods(SubmitMethod.Get, SubmitMethod.Post, SubmitMethod.Put, SubmitMethod.Patch, SubmitMethod.Delete);
|
||||
c.ShowExtensions();
|
||||
|
|
@ -129,8 +145,11 @@ namespace BotSharp.WebHost
|
|||
await next.Invoke();
|
||||
});
|
||||
app.UseAuthentication();
|
||||
|
||||
app.UseMvc();
|
||||
app.UseAuthorization();
|
||||
app.UseEndpoints(routes=>
|
||||
{
|
||||
routes.MapControllers();
|
||||
});
|
||||
|
||||
this.modulesStartup.Configure(app, env);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using Swashbuckle.AspNetCore.Swagger;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Swashbuckle.AspNetCore.Swagger;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -9,22 +10,18 @@ namespace BotSharp.WebHost
|
|||
{
|
||||
public class SwaggerFileUploadOperation : IOperationFilter
|
||||
{
|
||||
public void Apply(Operation operation, OperationFilterContext context)
|
||||
{
|
||||
if (operation.OperationId == "Import")
|
||||
{
|
||||
operation.Parameters.Clear();
|
||||
|
||||
operation.Parameters.Add(new NonBodyParameter
|
||||
public void Apply(OpenApiOperation operation, OperationFilterContext context)
|
||||
{
|
||||
if(context.MethodInfo.Name == "Import")
|
||||
{
|
||||
if(operation.RequestBody.Content.FirstOrDefault().Value?.Schema?.Properties.ContainsKey("uploadedFile") == true)
|
||||
{
|
||||
Name = "uploadedFile",
|
||||
In = "formData",
|
||||
Description = "Upload Zip File, meta.json is the extra data for customized function.",
|
||||
Required = true,
|
||||
Type = "file"
|
||||
});
|
||||
operation.Consumes.Add("multipart/form-data");
|
||||
var p = operation.RequestBody.Content.FirstOrDefault();
|
||||
p.Value.Schema.Properties["uploadedFile"].Description = "Upload Zip File, meta.json is the extra data for customized function.";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Platform.Rasa", "B
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Platform.Articulate", "BotSharp.Platform.Articulate\BotSharp.Platform.Articulate.csproj", "{7290AC89-88DE-4CF8-946A-A1BB0E4C30EB}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution items", "solution items", "{44D9C8BF-FA7B-4FA1-AF2D-93BC223D11B6}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.editorconfig = .editorconfig
|
||||
Directory.Build.props = Directory.Build.props
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
|
|||
8
Directory.Build.props
Normal file
8
Directory.Build.props
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<Project>
|
||||
<PropertyGroup>
|
||||
<DefaultTargetFramework>netcoreapp3.1</DefaultTargetFramework>
|
||||
<MvcVersion>3.1.7</MvcVersion>
|
||||
<Version Condition="$(Version) == ''">0.2.1</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Loading…
Reference in a new issue