Merge branch 'master' of https://github.com/SciSharp/BotSharp into features/refine-audio-handler

This commit is contained in:
Jicheng Lu 2024-09-04 10:11:36 -05:00
commit 1d704051bd
4 changed files with 17 additions and 9 deletions

View file

@ -29,7 +29,7 @@ public class RoleDialogModel : ITrackableMessage
public string? SecondaryContent { get; set; }
/// <summary>
/// Postback content
/// Postback of previous round payload
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("payload")]

View file

@ -41,7 +41,7 @@ public partial class ConversationService
routing.Context.SetMessageId(_conversationId, message.MessageId);
routing.Context.Push(agent.Id, reason: "request started");
// Save payload
// Save payload in order to assign the payload before hook is invoked
if (replyMessage != null && !string.IsNullOrEmpty(replyMessage.Payload))
{
message.Payload = replyMessage.Payload;

View file

@ -16,7 +16,15 @@ public partial class RoutingService
role = agent.Name;
}
conversation += $"{role}: {dialog.Payload ?? dialog.Content}\r\n";
if (role == AgentRole.User)
{
conversation += $"{role}: {dialog.Payload ?? dialog.Content}\r\n";
}
else
{
// Assistant reply deosn't need help with payload
conversation += $"{role}: {dialog.Content}\r\n";
}
}
return conversation;

View file

@ -66,7 +66,7 @@ public class TwilioService
return response;
}
public VoiceResponse ReturnInstructions(List<string> speechPaths, string callbackPath, bool actionOnEmptyResult, int timeout = 2)
public VoiceResponse ReturnInstructions(List<string> speechPaths, string callbackPath, bool actionOnEmptyResult, int timeout = 3)
{
var response = new VoiceResponse();
var gather = new Gather()
@ -78,8 +78,8 @@ public class TwilioService
},
Action = new Uri($"{_settings.CallbackHost}/{callbackPath}"),
SpeechModel = Gather.SpeechModelEnum.PhoneCall,
SpeechTimeout = timeout > 0 ? timeout.ToString() : "2",
Timeout = timeout > 0 ? timeout : 2,
SpeechTimeout = "auto", // timeout > 0 ? timeout.ToString() : "3",
Timeout = timeout > 0 ? timeout : 3,
ActionOnEmptyResult = actionOnEmptyResult
};
@ -94,7 +94,7 @@ public class TwilioService
return response;
}
public VoiceResponse ReturnNoninterruptedInstructions(List<string> speechPaths, string callbackPath, bool actionOnEmptyResult, int timeout = 2)
public VoiceResponse ReturnNoninterruptedInstructions(List<string> speechPaths, string callbackPath, bool actionOnEmptyResult, int timeout = 3)
{
var response = new VoiceResponse();
if (speechPaths != null && speechPaths.Any())
@ -113,8 +113,8 @@ public class TwilioService
},
Action = new Uri($"{_settings.CallbackHost}/{callbackPath}"),
SpeechModel = Gather.SpeechModelEnum.PhoneCall,
SpeechTimeout = timeout > 0 ? timeout.ToString() : "2",
Timeout = timeout > 0 ? timeout : 2,
SpeechTimeout = "auto", // timeout > 0 ? timeout.ToString() : "3",
Timeout = timeout > 0 ? timeout : 3,
ActionOnEmptyResult = actionOnEmptyResult
};
response.Append(gather);