Fix InvokeFunction name.

This commit is contained in:
Haiping Chen 2024-03-14 19:52:58 -05:00
parent 0cdaee0c9e
commit be7b5a9849
4 changed files with 9 additions and 7 deletions

View file

@ -31,7 +31,7 @@ public interface IRoutingService
List<RoutingHandlerDef> GetHandlers(Agent router);
void ResetRecursiveCounter();
Task<bool> InvokeAgent(string agentId, List<RoleDialogModel> dialogs);
Task<bool> InvokeFunction(string name, RoleDialogModel message, bool restoreOriginalFunctionName = true);
Task<bool> InvokeFunction(string name, RoleDialogModel message);
Task<RoleDialogModel> InstructLoop(RoleDialogModel message);
/// <summary>

View file

@ -1,3 +1,4 @@
using Amazon.Runtime.Internal.Transform;
using BotSharp.Abstraction.Agents.Models;
using BotSharp.Abstraction.Functions.Models;
using BotSharp.Abstraction.Repositories.Filters;
@ -111,9 +112,11 @@ public class NaivePlanner : IPlaner
{
var template = router.Templates.First(x => x.Name == "planner_prompt.naive").Content;
var states = _services.GetRequiredService<IConversationStateService>();
var render = _services.GetRequiredService<ITemplateRender>();
return render.Render(template, new Dictionary<string, object>
{
{ "next_action_agent", states.GetState("next_action_agent")}
});
}

View file

@ -4,7 +4,7 @@ namespace BotSharp.Core.Routing;
public partial class RoutingService
{
public async Task<bool> InvokeFunction(string name, RoleDialogModel message, bool restoreOriginalFunctionName = true)
public async Task<bool> InvokeFunction(string name, RoleDialogModel message)
{
var function = _services.GetServices<IFunctionCallback>().FirstOrDefault(x => x.Name == name);
if (function == null)
@ -57,8 +57,7 @@ public partial class RoutingService
// restore original function name
if (!message.StopCompletion &&
message.FunctionName != originalFunctionName &&
restoreOriginalFunctionName)
message.FunctionName != originalFunctionName)
{
message.FunctionName = originalFunctionName;
}

View file

@ -1,3 +1,3 @@
What is the next step based on the CONVERSATION?
Route to the Agent that last handled the conversation if necessary.
If user wants to speak to customer service, use function human_intervention_needed.
What is the next step based on the CONVERSATION?
If user is replying with agent's question, you must route back to the previous agent {{ next_action_agent }}.
If user wants to speak to customer service, use function human_intervention_needed.