This demo adds a Chat Playground page to a basic .NET Aspire solution. It provides an experience similar to that of the Chat Playground feature in Azure AI Foundry.
The source code demonstrates using the streaming variant of the completions API to display the chat response fragments as they are received from the API call.
-
Create a resource group. Name it something like
AI-RG.Don't have an Azure account? Create a free account from https://azure.microsoft.com. The $200 credit allows for plenty of experimentation for a month.
-
In the resource group, create an
Azure OpenAI serviceresource. Preferrably chooseEastUS2, if there is enough quota. -
Click on the created in step 2.
-
Click on the
Explore Azure AI Foundry portal. -
In
Azure AI Foundry, click onDeploymentsin the left nav menu. -
Click on
+ Deploy Model. Click onDeploy Base Modelfrom the dropdown. -
Click on the model name. Copy the following pieces of information: a.
Endpoint subdomain: It is usuallyopenai.azure.combut could becognitiveservices.azure.com. b.Service name(the name of the resource created in step 2) c.Model name(e.g. gpt-4.1) d.Deployment name(e.g. gpt-4.1) e. TheAPI key
- Open the solution in
Visual Studio(the free Community Edition can be used). - From the Build menu, choose
Build Solution. - Run the solution (press
F5key).
- From the Aspire dashboard's
Resourcestab, click on the first link under theEndpointscolumn for thewebfrontendrow. - Click on
Chat Playgroundfrom the left nav. - Plug the settings gathered in the
Pre-requisitessection above into the page's fields and click on theGet Answerbutton. - Modify the system prompt and test with different user prompts changing the
sampling temperaturebetween 0 and 2. Higher values enable more creative answers, but beware that as you get close to 2, the results can be unpredictable and non-deterministic (LSD-ish).