Skip to content

.Net: Not able to use semantic kernel for simple prompt #12021

@ktjosh

Description

@ktjosh

Hello I am using semantic kernel for a single prompt I want to use. As its a single prompt I do not want to create a plugin with skprompts file. Below is the sample code I have. When I run this code I receive Keynotfound exception saying .

As there is lack of examples I am not sure if we want to import plugins first after creation.

One or more errors occurred. (The plugin collection does not contain a plugin and/or function with the specified names. Plugin name - '', function name - 'topic'.)

Here is the sample code

            Kernel kernel = Kernel.CreateBuilder().AddAzureOpenAIChatCompletion(deploymentName, openAiEndpoint, new DefaultAzureCredential()).Build();


            var prompt = "Tell me a joke about {{topic}}";
            var jokeFunction = kernel.CreateFunctionFromPrompt(prompt, functionName: "JokeFunction");

            var jokePlugin = kernel.CreatePluginFromFunctions("JokePlugin", new List<KernelFunction>() { jokeFunction });


            KernelArguments args = new KernelArguments
            {
                {"topic" , "cats" }
            };

            var result = kernel.InvokeAsync<string>(pluginName: "JokePlugin", functionName: "JokeFunction", args).Result;

Metadata

Metadata

Labels

.NETIssue or Pull requests regarding .NET codequestionFurther information is requested

Type

No type

Projects

Status

Sprint: Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions