Skip to content

Commit b5135ab

Browse files
committed
docker pull microsoft/aspnetcore-build
1 parent fde4c0e commit b5135ab

File tree

6 files changed

+79
-37
lines changed

6 files changed

+79
-37
lines changed

Diff for: .dockerignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
bin/
2+
obj/
3+
node_modules/

Diff for: BotSharp.RestApi/BotSharp.RestApi.csproj

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919

2020
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
2121
<DocumentationFile>bin\Debug\netcoreapp2.1\BotSharp.RestApi.xml</DocumentationFile>
22+
<DefineConstants>TRACE;DEBUG;MODE_DIALOGFLOW</DefineConstants>
23+
</PropertyGroup>
24+
25+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
26+
<DefineConstants>TRACE;MODE_DIALOGFLOW</DefineConstants>
2227
</PropertyGroup>
2328

2429
<ItemGroup>

Diff for: BotSharp.RestApi/Dialogs/DialogController.cs renamed to BotSharp.RestApi/Dialogflow/QueryController.cs

+10-8
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,41 @@
22
using BotSharp.Core.Models;
33
using Microsoft.AspNetCore.Authorization;
44
using Microsoft.AspNetCore.Mvc;
5-
using Newtonsoft.Json.Linq;
65
using System;
76
using System.Collections.Generic;
87
using System.Linq;
98
using System.Text;
109

11-
namespace BotSharp.RestApi.Dialogs
10+
namespace BotSharp.RestApi.Dialogflow
1211
{
12+
#if MODE_DIALOGFLOW
1313
/// <summary>
14-
/// Conversation controller
14+
/// Dialogflow mode query controller
1515
/// </summary>
1616
[Authorize]
1717
[Route("v1/[controller]")]
18-
public class DialogController : ControllerBase
18+
public class QueryController : ControllerBase
1919
{
2020
private readonly IBotPlatform _platform;
2121

2222
/// <summary>
2323
/// Initialize dialog controller and get a platform instance
2424
/// </summary>
2525
/// <param name="platform"></param>
26-
public DialogController(IBotPlatform platform)
26+
public QueryController(IBotPlatform platform)
2727
{
2828
_platform = platform;
2929
}
3030

3131
/// <summary>
3232
/// The query endpoint is used to process natural language in the form of text.
3333
/// The query requests return structured data in JSON format with an action and parameters for that action.
34+
/// Both GET and POST methods return the same JSON response.
3435
/// </summary>
3536
/// <param name="request"></param>
3637
/// <returns></returns>
37-
[HttpPost("/v1/query")]
38-
public ActionResult<AIResponse> Query([FromBody] QueryModel request)
38+
[HttpGet, HttpPost]
39+
public ActionResult<AIResponse> Query(QueryModel request)
3940
{
4041
String clientAccessToken = Request.Headers["ClientAccessToken"];
4142
var config = new AIConfiguration(clientAccessToken, SupportedLanguage.English);
@@ -50,8 +51,9 @@ public ActionResult<AIResponse> Query([FromBody] QueryModel request)
5051
Language = request.Lang,
5152
Query = new String[] { request.Query }
5253
});
53-
54+
5455
return aIResponse;
5556
}
5657
}
58+
#endif
5759
}

Diff for: BotSharp.RestApi/Dialogflow/QueryModel.cs

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel.DataAnnotations;
4+
using System.Text;
5+
6+
namespace BotSharp.RestApi.Dialogflow
7+
{
8+
public class QueryModel
9+
{
10+
public QueryModel()
11+
{
12+
Contexts = new List<string>();
13+
}
14+
15+
/// <summary>
16+
/// Array of additional context objects. Should be sent via a POST /query request.
17+
/// Contexts sent in a query are activated before the query.
18+
/// </summary>
19+
public List<String> Contexts { get; set; }
20+
21+
/// <summary>
22+
/// Object containing event name and additional data.
23+
/// The "data" parameter can be submitted only in POST requests.
24+
/// </summary>
25+
public String Event { get;set; }
26+
27+
/// <summary>
28+
/// Language tag, e.g., en, es etc.
29+
/// </summary>
30+
public String Lang { get; set; }
31+
32+
/// <summary>
33+
/// Natural language text to be processed. Query length should not exceed 256 characters.
34+
/// </summary>
35+
[Required]
36+
public String Query { get; set; }
37+
38+
/// <summary>
39+
/// A string token up to 36 symbols long, used to identify the client and to manage session parameters (including contexts) per client.
40+
/// </summary>
41+
[Required]
42+
public String SessionId { get; set; }
43+
44+
/// <summary>
45+
/// Time zone from IANA Time Zone Database Examples: America/New_York, Europe/Paris
46+
/// </summary>
47+
public String Timezone { get; set; }
48+
}
49+
}

Diff for: BotSharp.RestApi/Dialogs/QueryModel.cs

-27
This file was deleted.

Diff for: Dockerfile

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1+
# stage 1: build
2+
FROM microsoft/aspnetcore-build AS builder
3+
WORKDIR /source
4+
5+
# copies the rest of your code
6+
COPY . .
7+
RUN dotnet build
8+
RUN dotnet publish --output /app/ --configuration Release
9+
10+
# stage 2: install
111
FROM microsoft/aspnetcore
212
WORKDIR /app
3-
COPY ./BotSharp.WebHost/PublishOutput .
4-
# ENTRYPOINT [ "dotnet", "BotSharp.WebHost.dll" ]
13+
COPY --from=builder /app .
14+
ENTRYPOINT [ "dotnet", "BotSharp.WebHost.dll" ]

0 commit comments

Comments
 (0)