From the course: A Start to Using Generative AI in .NET
Unlock the full course today
Join today to access over 23,400 courses taught by industry experts.
Hello chat - .NET Tutorial
From the course: A Start to Using Generative AI in .NET
Hello chat
- [Instructor] After all the preparation we are finally ready to make our first request to the OpenAI API. Let's try to figure out how to make a request to the OpenAI API. Previously, I mentioned that the central object was the OpenAIClient object, which we have created. So, let's type client., and then chat. This should filter the OpenAIClient's methods to only show the ones that contain the word chat. As you can see, we have four options. GetChatCompletions is the simplest one. The others provide asynchronous and streaming versions to the same. So, let's just stick with the simplest one for now, GetChatCompletions. The term chat completion may sound a bit strange by the way, but it essentially means that it completes the conversation with an answer. The GetChatCompletions method requires a ChatCompletionsOptions parameter and an optional cancellation token, which we will generously ignore for now. So, we need a ChatCompletions object. Let's create one, ChatCompletionsOptions, let's…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Choosing a .NET library3m 37s
-
(Locked)
Creating a basic .NET Core console application3m 42s
-
(Locked)
Create the OpenAIClient object5m 17s
-
(Locked)
Hello chat6m 25s
-
(Locked)
The chat loop5m 19s
-
(Locked)
Error handling7m 35s
-
(Locked)
Using the Azure OpenAI service5m 35s
-
(Locked)
Streaming vs. non-streaming2m 43s
-
(Locked)
Implementing streaming completion7m 18s
-
(Locked)
Challenge: Fix the bugs41s
-
(Locked)
Solution: Fix the bugs6m 40s
-
-
-