Friday, 21 February 2025

AI Agents using Semantic Kernel SDK

 >dotnet new console (After creating a folder in VSCode run this command to create a C# project)

>dotnet add package Microsoft.SemanticKernel --version 1.30.0 (This command will install the Semantic Kernal SDK

>dotnet run

Create Azure OpenAI end-point and deployment and the following code is a hello-world code to test your setup:

using Microsoft.SemanticKernel;

// Populate values from your OpenAI deployment
var modelId = "<Model Name From Deployment>";
var endpoint = "<EndPoint URL>";
var apiKey = "<API KEY>";

// Create a kernel with Azure OpenAI chat completion
var builder = Kernel.CreateBuilder().AddAzureOpenAIChatCompletion(modelId, endpoint, apiKey);

// Build the kernel
Kernel kernel = builder.Build();

var result = await kernel.InvokePromptAsync("Give me a list of breakfast foods with eggs and cheese");
Console.WriteLine(result);

No comments:

Post a Comment

Using Handlebar Prompt in Semantic Kernal

> dotnet add package Microsoft.SemanticKernel.PromptTemplates.Handlebars --version 1.30.0 using Microsoft . SemanticKernel ; using Micr...