forked from microsoft/BotBuilder-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBotServices.cs
61 lines (50 loc) · 2.46 KB
/
BotServices.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using Microsoft.Bot.Builder.AI.Luis;
using Microsoft.Bot.Builder.AI.Orchestrator;
using Microsoft.Bot.Builder.AI.QnA;
using Microsoft.Extensions.Configuration;
namespace Microsoft.BotBuilderSamples
{
public class BotServices : IBotServices
{
public BotServices(IConfiguration configuration, OrchestratorRecognizer dispatcher)
{
// Read the setting for cognitive services (LUIS, QnA) from the appsettings.json
// If includeApiResults is set to true, the full response from the LUIS api (LuisResult)
// will be made available in the properties collection of the RecognizerResult
LuisHomeAutomationRecognizer = CreateLuisRecognizer(configuration, "LuisHomeAutomationAppId");
LuisWeatherRecognizer = CreateLuisRecognizer(configuration, "LuisWeatherAppId");
Dispatch = dispatcher;
SampleQnA = new QnAMaker(new QnAMakerEndpoint
{
KnowledgeBaseId = configuration["QnAKnowledgebaseId"],
EndpointKey = configuration["QnAEndpointKey"],
Host = configuration["QnAEndpointHostName"]
});
}
public OrchestratorRecognizer Dispatch { get; private set; }
public QnAMaker SampleQnA { get; private set; }
public LuisRecognizer LuisHomeAutomationRecognizer { get; private set; }
public LuisRecognizer LuisWeatherRecognizer { get; private set; }
private LuisRecognizer CreateLuisRecognizer(IConfiguration configuration, string appIdKey)
{
var luisApplication = new LuisApplication(
configuration[appIdKey],
configuration["LuisAPIKey"],
configuration["LuisAPIHostName"]);
// Set the recognizer options depending on which endpoint version you want to use.
// More details can be found in https://docs.microsoft.com/en-gb/azure/cognitive-services/luis/luis-migration-api-v3
var recognizerOptions = new LuisRecognizerOptionsV2(luisApplication)
{
IncludeAPIResults = true,
PredictionOptions = new LuisPredictionOptions()
{
IncludeAllIntents = true,
IncludeInstanceData = true
}
};
return new LuisRecognizer(recognizerOptions);
}
}
}