Merge 4.9 into master (#3890)
* [Expression] Add formatNumber, formatEpoch and formatTicks as prebuilt functions (#3876) (#3883) * add formatNumber prebuilt function * change to string output to keep tailing zeors * Add formatEpoch and formatTicks. Removed ticks from formatDate and fixed some bugs. Fixed a bug in JSON conversion where 64 bit/double values were getting truncated. * Add tests that were dropped. * Add locale to formatNumber. * Add 1000's seperators. * fix a test case * change a test case Co-authored-by: Chris McConnell <chrimc@microsoft.com> Co-authored-by: Chris McConnell <chrimc@microsoft.com> * override OnComputeId in AdaptiveSkillDialog (#3882) * override OnComputeId in AdaptiveSkillDialog * refactor AdaptiveSkillDialog.OnComputeId() * remove superfluous parenthesis around activity * apply @stevenic's PR feedback * Rename $kind Microsoft.SkillDialog => Microsoft.BeginSkillDialog Rename class AdaptiveSkillDialog => BeginSkillDialog Move files into actions folders replace all $kind => new $kind * Style: Async method nomenclature, missing ConfigureAwait and CancellationTokens * Rename $kind Microsoft.BeginSkillDialog => Microsoft.BeginSkill Rename class BeginSkillDialog to BeginSkill * update title for begin skill * Cancellation, nomenclature and style improvements * Cancellation tokens and propagation * merge CheckForVersionChangeAsync() * Missing cancellation tokens Co-authored-by: Shuai Wang <shuwan@microsoft.com> Co-authored-by: Chris McConnell <chrimc@microsoft.com> Co-authored-by: Tom Laird-McConnell <tomlm@microsoft.com> Co-authored-by: Carlos Castro <ccastro@microsoft.com> Co-authored-by: Carlos Castro <carlosscastro@users.noreply.github.com>
This commit is contained in:
Родитель
2e0ffe4ec6
Коммит
0908005f49
|
@ -17,7 +17,7 @@ namespace Microsoft.Bot.Builder.FunctionalTests
|
|||
{
|
||||
public IDictionary<string, HashSet<string>> EndorsementTable { get; } = new Dictionary<string, HashSet<string>>();
|
||||
|
||||
public Task<IDictionary<string, HashSet<string>>> GetConfigurationAsync(string address, IDocumentRetriever retriever, CancellationToken cancel)
|
||||
public Task<IDictionary<string, HashSet<string>>> GetConfigurationAsync(string address, IDocumentRetriever retriever, CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult(EndorsementTable);
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AsyncUsageAnalyzers" Version="1.0.0-alpha003" PrivateAssets="all" />
|
||||
<PackageReference Include="Antlr4.CodeGenerator" Version="4.6.6">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Bot.Builder.Dialogs;
|
||||
using Microsoft.Bot.Schema;
|
||||
|
@ -15,7 +16,7 @@ namespace Microsoft.Bot.Builder.AI.QnA.Utils
|
|||
this.activity = activity;
|
||||
}
|
||||
|
||||
public Task<Activity> BindAsync(DialogContext context, object data = null)
|
||||
public Task<Activity> BindAsync(DialogContext context, object data = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return Task.FromResult(activity);
|
||||
}
|
||||
|
|
|
@ -7,19 +7,23 @@ using System.Runtime.CompilerServices;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AdaptiveExpressions.Properties;
|
||||
using Microsoft.Bot.Builder.Dialogs.Adaptive.Templates;
|
||||
using Microsoft.Bot.Builder.Skills;
|
||||
using Microsoft.Bot.Schema;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Skills
|
||||
namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
|
||||
{
|
||||
public class AdaptiveSkillDialog : SkillDialog
|
||||
/// <summary>
|
||||
/// Begin a Skill.
|
||||
/// </summary>
|
||||
public class BeginSkill : SkillDialog
|
||||
{
|
||||
[JsonProperty("$kind")]
|
||||
public const string Kind = "Microsoft.SkillDialog";
|
||||
public const string Kind = "Microsoft.BeginSkill";
|
||||
|
||||
[JsonConstructor]
|
||||
public AdaptiveSkillDialog([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
|
||||
public BeginSkill([CallerFilePath] string callerPath = "", [CallerLineNumber] int callerLine = 0)
|
||||
: base(new SkillDialogOptions())
|
||||
{
|
||||
DialogOptions.Skill = new BotFrameworkSkill();
|
||||
|
@ -161,5 +165,22 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Skills
|
|||
|
||||
return base.ContinueDialogAsync(dc, cancellationToken);
|
||||
}
|
||||
|
||||
protected override string OnComputeId()
|
||||
{
|
||||
var appId = SkillAppId?.ToString() ?? string.Empty;
|
||||
string activity;
|
||||
|
||||
if (Activity is ActivityTemplate at)
|
||||
{
|
||||
activity = StringUtils.Ellipsis(at.Template.Trim(), 30);
|
||||
}
|
||||
else
|
||||
{
|
||||
activity = StringUtils.Ellipsis(Activity?.ToString().Trim(), 30);
|
||||
}
|
||||
|
||||
return $"{this.GetType().Name}['{appId}','{activity}']";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -71,7 +71,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
|
|||
}
|
||||
}
|
||||
|
||||
return await dc.EndDialogAsync();
|
||||
return await dc.EndDialogAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
|
|||
}
|
||||
|
||||
dc.State.RemoveValue(Property.GetValue(dc.State));
|
||||
return await dc.EndDialogAsync();
|
||||
return await dc.EndDialogAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -231,7 +231,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
|
|||
dc.State.SetValue(this.ResultProperty.GetValue(dc.State), result);
|
||||
}
|
||||
|
||||
return await dc.EndDialogAsync(result);
|
||||
return await dc.EndDialogAsync(result, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
protected override string OnComputeId()
|
||||
|
|
|
@ -217,7 +217,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
|
|||
// Bind each string token to the data in state
|
||||
if (instanceBody != null)
|
||||
{
|
||||
await ReplaceJTokenRecursively(dc, instanceBody);
|
||||
await ReplaceJTokenRecursivelyAsync(dc, instanceBody, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
// Set headers
|
||||
|
@ -243,14 +243,14 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
|
|||
case HttpMethod.POST:
|
||||
if (instanceBody == null)
|
||||
{
|
||||
response = await client.PostAsync(instanceUrl, null);
|
||||
response = await client.PostAsync(instanceUrl, content: null, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
var postContent = new StringContent(instanceBody.ToString(), Encoding.UTF8, contentType);
|
||||
traceInfo.request.content = instanceBody.ToString();
|
||||
traceInfo.request.headers = JObject.FromObject(postContent?.Headers.ToDictionary(t => t.Key, t => (object)t.Value?.FirstOrDefault()));
|
||||
response = await client.PostAsync(instanceUrl, postContent);
|
||||
response = await client.PostAsync(instanceUrl, postContent, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -259,7 +259,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
|
|||
if (instanceBody == null)
|
||||
{
|
||||
var request = new HttpRequestMessage(new System.Net.Http.HttpMethod("PATCH"), instanceUrl);
|
||||
response = await client.SendAsync(request);
|
||||
response = await client.SendAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -267,7 +267,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
|
|||
request.Content = new StringContent(instanceBody.ToString(), Encoding.UTF8, contentType);
|
||||
traceInfo.request.content = instanceBody.ToString();
|
||||
traceInfo.request.headers = JObject.FromObject(request.Content.Headers.ToDictionary(t => t.Key, t => (object)t.Value?.FirstOrDefault()));
|
||||
response = await client.SendAsync(request);
|
||||
response = await client.SendAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -275,24 +275,24 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
|
|||
case HttpMethod.PUT:
|
||||
if (instanceBody == null)
|
||||
{
|
||||
response = await client.PutAsync(instanceUrl, null);
|
||||
response = await client.PutAsync(instanceUrl, content: null, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
var putContent = new StringContent(instanceBody.ToString(), Encoding.UTF8, contentType);
|
||||
traceInfo.request.content = instanceBody.ToString();
|
||||
traceInfo.request.headers = JObject.FromObject(putContent.Headers.ToDictionary(t => t.Key, t => (object)t.Value?.FirstOrDefault()));
|
||||
response = await client.PutAsync(instanceUrl, putContent);
|
||||
response = await client.PutAsync(instanceUrl, putContent, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case HttpMethod.DELETE:
|
||||
response = await client.DeleteAsync(instanceUrl);
|
||||
response = await client.DeleteAsync(instanceUrl, cancellationToken).ConfigureAwait(false);
|
||||
break;
|
||||
|
||||
case HttpMethod.GET:
|
||||
response = await client.GetAsync(instanceUrl);
|
||||
response = await client.GetAsync(instanceUrl, cancellationToken).ConfigureAwait(false);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -302,7 +302,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
|
|||
ReasonPhrase = response.ReasonPhrase,
|
||||
};
|
||||
|
||||
object content = (object)await response.Content.ReadAsStringAsync();
|
||||
object content = (object)await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
|
||||
switch (this.ResponseType.GetValue(dc.State))
|
||||
{
|
||||
|
@ -348,7 +348,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
|
|||
}
|
||||
|
||||
// return the actionResult as the result of this operation
|
||||
return await dc.EndDialogAsync(result: requestResult, cancellationToken: cancellationToken);
|
||||
return await dc.EndDialogAsync(result: requestResult, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
protected override string OnComputeId()
|
||||
|
@ -356,14 +356,14 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
|
|||
return $"{this.GetType().Name}[{Method} {Url?.ToString()}]";
|
||||
}
|
||||
|
||||
private async Task ReplaceJTokenRecursively(DialogContext dc, JToken token)
|
||||
private async Task ReplaceJTokenRecursivelyAsync(DialogContext dc, JToken token, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
switch (token.Type)
|
||||
{
|
||||
case JTokenType.Object:
|
||||
foreach (var child in token.Children<JProperty>())
|
||||
{
|
||||
await ReplaceJTokenRecursively(dc, child);
|
||||
await ReplaceJTokenRecursivelyAsync(dc, child, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -372,13 +372,13 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
|
|||
// NOTE: ToList() is required because JToken.Replace will break the enumeration.
|
||||
foreach (var child in token.Children().ToList())
|
||||
{
|
||||
await ReplaceJTokenRecursively(dc, child);
|
||||
await ReplaceJTokenRecursivelyAsync(dc, child, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case JTokenType.Property:
|
||||
await ReplaceJTokenRecursively(dc, ((JProperty)token).Value);
|
||||
await ReplaceJTokenRecursivelyAsync(dc, ((JProperty)token).Value, cancellationToken).ConfigureAwait(false);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -80,7 +80,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
|
|||
return await dc.EndDialogAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
var text = await Text.BindAsync(dc, dc.State).ConfigureAwait(false);
|
||||
var text = await Text.BindAsync(dc, dc.State, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var properties = new Dictionary<string, string>()
|
||||
{
|
||||
|
|
|
@ -74,7 +74,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Actions
|
|||
return await dc.EndDialogAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
var activity = await Activity.BindAsync(dc, dc.State).ConfigureAwait(false);
|
||||
var activity = await Activity.BindAsync(dc, dc.State, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var properties = new Dictionary<string, string>()
|
||||
{
|
||||
|
|
|
@ -13,7 +13,6 @@ using Microsoft.Bot.Builder.Dialogs.Adaptive.Generators;
|
|||
using Microsoft.Bot.Builder.Dialogs.Adaptive.Input;
|
||||
using Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers;
|
||||
using Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors;
|
||||
using Microsoft.Bot.Builder.Dialogs.Adaptive.Skills;
|
||||
using Microsoft.Bot.Builder.Dialogs.Choices;
|
||||
using Microsoft.Bot.Builder.Dialogs.Debugging;
|
||||
using Microsoft.Bot.Builder.Dialogs.Declarative;
|
||||
|
@ -59,6 +58,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
|
|||
|
||||
// Actions
|
||||
yield return new DeclarativeType<BeginDialog>(BeginDialog.Kind);
|
||||
yield return new DeclarativeType<BeginSkill>(BeginSkill.Kind);
|
||||
yield return new DeclarativeType<CancelDialog>(CancelDialog.Kind);
|
||||
yield return new DeclarativeType<CancelAllDialogs>(CancelAllDialogs.Kind);
|
||||
yield return new DeclarativeType<DebugBreak>(DebugBreak.Kind);
|
||||
|
@ -141,7 +141,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
|
|||
|
||||
// Dialogs
|
||||
yield return new DeclarativeType<AdaptiveDialog>(AdaptiveDialog.Kind);
|
||||
yield return new DeclarativeType<AdaptiveSkillDialog>(AdaptiveSkillDialog.Kind);
|
||||
|
||||
// register x.dialog.schema/x.dialog as DynamicBeginDialog $kind="x" => DynamicBeginDialog(x.dialog) resource.
|
||||
foreach (var schema in resourceExplorer.GetResources(".schema").Where(s => resourceExplorer.GetTypeForKind(Path.GetFileNameWithoutExtension(s.Id)) == null))
|
||||
|
|
|
@ -151,7 +151,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
|
|||
|
||||
EnsureDependenciesInstalled();
|
||||
|
||||
await this.CheckForVersionChangeAsync(dc).ConfigureAwait(false);
|
||||
await this.CheckForVersionChangeAsync(dc, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (!dc.State.ContainsKey(DialogPath.EventCounter))
|
||||
{
|
||||
|
@ -217,10 +217,10 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
|
|||
{
|
||||
EnsureDependenciesInstalled();
|
||||
|
||||
await this.CheckForVersionChangeAsync(dc).ConfigureAwait(false);
|
||||
await this.CheckForVersionChangeAsync(dc, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// Continue step execution
|
||||
return await ContinueActionsAsync(dc, null, cancellationToken).ConfigureAwait(false);
|
||||
return await ContinueActionsAsync(dc, options: null, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public override async Task<DialogTurnResult> ResumeDialogAsync(DialogContext dc, DialogReason reason, object result = null, CancellationToken cancellationToken = default)
|
||||
|
@ -230,14 +230,14 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
|
|||
throw new ArgumentException($"{nameof(result)} cannot be a cancellation token");
|
||||
}
|
||||
|
||||
await this.CheckForVersionChangeAsync(dc).ConfigureAwait(false);
|
||||
await this.CheckForVersionChangeAsync(dc, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// Containers are typically leaf nodes on the stack but the dev is free to push other dialogs
|
||||
// on top of the stack which will result in the container receiving an unexpected call to
|
||||
// resumeDialog() when the pushed on dialog ends.
|
||||
// To avoid the container prematurely ending we need to implement this method and simply
|
||||
// ask our inner dialog stack to re-prompt.
|
||||
await RepromptDialogAsync(dc.Context, dc.ActiveDialog).ConfigureAwait(false);
|
||||
await RepromptDialogAsync(dc.Context, dc.ActiveDialog, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return EndOfTurn;
|
||||
}
|
||||
|
@ -464,7 +464,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
|
|||
if (activity.Type == ActivityTypes.Message)
|
||||
{
|
||||
// Recognize utterance
|
||||
var recognizedResult = await OnRecognize(actionContext, activity, cancellationToken).ConfigureAwait(false);
|
||||
var recognizedResult = await OnRecognizeAsync(actionContext, activity, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// TODO figure out way to not use turn state to pass this value back to caller.
|
||||
actionContext.State.SetValue(TurnPath.Recognized, recognizedResult);
|
||||
|
@ -681,7 +681,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
|
|||
return new DialogTurnResult(DialogTurnStatus.Cancelled);
|
||||
}
|
||||
|
||||
protected async Task<RecognizerResult> OnRecognize(ActionContext actionContext, Activity activity, CancellationToken cancellationToken = default)
|
||||
protected async Task<RecognizerResult> OnRecognizeAsync(ActionContext actionContext, Activity activity, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (Recognizer != null)
|
||||
{
|
||||
|
@ -823,7 +823,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
|
|||
if (nextAssignment != null && nextAssignment.Event != AdaptiveEvents.AssignEntity)
|
||||
{
|
||||
assignments.Dequeue(actionContext);
|
||||
handled = await this.ProcessQueuesAsync(actionContext, cancellationToken);
|
||||
handled = await this.ProcessQueuesAsync(actionContext, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -837,7 +837,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
|
|||
|
||||
private async Task<bool> QueueFirstMatchAsync(ActionContext actionContext, DialogEvent dialogEvent, bool preBubble, CancellationToken cancellationToken)
|
||||
{
|
||||
var selection = await Selector.Select(actionContext, cancellationToken).ConfigureAwait(false);
|
||||
var selection = await Selector.SelectAsync(actionContext, cancellationToken).ConfigureAwait(false);
|
||||
if (selection.Any())
|
||||
{
|
||||
var condition = selection.First();
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
@ -39,8 +40,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Generators
|
|||
/// <param name="dialogContext">Context for the current turn of conversation.</param>
|
||||
/// <param name="template">The template.</param>
|
||||
/// <param name="data">data to bind to.</param>
|
||||
/// <param name="cancellationToken">the <see cref="CancellationToken"/> for the task.</param>
|
||||
/// <returns>The generator.</returns>
|
||||
public override async Task<object> Generate(DialogContext dialogContext, string template, object data)
|
||||
public override async Task<object> GenerateAsync(DialogContext dialogContext, string template, object data, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var targetLocale = dialogContext.Context.Activity.Locale?.ToLower() ?? string.Empty;
|
||||
|
||||
|
@ -89,7 +91,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Generators
|
|||
{
|
||||
try
|
||||
{
|
||||
return await generator.Generate(dialogContext, template, data);
|
||||
return await generator.GenerateAsync(dialogContext, template, data, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Bot.Builder.Dialogs.Declarative.Resources;
|
||||
using Microsoft.Bot.Builder.LanguageGeneration;
|
||||
|
@ -84,12 +85,13 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Generators
|
|||
/// <param name="dialogContext">Context for the current turn of conversation.</param>
|
||||
/// <param name="template">template to evaluate.</param>
|
||||
/// <param name="data">data to bind to.</param>
|
||||
/// <param name="cancellationToken">the <see cref="CancellationToken"/> for the task.</param>
|
||||
/// <returns>generated text.</returns>
|
||||
public override async Task<object> Generate(DialogContext dialogContext, string template, object data)
|
||||
public override Task<object> GenerateAsync(DialogContext dialogContext, string template, object data, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await Task.FromResult(lg.EvaluateText(template, data));
|
||||
return Task.FromResult(lg.EvaluateText(template, data));
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AdaptiveExpressions.Properties;
|
||||
using Microsoft.Bot.Schema;
|
||||
|
@ -50,7 +51,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
[JsonProperty("outputFormat")]
|
||||
public EnumExpression<AttachmentOutputFormat> OutputFormat { get; set; } = AttachmentOutputFormat.First;
|
||||
|
||||
protected override Task<InputState> OnRecognizeInput(DialogContext dc)
|
||||
protected override Task<InputState> OnRecognizeInputAsync(DialogContext dc, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var input = dc.State.GetValue<List<Attachment>>(VALUE_PROPERTY);
|
||||
var first = input.Count > 0 ? input[0] : null;
|
||||
|
|
|
@ -140,7 +140,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
return base.OnInitializeOptions(dc, op);
|
||||
}
|
||||
|
||||
protected override Task<InputState> OnRecognizeInput(DialogContext dc)
|
||||
protected override Task<InputState> OnRecognizeInputAsync(DialogContext dc, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
var input = dc.State.GetValue<object>(VALUE_PROPERTY);
|
||||
var options = dc.State.GetValue<ChoiceInputOptions>(ThisPath.Options);
|
||||
|
@ -174,10 +174,10 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
return Task.FromResult(InputState.Valid);
|
||||
}
|
||||
|
||||
protected override async Task<IActivity> OnRenderPrompt(DialogContext dc, InputState state)
|
||||
protected override async Task<IActivity> OnRenderPromptAsync(DialogContext dc, InputState state, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
var locale = GetCulture(dc);
|
||||
var prompt = await base.OnRenderPrompt(dc, state);
|
||||
var prompt = await base.OnRenderPromptAsync(dc, state, cancellationToken).ConfigureAwait(false);
|
||||
var channelId = dc.Context.Activity.ChannelId;
|
||||
var choicePrompt = new ChoicePrompt(this.Id);
|
||||
var choiceOptions = this.ChoiceOptions?.GetValue(dc.State) ?? ChoiceInput.DefaultChoiceOptions[locale];
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AdaptiveExpressions.Properties;
|
||||
using Microsoft.Bot.Builder.Dialogs.Choices;
|
||||
|
@ -77,7 +78,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
[JsonProperty("outputFormat")]
|
||||
public ValueExpression OutputFormat { get; set; }
|
||||
|
||||
protected override Task<InputState> OnRecognizeInput(DialogContext dc)
|
||||
protected override Task<InputState> OnRecognizeInputAsync(DialogContext dc, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var input = dc.State.GetValue<object>(VALUE_PROPERTY);
|
||||
if (dc.Context.Activity.Type == ActivityTypes.Message)
|
||||
|
@ -139,7 +140,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
return Task.FromResult(InputState.Valid);
|
||||
}
|
||||
|
||||
protected override async Task<IActivity> OnRenderPrompt(DialogContext dc, InputState state)
|
||||
protected override async Task<IActivity> OnRenderPromptAsync(DialogContext dc, InputState state, CancellationToken cancellationToken = default)
|
||||
{
|
||||
// Format prompt to send
|
||||
var channelId = dc.Context.Activity.ChannelId;
|
||||
|
@ -148,7 +149,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
var choiceOptions = ChoiceOptions?.GetValue(dc.State) ?? defaults.Item3;
|
||||
var confirmChoices = ConfirmChoices?.GetValue(dc.State) ?? new List<Choice>() { defaults.Item1, defaults.Item2 };
|
||||
|
||||
var prompt = await base.OnRenderPrompt(dc, state);
|
||||
var prompt = await base.OnRenderPromptAsync(dc, state, cancellationToken).ConfigureAwait(false);
|
||||
var (style, error) = this.Style.TryGetValue(dc.State);
|
||||
return this.AppendChoices(prompt.AsMessageActivity(), channelId, confirmChoices, style, choiceOptions);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AdaptiveExpressions;
|
||||
using AdaptiveExpressions.Properties;
|
||||
|
@ -45,7 +46,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
[JsonProperty("outputFormat")]
|
||||
public Expression OutputFormat { get; set; }
|
||||
|
||||
protected override Task<InputState> OnRecognizeInput(DialogContext dc)
|
||||
protected override Task<InputState> OnRecognizeInputAsync(DialogContext dc, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
var input = dc.State.GetValue<object>(VALUE_PROPERTY);
|
||||
var culture = GetCulture(dc);
|
||||
|
|
|
@ -176,7 +176,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
dc.State.SetValue(property, null);
|
||||
}
|
||||
|
||||
var state = alwaysPrompt ? InputState.Missing : await this.RecognizeInput(dc, 0);
|
||||
var state = alwaysPrompt ? InputState.Missing : await this.RecognizeInputAsync(dc, 0, cancellationToken).ConfigureAwait(false);
|
||||
if (state == InputState.Valid)
|
||||
{
|
||||
var input = dc.State.GetValue<object>(VALUE_PROPERTY);
|
||||
|
@ -185,7 +185,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
dc.State.SetValue(property, input);
|
||||
|
||||
// return as result too
|
||||
return await dc.EndDialogAsync(input);
|
||||
return await dc.EndDialogAsync(input, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -193,7 +193,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
// We will set the turn count to 1 so the input will not pick from "dialog.value"
|
||||
// and instead go with "turn.activity.text"
|
||||
dc.State.SetValue(TURN_COUNT_PROPERTY, 1);
|
||||
return await this.PromptUser(dc, state);
|
||||
return await this.PromptUserAsync(dc, state, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,7 +209,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
var turnCount = dc.State.GetValue<int>(TURN_COUNT_PROPERTY, () => 0);
|
||||
|
||||
// Perform base recognition
|
||||
var state = await this.RecognizeInput(dc, interrupted ? 0 : turnCount);
|
||||
var state = await this.RecognizeInputAsync(dc, interrupted ? 0 : turnCount, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (state == InputState.Valid)
|
||||
{
|
||||
|
@ -221,13 +221,13 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
dc.State.SetValue(this.Property.GetValue(dc.State), input);
|
||||
}
|
||||
|
||||
return await dc.EndDialogAsync(input).ConfigureAwait(false);
|
||||
return await dc.EndDialogAsync(input, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
else if (this.MaxTurnCount == null || turnCount < this.MaxTurnCount.GetValue(dc.State))
|
||||
{
|
||||
// increase the turnCount as last step
|
||||
dc.State.SetValue(TURN_COUNT_PROPERTY, turnCount + 1);
|
||||
return await this.PromptUser(dc, state).ConfigureAwait(false);
|
||||
return await this.PromptUserAsync(dc, state, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -236,7 +236,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
var (value, error) = this.DefaultValue.TryGetValue(dc.State);
|
||||
if (this.DefaultValueResponse != null)
|
||||
{
|
||||
var response = await this.DefaultValueResponse.BindAsync(dc).ConfigureAwait(false);
|
||||
var response = await this.DefaultValueResponse.BindAsync(dc, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var properties = new Dictionary<string, string>()
|
||||
{
|
||||
|
@ -245,13 +245,13 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
};
|
||||
TelemetryClient.TrackEvent("GeneratorResult", properties);
|
||||
|
||||
await dc.Context.SendActivityAsync(response).ConfigureAwait(false);
|
||||
await dc.Context.SendActivityAsync(response, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
// set output property
|
||||
dc.State.SetValue(this.Property.GetValue(dc.State), value);
|
||||
|
||||
return await dc.EndDialogAsync(value).ConfigureAwait(false);
|
||||
return await dc.EndDialogAsync(value, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -260,15 +260,16 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
|
||||
public override async Task<DialogTurnResult> ResumeDialogAsync(DialogContext dc, DialogReason reason, object result = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return await this.PromptUser(dc, InputState.Missing).ConfigureAwait(false);
|
||||
return await this.PromptUserAsync(dc, InputState.Missing, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when input has been received, override this method to cutomize recognition of the input.
|
||||
/// </summary>
|
||||
/// <param name="dc">dialogContext.</param>
|
||||
/// <param name="cancellationToken">the <see cref="CancellationToken"/> for the task.</param>
|
||||
/// <returns>InputState which reflects whether input was recognized as valid or not.</returns>
|
||||
protected abstract Task<InputState> OnRecognizeInput(DialogContext dc);
|
||||
protected abstract Task<InputState> OnRecognizeInputAsync(DialogContext dc, CancellationToken cancellationToken);
|
||||
|
||||
protected override async Task<bool> OnPreBubbleEventAsync(DialogContext dc, DialogEvent e, CancellationToken cancellationToken)
|
||||
{
|
||||
|
@ -382,8 +383,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
/// <remarks>Override this to customize the output sent to the user.</remarks>
|
||||
/// <param name="dc">dialogcontext.</param>
|
||||
/// <param name="state">inputState.</param>
|
||||
/// <param name="cancellationToken">the <see cref="CancellationToken"/> for the task.</param>
|
||||
/// <returns>activity to send to the user.</returns>
|
||||
protected virtual async Task<IActivity> OnRenderPrompt(DialogContext dc, InputState state)
|
||||
protected virtual async Task<IActivity> OnRenderPromptAsync(DialogContext dc, InputState state, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
IMessageActivity msg = null;
|
||||
ITemplate<Activity> template = null;
|
||||
|
@ -393,12 +395,12 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
if (this.UnrecognizedPrompt != null)
|
||||
{
|
||||
template = this.UnrecognizedPrompt;
|
||||
msg = await this.UnrecognizedPrompt.BindAsync(dc).ConfigureAwait(false);
|
||||
msg = await this.UnrecognizedPrompt.BindAsync(dc, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
else if (this.InvalidPrompt != null)
|
||||
{
|
||||
template = this.InvalidPrompt;
|
||||
msg = await this.InvalidPrompt.BindAsync(dc).ConfigureAwait(false);
|
||||
msg = await this.InvalidPrompt.BindAsync(dc, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -407,12 +409,12 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
if (this.InvalidPrompt != null)
|
||||
{
|
||||
template = this.InvalidPrompt;
|
||||
msg = await this.InvalidPrompt.BindAsync(dc).ConfigureAwait(false);
|
||||
msg = await this.InvalidPrompt.BindAsync(dc, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
else if (this.UnrecognizedPrompt != null)
|
||||
{
|
||||
template = this.UnrecognizedPrompt;
|
||||
msg = await this.UnrecognizedPrompt.BindAsync(dc).ConfigureAwait(false);
|
||||
msg = await this.UnrecognizedPrompt.BindAsync(dc, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -421,7 +423,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
if (msg == null)
|
||||
{
|
||||
template = this.Prompt;
|
||||
msg = await this.Prompt.BindAsync(dc).ConfigureAwait(false);
|
||||
msg = await this.Prompt.BindAsync(dc, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
msg.InputHint = InputHints.ExpectingInput;
|
||||
|
@ -436,7 +438,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
return msg;
|
||||
}
|
||||
|
||||
private async Task<InputState> RecognizeInput(DialogContext dc, int turnCount)
|
||||
private async Task<InputState> RecognizeInputAsync(DialogContext dc, int turnCount, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
dynamic input = null;
|
||||
|
||||
|
@ -487,7 +489,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
dc.State.SetValue(VALUE_PROPERTY, input);
|
||||
if (input != null)
|
||||
{
|
||||
var state = await this.OnRecognizeInput(dc).ConfigureAwait(false);
|
||||
var state = await this.OnRecognizeInputAsync(dc, cancellationToken).ConfigureAwait(false);
|
||||
if (state == InputState.Valid)
|
||||
{
|
||||
foreach (var validation in this.Validations)
|
||||
|
@ -513,10 +515,10 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
}
|
||||
}
|
||||
|
||||
private async Task<DialogTurnResult> PromptUser(DialogContext dc, InputState state)
|
||||
private async Task<DialogTurnResult> PromptUserAsync(DialogContext dc, InputState state, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
var prompt = await this.OnRenderPrompt(dc, state).ConfigureAwait(false);
|
||||
await dc.Context.SendActivityAsync(prompt).ConfigureAwait(false);
|
||||
var prompt = await this.OnRenderPromptAsync(dc, state, cancellationToken).ConfigureAwait(false);
|
||||
await dc.Context.SendActivityAsync(prompt, cancellationToken).ConfigureAwait(false);
|
||||
return Dialog.EndOfTurn;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AdaptiveExpressions.Properties;
|
||||
using Microsoft.Recognizers.Text.Number;
|
||||
|
@ -42,7 +43,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
[JsonProperty("outputFormat")]
|
||||
public NumberExpression OutputFormat { get; set; }
|
||||
|
||||
protected override Task<InputState> OnRecognizeInput(DialogContext dc)
|
||||
protected override Task<InputState> OnRecognizeInputAsync(DialogContext dc, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
var input = dc.State.GetValue<object>(VALUE_PROPERTY);
|
||||
|
||||
|
|
|
@ -226,8 +226,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
{
|
||||
// increase the turnCount as last step
|
||||
dc.State.SetValue(TURN_COUNT_PROPERTY, turnCount + 1);
|
||||
var prompt = await this.OnRenderPrompt(dc, inputState).ConfigureAwait(false);
|
||||
await dc.Context.SendActivityAsync(prompt).ConfigureAwait(false);
|
||||
var prompt = await this.OnRenderPromptAsync(dc, inputState, cancellationToken).ConfigureAwait(false);
|
||||
await dc.Context.SendActivityAsync(prompt, cancellationToken).ConfigureAwait(false);
|
||||
await SendOAuthCardAsync(dc, promptOptions?.Prompt, cancellationToken).ConfigureAwait(false);
|
||||
return Dialog.EndOfTurn;
|
||||
}
|
||||
|
@ -238,23 +238,23 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
var (value, _) = this.DefaultValue.TryGetValue(dc.State);
|
||||
if (this.DefaultValueResponse != null)
|
||||
{
|
||||
var response = await this.DefaultValueResponse.BindAsync(dc).ConfigureAwait(false);
|
||||
var response = await this.DefaultValueResponse.BindAsync(dc, cancellationToken).ConfigureAwait(false);
|
||||
var properties = new Dictionary<string, string>()
|
||||
{
|
||||
{ "template", JsonConvert.SerializeObject(this.DefaultValueResponse) },
|
||||
{ "result", response == null ? string.Empty : JsonConvert.SerializeObject(response, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }) },
|
||||
};
|
||||
TelemetryClient.TrackEvent("GeneratorResult", properties);
|
||||
await dc.Context.SendActivityAsync(response).ConfigureAwait(false);
|
||||
await dc.Context.SendActivityAsync(response, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
// set output property
|
||||
dc.State.SetValue(this.Property.GetValue(dc.State), value);
|
||||
return await dc.EndDialogAsync(value).ConfigureAwait(false);
|
||||
return await dc.EndDialogAsync(value, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
return await dc.EndDialogAsync().ConfigureAwait(false);
|
||||
return await dc.EndDialogAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -295,7 +295,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
await adapter.SignOutUserAsync(dc.Context, ConnectionName.GetValue(dc.State), dc.Context.Activity?.From?.Id, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
protected override Task<InputState> OnRecognizeInput(DialogContext dc)
|
||||
protected override Task<InputState> OnRecognizeInputAsync(DialogContext dc, CancellationToken cancellationToken = default)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AdaptiveExpressions.Properties;
|
||||
using Newtonsoft.Json;
|
||||
|
@ -30,7 +31,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Input
|
|||
[JsonProperty("outputFormat")]
|
||||
public StringExpression OutputFormat { get; set; }
|
||||
|
||||
protected override Task<InputState> OnRecognizeInput(DialogContext dc)
|
||||
protected override Task<InputState> OnRecognizeInputAsync(DialogContext dc, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
var input = dc.State.GetValue<string>(VALUE_PROPERTY);
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.Bot.Builder.Dialogs.Adaptive
|
||||
|
@ -16,7 +17,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
|
|||
/// <param name="dialogContext">dialogContext.</param>
|
||||
/// <param name="template">template or [templateId].</param>
|
||||
/// <param name="data">data to bind to.</param>
|
||||
/// <param name="cancellationToken">the <see cref="CancellationToken"/> for the task.</param>
|
||||
/// <returns>object or text.</returns>
|
||||
public abstract Task<object> Generate(DialogContext dialogContext, string template, object data);
|
||||
public abstract Task<object> GenerateAsync(DialogContext dialogContext, string template, object data, CancellationToken cancellationToken = default);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AsyncUsageAnalyzers" Version="1.0.0-alpha003" PrivateAssets="all" />
|
||||
<PackageReference Include="Microsoft.Bot.Builder.Dialogs.Declarative" Condition=" '$(IsBuildServer)' == '' " Version="$(LocalPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.Bot.Builder.Dialogs.Declarative" Condition=" '$(IsBuildServer)' != '' " Version="$(ReleasePackageVersion)" />
|
||||
<PackageReference Include="Microsoft.Bot.Builder.LanguageGeneration" Condition=" '$(IsBuildServer)' == '' " Version="$(LocalPackageVersion)" />
|
||||
|
|
|
@ -87,7 +87,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
|
|||
var result = await recognizer.RecognizeAsync(dialogContext, activity, cancellationToken, telemetryProperties, telemetryMetrics).ConfigureAwait(false);
|
||||
result.Properties["id"] = recognizer.Id;
|
||||
return result;
|
||||
}));
|
||||
})).ConfigureAwait(false);
|
||||
|
||||
var result = ProcessResults(results);
|
||||
|
||||
|
|
|
@ -16,22 +16,22 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
|
|||
{
|
||||
}
|
||||
|
||||
public virtual Task<IEnumerable<Entity>> RecognizeEntities(DialogContext dialogContext, IEnumerable<Entity> entities, CancellationToken cancellationToken = default)
|
||||
public virtual Task<IEnumerable<Entity>> RecognizeEntitiesAsync(DialogContext dialogContext, IEnumerable<Entity> entities, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return this.RecognizeEntities(dialogContext, dialogContext.Context.Activity, entities, cancellationToken);
|
||||
return this.RecognizeEntitiesAsync(dialogContext, dialogContext.Context.Activity, entities, cancellationToken);
|
||||
}
|
||||
|
||||
public virtual async Task<IEnumerable<Entity>> RecognizeEntities(DialogContext dialogContext, Activity activity, IEnumerable<Entity> entities, CancellationToken cancellationToken = default)
|
||||
public virtual async Task<IEnumerable<Entity>> RecognizeEntitiesAsync(DialogContext dialogContext, Activity activity, IEnumerable<Entity> entities, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (activity.Type == ActivityTypes.Message)
|
||||
{
|
||||
return await this.RecognizeEntities(dialogContext, activity.Text, activity.Locale, entities, cancellationToken).ConfigureAwait(false);
|
||||
return await this.RecognizeEntitiesAsync(dialogContext, activity.Text, activity.Locale, entities, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
return new List<Entity>();
|
||||
}
|
||||
|
||||
public virtual Task<IEnumerable<Entity>> RecognizeEntities(DialogContext dialogContext, string text, string locale, IEnumerable<Entity> entities, CancellationToken cancellationToken = default)
|
||||
public virtual Task<IEnumerable<Entity>> RecognizeEntitiesAsync(DialogContext dialogContext, string text, string locale, IEnumerable<Entity> entities, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return Task.FromResult<IEnumerable<Entity>>(Array.Empty<Entity>());
|
||||
}
|
||||
|
|
|
@ -30,9 +30,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
|
|||
/// <param name="dialogContext">Context for the current turn of conversation.</param>
|
||||
/// <param name="entities">if no entities are passed in, it will generate a <see cref="TextEntity"/> for turnContext.Activity.Text and then generate entities off of that.</param>
|
||||
/// <returns><see cref="Entity"/> list.</returns>
|
||||
public virtual Task<IList<Entity>> RecognizeEntities(DialogContext dialogContext, IEnumerable<Entity> entities = null)
|
||||
public virtual Task<IList<Entity>> RecognizeEntitiesAsync(DialogContext dialogContext, IEnumerable<Entity> entities = null)
|
||||
{
|
||||
return this.RecognizeEntities(dialogContext, dialogContext.Context.Activity, entities);
|
||||
return this.RecognizeEntitiesAsync(dialogContext, dialogContext.Context.Activity, entities);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -42,11 +42,11 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
|
|||
/// <param name="activity">activity to recognize against.</param>
|
||||
/// <param name="entities">if no entities are passed in, it will generate a <see cref="TextEntity"/> for turnContext.Activity.Text and then generate entities off of that.</param>
|
||||
/// <returns><see cref="Entity"/> list.</returns>
|
||||
public virtual async Task<IList<Entity>> RecognizeEntities(DialogContext dialogContext, Activity activity, IEnumerable<Entity> entities = null)
|
||||
public virtual async Task<IList<Entity>> RecognizeEntitiesAsync(DialogContext dialogContext, Activity activity, IEnumerable<Entity> entities = null)
|
||||
{
|
||||
if (activity.Type == ActivityTypes.Message)
|
||||
{
|
||||
return await this.RecognizeEntities(dialogContext, activity.Text, activity.Locale, entities).ConfigureAwait(false);
|
||||
return await this.RecognizeEntitiesAsync(dialogContext, activity.Text, activity.Locale, entities).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
return new List<Entity>();
|
||||
|
@ -60,7 +60,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
|
|||
/// <param name="locale">locale to use.</param>
|
||||
/// <param name="entities">if no entities are passed in, it will generate a <see cref="TextEntity"/> for turnContext.Activity.Text and then generate entities off of that.</param>
|
||||
/// <returns><see cref="Entity"/> list.</returns>
|
||||
public virtual async Task<IList<Entity>> RecognizeEntities(DialogContext dialogContext, string text, string locale, IEnumerable<Entity> entities = null)
|
||||
public virtual async Task<IList<Entity>> RecognizeEntitiesAsync(DialogContext dialogContext, string text, string locale, IEnumerable<Entity> entities = null)
|
||||
{
|
||||
List<Entity> allNewEntities = new List<Entity>();
|
||||
List<Entity> entitiesToProcess = new List<Entity>(entities ?? Array.Empty<Entity>());
|
||||
|
@ -84,7 +84,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
|
|||
try
|
||||
{
|
||||
// get new entities
|
||||
var newEntities = await recognizer.RecognizeEntities(dialogContext, text, locale, entitiesToProcess).ConfigureAwait(false);
|
||||
var newEntities = await recognizer.RecognizeEntitiesAsync(dialogContext, text, locale, entitiesToProcess).ConfigureAwait(false);
|
||||
|
||||
foreach (var newEntity in newEntities)
|
||||
{
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
|
|||
{
|
||||
}
|
||||
|
||||
public override Task<IEnumerable<Entity>> RecognizeEntities(DialogContext dialogContext, string text, string locale, IEnumerable<Entity> entities, CancellationToken cancellationToken = default)
|
||||
public override Task<IEnumerable<Entity>> RecognizeEntitiesAsync(DialogContext dialogContext, string text, string locale, IEnumerable<Entity> entities, CancellationToken cancellationToken = default)
|
||||
{
|
||||
List<Entity> newEntities = new List<Entity>();
|
||||
var culture = Culture.MapToNearestLanguage(locale ?? string.Empty);
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
|
|||
}
|
||||
|
||||
// run all of the recognizers in parallel
|
||||
var results = await Task.WhenAll(Recognizers.Select(r => r.RecognizeAsync(dialogContext, activity, cancellationToken, telemetryProperties, telemetryMetrics)));
|
||||
var results = await Task.WhenAll(Recognizers.Select(r => r.RecognizeAsync(dialogContext, activity, cancellationToken, telemetryProperties, telemetryMetrics))).ConfigureAwait(false);
|
||||
|
||||
// merge intents
|
||||
var result = MergeResults(results);
|
||||
|
|
|
@ -115,7 +115,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers
|
|||
{
|
||||
// process entities using EntityRecognizerSet
|
||||
var entitySet = new EntityRecognizerSet(this.Entities);
|
||||
var newEntities = await entitySet.RecognizeEntities(dialogContext, text, locale, entityPool).ConfigureAwait(false);
|
||||
var newEntities = await entitySet.RecognizeEntitiesAsync(dialogContext, text, locale, entityPool).ConfigureAwait(false);
|
||||
if (newEntities.Any())
|
||||
{
|
||||
entityPool.AddRange(newEntities);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"$schema": "https://raw.githubusercontent.com/microsoft/botframework-sdk/master/schemas/component/component.schema",
|
||||
"$role": "implements(Microsoft.IDialog)",
|
||||
"title": "Begin a skill dialog",
|
||||
"description": "Begin a remote skill dialog.",
|
||||
"title": "Begin a skill",
|
||||
"description": "Begin a remote skill.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
|
@ -55,7 +55,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors
|
|||
_evaluate = evaluate;
|
||||
}
|
||||
|
||||
public override async Task<IReadOnlyList<OnCondition>> Select(ActionContext actionContext, CancellationToken cancel = default)
|
||||
public override async Task<IReadOnlyList<OnCondition>> SelectAsync(ActionContext actionContext, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var (eval, _) = Condition.TryGetValue(actionContext.State);
|
||||
TriggerSelector selector;
|
||||
|
@ -70,7 +70,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors
|
|||
IfFalse.Initialize(_conditionals, _evaluate);
|
||||
}
|
||||
|
||||
return await selector.Select(actionContext, cancel).ConfigureAwait(false);
|
||||
return await selector.SelectAsync(actionContext, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors
|
|||
_evaluate = evaluate;
|
||||
}
|
||||
|
||||
public override Task<IReadOnlyList<OnCondition>> Select(ActionContext context, CancellationToken cancel)
|
||||
public override Task<IReadOnlyList<OnCondition>> SelectAsync(ActionContext context, CancellationToken cancellationToken)
|
||||
{
|
||||
OnCondition selection = null;
|
||||
var lowestPriority = int.MaxValue;
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors
|
|||
}
|
||||
}
|
||||
|
||||
public override async Task<IReadOnlyList<OnCondition>> Select(ActionContext context, CancellationToken cancel)
|
||||
public override async Task<IReadOnlyList<OnCondition>> SelectAsync(ActionContext context, CancellationToken cancellationToken)
|
||||
{
|
||||
var triggers = _tree.Matches(context.State);
|
||||
var matches = new List<OnCondition>();
|
||||
|
@ -50,7 +50,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors
|
|||
if (Selector != null)
|
||||
{
|
||||
Selector.Initialize(matches, false);
|
||||
selections = await Selector.Select(context, cancel).ConfigureAwait(false);
|
||||
selections = await Selector.SelectAsync(context, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
return selections;
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors
|
|||
}
|
||||
}
|
||||
|
||||
public override Task<IReadOnlyList<OnCondition>> Select(ActionContext context, CancellationToken cancel = default)
|
||||
public override Task<IReadOnlyList<OnCondition>> SelectAsync(ActionContext context, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var candidates = _conditionals;
|
||||
if (_evaluate)
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Selectors
|
|||
_evaluate = evaluate;
|
||||
}
|
||||
|
||||
public override Task<IReadOnlyList<OnCondition>> Select(ActionContext context, CancellationToken cancel = default)
|
||||
public override Task<IReadOnlyList<OnCondition>> SelectAsync(ActionContext context, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var candidates = _conditionals;
|
||||
if (_evaluate)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Bot.Builder.Dialogs.Adaptive.Generators;
|
||||
using Microsoft.Bot.Schema;
|
||||
|
@ -40,14 +41,14 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Templates
|
|||
[JsonProperty("template")]
|
||||
public string Template { get; set; }
|
||||
|
||||
public virtual async Task<Activity> BindAsync(DialogContext dialogContext, object data = null)
|
||||
public virtual async Task<Activity> BindAsync(DialogContext dialogContext, object data = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(this.Template))
|
||||
{
|
||||
var languageGenerator = dialogContext.Services.Get<LanguageGenerator>();
|
||||
if (languageGenerator != null)
|
||||
{
|
||||
var lgStringResult = await languageGenerator.Generate(dialogContext, this.Template, data ?? dialogContext.State).ConfigureAwait(false);
|
||||
var lgStringResult = await languageGenerator.GenerateAsync(dialogContext, this.Template, data ?? dialogContext.State, cancellationToken).ConfigureAwait(false);
|
||||
var result = ActivityFactory.FromObject(lgStringResult);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Bot.Schema;
|
||||
using Newtonsoft.Json;
|
||||
|
@ -28,7 +29,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Templates
|
|||
[JsonProperty("activity")]
|
||||
public Activity Activity { get; set; }
|
||||
|
||||
public Task<Activity> BindAsync(DialogContext context, object data = null)
|
||||
public Task<Activity> BindAsync(DialogContext context, object data = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return Task.FromResult(Activity);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
@ -33,7 +34,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Templates
|
|||
[JsonProperty("template")]
|
||||
public string Template { get; set; }
|
||||
|
||||
public virtual async Task<string> BindAsync(DialogContext dialogContext, object data = null)
|
||||
public virtual async Task<string> BindAsync(DialogContext dialogContext, object data = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.Template))
|
||||
{
|
||||
|
@ -43,10 +44,11 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Templates
|
|||
LanguageGenerator languageGenerator = dialogContext.Services.Get<LanguageGenerator>();
|
||||
if (languageGenerator != null)
|
||||
{
|
||||
var result = await languageGenerator.Generate(
|
||||
var result = await languageGenerator.GenerateAsync(
|
||||
dialogContext,
|
||||
template: Template,
|
||||
data: data ?? dialogContext.State).ConfigureAwait(false);
|
||||
data: data ?? dialogContext.State,
|
||||
cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
|
|
|
@ -226,7 +226,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Conditions
|
|||
/// </summary>
|
||||
/// <param name="actionContext">Context.</param>
|
||||
/// <returns>A <see cref="Task"/> with plan change list.</returns>
|
||||
public virtual async Task<List<ActionChangeList>> ExecuteAsync(ActionContext actionContext)
|
||||
public virtual Task<List<ActionChangeList>> ExecuteAsync(ActionContext actionContext)
|
||||
{
|
||||
if (RunOnce)
|
||||
{
|
||||
|
@ -234,7 +234,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Conditions
|
|||
actionContext.State.SetValue($"{AdaptiveDialog.ConditionTracker}.{Id}.lastRun", count);
|
||||
}
|
||||
|
||||
return await Task.FromResult(new List<ActionChangeList>()
|
||||
return Task.FromResult(new List<ActionChangeList>()
|
||||
{
|
||||
this.OnCreateChangeList(actionContext)
|
||||
});
|
||||
|
|
|
@ -24,8 +24,8 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive
|
|||
/// Select the best rule to execute.
|
||||
/// </summary>
|
||||
/// <param name="actionContext">Dialog context for evaluation.</param>
|
||||
/// <param name="cancel">Cancellation token.</param>
|
||||
/// <param name="cancellationToken">Cancellation token.</param>
|
||||
/// <returns>Best rule in original list to execute or -1 if none.</returns>
|
||||
public abstract Task<IReadOnlyList<OnCondition>> Select(ActionContext actionContext, CancellationToken cancel = default);
|
||||
public abstract Task<IReadOnlyList<OnCondition>> SelectAsync(ActionContext actionContext, CancellationToken cancellationToken = default);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AsyncUsageAnalyzers" Version="1.0.0-alpha003" PrivateAssets="all" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.1.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Json.Pointer" Version="0.61.0" />
|
||||
<PackageReference Include="AsyncUsageAnalyzers" Version="1.0.0-alpha003" PrivateAssets="all" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="NuGet.Client" Version="4.2.0" />
|
||||
<PackageReference Include="Microsoft.Bot.Builder.Dialogs" Condition=" '$(IsBuildServer)' == '' " Version="$(LocalPackageVersion)" />
|
||||
|
|
|
@ -13,7 +13,6 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources
|
|||
public class FileResource : Resource
|
||||
{
|
||||
private Task<byte[]> contentTask;
|
||||
private Task<string> textTask;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FileResource"/> class.
|
||||
|
|
|
@ -151,8 +151,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources
|
|||
/// </summary>
|
||||
/// <typeparam name="T">type to create.</typeparam>
|
||||
/// <param name="resource">resource to bind to.</param>
|
||||
/// <param name="cancellationToken">the <see cref="CancellationToken"/> for the task.</param>
|
||||
/// <returns>task which will resolve to created type.</returns>
|
||||
public async Task<T> LoadTypeAsync<T>(Resource resource)
|
||||
public async Task<T> LoadTypeAsync<T>(Resource resource, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RegisterComponentTypes();
|
||||
|
||||
|
@ -165,7 +166,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources
|
|||
try
|
||||
{
|
||||
var sourceContext = new SourceContext();
|
||||
var (json, range) = await ReadTokenRangeAsync(resource, sourceContext);
|
||||
var (json, range) = await ReadTokenRangeAsync(resource, sourceContext, cancellationToken).ConfigureAwait(false);
|
||||
using (new SourceScope(sourceContext, range))
|
||||
{
|
||||
var result = Load<T>(json, sourceContext);
|
||||
|
@ -368,8 +369,9 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources
|
|||
/// </summary>
|
||||
/// <param name="refToken">reference.</param>
|
||||
/// <param name="sourceContext">source context to build debugger source map.</param>
|
||||
/// <param name="cancellationToken">the <see cref="CancellationToken"/> for the task.</param>
|
||||
/// <returns>resolved object the reference refers to.</returns>
|
||||
public async Task<JToken> ResolveRefAsync(JToken refToken, SourceContext sourceContext)
|
||||
public async Task<JToken> ResolveRefAsync(JToken refToken, SourceContext sourceContext, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var refTarget = GetRefTarget(refToken);
|
||||
|
||||
|
@ -388,7 +390,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources
|
|||
}
|
||||
}
|
||||
|
||||
var (json, range) = await ReadTokenRangeAsync(resource, sourceContext);
|
||||
var (json, range) = await ReadTokenRangeAsync(resource, sourceContext, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
foreach (JProperty prop in refToken.Children<JProperty>())
|
||||
{
|
||||
|
@ -538,7 +540,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Declarative.Resources
|
|||
return token.ToObject<T>(serializer);
|
||||
}
|
||||
|
||||
private async Task<(JToken, SourceRange)> ReadTokenRangeAsync(Resource resource, SourceContext sourceContext)
|
||||
private async Task<(JToken, SourceRange)> ReadTokenRangeAsync(Resource resource, SourceContext sourceContext, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var text = await resource.ReadTextAsync().ConfigureAwait(false);
|
||||
using (var readerText = new StringReader(text))
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
@ -46,6 +47,7 @@ namespace Microsoft.Bot.Builder.Dialogs
|
|||
/// CheckForVersionChangeAsync.
|
||||
/// </summary>
|
||||
/// <param name="dc">dialog context.</param>
|
||||
/// <param name="cancellationToken">cancellationToken.</param>
|
||||
/// <returns>task.</returns>
|
||||
/// <remarks>
|
||||
/// Checks to see if a containers child dialogs have changed since the current dialog instance
|
||||
|
@ -53,7 +55,7 @@ namespace Microsoft.Bot.Builder.Dialogs
|
|||
///
|
||||
/// This should be called at the start of `beginDialog()`, `continueDialog()`, and `resumeDialog()`.
|
||||
/// </remarks>
|
||||
protected virtual async Task CheckForVersionChangeAsync(DialogContext dc)
|
||||
protected virtual async Task CheckForVersionChangeAsync(DialogContext dc, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
var current = dc.ActiveDialog.Version;
|
||||
dc.ActiveDialog.Version = this.GetInternalVersion();
|
||||
|
@ -64,7 +66,7 @@ namespace Microsoft.Bot.Builder.Dialogs
|
|||
// Give bot an opportunity to handle the change.
|
||||
// - If bot handles it the changeHash will have been updated as to avoid triggering the
|
||||
// change again.
|
||||
var handled = await dc.EmitEventAsync(DialogEvents.VersionChanged, this.Id, true, false).ConfigureAwait(false);
|
||||
var handled = await dc.EmitEventAsync(DialogEvents.VersionChanged, this.Id, true, false, cancellationToken).ConfigureAwait(false);
|
||||
if (!handled)
|
||||
{
|
||||
// Throw an error for bot to catch
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.Bot.Builder.Dialogs
|
||||
|
@ -15,7 +16,8 @@ namespace Microsoft.Bot.Builder.Dialogs
|
|||
/// </summary>
|
||||
/// <param name="dialogContext">dialogContext.</param>
|
||||
/// <param name="data">data to bind to. If Null, then dc.State will be used.</param>
|
||||
/// <param name="cancellationToken">the <see cref="CancellationToken"/> for this task.</param>
|
||||
/// <returns>instance of T.</returns>
|
||||
Task<T> BindAsync(DialogContext dialogContext, object data = null);
|
||||
Task<T> BindAsync(DialogContext dialogContext, object data = null, CancellationToken cancellationToken = default(CancellationToken));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Profiling
|
|||
Console.WriteLine($" loading took {loading} ms");
|
||||
|
||||
var iterationTime = 0L;
|
||||
var firstTime = 0l;
|
||||
var firstTime = 0L;
|
||||
for (var iter = 0; iter < iterations; ++iter)
|
||||
{
|
||||
timer.Restart();
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace Microsoft.Bot.Builder.AI.LanguageGeneration.Tests
|
|||
{
|
||||
var context = GetDialogContext(string.Empty);
|
||||
var lg = new TemplateEngineLanguageGenerator();
|
||||
await lg.Generate(context, "${tesdfdfsst()}", null);
|
||||
await lg.GenerateAsync(context, "${tesdfdfsst()}", null);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
@ -43,35 +43,35 @@ namespace Microsoft.Bot.Builder.AI.LanguageGeneration.Tests
|
|||
|
||||
var resource = resourceExplorer.GetResource("a.en-US.lg") as FileResource;
|
||||
var generator = new TemplateEngineLanguageGenerator(resource.FullName, lgResourceGroup);
|
||||
var result = await generator.Generate(GetDialogContext(), "${templatea()}", null);
|
||||
var result = await generator.GenerateAsync(GetDialogContext(), "${templatea()}", null);
|
||||
Assert.AreEqual("from a.en-us.lg", result);
|
||||
|
||||
// import b.en-us.lg
|
||||
result = await generator.Generate(GetDialogContext(), "${templateb()}", null);
|
||||
result = await generator.GenerateAsync(GetDialogContext(), "${templateb()}", null);
|
||||
Assert.AreEqual("from b.en-us.lg", result);
|
||||
|
||||
// fallback to c.en.lg
|
||||
result = await generator.Generate(GetDialogContext(), "${templatec()}", null);
|
||||
result = await generator.GenerateAsync(GetDialogContext(), "${templatec()}", null);
|
||||
Assert.AreEqual("from c.en.lg", result);
|
||||
|
||||
// there is no 'greeting' template in b.en-us.lg, no more fallback to b.lg
|
||||
var ex = await Assert.ThrowsExceptionAsync<Exception>(async () => await generator.Generate(GetDialogContext(), "${greeting()}", null));
|
||||
var ex = await Assert.ThrowsExceptionAsync<Exception>(async () => await generator.GenerateAsync(GetDialogContext(), "${greeting()}", null));
|
||||
Assert.IsTrue(ex.Message.Contains("greeting does not have an evaluator"));
|
||||
|
||||
resource = resourceExplorer.GetResource("a.lg") as FileResource;
|
||||
generator = new TemplateEngineLanguageGenerator(resource.FullName, lgResourceGroup);
|
||||
|
||||
result = await generator.Generate(GetDialogContext(), "${templatea()}", null);
|
||||
result = await generator.GenerateAsync(GetDialogContext(), "${templatea()}", null);
|
||||
Assert.AreEqual("from a.lg", result);
|
||||
|
||||
result = await generator.Generate(GetDialogContext(), "${templateb()}", null);
|
||||
result = await generator.GenerateAsync(GetDialogContext(), "${templateb()}", null);
|
||||
Assert.AreEqual("from b.lg", result);
|
||||
|
||||
// ignore the "en" in c.en.lg, just load c.lg
|
||||
result = await generator.Generate(GetDialogContext(), "${templatec()}", null);
|
||||
result = await generator.GenerateAsync(GetDialogContext(), "${templatec()}", null);
|
||||
Assert.AreEqual("from c.lg", result);
|
||||
|
||||
result = await generator.Generate(GetDialogContext(), "${greeting()}", null);
|
||||
result = await generator.GenerateAsync(GetDialogContext(), "${greeting()}", null);
|
||||
Assert.AreEqual("hi", result);
|
||||
}
|
||||
|
||||
|
@ -86,19 +86,19 @@ namespace Microsoft.Bot.Builder.AI.LanguageGeneration.Tests
|
|||
Assert.IsNotNull(lg, "ILanguageGenerator should not be null");
|
||||
Assert.IsNotNull(dialogContext.Services.Get<ResourceExplorer>(), "ResourceExplorer should not be null");
|
||||
|
||||
var result = await lg.Generate(dialogContext, "${templatea()}", null);
|
||||
var result = await lg.GenerateAsync(dialogContext, "${templatea()}", null);
|
||||
Assert.AreEqual("from a.en-us.lg", result);
|
||||
|
||||
// import b.en-us.lg
|
||||
result = await lg.Generate(dialogContext, "${templateb()}", null);
|
||||
result = await lg.GenerateAsync(dialogContext, "${templateb()}", null);
|
||||
Assert.AreEqual("from b.en-us.lg", result);
|
||||
|
||||
// fallback to c.en.lg
|
||||
result = await lg.Generate(dialogContext, "${templatec()}", null);
|
||||
result = await lg.GenerateAsync(dialogContext, "${templatec()}", null);
|
||||
Assert.AreEqual("from c.en.lg", result);
|
||||
|
||||
// there is no 'greeting' template in b.en-us.lg, fallback to a.lg to find it.
|
||||
result = await lg.Generate(dialogContext, "${greeting()}", null);
|
||||
result = await lg.GenerateAsync(dialogContext, "${greeting()}", null);
|
||||
Assert.AreEqual("hi", result);
|
||||
|
||||
//en locale
|
||||
|
@ -106,34 +106,34 @@ namespace Microsoft.Bot.Builder.AI.LanguageGeneration.Tests
|
|||
Assert.IsNotNull(lg, "ILanguageGenerator should not be null");
|
||||
Assert.IsNotNull(dialogContext.Services.Get<ResourceExplorer>(), "ResourceExplorer should not be null");
|
||||
|
||||
result = await lg.Generate(dialogContext, "${templatea()}", null);
|
||||
result = await lg.GenerateAsync(dialogContext, "${templatea()}", null);
|
||||
Assert.AreEqual("from a.lg", result);
|
||||
|
||||
// import b.en-us.lg
|
||||
result = await lg.Generate(dialogContext, "${templateb()}", null);
|
||||
result = await lg.GenerateAsync(dialogContext, "${templateb()}", null);
|
||||
Assert.AreEqual("from b.lg", result);
|
||||
|
||||
// c.en.lg is ignore in b.lg
|
||||
result = await lg.Generate(dialogContext, "${templatec()}", null);
|
||||
result = await lg.GenerateAsync(dialogContext, "${templatec()}", null);
|
||||
Assert.AreEqual("from c.lg", result);
|
||||
|
||||
// there is no 'greeting' template in b.en-us.lg, fallback to a.lg to find it.
|
||||
result = await lg.Generate(dialogContext, "${greeting()}", null);
|
||||
result = await lg.GenerateAsync(dialogContext, "${greeting()}", null);
|
||||
Assert.AreEqual("hi", result);
|
||||
|
||||
// empty locale
|
||||
dialogContext.Context.Activity.Locale = string.Empty;
|
||||
result = await lg.Generate(dialogContext, "${templatea()}", null);
|
||||
result = await lg.GenerateAsync(dialogContext, "${templatea()}", null);
|
||||
Assert.AreEqual("from a.lg", result);
|
||||
|
||||
result = await lg.Generate(dialogContext, "${templateb()}", null);
|
||||
result = await lg.GenerateAsync(dialogContext, "${templateb()}", null);
|
||||
Assert.AreEqual("from b.lg", result);
|
||||
|
||||
// ignore the "en" in c.en.lg, just load c.lg
|
||||
result = await lg.Generate(dialogContext, "${templatec()}", null);
|
||||
result = await lg.GenerateAsync(dialogContext, "${templatec()}", null);
|
||||
Assert.AreEqual("from c.lg", result);
|
||||
|
||||
result = await lg.Generate(dialogContext, "${greeting()}", null);
|
||||
result = await lg.GenerateAsync(dialogContext, "${greeting()}", null);
|
||||
Assert.AreEqual("hi", result);
|
||||
|
||||
return await dialogContext.EndDialogAsync();
|
||||
|
@ -174,18 +174,18 @@ namespace Microsoft.Bot.Builder.AI.LanguageGeneration.Tests
|
|||
lg.LanguageGenerators["fr"] = new TemplateEngineLanguageGenerator(resourceExplorer.GetResource("test.fr.lg").ReadTextAsync().Result, "test.fr.lg", multilanguageresources);
|
||||
|
||||
// test targeted in each language
|
||||
Assert.AreEqual("english-us", await lg.Generate(GetDialogContext(locale: "en-us"), "${test()}", null));
|
||||
Assert.AreEqual("english-gb", await lg.Generate(GetDialogContext(locale: "en-gb"), "${test()}", null));
|
||||
Assert.AreEqual("english", await lg.Generate(GetDialogContext(locale: "en"), "${test()}", null));
|
||||
Assert.AreEqual("default", await lg.Generate(GetDialogContext(locale: string.Empty), "${test()}", null));
|
||||
Assert.AreEqual("default", await lg.Generate(GetDialogContext(locale: "foo"), "${test()}", null));
|
||||
Assert.AreEqual("english-us", await lg.GenerateAsync(GetDialogContext(locale: "en-us"), "${test()}", null));
|
||||
Assert.AreEqual("english-gb", await lg.GenerateAsync(GetDialogContext(locale: "en-gb"), "${test()}", null));
|
||||
Assert.AreEqual("english", await lg.GenerateAsync(GetDialogContext(locale: "en"), "${test()}", null));
|
||||
Assert.AreEqual("default", await lg.GenerateAsync(GetDialogContext(locale: string.Empty), "${test()}", null));
|
||||
Assert.AreEqual("default", await lg.GenerateAsync(GetDialogContext(locale: "foo"), "${test()}", null));
|
||||
|
||||
// test fallback for en-us -> en -> default
|
||||
//Assert.AreEqual("default2", await lg.Generate(GetTurnContext(locale: "en-us"), "${test2()}", null));
|
||||
Assert.AreEqual("default2", await lg.Generate(GetDialogContext(locale: "en-gb"), "${test2()}", null));
|
||||
Assert.AreEqual("default2", await lg.Generate(GetDialogContext(locale: "en"), "${test2()}", null));
|
||||
Assert.AreEqual("default2", await lg.Generate(GetDialogContext(locale: string.Empty), "${test2()}", null));
|
||||
Assert.AreEqual("default2", await lg.Generate(GetDialogContext(locale: "foo"), "${test2()}", null));
|
||||
Assert.AreEqual("default2", await lg.GenerateAsync(GetDialogContext(locale: "en-gb"), "${test2()}", null));
|
||||
Assert.AreEqual("default2", await lg.GenerateAsync(GetDialogContext(locale: "en"), "${test2()}", null));
|
||||
Assert.AreEqual("default2", await lg.GenerateAsync(GetDialogContext(locale: string.Empty), "${test2()}", null));
|
||||
Assert.AreEqual("default2", await lg.GenerateAsync(GetDialogContext(locale: "foo"), "${test2()}", null));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
@ -194,19 +194,19 @@ namespace Microsoft.Bot.Builder.AI.LanguageGeneration.Tests
|
|||
var lg = new ResourceMultiLanguageGenerator("test.lg");
|
||||
|
||||
// test targeted in each language
|
||||
Assert.AreEqual("english-us", await lg.Generate(GetDialogContext("en-us", lg), "${test()}", null));
|
||||
Assert.AreEqual("english-us", await lg.Generate(GetDialogContext("en-us", lg), "${test()}", new { country = "us" }));
|
||||
Assert.AreEqual("english-gb", await lg.Generate(GetDialogContext("en-gb", lg), "${test()}", null));
|
||||
Assert.AreEqual("english", await lg.Generate(GetDialogContext("en", lg), "${test()}", null));
|
||||
Assert.AreEqual("default", await lg.Generate(GetDialogContext(string.Empty, lg), "${test()}", null));
|
||||
Assert.AreEqual("default", await lg.Generate(GetDialogContext("foo", lg), "${test()}", null));
|
||||
Assert.AreEqual("english-us", await lg.GenerateAsync(GetDialogContext("en-us", lg), "${test()}", null));
|
||||
Assert.AreEqual("english-us", await lg.GenerateAsync(GetDialogContext("en-us", lg), "${test()}", new { country = "us" }));
|
||||
Assert.AreEqual("english-gb", await lg.GenerateAsync(GetDialogContext("en-gb", lg), "${test()}", null));
|
||||
Assert.AreEqual("english", await lg.GenerateAsync(GetDialogContext("en", lg), "${test()}", null));
|
||||
Assert.AreEqual("default", await lg.GenerateAsync(GetDialogContext(string.Empty, lg), "${test()}", null));
|
||||
Assert.AreEqual("default", await lg.GenerateAsync(GetDialogContext("foo", lg), "${test()}", null));
|
||||
|
||||
// test fallback for en-us -> en -> default
|
||||
//Assert.AreEqual("default2", await lg.Generate(GetTurnContext("en-us", lg), "${test2()}", null));
|
||||
Assert.AreEqual("default2", await lg.Generate(GetDialogContext("en-gb", lg), "${test2()}", null));
|
||||
Assert.AreEqual("default2", await lg.Generate(GetDialogContext("en", lg), "${test2()}", null));
|
||||
Assert.AreEqual("default2", await lg.Generate(GetDialogContext(string.Empty, lg), "${test2()}", null));
|
||||
Assert.AreEqual("default2", await lg.Generate(GetDialogContext("foo", lg), "${test2()}", null));
|
||||
Assert.AreEqual("default2", await lg.GenerateAsync(GetDialogContext("en-gb", lg), "${test2()}", null));
|
||||
Assert.AreEqual("default2", await lg.GenerateAsync(GetDialogContext("en", lg), "${test2()}", null));
|
||||
Assert.AreEqual("default2", await lg.GenerateAsync(GetDialogContext(string.Empty, lg), "${test2()}", null));
|
||||
Assert.AreEqual("default2", await lg.GenerateAsync(GetDialogContext("foo", lg), "${test2()}", null));
|
||||
}
|
||||
|
||||
public class TestLanguageGeneratorMiddlewareDialog : Dialog
|
||||
|
@ -216,7 +216,7 @@ namespace Microsoft.Bot.Builder.AI.LanguageGeneration.Tests
|
|||
var lg = dialogContext.Services.Get<LanguageGenerator>();
|
||||
Assert.IsNotNull(lg, "ILanguageGenerator should not be null");
|
||||
Assert.IsNotNull(dialogContext.Services.Get<ResourceExplorer>(), "ResourceExplorer should not be null");
|
||||
var text = await lg.Generate(dialogContext, "${test()}", null);
|
||||
var text = await lg.GenerateAsync(dialogContext, "${test()}", null);
|
||||
Assert.AreEqual("english-us", text, "template should be there");
|
||||
return await dialogContext.EndDialogAsync();
|
||||
}
|
||||
|
@ -359,7 +359,7 @@ namespace Microsoft.Bot.Builder.AI.LanguageGeneration.Tests
|
|||
{
|
||||
var lg = dialogContext.Services.Get<LanguageGenerator>();
|
||||
|
||||
var result = await lg.Generate(dialogContext, "This is ${test.name}", new
|
||||
var result = await lg.GenerateAsync(dialogContext, "This is ${test.name}", new
|
||||
{
|
||||
test = new
|
||||
{
|
||||
|
@ -473,7 +473,7 @@ namespace Microsoft.Bot.Builder.AI.LanguageGeneration.Tests
|
|||
|
||||
public class MockLanguageGenerator : LanguageGenerator
|
||||
{
|
||||
public override Task<object> Generate(DialogContext dialogContext, string template, object data)
|
||||
public override Task<object> GenerateAsync(DialogContext dialogContext, string template, object data, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return Task.FromResult((object)template);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers.Tests
|
|||
public void TestAge()
|
||||
{
|
||||
var turnContext = GetTurnContext("This is a test of one, 2, three years old");
|
||||
var results = recognizers.Value.RecognizeEntities(turnContext).Result;
|
||||
var results = recognizers.Value.RecognizeEntitiesAsync(turnContext).Result;
|
||||
|
||||
Assert.AreEqual(6, results.Count, "Should be 5 entities found");
|
||||
Assert.AreEqual(1, results.Where(entity => entity.Type == "age").Count(), "Should have 1 age entity");
|
||||
|
@ -56,7 +56,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers.Tests
|
|||
public void TestConfirmation()
|
||||
{
|
||||
var turnContext = GetTurnContext("yes, please");
|
||||
var results = recognizers.Value.RecognizeEntities(turnContext).Result;
|
||||
var results = recognizers.Value.RecognizeEntitiesAsync(turnContext).Result;
|
||||
|
||||
Assert.AreEqual(2, results.Count, "Should be 1 entities found");
|
||||
Assert.AreEqual(1, results.Where(entity => entity.Type == "boolean").Count(), "Should have 1 boolean results");
|
||||
|
@ -66,7 +66,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers.Tests
|
|||
public void TestCurrency()
|
||||
{
|
||||
var turnContext = GetTurnContext("I would pay four dollars for that.");
|
||||
var results = recognizers.Value.RecognizeEntities(turnContext).Result;
|
||||
var results = recognizers.Value.RecognizeEntitiesAsync(turnContext).Result;
|
||||
|
||||
Assert.AreEqual(3, results.Count, "Should be 2 entities found");
|
||||
Assert.AreEqual(1, results.Where(entity => entity.Type == "currency").Count(), "Should have 1 currency result");
|
||||
|
@ -76,7 +76,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers.Tests
|
|||
public void TestDateTime()
|
||||
{
|
||||
var turnContext = GetTurnContext("Next thursday at 4pm.");
|
||||
var results = recognizers.Value.RecognizeEntities(turnContext).Result;
|
||||
var results = recognizers.Value.RecognizeEntitiesAsync(turnContext).Result;
|
||||
|
||||
Assert.AreEqual(4, results.Count, "Should be 3 entities found");
|
||||
Assert.AreEqual(1, results.Where(entity => entity.Type == "datetimeV2.datetime").Count(), "Should have 1 datetime result");
|
||||
|
@ -88,7 +88,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers.Tests
|
|||
public void TestDimension()
|
||||
{
|
||||
var turnContext = GetTurnContext("I think he's 5 foot ten");
|
||||
var results = recognizers.Value.RecognizeEntities(turnContext).Result;
|
||||
var results = recognizers.Value.RecognizeEntitiesAsync(turnContext).Result;
|
||||
|
||||
Assert.AreEqual(4, results.Count, "Should be 3 entities found");
|
||||
Assert.AreEqual(1, results.Where(entity => entity.Type == "dimension").Count(), "Should have 1 dimension result");
|
||||
|
@ -98,7 +98,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers.Tests
|
|||
public void TestEmail()
|
||||
{
|
||||
var turnContext = GetTurnContext("my email address is foo@att.uk.co");
|
||||
var results = recognizers.Value.RecognizeEntities(turnContext).Result;
|
||||
var results = recognizers.Value.RecognizeEntitiesAsync(turnContext).Result;
|
||||
|
||||
Assert.AreEqual(2, results.Count, "Should be 1 entities found");
|
||||
Assert.AreEqual(1, results.Where(entity => entity.Type == "email").Count(), "Should have 1 email result");
|
||||
|
@ -109,7 +109,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers.Tests
|
|||
{
|
||||
var guid = Guid.Empty;
|
||||
var turnContext = GetTurnContext($"my account number is {guid}...");
|
||||
var results = recognizers.Value.RecognizeEntities(turnContext).Result;
|
||||
var results = recognizers.Value.RecognizeEntitiesAsync(turnContext).Result;
|
||||
|
||||
Assert.AreEqual(7, results.Count, "Should be 6 entities found");
|
||||
Assert.AreEqual(1, results.Where(entity => entity.Type == "guid").Count(), "Should have 1 guid result");
|
||||
|
@ -119,7 +119,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers.Tests
|
|||
public void TestHashtag()
|
||||
{
|
||||
var turnContext = GetTurnContext($"I'm so cool #cool #groovy...");
|
||||
var results = recognizers.Value.RecognizeEntities(turnContext).Result;
|
||||
var results = recognizers.Value.RecognizeEntitiesAsync(turnContext).Result;
|
||||
|
||||
Assert.AreEqual(3, results.Count, "Should be 2 entities found");
|
||||
Assert.AreEqual(2, results.Where(entity => entity.Type == "hashtag").Count(), "Should have 2 hashtag result");
|
||||
|
@ -129,7 +129,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers.Tests
|
|||
public void TestIp()
|
||||
{
|
||||
var turnContext = GetTurnContext($"My address is 1.2.3.4");
|
||||
var results = recognizers.Value.RecognizeEntities(turnContext).Result;
|
||||
var results = recognizers.Value.RecognizeEntitiesAsync(turnContext).Result;
|
||||
|
||||
Assert.AreEqual(6, results.Count, "Should be 5 entities found");
|
||||
Assert.AreEqual(1, results.Where(entity => entity.Type == "ip").Count(), "Should have 1 ip result");
|
||||
|
@ -139,7 +139,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers.Tests
|
|||
public void TestMention()
|
||||
{
|
||||
var turnContext = GetTurnContext($"Tell @joesmith I'm coming...");
|
||||
var results = recognizers.Value.RecognizeEntities(turnContext).Result;
|
||||
var results = recognizers.Value.RecognizeEntitiesAsync(turnContext).Result;
|
||||
|
||||
Assert.AreEqual(2, results.Count, "Should be 1 entities found");
|
||||
Assert.AreEqual(1, results.Where(entity => entity.Type == "mention").Count(), "Should have 1 mention result");
|
||||
|
@ -149,7 +149,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers.Tests
|
|||
public void TestNumber()
|
||||
{
|
||||
var turnContext = GetTurnContext("This is a test of one, 2, three");
|
||||
var results = recognizers.Value.RecognizeEntities(turnContext).Result;
|
||||
var results = recognizers.Value.RecognizeEntitiesAsync(turnContext).Result;
|
||||
|
||||
Assert.AreEqual(4, results.Count, "Should be 3 numbers found");
|
||||
Assert.AreEqual(3, results.Where(entity => entity.Type == "number").Count(), "Should have 3 numbers");
|
||||
|
@ -159,7 +159,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers.Tests
|
|||
public void TestNumberRange()
|
||||
{
|
||||
var turnContext = GetTurnContext("there are 3 to 5 of them");
|
||||
var results = recognizers.Value.RecognizeEntities(turnContext).Result;
|
||||
var results = recognizers.Value.RecognizeEntitiesAsync(turnContext).Result;
|
||||
|
||||
Assert.AreEqual(4, results.Count, "Should be 3 entities found");
|
||||
Assert.AreEqual(1, results.Where(entity => entity.Type == "numberrange").Count(), "Should have 1 number range");
|
||||
|
@ -169,7 +169,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers.Tests
|
|||
public void TestOrdinal()
|
||||
{
|
||||
var turnContext = GetTurnContext("First, second or third");
|
||||
var results = recognizers.Value.RecognizeEntities(turnContext).Result;
|
||||
var results = recognizers.Value.RecognizeEntitiesAsync(turnContext).Result;
|
||||
|
||||
Assert.AreEqual(4, results.Count, "Should be 3 entities found");
|
||||
Assert.AreEqual(3, results.Where(entity => entity.Type == "ordinal").Count(), "Should have 3 ordinals");
|
||||
|
@ -179,7 +179,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers.Tests
|
|||
public void TestPercentage()
|
||||
{
|
||||
var turnContext = GetTurnContext("The population hit 33.3%");
|
||||
var results = recognizers.Value.RecognizeEntities(turnContext).Result;
|
||||
var results = recognizers.Value.RecognizeEntitiesAsync(turnContext).Result;
|
||||
|
||||
Assert.AreEqual(3, results.Count, "Should be 2 entities found");
|
||||
Assert.AreEqual(1, results.Where(entity => entity.Type == "percentage").Count(), "Should have 1 percentage");
|
||||
|
@ -189,7 +189,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers.Tests
|
|||
public void TestPhoneNumber()
|
||||
{
|
||||
var turnContext = GetTurnContext("Call 425-882-8080");
|
||||
var results = recognizers.Value.RecognizeEntities(turnContext).Result;
|
||||
var results = recognizers.Value.RecognizeEntitiesAsync(turnContext).Result;
|
||||
|
||||
Assert.AreEqual(5, results.Count, "Should be 4 entities found");
|
||||
Assert.AreEqual(1, results.Where(entity => entity.Type == "phonenumber").Count(), "Should have 1 phonenumber");
|
||||
|
@ -199,7 +199,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers.Tests
|
|||
public void TestTemperature()
|
||||
{
|
||||
var turnContext = GetTurnContext("set the oven to 350 degrees");
|
||||
var results = recognizers.Value.RecognizeEntities(turnContext).Result;
|
||||
var results = recognizers.Value.RecognizeEntitiesAsync(turnContext).Result;
|
||||
|
||||
Assert.AreEqual(3, results.Count, "Should be 2 entities found");
|
||||
Assert.AreEqual(1, results.Where(entity => entity.Type == "temperature").Count(), "Should have 1 temperature");
|
||||
|
@ -209,7 +209,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers.Tests
|
|||
public void TestUrl()
|
||||
{
|
||||
var turnContext = GetTurnContext("go to http://about.me for more info");
|
||||
var results = recognizers.Value.RecognizeEntities(turnContext).Result;
|
||||
var results = recognizers.Value.RecognizeEntitiesAsync(turnContext).Result;
|
||||
|
||||
Assert.AreEqual(2, results.Count, "Should be 1 entities found");
|
||||
Assert.AreEqual(1, results.Where(entity => entity.Type == "url").Count(), "Should have 1 url");
|
||||
|
@ -220,7 +220,7 @@ namespace Microsoft.Bot.Builder.Dialogs.Adaptive.Recognizers.Tests
|
|||
{
|
||||
// I would like {order}
|
||||
var turnContext = GetTurnContext("I would like a red or Blue cat");
|
||||
var results = recognizers.Value.RecognizeEntities(turnContext).Result;
|
||||
var results = recognizers.Value.RecognizeEntitiesAsync(turnContext).Result;
|
||||
|
||||
Assert.AreEqual(3, results.Count, "Should be 2 entities found");
|
||||
Assert.AreEqual(2, results.Where(entity => entity.Type == "color").Count(), "Should have 2 color results");
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"$schema": "../../testbot.schema",
|
||||
"$kind": "Microsoft.SkillDialog",
|
||||
"$kind": "Microsoft.BeginSkill",
|
||||
"skillAppId": "f3fe8762-e50c-4688-b202-a040f522d916",
|
||||
"skillEndpoint": "http://localhost:39783/api/messages",
|
||||
"activity": {
|
||||
|
|
|
@ -1,21 +1,22 @@
|
|||
{
|
||||
"$schema": "../../testbot.schema",
|
||||
"$kind": "Microsoft.AdaptiveDialog",
|
||||
"triggers": [
|
||||
{
|
||||
"$kind": "Microsoft.OnBeginDialog",
|
||||
"actions": [
|
||||
{
|
||||
"$kind": "Microsoft.SendActivity",
|
||||
"activity": "World"
|
||||
},
|
||||
{
|
||||
"$kind": "Microsoft.EndTurn"
|
||||
},
|
||||
{
|
||||
"$kind": "Microsoft.BeginDialog",
|
||||
"dialog": "Root.dialog"
|
||||
}
|
||||
]
|
||||
"actions": [
|
||||
{
|
||||
"$kind": "Microsoft.SendActivity",
|
||||
"activity": "World"
|
||||
},
|
||||
{
|
||||
"$kind": "Microsoft.EndTurn"
|
||||
},
|
||||
{
|
||||
"$kind": "Microsoft.BeginDialog",
|
||||
"dialog": "Root.dialog"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"$schema": "../../testbot.schema",
|
||||
"$kind": "Microsoft.AdaptiveDialog",
|
||||
"triggers": [
|
||||
{
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
{
|
||||
"$ref": "#/definitions/Microsoft.BeginDialog"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.BeginSkill"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.BreakLoop"
|
||||
},
|
||||
|
@ -274,9 +277,6 @@
|
|||
{
|
||||
"$ref": "#/definitions/Microsoft.SignOutUser"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.SkillDialog"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.StaticActivityTemplate"
|
||||
},
|
||||
|
@ -1085,6 +1085,108 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.BeginSkill": {
|
||||
"$role": "implements(Microsoft.IDialog)",
|
||||
"title": "Begin a skill dialog",
|
||||
"description": "Begin a remote skill dialog.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"$kind"
|
||||
],
|
||||
"additionalProperties": false,
|
||||
"patternProperties": {
|
||||
"^\\$": {
|
||||
"title": "Tooling property",
|
||||
"description": "Open ended property for tooling."
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"title": "Id",
|
||||
"description": "Optional id for the skill dialog"
|
||||
},
|
||||
"disabled": {
|
||||
"$ref": "#/definitions/booleanExpression",
|
||||
"title": "Disabled",
|
||||
"description": "Optional condition which if true will disable this action.",
|
||||
"examples": [
|
||||
true,
|
||||
"=f(x)"
|
||||
]
|
||||
},
|
||||
"activityProcessed": {
|
||||
"$ref": "#/definitions/booleanExpression",
|
||||
"title": "Activity Processed",
|
||||
"description": "When set to false, the skill will be started using the activity in the current turn context instead of the activity in the Activity property.",
|
||||
"default": true,
|
||||
"examples": [
|
||||
true,
|
||||
"=f(x)"
|
||||
]
|
||||
},
|
||||
"resultProperty": {
|
||||
"$ref": "#/definitions/stringExpression",
|
||||
"title": "Property",
|
||||
"description": "Property to store any value returned by the dialog that is called.",
|
||||
"examples": [
|
||||
"dialog.userName"
|
||||
]
|
||||
},
|
||||
"botId": {
|
||||
"$ref": "#/definitions/stringExpression",
|
||||
"title": "Skill host bot ID",
|
||||
"description": "The Microsoft App ID that will be calling the skill.",
|
||||
"default": "=settings.MicrosoftAppId"
|
||||
},
|
||||
"skillHostEndpoint": {
|
||||
"$ref": "#/definitions/stringExpression",
|
||||
"title": "Skill host",
|
||||
"description": "The callback Url for the skill host.",
|
||||
"default": "=settings.skillHostEndpoint",
|
||||
"examples": [
|
||||
"https://mybot.contoso.com/api/skills/"
|
||||
]
|
||||
},
|
||||
"connectionName": {
|
||||
"$ref": "#/definitions/stringExpression",
|
||||
"title": "OAuth Connection Name (SSO)",
|
||||
"description": "The OAuth Connection Name, that would be used to perform Single SignOn with a skill.",
|
||||
"default": "=settings.connectionName"
|
||||
},
|
||||
"skillAppId": {
|
||||
"$ref": "#/definitions/stringExpression",
|
||||
"title": "Skill App ID",
|
||||
"description": "The Microsoft App ID for the skill."
|
||||
},
|
||||
"skillEndpoint": {
|
||||
"$ref": "#/definitions/stringExpression",
|
||||
"title": "Skill endpoint ",
|
||||
"description": "The /api/messages endpoint for the skill.",
|
||||
"examples": [
|
||||
"https://myskill.contoso.com/api/messages/"
|
||||
]
|
||||
},
|
||||
"activity": {
|
||||
"$kind": "Microsoft.IActivityTemplate",
|
||||
"title": "Activity",
|
||||
"description": "The activity to send to the skill.",
|
||||
"$ref": "#/definitions/Microsoft.IActivityTemplate"
|
||||
},
|
||||
"$kind": {
|
||||
"title": "Kind of dialog object",
|
||||
"description": "Defines the valid properties for the component you are configuring (from a dialog .schema file)",
|
||||
"type": "string",
|
||||
"pattern": "^[a-zA-Z][a-zA-Z0-9.]*$",
|
||||
"const": "Microsoft.BeginSkill"
|
||||
},
|
||||
"$designer": {
|
||||
"title": "Designer information",
|
||||
"type": "object",
|
||||
"description": "Extra information for the Bot Framework Composer."
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.BreakLoop": {
|
||||
"$role": "implements(Microsoft.IDialog)",
|
||||
"title": "Break Loop",
|
||||
|
@ -3927,10 +4029,10 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.StaticActivityTemplate"
|
||||
"$ref": "#/definitions/Microsoft.ActivityTemplate"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.ActivityTemplate"
|
||||
"$ref": "#/definitions/Microsoft.StaticActivityTemplate"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -3954,17 +4056,23 @@
|
|||
{
|
||||
"$ref": "#/definitions/Microsoft.BeginDialog"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.BeginSkill"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.BreakLoop"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.CancelAllDialogs"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.CancelDialog"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.ContinueLoop"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.CancelDialog"
|
||||
"$ref": "#/definitions/Microsoft.DebugBreak"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.DeleteActivity"
|
||||
|
@ -3973,50 +4081,47 @@
|
|||
"$ref": "#/definitions/Microsoft.DeleteProperties"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.DebugBreak"
|
||||
"$ref": "#/definitions/Microsoft.DeleteProperty"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.EditActions"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.DeleteProperty"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.EditArray"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.EndDialog"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.EmitEvent"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.EndTurn"
|
||||
"$ref": "#/definitions/Microsoft.EndDialog"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.ForeachPage"
|
||||
"$ref": "#/definitions/Microsoft.EndTurn"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.Foreach"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.GetConversationMembers"
|
||||
"$ref": "#/definitions/Microsoft.ForeachPage"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.GetActivityMembers"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.HttpRequest"
|
||||
"$ref": "#/definitions/Microsoft.GetConversationMembers"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.GotoAction"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.LogAction"
|
||||
"$ref": "#/definitions/Microsoft.HttpRequest"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.IfCondition"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.LogAction"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.RepeatDialog"
|
||||
},
|
||||
|
@ -4036,10 +4141,10 @@
|
|||
"$ref": "#/definitions/Microsoft.SignOutUser"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.TraceActivity"
|
||||
"$ref": "#/definitions/Microsoft.SwitchCondition"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.SwitchCondition"
|
||||
"$ref": "#/definitions/Microsoft.TraceActivity"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.UpdateActivity"
|
||||
|
@ -4051,10 +4156,10 @@
|
|||
"$ref": "#/definitions/Microsoft.AttachmentInput"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.ConfirmInput"
|
||||
"$ref": "#/definitions/Microsoft.ChoiceInput"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.ChoiceInput"
|
||||
"$ref": "#/definitions/Microsoft.ConfirmInput"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.DateTimeInput"
|
||||
|
@ -4069,13 +4174,10 @@
|
|||
"$ref": "#/definitions/Microsoft.TextInput"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.SkillDialog"
|
||||
"$ref": "#/definitions/Testbot.JavascriptAction"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Testbot.Multiply"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Testbot.JavascriptAction"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -4133,13 +4235,13 @@
|
|||
"$ref": "#/definitions/Microsoft.PercentageEntityRecognizer"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.TemperatureEntityRecognizer"
|
||||
"$ref": "#/definitions/Microsoft.PhoneNumberEntityRecognizer"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.RegexEntityRecognizer"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.PhoneNumberEntityRecognizer"
|
||||
"$ref": "#/definitions/Microsoft.TemperatureEntityRecognizer"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.UrlEntityRecognizer"
|
||||
|
@ -4180,10 +4282,10 @@
|
|||
"$ref": "#/definitions/Microsoft.CrossTrainedRecognizerSet"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.RecognizerSet"
|
||||
"$ref": "#/definitions/Microsoft.MultiLanguageRecognizer"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.MultiLanguageRecognizer"
|
||||
"$ref": "#/definitions/Microsoft.RecognizerSet"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.RegexRecognizer"
|
||||
|
@ -4213,15 +4315,15 @@
|
|||
"title": "Reference to Microsoft.ITrigger",
|
||||
"description": "Reference to Microsoft.ITrigger .dialog file."
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.OnBeginDialog"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.OnActivity"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.OnAssignEntity"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.OnBeginDialog"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.OnCancelDialog"
|
||||
},
|
||||
|
@ -4241,26 +4343,26 @@
|
|||
"$ref": "#/definitions/Microsoft.OnConversationUpdateActivity"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.OnEndOfActions"
|
||||
"$ref": "#/definitions/Microsoft.OnDialogEvent"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.OnDialogEvent"
|
||||
"$ref": "#/definitions/Microsoft.OnEndOfActions"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.OnEndOfConversationActivity"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.OnEventActivity"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.OnError"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.OnIntent"
|
||||
"$ref": "#/definitions/Microsoft.OnEventActivity"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.OnHandoffActivity"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.OnIntent"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.OnInvokeActivity"
|
||||
},
|
||||
|
@ -4276,17 +4378,17 @@
|
|||
{
|
||||
"$ref": "#/definitions/Microsoft.OnMessageUpdateActivity"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.OnRepromptDialog"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.OnQnAMatch"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.OnUnknownIntent"
|
||||
"$ref": "#/definitions/Microsoft.OnRepromptDialog"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.OnTypingActivity"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.OnUnknownIntent"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -4300,20 +4402,20 @@
|
|||
"title": "Reference to Microsoft.ITriggerSelector",
|
||||
"description": "Reference to Microsoft.ITriggerSelector .dialog file."
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.ConditionalSelector"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.FirstSelector"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.ConditionalSelector"
|
||||
"$ref": "#/definitions/Microsoft.MostSpecificSelector"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.RandomSelector"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.TrueSelector"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.MostSpecificSelector"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -7964,102 +8066,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.SkillDialog": {
|
||||
"$role": "implements(Microsoft.IDialog)",
|
||||
"title": "Begin a skill dialog",
|
||||
"description": "Begin a remote skill dialog.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"$kind"
|
||||
],
|
||||
"additionalProperties": false,
|
||||
"patternProperties": {
|
||||
"^\\$": {
|
||||
"title": "Tooling property",
|
||||
"description": "Open ended property for tooling."
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"title": "Id",
|
||||
"description": "Optional id for the skill dialog"
|
||||
},
|
||||
"disabled": {
|
||||
"$ref": "#/definitions/booleanExpression",
|
||||
"title": "Disabled",
|
||||
"description": "Optional condition which if true will disable this action.",
|
||||
"examples": [
|
||||
true,
|
||||
"=f(x)"
|
||||
]
|
||||
},
|
||||
"activityProcessed": {
|
||||
"$ref": "#/definitions/booleanExpression",
|
||||
"title": "Activity Processed",
|
||||
"description": "When set to false, the skill will be started using the activity in the current turn context instead of the activity in the Activity property.",
|
||||
"default": true,
|
||||
"examples": [
|
||||
true,
|
||||
"=f(x)"
|
||||
]
|
||||
},
|
||||
"resultProperty": {
|
||||
"$ref": "#/definitions/stringExpression",
|
||||
"title": "Property",
|
||||
"description": "Property to store any value returned by the dialog that is called.",
|
||||
"examples": [
|
||||
"dialog.userName"
|
||||
]
|
||||
},
|
||||
"botId": {
|
||||
"$ref": "#/definitions/stringExpression",
|
||||
"title": "Skill host bot ID",
|
||||
"description": "The Microsoft App ID that will be calling the skill.",
|
||||
"default": "=settings.MicrosoftAppId"
|
||||
},
|
||||
"skillHostEndpoint": {
|
||||
"$ref": "#/definitions/stringExpression",
|
||||
"title": "Skill host",
|
||||
"description": "The callback Url for the skill host.",
|
||||
"default": "=settings.skillHostEndpoint",
|
||||
"examples": [
|
||||
"https://mybot.contoso.com/api/skills/"
|
||||
]
|
||||
},
|
||||
"skillAppId": {
|
||||
"$ref": "#/definitions/stringExpression",
|
||||
"title": "Skill App ID",
|
||||
"description": "The Microsoft App ID for the skill."
|
||||
},
|
||||
"skillEndpoint": {
|
||||
"$ref": "#/definitions/stringExpression",
|
||||
"title": "Skill endpoint ",
|
||||
"description": "The /api/messages endpoint for the skill.",
|
||||
"examples": [
|
||||
"https://myskill.contoso.com/api/messages/"
|
||||
]
|
||||
},
|
||||
"activity": {
|
||||
"$kind": "Microsoft.IActivityTemplate",
|
||||
"title": "Activity",
|
||||
"description": "The activity to send to the skill.",
|
||||
"$ref": "#/definitions/Microsoft.IActivityTemplate"
|
||||
},
|
||||
"$kind": {
|
||||
"title": "Kind of dialog object",
|
||||
"description": "Defines the valid properties for the component you are configuring (from a dialog .schema file)",
|
||||
"type": "string",
|
||||
"pattern": "^[a-zA-Z][a-zA-Z0-9.]*$",
|
||||
"const": "Microsoft.SkillDialog"
|
||||
},
|
||||
"$designer": {
|
||||
"title": "Designer information",
|
||||
"type": "object",
|
||||
"description": "Extra information for the Bot Framework Composer."
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.StaticActivityTemplate": {
|
||||
"$role": "implements(Microsoft.IActivityTemplate)",
|
||||
"title": "Microsoft Static Activity Template",
|
||||
|
@ -8509,10 +8515,10 @@
|
|||
"$ref": "#/definitions/Microsoft.Test.AssertReply"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.Test.AssertReplyOneOf"
|
||||
"$ref": "#/definitions/Microsoft.Test.AssertReplyActivity"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.Test.AssertReplyActivity"
|
||||
"$ref": "#/definitions/Microsoft.Test.AssertReplyOneOf"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.Test.UserActivity"
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
{
|
||||
"$ref": "#/definitions/Microsoft.BeginDialog"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.BeginSkill"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.BreakLoop"
|
||||
},
|
||||
|
@ -280,9 +283,6 @@
|
|||
{
|
||||
"$ref": "#/definitions/Microsoft.SignOutUser"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.SkillDialog"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.StaticActivityTemplate"
|
||||
},
|
||||
|
@ -1195,6 +1195,108 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.BeginSkill": {
|
||||
"$role": "implements(Microsoft.IDialog)",
|
||||
"title": "Begin a skill dialog",
|
||||
"description": "Begin a remote skill dialog.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"$kind"
|
||||
],
|
||||
"additionalProperties": false,
|
||||
"patternProperties": {
|
||||
"^\\$": {
|
||||
"title": "Tooling property",
|
||||
"description": "Open ended property for tooling."
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"title": "Id",
|
||||
"description": "Optional id for the skill dialog"
|
||||
},
|
||||
"disabled": {
|
||||
"$ref": "#/definitions/booleanExpression",
|
||||
"title": "Disabled",
|
||||
"description": "Optional condition which if true will disable this action.",
|
||||
"examples": [
|
||||
true,
|
||||
"=f(x)"
|
||||
]
|
||||
},
|
||||
"activityProcessed": {
|
||||
"$ref": "#/definitions/booleanExpression",
|
||||
"title": "Activity Processed",
|
||||
"description": "When set to false, the skill will be started using the activity in the current turn context instead of the activity in the Activity property.",
|
||||
"default": true,
|
||||
"examples": [
|
||||
true,
|
||||
"=f(x)"
|
||||
]
|
||||
},
|
||||
"resultProperty": {
|
||||
"$ref": "#/definitions/stringExpression",
|
||||
"title": "Property",
|
||||
"description": "Property to store any value returned by the dialog that is called.",
|
||||
"examples": [
|
||||
"dialog.userName"
|
||||
]
|
||||
},
|
||||
"botId": {
|
||||
"$ref": "#/definitions/stringExpression",
|
||||
"title": "Skill host bot ID",
|
||||
"description": "The Microsoft App ID that will be calling the skill.",
|
||||
"default": "=settings.MicrosoftAppId"
|
||||
},
|
||||
"skillHostEndpoint": {
|
||||
"$ref": "#/definitions/stringExpression",
|
||||
"title": "Skill host",
|
||||
"description": "The callback Url for the skill host.",
|
||||
"default": "=settings.skillHostEndpoint",
|
||||
"examples": [
|
||||
"https://mybot.contoso.com/api/skills/"
|
||||
]
|
||||
},
|
||||
"connectionName": {
|
||||
"$ref": "#/definitions/stringExpression",
|
||||
"title": "OAuth Connection Name (SSO)",
|
||||
"description": "The OAuth Connection Name, that would be used to perform Single SignOn with a skill.",
|
||||
"default": "=settings.connectionName"
|
||||
},
|
||||
"skillAppId": {
|
||||
"$ref": "#/definitions/stringExpression",
|
||||
"title": "Skill App ID",
|
||||
"description": "The Microsoft App ID for the skill."
|
||||
},
|
||||
"skillEndpoint": {
|
||||
"$ref": "#/definitions/stringExpression",
|
||||
"title": "Skill endpoint ",
|
||||
"description": "The /api/messages endpoint for the skill.",
|
||||
"examples": [
|
||||
"https://myskill.contoso.com/api/messages/"
|
||||
]
|
||||
},
|
||||
"activity": {
|
||||
"$kind": "Microsoft.IActivityTemplate",
|
||||
"title": "Activity",
|
||||
"description": "The activity to send to the skill.",
|
||||
"$ref": "#/definitions/Microsoft.IActivityTemplate"
|
||||
},
|
||||
"$kind": {
|
||||
"title": "Kind of dialog object",
|
||||
"description": "Defines the valid properties for the component you are configuring (from a dialog .schema file)",
|
||||
"type": "string",
|
||||
"pattern": "^[a-zA-Z][a-zA-Z0-9.]*$",
|
||||
"const": "Microsoft.BeginSkill"
|
||||
},
|
||||
"$designer": {
|
||||
"title": "Designer information",
|
||||
"type": "object",
|
||||
"description": "Extra information for the Bot Framework Composer."
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.BreakLoop": {
|
||||
"$role": "implements(Microsoft.IDialog)",
|
||||
"title": "Break Loop",
|
||||
|
@ -4064,6 +4166,9 @@
|
|||
{
|
||||
"$ref": "#/definitions/Microsoft.BeginDialog"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.BeginSkill"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.BreakLoop"
|
||||
},
|
||||
|
@ -4175,9 +4280,6 @@
|
|||
{
|
||||
"$ref": "#/definitions/Microsoft.OAuthInput"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.SkillDialog"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/Microsoft.TextInput"
|
||||
},
|
||||
|
@ -8080,108 +8182,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.SkillDialog": {
|
||||
"$role": "implements(Microsoft.IDialog)",
|
||||
"title": "Begin a skill dialog",
|
||||
"description": "Begin a remote skill dialog.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"$kind"
|
||||
],
|
||||
"additionalProperties": false,
|
||||
"patternProperties": {
|
||||
"^\\$": {
|
||||
"title": "Tooling property",
|
||||
"description": "Open ended property for tooling."
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"title": "Id",
|
||||
"description": "Optional id for the skill dialog"
|
||||
},
|
||||
"disabled": {
|
||||
"$ref": "#/definitions/booleanExpression",
|
||||
"title": "Disabled",
|
||||
"description": "Optional condition which if true will disable this action.",
|
||||
"examples": [
|
||||
true,
|
||||
"=f(x)"
|
||||
]
|
||||
},
|
||||
"activityProcessed": {
|
||||
"$ref": "#/definitions/booleanExpression",
|
||||
"title": "Activity Processed",
|
||||
"description": "When set to false, the skill will be started using the activity in the current turn context instead of the activity in the Activity property.",
|
||||
"default": true,
|
||||
"examples": [
|
||||
true,
|
||||
"=f(x)"
|
||||
]
|
||||
},
|
||||
"resultProperty": {
|
||||
"$ref": "#/definitions/stringExpression",
|
||||
"title": "Property",
|
||||
"description": "Property to store any value returned by the dialog that is called.",
|
||||
"examples": [
|
||||
"dialog.userName"
|
||||
]
|
||||
},
|
||||
"botId": {
|
||||
"$ref": "#/definitions/stringExpression",
|
||||
"title": "Skill host bot ID",
|
||||
"description": "The Microsoft App ID that will be calling the skill.",
|
||||
"default": "=settings.MicrosoftAppId"
|
||||
},
|
||||
"skillHostEndpoint": {
|
||||
"$ref": "#/definitions/stringExpression",
|
||||
"title": "Skill host",
|
||||
"description": "The callback Url for the skill host.",
|
||||
"default": "=settings.skillHostEndpoint",
|
||||
"examples": [
|
||||
"https://mybot.contoso.com/api/skills/"
|
||||
]
|
||||
},
|
||||
"connectionName": {
|
||||
"$ref": "#/definitions/stringExpression",
|
||||
"title": "OAuth Connection Name (SSO)",
|
||||
"description": "The OAuth Connection Name, that would be used to perform Single SignOn with a skill.",
|
||||
"default": "=settings.connectionName"
|
||||
},
|
||||
"skillAppId": {
|
||||
"$ref": "#/definitions/stringExpression",
|
||||
"title": "Skill App ID",
|
||||
"description": "The Microsoft App ID for the skill."
|
||||
},
|
||||
"skillEndpoint": {
|
||||
"$ref": "#/definitions/stringExpression",
|
||||
"title": "Skill endpoint ",
|
||||
"description": "The /api/messages endpoint for the skill.",
|
||||
"examples": [
|
||||
"https://myskill.contoso.com/api/messages/"
|
||||
]
|
||||
},
|
||||
"activity": {
|
||||
"$kind": "Microsoft.IActivityTemplate",
|
||||
"title": "Activity",
|
||||
"description": "The activity to send to the skill.",
|
||||
"$ref": "#/definitions/Microsoft.IActivityTemplate"
|
||||
},
|
||||
"$kind": {
|
||||
"title": "Kind of dialog object",
|
||||
"description": "Defines the valid properties for the component you are configuring (from a dialog .schema file)",
|
||||
"type": "string",
|
||||
"pattern": "^[a-zA-Z][a-zA-Z0-9.]*$",
|
||||
"const": "Microsoft.SkillDialog"
|
||||
},
|
||||
"$designer": {
|
||||
"title": "Designer information",
|
||||
"type": "object",
|
||||
"description": "Extra information for the Bot Framework Composer."
|
||||
}
|
||||
}
|
||||
},
|
||||
"Microsoft.StaticActivityTemplate": {
|
||||
"$role": "implements(Microsoft.IActivityTemplate)",
|
||||
"title": "Microsoft Static Activity Template",
|
||||
|
|
Загрузка…
Ссылка в новой задаче