We will first start with a basic chat, and then evolve it to a more complex chat.
- Print hardcoded answer to console
- Read the user input from console instead of hard coding it
Hint
Configure Kernelvar 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 Servicevar chatService = kernel.GetRequiredService<IChatCompletionService>();
var chatResponse = await chatService.GetChatMessageContentAsync("Hi! How are you?");
Console.WriteLine(chatResponse);
- Now that we can chat, let's allow for us to keep asking until we kill our app!
- Add a history to the chat so the model remembers what we talked about!
Hint
Keep array of messages to pass to callIf you would like to get that delayed output feel, you can use the GetStreamChatMessageContentAsync Method:
- Create a plugin get Chuck Norris jokes, pokemon, or any other API you like.
- Initialize your light plugin with some data