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 service
resource. 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 onDeployments
in the left nav menu. -
Click on
+ Deploy Model
. Click onDeploy Base Model
from the dropdown. -
Click on the model name. Copy the following pieces of information: a.
Endpoint subdomain
: It is usuallyopenai.azure.com
but 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
F5
key).
- From the Aspire dashboard's
Resources
tab, click on the first link under theEndpoints
column for thewebfrontend
row. - Click on
Chat Playground
from the left nav. - Plug the settings gathered in the
Pre-requisites
section above into the page's fields and click on theGet Answer
button. - Modify the system prompt and test with different user prompts changing the
sampling temperature
between 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).