Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/Infrastructure/BotSharp.Core.Realtime/Services/RealtimeHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,7 @@ await _completer.Connect(_conn,
onModelReady: async () =>
{
// Not TriggerModelInference, waiting for user utter.
await _completer.UpdateSession(_conn);

// Push dialogs into model context
foreach (var message in dialogs)
{
await _completer.InsertConversationItem(message);
}
var instruction = await _completer.UpdateSession(_conn);

// Trigger model inference if there is no audio file in the conversation
if (!states.ContainsState("init_audio_file"))
Expand All @@ -119,6 +113,16 @@ await _completer.Connect(_conn,
await _completer.TriggerModelInference("Reply based on the conversation context.");
}
}
else
{
// Push dialogs into model context
foreach (var message in dialogs)
{
await _completer.InsertConversationItem(message);
}

await _completer.TriggerModelInference($"{instruction}\r\n\r\nAssist user without repeating your previous statement.");
}
},
onModelAudioDeltaReceived: async (audioDeltaData, itemId) =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public async Task<TwiMLResult> InitiateStreamConversation(ConversationalVoiceReq

if (request.InitAudioFile != null)
{
instruction.SpeechPaths.Add($"twilio/voice/speeches/{request.ConversationId}/{request.InitAudioFile}");
instruction.SpeechPaths.Add(request.InitAudioFile);
}

await HookEmitter.Emit<ITwilioSessionHook>(_services, async hook =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public VoiceResponse ReturnBidirectionalMediaStreamsInstructions(string conversa
}
else
{
response.Play(new Uri($"{_settings.CallbackHost}/{speechPath}"));
response.Play(new Uri($"{_settings.CallbackHost}/twilio/voice/speeches/{conversationalVoiceResponse.ConversationId}/{speechPath}"));
}
}
}
Expand Down
Loading