Semantic Kernel 的 Connector 是一种用于连接外部数据源和服务的设计模式,包括获取数据和保存输出结果,而 Semantic Kernel 已经原生集成了许多开箱即用的大模型服务 Plugin,其中就包括了基于 Hugging Face Transformers 构建的的 Embedding 和 Text completion Service,因此我们可以参考这两个 Service 的代码,来实现一组 ...
在kernel中加入这个插件: builder.Plugins.AddFromType<TimeInformation>(); var kernel = builder.Build(); 现在来试试效果: // Example 1. Invoke the kernel with a prompt that asks the AI for information it cannot provide and may hallucinate Text += "问:还有多少天到7月1号?\r\n"; Text +...
Program 中调用AddFromPromptDirectory方法添加 plugin,注意参数中的路径是 plugin 的路径,不是 prompt function 的路径 varbuilder = Kernel.CreateBuilder(); builder.AddOpenAIChatCompletion("gpt-3.5-turbo", apiKey); builder.Plugins.AddFromPromptDirectory("Plugins/DevOps");varkernel = builder.Build(); 控制...
publicstaticKernelPluginImportPluginFromType<T>(thisKernel kernel,string? pluginName =null){ KernelPlugin plugin = CreatePluginFromType<T>(kernel, pluginName); kernel.Plugins.Add(plugin);returnplugin; } 在Semantic Kernel 中定义函数插件,需要用到两个特性KernelFunction和Description KernelFunction特性把函数...
kernel.add_plugin(WeatherPlugin(), plugin_name="weather") A Glimpse into the TimePlugin We’ll dive into the details of the PythonTimePluginshowcasing the use of plguins and how a plugin can return the time and additional items through a user to agent chat. ...
首先,需要打开 Visual Studio 2022 并创建一个名为 5_1_SKPluginSQL的控制台项目。 接下来,我们将使用 SemanticKernel来导入目录中所有的插件。 在项目目录中,创建一个 plugins文件夹,并在其中创建 BasePlugins文件夹。这个文件夹将用来存放我们系统的基础插件。
dotnet add package Microsoft.SemanticKernel 1. 2. 3、创建TimePlugin插件类 项目结构如下: dotnet-sk-plugins |--Plugins |--|--Plugin.Time |--|--|--TimePlugin.cs |--Program.cs 1. 2. 3. 4. 5. 代码示例如下: using System.ComponentModel; ...
这是一个基础的Native Function的示例,Native Function就和c#里正常的Function一样,只需要加上[KernelFunction] 特性即可。 Example03_Arguments-参数 Kernel kernel =new;vartextPlugin = kernel.ImportPluginFromType<StaticTextPlugin>; vararguments =newKernelArguments{["input"] ="Today is: ",["day"] = Dat...
Create a sample that uses a plugin which depends on a service made available using dependency injection Native function Open API function Activity markwallace-microsoftmoved this to Sprint: In Progress in Semantic Kernelon Nov 21, 2024 markwallace-microsoftadded this to Semantic Kernelon Nov 21...
Plugin本质上是 Function 的容器形式,一个 Plugin 中可以包含多个 Function 。 我们可以像上期一样,单独调用一个 Function , 也可以将多个 Function 链接在一起统一调用。 将多个 Function 连接在一起就会形成 Pipeline 管道,Semantic Kernel 会使用变量自动将每个插件函数的输出结果传递给管道中下一个插件函数。 创建...