Created
March 17, 2017 20:45
-
-
Save zelinskiy/d0fd8f55ae100abdd340aed0baeb6523 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Microsoft.Bot.Builder.Dialogs; | |
| using System; | |
| using System.Linq; | |
| using System.Threading.Tasks; | |
| using Microsoft.Bot.Connector; | |
| namespace Kirill.Supports | |
| { | |
| public class RequestMaker:LuisDialog<object> | |
| { | |
| public async Task<LuisServiceResult> MakeRequest( | |
| IDialogContext context, | |
| IAwaitable<IMessageActivity> item) | |
| { | |
| var message = await item; | |
| var messageText = await GetLuisQueryTextAsync(context, message); | |
| var tasks = this.services | |
| .Select(s => | |
| s.QueryAsync( | |
| new Uri(messageText), | |
| context.CancellationToken)) | |
| .ToArray(); | |
| var results = await Task.WhenAll(tasks); | |
| var winners = from result in results.Select((value, index) => new { value, index }) | |
| let resultWinner = BestIntentFrom(result.value) | |
| where resultWinner != null | |
| select new LuisServiceResult(result.value, resultWinner, this.services[result.index]); | |
| return this.BestResultFrom(winners); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment