Expand surprise facts into robot and human categories
This commit is contained in:
@@ -192,9 +192,17 @@ public sealed class LegacyMimCatalogImporterTests
|
||||
Assert.Contains("I love jokes. Did you hear about the theater actor who fell through the floorboards? He was just going through a stage.",
|
||||
catalog.Jokes);
|
||||
Assert.Contains("Sure I got one. What did the zero say to the eight. Nice belt.", catalog.Jokes);
|
||||
Assert.Contains("Here's an interesting fact about me. I have two cameras but they're different focal lengths. One's for far things, and the other's for near things.",
|
||||
Assert.Contains(catalog.RobotFacts, reply =>
|
||||
reply.Contains("Leonardo Da Vinci made sketches", StringComparison.OrdinalIgnoreCase));
|
||||
Assert.Contains(catalog.RobotFacts, reply =>
|
||||
reply.Contains("first programmable robot arm", StringComparison.OrdinalIgnoreCase));
|
||||
Assert.Contains(catalog.RobotFacts, reply =>
|
||||
reply.Contains("robots have a human form", StringComparison.OrdinalIgnoreCase));
|
||||
Assert.Contains(catalog.RobotFacts, reply =>
|
||||
reply.Contains("two cameras but they're different focal lengths", StringComparison.OrdinalIgnoreCase));
|
||||
Assert.Contains("A random fact for you. A shrimp's heart is in its head.", catalog.FunFacts);
|
||||
Assert.Contains("An amazing but true fact for you. Dogs and elephants are the only animals that understand pointing.",
|
||||
catalog.FunFacts);
|
||||
Assert.Contains("True fact. Children have more taste buds than grown ups.", catalog.FunFacts);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -2915,10 +2915,30 @@ public sealed class JiboInteractionServiceTests
|
||||
Assert.Equal("proactive_fun_fact", decision.IntentName);
|
||||
Assert.Equal("chitchat-skill", decision.SkillName);
|
||||
Assert.Equal("fun_fact", decision.SkillPayload!["replyType"]);
|
||||
Assert.Equal("fun_fact", decision.SkillPayload["factCategory"]);
|
||||
Assert.NotNull(decision.ReplyText);
|
||||
Assert.NotEmpty(decision.ReplyText);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task BuildDecisionAsync_Surprise_UsesHumanFactWhenRandomizerChoosesLastCategory()
|
||||
{
|
||||
var service = CreateService(randomizer: new FactCategoryLastRandomizer());
|
||||
|
||||
var decision = await service.BuildDecisionAsync(new TurnContext
|
||||
{
|
||||
RawTranscript = "surprise me",
|
||||
NormalizedTranscript = "surprise me"
|
||||
});
|
||||
|
||||
Assert.Equal("proactive_fun_fact", decision.IntentName);
|
||||
Assert.Equal("chitchat-skill", decision.SkillName);
|
||||
Assert.Equal("fun_fact", decision.SkillPayload!["replyType"]);
|
||||
Assert.Equal("human_fact", decision.SkillPayload["factCategory"]);
|
||||
Assert.NotNull(decision.ReplyText);
|
||||
Assert.Contains("human", decision.ReplyText, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task BuildDecisionAsync_WordOfDayOfferPrompt_WithNoisyAffirmation_MapsToWordOfDayLaunch()
|
||||
{
|
||||
@@ -3872,11 +3892,12 @@ public sealed class JiboInteractionServiceTests
|
||||
IPersonalMemoryStore? personalMemoryStore = null,
|
||||
IWeatherReportProvider? weatherReportProvider = null,
|
||||
INewsBriefingProvider? newsBriefingProvider = null,
|
||||
IJiboExperienceContentRepository? contentRepository = null)
|
||||
IJiboExperienceContentRepository? contentRepository = null,
|
||||
IJiboRandomizer? randomizer = null)
|
||||
{
|
||||
return new JiboInteractionService(
|
||||
new JiboExperienceContentCache(contentRepository ?? new InMemoryJiboExperienceContentRepository()),
|
||||
new FirstItemRandomizer(),
|
||||
randomizer ?? new FirstItemRandomizer(),
|
||||
personalMemoryStore ?? new InMemoryPersonalMemoryStore(),
|
||||
weatherReportProvider,
|
||||
newsBriefingProvider);
|
||||
@@ -3915,6 +3936,24 @@ public sealed class JiboInteractionServiceTests
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class LastItemRandomizer : IJiboRandomizer
|
||||
{
|
||||
public T Choose<T>(IReadOnlyList<T> items)
|
||||
{
|
||||
return items[^1];
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class FactCategoryLastRandomizer : IJiboRandomizer
|
||||
{
|
||||
public T Choose<T>(IReadOnlyList<T> items)
|
||||
{
|
||||
return typeof(T).Name == "ProactiveFactCategory"
|
||||
? items[^1]
|
||||
: items[0];
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class CapturingWeatherReportProvider : IWeatherReportProvider
|
||||
{
|
||||
public WeatherReportRequest? LastRequest { get; private set; }
|
||||
|
||||
Reference in New Issue
Block a user