Merge pull request #112 from hchen2020/master

Fix dead loop when depth exceeds the limit.
This commit is contained in:
Haiping 2023-08-23 10:42:28 -05:00 committed by GitHub
commit 76b1e6de32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -21,12 +21,21 @@ public partial class ConversationService
currentRecursiveDepth++;
if (currentRecursiveDepth > maxRecursiveDepth)
{
_logger.LogError($"Exceeded max recursive depth.");
await HandleAssistantMessage(new RoleDialogModel(AgentRole.Assistant, "I'm sorry, can you see it again?")
_logger.LogWarning($"Exceeded max recursive depth.");
var latestResponse = wholeDialogs.Last();
var text = latestResponse.Content;
if (latestResponse.Role == AgentRole.Function)
{
text = latestResponse.Content.Split("=>").Last();
}
await HandleAssistantMessage(new RoleDialogModel(AgentRole.Assistant, text)
{
CurrentAgentId = agent.Id,
Channel = wholeDialogs.Last().Channel
}, onMessageReceived);
return false;
}