Skip to content

Commit 4343243

Browse files
author
hchen2020
committed
MaxRecursiveDepth setting.
1 parent c8b9ce1 commit 4343243

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/Infrastructure/BotSharp.Abstraction/Agents/Settings/AgentSettings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ public class AgentSettings
88
public string RouterId { get; set; }
99
public string DataDir { get; set; }
1010
public string TemplateFormat { get; set; }
11+
public int MaxRecursiveDepth { get; set; } = 3;
1112
}

src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.GetChatCompletionsAsyncRecursively.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ namespace BotSharp.Core.Conversations.Services;
77

88
public partial class ConversationService
99
{
10-
const int maxRecursiveDepth = 3;
1110
int currentRecursiveDepth = 0;
1211

1312
private async Task<bool> GetChatCompletionsAsyncRecursively(IChatCompletion chatCompletion,
1413
string conversationId,
1514
Agent agent,
1615
List<RoleDialogModel> wholeDialogs,
16+
int maxRecursiveDepth,
1717
Func<RoleDialogModel, Task> onMessageReceived,
1818
Func<RoleDialogModel, Task> onFunctionExecuting,
1919
Func<RoleDialogModel, Task> onFunctionExecuted)
@@ -83,6 +83,7 @@ await GetChatCompletionsAsyncRecursively(chatCompletion,
8383
conversationId,
8484
agent,
8585
wholeDialogs,
86+
maxRecursiveDepth,
8687
onMessageReceived,
8788
onFunctionExecuting,
8889
onFunctionExecuted);

src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,14 @@ public async Task<bool> SendMessage(string agentId, string conversationId,
6565
await hook.BeforeCompletion();
6666
}
6767

68+
var agentSettings = _services.GetRequiredService<AgentSettings>();
69+
6870
var chatCompletion = GetChatCompletion();
6971
var result = await GetChatCompletionsAsyncRecursively(chatCompletion,
7072
conversationId,
7173
agent,
7274
wholeDialogs,
75+
agentSettings.MaxRecursiveDepth,
7376
onMessageReceived,
7477
onFunctionExecuting,
7578
onFunctionExecuted);

0 commit comments

Comments
 (0)