docker pull microsoft/aspnetcore-build
This commit is contained in:
parent
fde4c0eb36
commit
b5135ab236
3
.dockerignore
Normal file
3
.dockerignore
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
bin/
|
||||
obj/
|
||||
node_modules/
|
||||
|
|
@ -19,6 +19,11 @@
|
|||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DocumentationFile>bin\Debug\netcoreapp2.1\BotSharp.RestApi.xml</DocumentationFile>
|
||||
<DefineConstants>TRACE;DEBUG;MODE_DIALOGFLOW</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DefineConstants>TRACE;MODE_DIALOGFLOW</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -2,20 +2,20 @@
|
|||
using BotSharp.Core.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BotSharp.RestApi.Dialogs
|
||||
namespace BotSharp.RestApi.Dialogflow
|
||||
{
|
||||
#if MODE_DIALOGFLOW
|
||||
/// <summary>
|
||||
/// Conversation controller
|
||||
/// Dialogflow mode query controller
|
||||
/// </summary>
|
||||
[Authorize]
|
||||
[Route("v1/[controller]")]
|
||||
public class DialogController : ControllerBase
|
||||
public class QueryController : ControllerBase
|
||||
{
|
||||
private readonly IBotPlatform _platform;
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ namespace BotSharp.RestApi.Dialogs
|
|||
/// Initialize dialog controller and get a platform instance
|
||||
/// </summary>
|
||||
/// <param name="platform"></param>
|
||||
public DialogController(IBotPlatform platform)
|
||||
public QueryController(IBotPlatform platform)
|
||||
{
|
||||
_platform = platform;
|
||||
}
|
||||
|
|
@ -31,11 +31,12 @@ namespace BotSharp.RestApi.Dialogs
|
|||
/// <summary>
|
||||
/// The query endpoint is used to process natural language in the form of text.
|
||||
/// The query requests return structured data in JSON format with an action and parameters for that action.
|
||||
/// Both GET and POST methods return the same JSON response.
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("/v1/query")]
|
||||
public ActionResult<AIResponse> Query([FromBody] QueryModel request)
|
||||
[HttpGet, HttpPost]
|
||||
public ActionResult<AIResponse> Query(QueryModel request)
|
||||
{
|
||||
String clientAccessToken = Request.Headers["ClientAccessToken"];
|
||||
var config = new AIConfiguration(clientAccessToken, SupportedLanguage.English);
|
||||
|
|
@ -54,4 +55,5 @@ namespace BotSharp.RestApi.Dialogs
|
|||
return aIResponse;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
49
BotSharp.RestApi/Dialogflow/QueryModel.cs
Normal file
49
BotSharp.RestApi/Dialogflow/QueryModel.cs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text;
|
||||
|
||||
namespace BotSharp.RestApi.Dialogflow
|
||||
{
|
||||
public class QueryModel
|
||||
{
|
||||
public QueryModel()
|
||||
{
|
||||
Contexts = new List<string>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Array of additional context objects. Should be sent via a POST /query request.
|
||||
/// Contexts sent in a query are activated before the query.
|
||||
/// </summary>
|
||||
public List<String> Contexts { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Object containing event name and additional data.
|
||||
/// The "data" parameter can be submitted only in POST requests.
|
||||
/// </summary>
|
||||
public String Event { get;set; }
|
||||
|
||||
/// <summary>
|
||||
/// Language tag, e.g., en, es etc.
|
||||
/// </summary>
|
||||
public String Lang { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Natural language text to be processed. Query length should not exceed 256 characters.
|
||||
/// </summary>
|
||||
[Required]
|
||||
public String Query { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A string token up to 36 symbols long, used to identify the client and to manage session parameters (including contexts) per client.
|
||||
/// </summary>
|
||||
[Required]
|
||||
public String SessionId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Time zone from IANA Time Zone Database Examples: America/New_York, Europe/Paris
|
||||
/// </summary>
|
||||
public String Timezone { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text;
|
||||
|
||||
namespace BotSharp.RestApi.Dialogs
|
||||
{
|
||||
public class QueryModel
|
||||
{
|
||||
public List<String> Contexts { get; set; }
|
||||
|
||||
public String Event { get;set; }
|
||||
|
||||
public String Lang { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// User says
|
||||
/// </summary>
|
||||
[Required]
|
||||
public String Query { get; set; }
|
||||
|
||||
[Required]
|
||||
public String SessionId { get; set; }
|
||||
|
||||
public String Timezone { get; set; }
|
||||
}
|
||||
}
|
||||
14
Dockerfile
14
Dockerfile
|
|
@ -1,4 +1,14 @@
|
|||
# stage 1: build
|
||||
FROM microsoft/aspnetcore-build AS builder
|
||||
WORKDIR /source
|
||||
|
||||
# copies the rest of your code
|
||||
COPY . .
|
||||
RUN dotnet build
|
||||
RUN dotnet publish --output /app/ --configuration Release
|
||||
|
||||
# stage 2: install
|
||||
FROM microsoft/aspnetcore
|
||||
WORKDIR /app
|
||||
COPY ./BotSharp.WebHost/PublishOutput .
|
||||
# ENTRYPOINT [ "dotnet", "BotSharp.WebHost.dll" ]
|
||||
COPY --from=builder /app .
|
||||
ENTRYPOINT [ "dotnet", "BotSharp.WebHost.dll" ]
|
||||
Loading…
Reference in a new issue