Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds a .NET 8.0 console example illustrating how to load AI model settings from Azure App Configuration, refresh them at runtime, and drive an Azure OpenAI chat loop.
- Loads ChatLLM settings via
Microsoft.Extensions.Configuration.AzureAppConfigurationwith auto-refresh. - Builds and invokes an Azure OpenAI chat client in a continuous console loop.
- Introduces
ModelConfigurationandMessageclasses for binding configuration sections.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| examples/DotNetCore/ChatApp/ChatApp/Program.cs | Top‐level console app: loads config, refreshes, loops chat interactions |
| examples/DotNetCore/ChatApp/ChatApp/ModelConfiguration.cs | Binds ChatLLM:Model section to a typed configuration object |
| examples/DotNetCore/ChatApp/ChatApp/Message.cs | Defines Message type for config-based chat messages |
| examples/DotNetCore/ChatApp/ChatApp/ChatApp.csproj | New .NET 8.0 project file with required package refs |
| examples/DotNetCore/ChatApp/ChatApp.sln | Solution file including the ChatApp project |
Comments suppressed due to low confidence (6)
examples/DotNetCore/ChatApp/ChatApp/Program.cs:38
- The .NET SDK ships an OpenAIClient class under Azure.AI.OpenAI, not AzureOpenAIClient. Replace AzureOpenAIClient with OpenAIClient to compile against the Azure.AI.OpenAI package.
AzureOpenAIClient azureClient = new(chatEndpoint, credential);
examples/DotNetCore/ChatApp/ChatApp/Program.cs:61
- There is no CompleteChat method on ChatClient in the Azure.AI.OpenAI SDK. Use the appropriate GetChatCompletions or GetChatCompletionsAsync call for chat completions.
var response = chatClient.CompleteChat(modelConfig.ChatMessages, requestOptions);
examples/DotNetCore/ChatApp/ChatApp/ModelConfiguration.cs:9
- With Nullable enabled, non-nullable properties must be initialized. Consider adding a default initializer (e.g.,
= string.Empty;) or use= default!;to suppress warnings.
public string Model { get; set; }
examples/DotNetCore/ChatApp/ChatApp/ModelConfiguration.cs:12
- Initialize the Messages list by default (e.g.,
= new List<Message>();) to satisfy non-nullable reference requirements and avoid potential null dereferences.
public List<Message> Messages { get; set; }
examples/DotNetCore/ChatApp/ChatApp/Message.cs:8
- Add a default initializer (e.g.,
= string.Empty;) or use= default!;for non-nullable properties under Nullable enable to prevent warnings.
public string Role { get; set; }
examples/DotNetCore/ChatApp/ChatApp/Program.cs:10
- [nitpick] Using an underscore for a local variable is unconventional; consider renaming to
refresherwithout the underscore to follow standard C# naming conventions.
IConfigurationRefresher _refresher = null;
|
So this one went with the approach where the user prompt is part of configuration right? |
Yes, the user prompt is also from the configuration. Do you prefer it input at runtime? |
No, the way you've done it is actually the way I prefer it. |
|
@Muksvso, FYI |
Example output of the ChatApp: