2024-07-25 22:11:51 +00:00
|
|
|
namespace BotSharp.Plugin.Planner.Hooks;
|
|
|
|
|
|
|
|
|
|
public class PlannerAgentHook : AgentHookBase
|
|
|
|
|
{
|
2024-12-10 18:30:41 +00:00
|
|
|
public override string SelfId => PlannerAgentId.TwoStagePlanner;
|
2024-07-25 22:11:51 +00:00
|
|
|
|
|
|
|
|
public PlannerAgentHook(IServiceProvider services, AgentSettings settings)
|
|
|
|
|
: base(services, settings)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-12 01:18:45 +00:00
|
|
|
public override bool OnInstructionLoaded(string template, Dictionary<string, object> dict)
|
|
|
|
|
{
|
|
|
|
|
var knowledgeHooks = _services.GetServices<IKnowledgeHook>();
|
|
|
|
|
|
|
|
|
|
// Get global knowledges
|
|
|
|
|
var Knowledges = new List<string>();
|
|
|
|
|
foreach (var hook in knowledgeHooks)
|
|
|
|
|
{
|
|
|
|
|
var k = hook.GetGlobalKnowledges(new RoleDialogModel(AgentRole.User, template)
|
|
|
|
|
{
|
2024-12-10 18:30:41 +00:00
|
|
|
CurrentAgentId = PlannerAgentId.TwoStagePlanner
|
2024-10-12 01:18:45 +00:00
|
|
|
}).Result;
|
|
|
|
|
Knowledges.AddRange(k);
|
|
|
|
|
}
|
|
|
|
|
dict["global_knowledges"] = Knowledges;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2024-07-25 22:11:51 +00:00
|
|
|
}
|