public async Task MessageReturnsLUISResultOK() { //Arrange Environment.SetEnvironmentVariable("LUISAPISubscriptionKey", SUBSCRIPTIONKEY); Environment.SetEnvironmentVariable("LUISAPPID", APPID); Environment.SetEnvironmentVariable("BingAPISubscriptionKey", BINGAPISUBSCRIPTIONKEY); _predictionHelperService.Setup(x => x.ResolveAsync( It.IsAny <IPrediction>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <double?>(), It.IsAny <bool?>(), It.IsAny <bool?>(), It.IsAny <bool?>(), It.IsAny <string>(), It.IsAny <bool?>(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult(new LuisResult())); _luisService = new LUISService(_logger.Object, _predictionHelperService.Object); //Act var result = await _luisService.ExtractEntitiesFromLUIS(It.IsAny <string>()); //Assert Assert.NotNull(result); }
private async Task askLuis(IDialogContext ctx, string message) { LUISResponse response = await LUISService.askLUIS(message); switch (response.topScoringIntent.intent) { case "Who worked on": ctx.Call <string>(new WhoWorkedOnDialog(response), ResumeAfterTellMeAboutDialog); break; case "GetYear": ctx.Call <object>(new WhatYearDialog(response), ResumeAfterWhatYearDialog); break; case "Tell me about": ctx.Call <string>(new TellMeAboutDialog(response), ResumeAfterTellMeAboutDialog); break; default: string failResponse = "Sorry, I didn't understand " + message + ".\n\n" + "Try 'Tell me about [movie]', 'In what year was [movie] released?' " + "or 'Have [actor] and [actor] been in any movies together?'"; await ctx.PostAsync(failResponse); ctx.Wait(MessageReceivedAsync); break; } }
public async Task MessageThrowsArgumentNullExceptionSubscriptionKey() { //Arrange _luisService = new LUISService(_logger.Object, _predictionHelperService.Object); //Act var result = await _luisService.ExtractEntitiesFromLUIS(It.IsAny <string>()); //Assert Assert.Null(result); }
public async Task MessageThrowsArgumentNullExceptionAppID() { //Arrange Environment.SetEnvironmentVariable("LUISAPISubscriptionKey", SUBSCRIPTIONKEY); _luisService = new LUISService(_logger.Object, _predictionHelperService.Object); //Act var result = await _luisService.ExtractEntitiesFromLUIS(It.IsAny <string>()); //Assert Assert.Null(result); }
public MainDialog(IConfiguration configuration, ILogger <MainDialog> logger) : base(nameof(MainDialog)) { Configuration = configuration; Logger = logger; serviceLuis = new LUISService(configuration); AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[] { IntroStepAsync, })); InitialDialogId = nameof(WaterfallDialog); }
public async Task MessageReceivedAsync(IDialogContext context, IAwaitable <Message> argument) { var message = await argument; var texto = message.Text.ToLowerInvariant(); //LUIS integration var luisResponse = await LUISService.GetIntent(texto); var mostRelevantIntent = luisResponse.Intents.FirstOrDefault(); if (mostRelevantIntent == null) { await context.PostAsync("No entendí lo que necesitabas, probá en [Stackoverflow](http://stackoverflow.com/)."); return; } switch (mostRelevantIntent.Intent) { case "FindContent": filter = luisResponse.Entities.Where(x => x.Type == "ContentType").Select(x => x.Entity).FirstOrDefault(); query = luisResponse.Entities.Where(x => x.Type == "Topic").Select(x => x.Entity).FirstOrDefault(); if (string.IsNullOrEmpty(query)) { query = texto.Split(' ').LastOrDefault(); } page = 1; await context.PostAsync(DoSearch(query, filter, page).ToMarkDown(query)); break; case "MoreResults": ++page; await context.PostAsync(DoSearch(query, filter, page).ToMarkDown(query)); break; case "AddContent": var newQuery = luisResponse.Entities.Where(x => x.Type == "Topic").Select(x => x.Entity).FirstOrDefault(); if (string.IsNullOrEmpty(newQuery)) { newQuery = texto.Split(' ').LastOrDefault(); } query = query + " " + newQuery; page = 1; await context.PostAsync(DoSearch(query, filter, page).ToMarkDown(query)); break; case "Greetings": await context.PostAsync("Hola! Soy una entidad etérea creada por [ealsur](https://twitter.com/ealsur) usando [Azure Search](https://azure.microsoft.com/services/search/), [Bot Framework](https://dev.botframework.com/) y [LUIS](https://www.luis.ai/). Probá *quiero ver videos de azure* o *mostrame lo que tengas sobre powershell*."); break; default: await context.PostAsync("No entendí lo que necesitabas, probá con preguntas como *quiero ver videos de azure* o *mostrame material sobre sharepoint*."); break; } context.Wait(MessageReceivedAsync); }