mirror of
https://kevinblog.sytes.net/Code/Jibo-Revival-Group/JiboExperiments.git
synced 2026-06-16 09:56:24 +00:00
version 18 test fixes
This commit is contained in:
@@ -70,6 +70,7 @@ public sealed class DemoConversationBroker(JiboInteractionService interactionSer
|
||||
{
|
||||
return intentName switch
|
||||
{
|
||||
"cloud_version" => false,
|
||||
"word_of_the_day" => false,
|
||||
"word_of_the_day_guess" => false,
|
||||
"radio" => false,
|
||||
|
||||
@@ -32,6 +32,19 @@ public sealed class JiboWebSocketService(
|
||||
|
||||
var parsedType = ReadMessageType(envelope.Text);
|
||||
session.LastMessageType = parsedType;
|
||||
var containsInlineTurnPayload = parsedType == "LISTEN" && ContainsInlineTurnPayload(envelope.Text);
|
||||
if (parsedType == "LISTEN" &&
|
||||
!containsInlineTurnPayload &&
|
||||
WebSocketTurnFinalizationService.ShouldIgnoreLateListenSetup(session, envelope.Text))
|
||||
{
|
||||
await telemetrySink.RecordTurnEventAsync(envelope, session, "late_listen_ignored", new Dictionary<string, object?>
|
||||
{
|
||||
["messageType"] = parsedType,
|
||||
["activeTransID"] = session.TurnState.TransId
|
||||
}, cancellationToken);
|
||||
return [];
|
||||
}
|
||||
|
||||
WebSocketTurnFinalizationService.ObserveIncomingMessage(session, envelope.Text);
|
||||
|
||||
switch (parsedType)
|
||||
@@ -47,7 +60,7 @@ public sealed class JiboWebSocketService(
|
||||
}
|
||||
case "LISTEN":
|
||||
{
|
||||
var replies = ContainsInlineTurnPayload(envelope.Text)
|
||||
var replies = containsInlineTurnPayload
|
||||
? await turnFinalizationService.HandleTurnAsync(session, envelope, parsedType, cancellationToken)
|
||||
: WebSocketTurnFinalizationService.HandleListenSetup(session, envelope);
|
||||
await telemetrySink.RecordTurnEventAsync(envelope, session, "turn_processed", new Dictionary<string, object?>
|
||||
|
||||
@@ -486,7 +486,7 @@ public sealed partial class WebSocketTurnFinalizationService(
|
||||
turnState.AwaitingTurnCompletion = false;
|
||||
turnState.IgnoreAdditionalAudioUntilUtc = plan.FollowUp.KeepMicOpen
|
||||
? null
|
||||
: DateTimeOffset.UtcNow.Add(WebSocketTurnState.DefaultLateAudioIgnoreWindow);
|
||||
: DateTimeOffset.UtcNow.Add(ResolveLateAudioIgnoreWindow(plan));
|
||||
|
||||
var emitSkillActions = !string.Equals(plan.IntentName, "word_of_the_day", StringComparison.OrdinalIgnoreCase) &&
|
||||
!string.Equals(plan.IntentName, "radio", StringComparison.OrdinalIgnoreCase) &&
|
||||
@@ -547,12 +547,62 @@ public sealed partial class WebSocketTurnFinalizationService(
|
||||
ignoreUntilUtc.Value > DateTimeOffset.UtcNow;
|
||||
}
|
||||
|
||||
public static bool ShouldIgnoreLateListenSetup(CloudSession session, string? text)
|
||||
{
|
||||
return ShouldIgnoreLateAudio(session) && IsHotphraseLaunchListenSetup(text);
|
||||
}
|
||||
|
||||
private static TimeSpan ResolveLateAudioIgnoreWindow(ResponsePlan plan)
|
||||
{
|
||||
return string.Equals(plan.IntentName, "cloud_version", StringComparison.OrdinalIgnoreCase)
|
||||
? WebSocketTurnState.DiagnosticSpeechLateAudioIgnoreWindow
|
||||
: WebSocketTurnState.DefaultLateAudioIgnoreWindow;
|
||||
}
|
||||
|
||||
private static bool ShouldIgnoreAudioWithoutListen(WebSocketTurnState turnState)
|
||||
{
|
||||
return !turnState.SawListen &&
|
||||
!string.IsNullOrWhiteSpace(turnState.TransId);
|
||||
}
|
||||
|
||||
private static bool IsHotphraseLaunchListenSetup(string? text)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using var document = JsonDocument.Parse(text);
|
||||
if (!document.RootElement.TryGetProperty("data", out var data) ||
|
||||
data.ValueKind != JsonValueKind.Object)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var isHotphrase = data.TryGetProperty("hotphrase", out var hotphrase) &&
|
||||
hotphrase.ValueKind is JsonValueKind.True or JsonValueKind.False &&
|
||||
hotphrase.GetBoolean();
|
||||
if (!isHotphrase ||
|
||||
!data.TryGetProperty("rules", out var rules) ||
|
||||
rules.ValueKind != JsonValueKind.Array)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return rules.EnumerateArray()
|
||||
.Where(static rule => rule.ValueKind == JsonValueKind.String)
|
||||
.Select(static rule => rule.GetString())
|
||||
.Any(static rule => string.Equals(rule, "launch", StringComparison.OrdinalIgnoreCase) ||
|
||||
string.Equals(rule, "globals/global_commands_launch", StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool ShouldIgnorePassiveLocalSkillContext(CloudSession session, string? text)
|
||||
{
|
||||
if (session.FollowUpOpen)
|
||||
|
||||
@@ -3,6 +3,7 @@ namespace Jibo.Cloud.Domain.Models;
|
||||
public sealed class WebSocketTurnState
|
||||
{
|
||||
public static readonly TimeSpan DefaultLateAudioIgnoreWindow = TimeSpan.FromSeconds(2);
|
||||
public static readonly TimeSpan DiagnosticSpeechLateAudioIgnoreWindow = TimeSpan.FromSeconds(8);
|
||||
|
||||
public string? TransId { get; set; }
|
||||
public string? ContextPayload { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user