using Microsoft.SemanticKernel;
using AI.KnowledgeBase;
using System.ComponentModel;
using System.Threading.Tasks;
namespace AI.Plugin
{
///
/// 知识库插件:仅负责根据查询返回知识库内容,不依赖会话或 Store。
/// 将结果写入当前会话 Store 由 在调用完成后统一处理。
///
/// 知识库实例
public class KnowledgeBasePlugin(IKnowledgeBase knowledgeBase)
{
private readonly IKnowledgeBase knowledgeBase = knowledgeBase;
///
/// 查询知识库中的信息
///
/// 查询语句
/// 返回匹配的知识条目
[KernelFunction]
[Description("当需要回答有关特定主题的知识时,搜索知识库。")]
[return: Description("从知识库中检索到的相关信息,用于回答用户的问题。")]
public async Task QueryKnowledgeBaseAsync(string query)
{
return await knowledgeBase.SearchKnowledgeAsync(query);
}
}
}