Skip to content

Commit b7a210e

Browse files
authored
Merge pull request #342 from hchen2020/master
Fix InvokeFunction name.
2 parents 0cdaee0 + be7b5a9 commit b7a210e

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

src/Infrastructure/BotSharp.Abstraction/Routing/IRoutingService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public interface IRoutingService
3131
List<RoutingHandlerDef> GetHandlers(Agent router);
3232
void ResetRecursiveCounter();
3333
Task<bool> InvokeAgent(string agentId, List<RoleDialogModel> dialogs);
34-
Task<bool> InvokeFunction(string name, RoleDialogModel message, bool restoreOriginalFunctionName = true);
34+
Task<bool> InvokeFunction(string name, RoleDialogModel message);
3535
Task<RoleDialogModel> InstructLoop(RoleDialogModel message);
3636

3737
/// <summary>

src/Infrastructure/BotSharp.Core/Routing/Planning/NaivePlanner.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Amazon.Runtime.Internal.Transform;
12
using BotSharp.Abstraction.Agents.Models;
23
using BotSharp.Abstraction.Functions.Models;
34
using BotSharp.Abstraction.Repositories.Filters;
@@ -111,9 +112,11 @@ private string GetNextStepPrompt(Agent router)
111112
{
112113
var template = router.Templates.First(x => x.Name == "planner_prompt.naive").Content;
113114

115+
var states = _services.GetRequiredService<IConversationStateService>();
114116
var render = _services.GetRequiredService<ITemplateRender>();
115117
return render.Render(template, new Dictionary<string, object>
116118
{
119+
{ "next_action_agent", states.GetState("next_action_agent")}
117120
});
118121
}
119122

src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeFunction.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace BotSharp.Core.Routing;
44

55
public partial class RoutingService
66
{
7-
public async Task<bool> InvokeFunction(string name, RoleDialogModel message, bool restoreOriginalFunctionName = true)
7+
public async Task<bool> InvokeFunction(string name, RoleDialogModel message)
88
{
99
var function = _services.GetServices<IFunctionCallback>().FirstOrDefault(x => x.Name == name);
1010
if (function == null)
@@ -57,8 +57,7 @@ public async Task<bool> InvokeFunction(string name, RoleDialogModel message, boo
5757

5858
// restore original function name
5959
if (!message.StopCompletion &&
60-
message.FunctionName != originalFunctionName &&
61-
restoreOriginalFunctionName)
60+
message.FunctionName != originalFunctionName)
6261
{
6362
message.FunctionName = originalFunctionName;
6463
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
What is the next step based on the CONVERSATION?
2-
Route to the Agent that last handled the conversation if necessary.
3-
If user wants to speak to customer service, use function human_intervention_needed.
1+
What is the next step based on the CONVERSATION?
2+
If user is replying with agent's question, you must route back to the previous agent {{ next_action_agent }}.
3+
If user wants to speak to customer service, use function human_intervention_needed.

0 commit comments

Comments
 (0)