/// <summary> /// A simple set of heuristics to govern if we should invoke the personality <see cref="QnAMakerDialog"/>. /// </summary> /// <param name="stepContext">Current dialog context.</param> /// <param name="dispatchIntent">Intent that Dispatch thinks should be invoked.</param> /// <param name="dispatchScore">Confidence score for intent.</param> /// <param name="threshold">User provided threshold between 0.0 and 1.0, if above this threshold do NOT show chitchat.</param> /// <returns>A <see cref="bool"/> indicating if we should invoke the personality dialog.</returns> private bool ShouldBeginChitChatDialog(WaterfallStepContext stepContext, DispatchLuis.Intent dispatchIntent, double dispatchScore, double threshold = 0.5) { if (threshold < 0.0 || threshold > 1.0) { throw new ArgumentOutOfRangeException(nameof(threshold)); } if (dispatchIntent == DispatchLuis.Intent.None) { return(true); } if (dispatchIntent == DispatchLuis.Intent.l_General) { // If dispatch classifies user query as general, we should check against the cached general Luis score instead. var generalResult = stepContext.Context.TurnState.Get <GeneralLuis>(StateProperties.GeneralResult); if (generalResult != null) { (var _, var generalScore) = generalResult.TopIntent(); return(generalScore < threshold); } } else if (dispatchScore < threshold) { return(true); } return(false); }
private bool IsSkillIntent(DispatchLuis.Intent dispatchIntent) { if (dispatchIntent.ToString().Equals(DispatchLuis.Intent.l_General.ToString(), StringComparison.InvariantCultureIgnoreCase) || dispatchIntent.ToString().Equals(DispatchLuis.Intent.q_Faq.ToString(), StringComparison.InvariantCultureIgnoreCase) || dispatchIntent.ToString().Equals(DispatchLuis.Intent.None.ToString(), StringComparison.InvariantCultureIgnoreCase)) { return(false); } return(true); }
public static DispatchLuis CreateIntent(string userInput, DispatchLuis.Intent intent) { var result = new DispatchLuis { Text = userInput, Intents = new Dictionary <DispatchLuis.Intent, IntentScore>() }; result.Intents.Add(intent, new IntentScore() { Score = 0.9 }); result.Entities = new DispatchLuis._Entities { _instance = new DispatchLuis._Entities._Instance() }; return(result); }