MathPlugin: Math 计算插件 TextPlugin:字符串操作插件 TimePlugin:获取当前时间和日期插件 WaitPlugin: WaitPlugin提供了一组函数,在进行其余操作之前等待。 实战 我们来对Semantic Kernel中提供的内置插件来做一个实战练习 第一步需要安装Nuget 包 NuGet\Install-Package Microsoft.
本文对Semantic Kernel中的 Kernel,Plugin,KernelFunction,Semantic Memory,Planner,Services,reliability 等进行概念介绍及源码梳理,参考semantic kernel python 源代码。 原文博客: https://kevinng77.github.io/posts/notes/articles/%E7%AC%94%E8%AE%B0semantic_kernel.html#_3-kernelfunctionkevinng77.github.io...
httpClient:newHttpClient(handler)); _kernel = builder.Build(); _kernel.ImportPluginFromType<TimePlugin>("Time"); _kernel.ImportPluginFromType<MathPlugin>("Math"); 测试代码: UniversalLLMFunctionCaller planner =new(_kernel);stringask ="What is the current hour number, plus 6?"; Debug.WriteLine...
通过定制PromptPlugin和NativePlugin,我们可以灵活地根据业务需求制作出专属的插件,从而在Semantic Kernel框架下构建出更加专业和高效的.Net应用。
接下来通过 mathPlugin["Sqt"]来使用其中的 Sqt 方法,下图中我固定传递了一个数字 64. 同时还使用了 Add 方法,只不过 Add 方法有多个参数,所以这里用到了kernel.CreateNewContext 来创建参数。 运行后就可以分别得到 8 和10 . 64 的平方根是8,3+7 等于10。 而这两项算数计算和 OpenAI 没有任何关系,完全...
添加Plugin Program 中调用AddFromPromptDirectory方法添加 plugin,注意参数中的路径是 plugin 的路径,不是 prompt function 的路径 varbuilder = Kernel.CreateBuilder(); builder.AddOpenAIChatCompletion("gpt-3.5-turbo", apiKey); builder.Plugins.AddFromPromptDirectory("Plugins/DevOps");varkernel = builder.Buil...
classMathPlugin:@kernel_function(name="Add")defadd(self, number1: Annotated[float,"the first number to add"], number2: Annotated[float,"the second number to add"],) -> Annotated[float,"the output is a float"]:returnfloat(number1) +float(number2)@kernel_function(description="...
Usage: kernel.add_plugin(MathPlugin(), plugin_name="math") SessionsPythonTool A plugin for running Python code in an Azure Container Apps dynamic sessions code interpreter. Initializes a new instance of the SessionsPythonTool class. TextMemoryPlugin A plugin to interact with a Semantic Text ...
dotnet add package Microsoft.KernelMemory.Core dotnet add package Microsoft.SemanticKernel 1. 2. 3、创建TimePlugin插件类 项目结构如下: dotnet-sk-plugins |--Plugins |--|--Plugin.Time |--|--|--TimePlugin.cs |--Program.cs 1. 2.
// Create a new kernel IKernel kernel = new Kernel( aiServices: new () { }, plugins: new () { intentPlugin, mathPlugin } ); // Start the chat ChatHistory chatHistory = gpt35Turbo.CreateNewChat(); while(true) { Console.Write("User > "); ...