public BotServices(BotSettings settings) { foreach (var pair in settings.CognitiveModels) { var set = new CognitiveModelSet(); var language = pair.Key; var config = pair.Value; var dispatchApp = new LuisApplication(config.DispatchModel.AppId, config.DispatchModel.SubscriptionKey, config.DispatchModel.GetEndpoint()); set.DispatchService = new LuisRecognizer(dispatchApp); if (config.LanguageModels != null) { foreach (var model in config.LanguageModels) { var luisApp = new LuisApplication(model.AppId, model.SubscriptionKey, model.GetEndpoint()); set.LuisServices.Add(model.Id, new LuisRecognizer(luisApp)); } } foreach (var kb in config.Knowledgebases) { var qnaEndpoint = new QnAMakerEndpoint() { KnowledgeBaseId = kb.KbId, EndpointKey = kb.EndpointKey, Host = kb.Hostname, }; var qnaMaker = new QnAMaker(qnaEndpoint); set.QnAServices.Add(kb.Id, qnaMaker); } CognitiveModelSets.Add(language, set); } }
public BotServices(BotSettings settings, IBotTelemetryClient client) { foreach (var pair in settings.CognitiveModels) { var set = new CognitiveModelSet(); var language = pair.Key; var config = pair.Value; var telemetryClient = client; LuisRecognizerOptionsV3 luisOptions; if (config.DispatchModel != null) { var dispatchApp = new LuisApplication(config.DispatchModel.AppId, config.DispatchModel.SubscriptionKey, config.DispatchModel.GetEndpoint()); luisOptions = new LuisRecognizerOptionsV3(dispatchApp) { TelemetryClient = telemetryClient, LogPersonalInformation = true, }; set.DispatchService = new LuisRecognizer(luisOptions); } if (config.LanguageModels != null) { foreach (var model in config.LanguageModels) { var luisApp = new LuisApplication(model.AppId, model.SubscriptionKey, model.GetEndpoint()); luisOptions = new LuisRecognizerOptionsV3(luisApp) { TelemetryClient = telemetryClient, LogPersonalInformation = true, PredictionOptions = new Microsoft.Bot.Builder.AI.LuisV3.LuisPredictionOptions() { IncludeInstanceData = true } }; set.LuisServices.Add(model.Id, new LuisRecognizer(luisOptions)); } } if (config.Knowledgebases != null) { foreach (var kb in config.Knowledgebases) { var qnaEndpoint = new QnAMakerEndpoint() { KnowledgeBaseId = kb.KbId, EndpointKey = kb.EndpointKey, Host = kb.Hostname, }; set.QnAConfiguration.Add(kb.Id, qnaEndpoint); } } CognitiveModelSets.Add(language, set); } }
public BotServices(BotSettings settings, IBotTelemetryClient client) { foreach (var pair in settings.CognitiveModels) { var set = new CognitiveModelSet(); var language = pair.Key; var config = pair.Value; var telemetryClient = client; var luisOptions = new LuisPredictionOptions() { TelemetryClient = telemetryClient, LogPersonalInformation = true, SpellCheck = string.IsNullOrEmpty(settings.BingSpellCheckSubscriptionKey) ? false : true, BingSpellCheckSubscriptionKey = settings.BingSpellCheckSubscriptionKey }; if (config.DispatchModel != null) { var dispatchApp = new LuisApplication(config.DispatchModel.AppId, config.DispatchModel.SubscriptionKey, config.DispatchModel.GetEndpoint()); set.DispatchService = new LuisRecognizer(dispatchApp, luisOptions); } if (config.LanguageModels != null) { foreach (var model in config.LanguageModels) { var luisApp = new LuisApplication(model.AppId, model.SubscriptionKey, model.GetEndpoint()); set.LuisServices.Add(model.Id, new LuisRecognizer(luisApp, luisOptions)); } } if (config.Knowledgebases != null) { foreach (var kb in config.Knowledgebases) { var qnaEndpoint = new QnAMakerEndpoint() { KnowledgeBaseId = kb.KbId, EndpointKey = kb.EndpointKey, Host = kb.Hostname, }; var qnaMaker = new QnAMaker(qnaEndpoint); set.QnAServices.Add(kb.Id, qnaMaker); } } CognitiveModelSets.Add(language, set); } }
public BotServices(BotSettings settings) { foreach (var pair in settings.CognitiveModels) { var set = new CognitiveModelSet(); var language = pair.Key; var config = pair.Value; var telemetryClient = new BotTelemetryClient(new TelemetryClient(settings.AppInsights)); var luisOptions = new LuisPredictionOptions() { TelemetryClient = telemetryClient, LogPersonalInformation = true, }; var dispatchApp = new LuisApplication(config.DispatchModel.AppId, config.DispatchModel.SubscriptionKey, config.DispatchModel.GetEndpoint()); set.DispatchService = new LuisRecognizer(dispatchApp, luisOptions); if (config.LanguageModels != null) { foreach (var model in config.LanguageModels) { var luisApp = new LuisApplication(model.AppId, model.SubscriptionKey, model.GetEndpoint()); set.LuisServices.Add(model.Id, new LuisRecognizer(luisApp, luisOptions)); } } foreach (var kb in config.Knowledgebases) { var qnaEndpoint = new QnAMakerEndpoint() { KnowledgeBaseId = kb.KbId, EndpointKey = kb.EndpointKey, Host = kb.Hostname, }; var qnaMaker = new QnAMaker(qnaEndpoint, null, null, telemetryClient: telemetryClient, logPersonalInformation: true); set.QnAServices.Add(kb.Id, qnaMaker); } CognitiveModelSets.Add(language, set); } }