BotSharp/src/Plugins/BotSharp.Plugin.KnowledgeBase/Hooks/KnowledgeBaseAgentHook.cs

31 lines
840 B
C#
Raw Normal View History

2024-07-17 21:03:46 +00:00
namespace BotSharp.Plugin.KnowledgeBase.Hooks;
public class KnowledgeBaseAgentHook : AgentHookBase, IAgentHook
{
2024-11-20 08:24:26 +00:00
private const string KNOWLEDGE_RETRIEVAL_FN = "knowledge_retrieval";
2024-07-17 21:03:46 +00:00
2024-11-20 08:24:26 +00:00
public override string SelfId => string.Empty;
2024-07-17 21:03:46 +00:00
2024-11-20 08:24:26 +00:00
public KnowledgeBaseAgentHook(IServiceProvider services, AgentSettings settings)
: base(services, settings)
2024-07-17 21:03:46 +00:00
{
}
2024-11-20 08:24:26 +00:00
public override void OnAgentLoaded(Agent agent)
2024-07-17 21:03:46 +00:00
{
2024-11-20 16:13:40 +00:00
var utilityLoad = new AgentUtility
2024-07-17 21:03:46 +00:00
{
2024-11-20 16:13:40 +00:00
Name = UtilityName.KnowledgeRetrieval,
2024-11-20 08:24:26 +00:00
Content = new UtilityContent
2024-07-17 21:03:46 +00:00
{
2024-11-20 08:24:26 +00:00
Functions = [new(KNOWLEDGE_RETRIEVAL_FN)],
Templates = [new($"{KNOWLEDGE_RETRIEVAL_FN}.fn")]
2024-07-17 21:03:46 +00:00
}
2024-11-20 08:24:26 +00:00
};
2024-07-17 21:03:46 +00:00
2024-11-20 08:24:26 +00:00
base.OnLoadAgentUtility(agent, [utilityLoad]);
base.OnAgentLoaded(agent);
2024-07-17 21:03:46 +00:00
}
}