Randomize how are you replies
This commit is contained in:
@@ -399,13 +399,18 @@ internal static class ChitchatStateMachine
|
|||||||
string? currentEmotion,
|
string? currentEmotion,
|
||||||
string? preferredName)
|
string? preferredName)
|
||||||
{
|
{
|
||||||
if (catalog.EmotionReplies.Count == 0)
|
if (catalog.EmotionReplies.Count > 0)
|
||||||
return PersonalizeHowAreYouReply(randomizer.Choose(catalog.HowAreYouReplies), preferredName);
|
{
|
||||||
|
|
||||||
var emotionVariants = ResolveEmotionVariants(currentEmotion);
|
var emotionVariants = ResolveEmotionVariants(currentEmotion);
|
||||||
foreach (var reply in catalog.EmotionReplies)
|
var matchingReplies = catalog.EmotionReplies
|
||||||
if (ConditionMatches(reply.Condition, emotionVariants))
|
.Where(reply => ConditionMatches(reply.Condition, emotionVariants))
|
||||||
return PersonalizeHowAreYouReply(reply.Reply, preferredName);
|
.Select(reply => reply.Reply)
|
||||||
|
.Where(reply => !string.IsNullOrWhiteSpace(reply))
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
if (matchingReplies.Length > 0)
|
||||||
|
return PersonalizeHowAreYouReply(randomizer.Choose(matchingReplies), preferredName);
|
||||||
|
}
|
||||||
|
|
||||||
return PersonalizeHowAreYouReply(randomizer.Choose(catalog.HowAreYouReplies), preferredName);
|
return PersonalizeHowAreYouReply(randomizer.Choose(catalog.HowAreYouReplies), preferredName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,7 +137,9 @@ public sealed class InMemoryJiboExperienceContentRepository : IJiboExperienceCon
|
|||||||
"I am feeling bright-eyed and ready to help.",
|
"I am feeling bright-eyed and ready to help.",
|
||||||
"I am having a pretty good day so far.",
|
"I am having a pretty good day so far.",
|
||||||
"I am feeling lively and ready for the next thing.",
|
"I am feeling lively and ready for the next thing.",
|
||||||
"Things are going nicely. Thanks for checking in."
|
"Things are going nicely. Thanks for checking in.",
|
||||||
|
"I am running smoothly and feeling upbeat.",
|
||||||
|
"I am ready for the next thing. Thanks for asking."
|
||||||
],
|
],
|
||||||
AgeReplies =
|
AgeReplies =
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -1040,6 +1040,21 @@ public sealed class JiboInteractionServiceTests
|
|||||||
Assert.Equal("All systems are go, Jake.", decision.ReplyText);
|
Assert.Equal("All systems are go, Jake.", decision.ReplyText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task BuildDecisionAsync_HowAreYou_CanSelectLaterEmotionReplyVariant()
|
||||||
|
{
|
||||||
|
var service = CreateService(randomizer: new LastItemRandomizer());
|
||||||
|
|
||||||
|
var decision = await service.BuildDecisionAsync(new TurnContext
|
||||||
|
{
|
||||||
|
RawTranscript = "how are you",
|
||||||
|
NormalizedTranscript = "how are you"
|
||||||
|
});
|
||||||
|
|
||||||
|
Assert.Equal("how_are_you", decision.IntentName);
|
||||||
|
Assert.Equal("Actually things are looking mostly sunny.", decision.ReplyText);
|
||||||
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("what are you up to", "being helpful")]
|
[InlineData("what are you up to", "being helpful")]
|
||||||
[InlineData("what are you doing", "making people smile")]
|
[InlineData("what are you doing", "making people smile")]
|
||||||
|
|||||||
Reference in New Issue
Block a user