You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-app-configuration/howto-chat-completion-config.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,7 +43,7 @@ You successfully added your chat completion configuration named **ChatApp:ChatCo
43
43
> This tutorial demonstrates how to use chat completion configuration with an Azure OpenAI model. However, the chat completion configuration demonstrated in the tutorial can be applied to any AI model you choose to work with in your application.
44
44
>
45
45
46
-
1. Follow the [Get started with Azure OpenAI Service](/azure/ai-services/openai/overview#get-started-with-azure-openai-service) to create and deploy an Azure OpenAI service resource with a **gpt-4o** model. Note down the deployment name for later use.
46
+
1. Follow the [Get started with Azure OpenAI Service](/azure/ai-foundry/openai/how-to/create-resource) to create and deploy an Azure OpenAI service resource with a **gpt-4o** model. Note down the deployment name for later use.
47
47
48
48
1. In your Azure OpenAI resource, from the **Resource Management** menu, select **Keys and Endpoint** and copy the Azure OpenAI resource endpoint. It should follow the format: `https://<open-ai-resource-name>.openai.azure.com`. If using the API key for authentication, copy the API key as well.
# Use chat completion configuration in a .NET console app
19
19
20
-
In this guide, you build an AI chat application and iterate on the prompt using chat completion configuration dynamically loaded from Azure App Configuration. Full [sample source code](https://github.com/Azure/AppConfiguration/tree/main/examples/DotNetCore/ChatApp) available.
20
+
In this guide, you build an AI chat application and iterate on the prompt using chat completion configuration dynamically loaded from Azure App Configuration.
21
+
22
+
The full sample source code is available in the [Azure App Configuration GitHub repository](https://github.com/Azure/AppConfiguration/tree/main/examples/DotNetCore/ChatApp).
21
23
22
24
## Prerequisites
23
25
@@ -162,6 +164,10 @@ In this guide, you build an AI chat application and iterate on the prompt using
162
164
1. Next, update the existing code in the _Program.cs_ file to refresh the configuration from Azure App Configuration, apply the latest AI configuration values to the chat completion settings, and retrieve a response from the AI model.
163
165
164
166
```csharp
167
+
// Initialize chat conversation
168
+
var chatConversation = new List<ChatMessage>();
169
+
Console.WriteLine("Chat started! What's on your mind?");
170
+
165
171
while (true)
166
172
{
167
173
// Get user input
@@ -175,6 +181,8 @@ In this guide, you build an AI chat application and iterate on the prompt using
// Get latest system message from AI configuration
281
287
var chatMessages = new List<ChatMessage>(GetChatMessages(chatCompletionConfiguration));
282
288
chatMessages.AddRange(chatConversation);
@@ -356,21 +362,29 @@ In this guide, you build an AI chat application and iterate on the prompt using
356
362
dotnet run
357
363
```
358
364
359
-
You should see the following output:
365
+
366
+
1. Type the message "What is your name?" when prompted with "You:" and then press the Enter key.
360
367
361
368
```Output
362
369
Chat started! What's on your mind?
370
+
You: What is your name ?
371
+
AI: I’m your helpful assistant! I don’t have a personal name, but you can call me whatever you’d like.
372
+
😊 Do you have a name in mind?
363
373
```
364
374
365
375
1. In Azure portal, select the App Configuration store instance that you created. From the **Operations** menu, select **Configuration explorer** and select the **ChatApp:ChatCompletion** key. Update the value of the Messages property:
366
376
- Role: **system**
367
377
- Content: "You are a pirate and your name is Eddy."
368
378
369
-
1. Type your message when prompted with "You:". Be sure to wait a few moments for the refresh interval to elapse, and then press the Enter key to see the updated AI response in the output.
379
+
1. Type the same message when prompted with "You:". Be sure to wait a few moments for the refresh interval to elapse, and then press the Enter key to see the updated AI response in the output.
370
380
371
381
```Output
372
382
Chat started! What's on your mind?
373
-
You: Hello, what is your name ?
374
-
AI: Ahoy, matey! Me name be Captain Eddy,
375
-
the most fearsome pirate to ever sail the seven seas! What be yer name, landlubber?
383
+
You: What is your name ?
384
+
AI: I’m your helpful assistant! I don’t have a personal name, but you can call me whatever you’d like.
385
+
😊 Do you have a name in mind?
386
+
387
+
You: What is your name ?
388
+
AI: Arrr, matey! Me name be Eddy, the most fearsome pirate to ever sail the seven seas!
0 commit comments