Skip to content

rename #784

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public AgentUtility(
Functions = functions ?? [];
Templates = templates ?? [];
}

public override string ToString()
{
return Name;
}
}


Expand Down
2 changes: 1 addition & 1 deletion src/Infrastructure/BotSharp.Core/Agents/AgentPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void RegisterDI(IServiceCollection services, IConfiguration config)
{
services.AddScoped<ILlmProviderService, LlmProviderService>();
services.AddScoped<IAgentService, AgentService>();
services.AddScoped<IAgentHook, CommonAgentHook>();
services.AddScoped<IAgentHook, BasicAgentHook>();

services.AddScoped(provider =>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
namespace BotSharp.Core.Agents.Hooks;

public class CommonAgentHook : AgentHookBase
public class BasicAgentHook : AgentHookBase
{
public override string SelfId => string.Empty;

public CommonAgentHook(IServiceProvider services, AgentSettings settings)
public BasicAgentHook(IServiceProvider services, AgentSettings settings)
: base(services, settings)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using BotSharp.Abstraction.Planning;
using BotSharp.Abstraction.Routing.Enums;
using BotSharp.Abstraction.Routing.Reasoning;
using BotSharp.Core.Routing.Reasoning;

namespace BotSharp.Core.Routing;

Expand All @@ -21,7 +20,7 @@ public async Task<RoleDialogModel> InstructLoop(RoleDialogModel message, List<Ro
var states = _services.GetRequiredService<IConversationStateService>();
var executor = _services.GetRequiredService<IExecutor>();

var planner = GetReasoner(_router);
var reasoner = GetReasoner(_router);

_context.Push(_router.Id);

Expand All @@ -46,7 +45,7 @@ public async Task<RoleDialogModel> InstructLoop(RoleDialogModel message, List<Ro

// Get first instruction
_router.TemplateDict["conversation"] = await GetConversationContent(dialogs);
var inst = await planner.GetNextInstruction(_router, message.MessageId, dialogs);
var inst = await reasoner.GetNextInstruction(_router, message.MessageId, dialogs);

int loopCount = 1;
while (true)
Expand All @@ -63,30 +62,30 @@ await hook.OnRoutingInstructionReceived(inst, message)
#else
_logger.LogInformation($"*** Next Instruction *** {inst}");
#endif
await planner.AgentExecuting(_router, inst, message, dialogs);
await reasoner.AgentExecuting(_router, inst, message, dialogs);

// Handover to Task Agent
if (inst.HandleDialogsByPlanner)
{
var dialogWithoutContext = planner.BeforeHandleContext(inst, message, dialogs);
var dialogWithoutContext = reasoner.BeforeHandleContext(inst, message, dialogs);
response = await executor.Execute(this, inst, message, dialogWithoutContext);
planner.AfterHandleContext(dialogs, dialogWithoutContext);
reasoner.AfterHandleContext(dialogs, dialogWithoutContext);
}
else
{
response = await executor.Execute(this, inst, message, dialogs);
}

await planner.AgentExecuted(_router, inst, response, dialogs);
await reasoner.AgentExecuted(_router, inst, response, dialogs);

if (loopCount >= planner.MaxLoopCount || _context.IsEmpty)
if (loopCount >= reasoner.MaxLoopCount || _context.IsEmpty)
{
break;
}

// Get next instruction from Planner
_router.TemplateDict["conversation"] = await GetConversationContent(dialogs);
inst = await planner.GetNextInstruction(_router, message.MessageId, dialogs);
inst = await reasoner.GetNextInstruction(_router, message.MessageId, dialogs);
loopCount++;
}

Expand All @@ -103,8 +102,7 @@ public IRoutingReasoner GetReasoner(Agent router)
return _services.GetServices<IRoutingReasoner>().First(x => x.Name == "Naive Reasoner");
}

var reasoner = _services.GetServices<IRoutingReasoner>().
FirstOrDefault(x => x.GetType().Name.EndsWith(rule.Field));
var reasoner = _services.GetServices<IRoutingReasoner>().FirstOrDefault(x => x.GetType().Name.EndsWith(rule.Field));

if (reasoner == null)
{
Expand Down