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 08:24:26 +00:00
|
|
|
var utilityLoad = new AgentUtilityLoadModel
|
2024-07-17 21:03:46 +00:00
|
|
|
{
|
2024-11-20 08:24:26 +00:00
|
|
|
UtilityName = UtilityName.KnowledgeRetrieval,
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
}
|