Skip to content

AzureCloudWorkshops/ACW-AI-Workshop

Repository files navigation

Workshop Semantic Kernel

Exercise 1 - Chat

We will first start with a basic chat, and then evolve it to a more complex chat.

A. Single message

  • Print hardcoded answer to console
  • Read the user input from console instead of hard coding it
Hint Configure Kernel
var kernelBuilder = Kernel.CreateBuilder();
var config = new { modelID = "gpt-4", azureEndpoint = "", apiKey = "….." };
kernelBuilder.AddAzureOpenAIChatCompletion(config.modelID, config.azureEndpoint,config.apiKey);
var kernel = kernelBuilder.Build();
Hint 2 Invoke Service
var chatService = kernel.GetRequiredService<IChatCompletionService>();
var chatResponse = await chatService.GetChatMessageContentAsync("Hi! How are you?");
Console.WriteLine(chatResponse);

B. Full back and forth chat

  • Now that we can chat, let's allow for us to keep asking until we kill our app!

C. Remember me!

  • Add a history to the chat so the model remembers what we talked about!
Hint Keep array of messages to pass to call

D. Bonus - streaming chat

If you would like to get that delayed output feel, you can use the GetStreamChatMessageContentAsync Method:

E. Bonus - Plugin

  • Create a plugin get Chuck Norris jokes, pokemon, or any other API you like.

F. Bonus - RAG

  • Initialize your light plugin with some data
Hint

URL Hint

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published