MaxRecursiveDepth setting.

This commit is contained in:
hchen2020 2023-08-24 07:18:41 -05:00
parent c8b9ce128f
commit 434324358a
3 changed files with 6 additions and 1 deletions

View file

@ -8,4 +8,5 @@ public class AgentSettings
public string RouterId { get; set; }
public string DataDir { get; set; }
public string TemplateFormat { get; set; }
public int MaxRecursiveDepth { get; set; } = 3;
}

View file

@ -7,13 +7,13 @@ namespace BotSharp.Core.Conversations.Services;
public partial class ConversationService
{
const int maxRecursiveDepth = 3;
int currentRecursiveDepth = 0;
private async Task<bool> GetChatCompletionsAsyncRecursively(IChatCompletion chatCompletion,
string conversationId,
Agent agent,
List<RoleDialogModel> wholeDialogs,
int maxRecursiveDepth,
Func<RoleDialogModel, Task> onMessageReceived,
Func<RoleDialogModel, Task> onFunctionExecuting,
Func<RoleDialogModel, Task> onFunctionExecuted)
@ -83,6 +83,7 @@ public partial class ConversationService
conversationId,
agent,
wholeDialogs,
maxRecursiveDepth,
onMessageReceived,
onFunctionExecuting,
onFunctionExecuted);

View file

@ -65,11 +65,14 @@ public partial class ConversationService
await hook.BeforeCompletion();
}
var agentSettings = _services.GetRequiredService<AgentSettings>();
var chatCompletion = GetChatCompletion();
var result = await GetChatCompletionsAsyncRecursively(chatCompletion,
conversationId,
agent,
wholeDialogs,
agentSettings.MaxRecursiveDepth,
onMessageReceived,
onFunctionExecuting,
onFunctionExecuted);