Add proactive fun facts, jokes, and current location

This commit is contained in:
Jacob Dubin
2026-05-17 17:41:55 -05:00
parent 9353e8d2e3
commit 8ed4763df5
11 changed files with 441 additions and 8 deletions

View File

@@ -496,6 +496,26 @@ public sealed class JiboInteractionServiceTests
Assert.Equal("ScriptedResponse", decision.ContextUpdates![ChitchatRouteKey]);
}
[Fact]
public async Task BuildDecisionAsync_CurrentLocation_UsesRuntimeLocationName()
{
var service = CreateService();
var decision = await service.BuildDecisionAsync(new TurnContext
{
RawTranscript = "what is our current location",
NormalizedTranscript = "what is our current location",
Attributes = new Dictionary<string, object?>
{
["context"] = """{"runtime":{"location":{"name":"Houston"}}}"""
}
});
Assert.Equal("current_location", decision.IntentName);
Assert.Contains("Houston", decision.ReplyText, StringComparison.OrdinalIgnoreCase);
Assert.Equal("ScriptedResponse", decision.ContextUpdates![ChitchatRouteKey]);
}
[Fact]
public async Task BuildDecisionAsync_Hello_RoutesThroughChitchatScriptedResponse()
{
@@ -2842,6 +2862,63 @@ public sealed class JiboInteractionServiceTests
Assert.Equal("Do you want to hear a fun pizza fact?", decision.ReplyText);
}
[Fact]
public async Task BuildDecisionAsync_SurprisesOtaPrompt_StaysDistinctFromPizzaProactivity()
{
var service = CreateService();
var decision = await service.BuildDecisionAsync(new TurnContext
{
RawTranscript = "yes",
NormalizedTranscript = "yes",
Attributes = new Dictionary<string, object?>
{
["listenRules"] = (string[])["surprises-ota/want_to_download_now", "globals/global_commands_launch"],
["listenAsrHints"] = (string[])["$YESNO"]
}
});
Assert.Equal("yes", decision.IntentName);
Assert.Equal("Yes.", decision.ReplyText);
Assert.NotEqual("proactive_offer_pizza_fact", decision.IntentName);
}
[Fact]
public async Task BuildDecisionAsync_SomethingFunOffer_MapsToFunFactIntent()
{
var service = CreateService();
var decision = await service.BuildDecisionAsync(new TurnContext
{
RawTranscript = "hey can i tell you something kind of fun",
NormalizedTranscript = "hey can i tell you something kind of fun"
});
Assert.Equal("proactive_fun_fact", decision.IntentName);
Assert.NotNull(decision.ReplyText);
Assert.NotEmpty(decision.ReplyText);
Assert.Equal("chitchat-skill", decision.SkillName);
Assert.Equal("fun_fact", decision.SkillPayload!["replyType"]);
}
[Fact]
public async Task BuildDecisionAsync_Surprise_DefaultsToAFunFactWhenNoPizzaSignalExists()
{
var service = CreateService();
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.NotNull(decision.ReplyText);
Assert.NotEmpty(decision.ReplyText);
}
[Fact]
public async Task BuildDecisionAsync_WordOfDayOfferPrompt_WithNoisyAffirmation_MapsToWordOfDayLaunch()
{

View File

@@ -21,7 +21,7 @@ public sealed class JiboWebSocketServiceTests
var contentRepository = new InMemoryJiboExperienceContentRepository();
var contentCache = new JiboExperienceContentCache(contentRepository);
var conversationBroker = new DemoConversationBroker(new JiboInteractionService(contentCache,
new DefaultJiboRandomizer(), new InMemoryPersonalMemoryStore()));
new LastItemRandomizer(), new InMemoryPersonalMemoryStore()));
var sttSelector = new DefaultSttStrategySelector(
[
new SyntheticBufferedAudioSttStrategy()
@@ -5111,4 +5111,12 @@ public sealed class JiboWebSocketServiceTests
return Task.FromResult<NewsBriefingSnapshot?>(snapshot);
}
}
private sealed class LastItemRandomizer : IJiboRandomizer
{
public T Choose<T>(IReadOnlyList<T> items)
{
return items[^1];
}
}
}