Skip to content

Commit 75b9ad3

Browse files
committed
Merge branch 'master' into v0.9.0-routing
2 parents 59e1788 + 88a69f3 commit 75b9ad3

File tree

5 files changed

+17
-28
lines changed

5 files changed

+17
-28
lines changed

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

+1
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.Abstraction/Functions/Models/FunctionExecutionValidationResult.cs

-24
This file was deleted.

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

+11-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,17 @@ private async Task CallFunctions(RoleDialogModel msg)
2929
await hook.OnFunctionExecuting(msg);
3030
}
3131

32-
// Execute function
33-
await fn.Execute(msg);
34-
32+
try
33+
{
34+
// Execute function
35+
await fn.Execute(msg);
36+
}
37+
catch (Exception ex)
38+
{
39+
msg.ExecutionResult = ex.Message;
40+
_logger.LogError(msg.ExecutionResult);
41+
}
42+
3543
// After functions have been executed
3644
foreach (var hook in hooks)
3745
{

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

+2-1
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

+3
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)