Randomize how are you replies
This commit is contained in:
@@ -399,13 +399,18 @@ internal static class ChitchatStateMachine
|
||||
string? currentEmotion,
|
||||
string? preferredName)
|
||||
{
|
||||
if (catalog.EmotionReplies.Count == 0)
|
||||
return PersonalizeHowAreYouReply(randomizer.Choose(catalog.HowAreYouReplies), preferredName);
|
||||
if (catalog.EmotionReplies.Count > 0)
|
||||
{
|
||||
var emotionVariants = ResolveEmotionVariants(currentEmotion);
|
||||
var matchingReplies = catalog.EmotionReplies
|
||||
.Where(reply => ConditionMatches(reply.Condition, emotionVariants))
|
||||
.Select(reply => reply.Reply)
|
||||
.Where(reply => !string.IsNullOrWhiteSpace(reply))
|
||||
.ToArray();
|
||||
|
||||
var emotionVariants = ResolveEmotionVariants(currentEmotion);
|
||||
foreach (var reply in catalog.EmotionReplies)
|
||||
if (ConditionMatches(reply.Condition, emotionVariants))
|
||||
return PersonalizeHowAreYouReply(reply.Reply, preferredName);
|
||||
if (matchingReplies.Length > 0)
|
||||
return PersonalizeHowAreYouReply(randomizer.Choose(matchingReplies), 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 having a pretty good day so far.",
|
||||
"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 =
|
||||
[
|
||||
|
||||
@@ -1040,6 +1040,21 @@ public sealed class JiboInteractionServiceTests
|
||||
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]
|
||||
[InlineData("what are you up to", "being helpful")]
|
||||
[InlineData("what are you doing", "making people smile")]
|
||||
|
||||
Reference in New Issue
Block a user