change default enginee as Dialogflow

This commit is contained in:
Oceania2018 2019-03-22 06:23:03 -05:00
parent bedbcd999d
commit 3c3898ddd7
9 changed files with 29 additions and 20 deletions

View file

@ -14,7 +14,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BotSharp.Platform.OwnThink\BotSharp.Platform.OwnThink.csproj" />
<ProjectReference Include="..\BotSharp.Platform.Dialogflow\BotSharp.Platform.Dialogflow.csproj" />
</ItemGroup>
</Project>

View file

@ -24,7 +24,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BotSharp.Platform.OwnThink\BotSharp.Platform.OwnThink.csproj" />
<ProjectReference Include="..\BotSharp.Platform.Dialogflow\BotSharp.Platform.Dialogflow.csproj" />
</ItemGroup>
</Project>

View file

@ -1,6 +1,6 @@
using BotSharp.Channel.Weixin.Models;
using BotSharp.Platform.Abstractions;
using BotSharp.Platform.OwnThink.Models;
using BotSharp.Platform.Dialogflow.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Senparc.CO2NET.HttpUtility;

View file

@ -32,7 +32,7 @@ using Senparc.Weixin.MP;
using BotSharp.Platform.Models.AiRequest;
using BotSharp.Platform.Abstractions;
using Microsoft.Extensions.Configuration;
using BotSharp.Platform.OwnThink.Models;
using BotSharp.Platform.Dialogflow.Models;
#if NET45
using System.Web;

View file

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks;
namespace BotSharp.Platform.OwnThink.Controllers
{
@ -19,8 +20,8 @@ namespace BotSharp.Platform.OwnThink.Controllers
builder = platform;
}
/*[HttpGet, HttpPost]
public async Task<ActionResult<AIResponse>> Query(QueryModel request)
[HttpGet, HttpPost]
public async Task<ActionResult<OwnThinkAiResponse>> Query(OwnThinkAiRequest request)
{
String clientAccessToken = (User.Identity as ClaimsIdentity).Claims.FirstOrDefault(x => x.Type == "UserId")?.Value;
@ -36,20 +37,15 @@ namespace BotSharp.Platform.OwnThink.Controllers
var aIResponse = await builder.TextRequest<AIResponseResult>(new AiRequest
{
Text = request.Query,
Text = request.Spoken,
AgentId = agent.Id,
SessionId = request.SessionId
SessionId = request.AppId
});
return new AIResponse
return new OwnThinkAiResponse
{
Result = aIResponse,
Id = Guid.NewGuid().ToString(),
Lang = request.Lang,
SessionId = request.SessionId,
Status = new AIResponseStatus(),
Timestamp = DateTime.UtcNow
};
}*/
}
}
}

View file

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace BotSharp.Platform.OwnThink.Models
{
public class OwnThinkAiRequest
{
public string AppId { get; set; }
public string Spoken { get; set; }
}
}

View file

@ -4,7 +4,7 @@ using System.Text;
namespace BotSharp.Platform.OwnThink.Models
{
public class OwnThinkChatResponse
public class OwnThinkAiResponse
{
public OwnThinkChatResponseData Data { get; set; }

View file

@ -102,7 +102,7 @@ namespace BotSharp.Platform.OwnThink
"https://api.ownthink.com/bot",
new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json"));
var content = await response.Content.ReadAsStringAsync();
var result = JsonConvert.DeserializeObject<OwnThinkChatResponse>(content);
var result = JsonConvert.DeserializeObject<OwnThinkAiResponse>(content);
return new TextClassificationResult
{

View file

@ -1,8 +1,8 @@
{
"version": "0.2.0",
"version": "0.5.0",
"assemblies": "BotSharp.Core",
"platformModuleName": "OwnThinkAi",
"platformModuleName": "DialogflowAi",
"overrideFallback": false,
"modules": [