Merge pull request #618 from hchen2020/master

Fix router history dialogs.
This commit is contained in:
Haiping 2024-09-04 10:06:21 -05:00 committed by GitHub
commit 1926914bd3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 17 additions and 9 deletions

View file

@ -30,7 +30,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

@ -64,7 +64,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()
@ -76,8 +76,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
};
if (speechPaths != null && speechPaths.Any())
@ -91,7 +91,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())
@ -110,8 +110,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);