Skip to content

Commit 8a26382

Browse files
Merge pull request #45163 from dotnet/main
Merge main into live
2 parents 591008b + d614b41 commit 8a26382

File tree

45 files changed

+764
-145
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+764
-145
lines changed

.github/policies/disallow-edits.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,14 @@ configuration:
7070
action: Created
7171
- isActivitySender:
7272
issueAuthor: True
73-
- filesMatchPattern:
74-
matchAny: true
75-
pattern: docs/csharp/*
7673
- commentContains:
7774
pattern: '#sign-off'
7875
isRegex: False
76+
- isAssignedToUser:
77+
user: BillWagner
7978
- not:
80-
or:
81-
- isActivitySender:
82-
user: BillWagner
79+
isActivitySender:
80+
user: BillWagner
8381
then:
8482
# Add the do-not-merge label, remove the ready-to-merge label, and add a reply asking the PR author not to sign off on the PR.
8583
- addReply:

.openpublishing.redirection.core.json

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,6 +1357,94 @@
13571357
{
13581358
"source_path_from_root": "/docs/core/docker/publish-as-container.md",
13591359
"redirect_url": "/dotnet/core/containers/sdk-publish"
1360+
},
1361+
{
1362+
"source_path_from_root": "/docs/core/testing/unit-testing-platform-architecture-capabilities.md",
1363+
"redirect_url": "/dotnet/core/testing/microsoft-testing-platform-architecture-capabilities"
1364+
},
1365+
{
1366+
"source_path_from_root": "/docs/core/testing/unit-testing-platform-architecture-extensions.md",
1367+
"redirect_url": "/dotnet/core/testing/microsoft-testing-platform-architecture-extensions"
1368+
},
1369+
{
1370+
"source_path_from_root": "/docs/core/testing/unit-testing-platform-architecture-services.md",
1371+
"redirect_url": "/dotnet/core/testing/microsoft-testing-platform-architecture-services"
1372+
},
1373+
{
1374+
"source_path_from_root": "/docs/core/testing/unit-testing-platform-architecture.md",
1375+
"redirect_url": "/dotnet/core/testing/microsoft-testing-platform-architecture"
1376+
},
1377+
{
1378+
"source_path_from_root": "/docs/core/testing/unit-testing-platform-config.md",
1379+
"redirect_url": "/dotnet/core/testing/microsoft-testing-platform-config"
1380+
},
1381+
{
1382+
"source_path_from_root": "/docs/core/testing/unit-testing-platform-diagnostics.md",
1383+
"redirect_url": "/dotnet/core/testing/microsoft-testing-platform-diagnostics"
1384+
},
1385+
{
1386+
"source_path_from_root": "/docs/core/testing/unit-testing-platform-exit-codes.md",
1387+
"redirect_url": "/dotnet/core/testing/microsoft-testing-platform-exit-codes"
1388+
},
1389+
{
1390+
"source_path_from_root": "/docs/core/testing/unit-testing-platform-extensions-code-coverage.md",
1391+
"redirect_url": "/dotnet/core/testing/microsoft-testing-platform-extensions-code-coverage"
1392+
},
1393+
{
1394+
"source_path_from_root": "/docs/core/testing/unit-testing-platform-extensions-diagnostics.md",
1395+
"redirect_url": "/dotnet/core/testing/microsoft-testing-platform-extensions-diagnostics"
1396+
},
1397+
{
1398+
"source_path_from_root": "/docs/core/testing/unit-testing-platform-extensions-fakes.md",
1399+
"redirect_url": "/dotnet/core/testing/microsoft-testing-platform-extensions-fakes"
1400+
},
1401+
{
1402+
"source_path_from_root": "/docs/core/testing/unit-testing-platform-faq.md",
1403+
"redirect_url": "/dotnet/core/testing/microsoft-testing-platform-faq"
1404+
},
1405+
{
1406+
"source_path_from_root": "/docs/core/testing/unit-testing-platform-extensions-hosting.md",
1407+
"redirect_url": "/dotnet/core/testing/microsoft-testing-platform-extensions-hosting"
1408+
},
1409+
{
1410+
"source_path_from_root": "/docs/core/testing/unit-testing-platform-extensions-output.md",
1411+
"redirect_url": "/dotnet/core/testing/microsoft-testing-platform-extensions-output"
1412+
},
1413+
{
1414+
"source_path_from_root": "/docs/core/testing/unit-testing-platform-extensions-policy.md",
1415+
"redirect_url": "/dotnet/core/testing/microsoft-testing-platform-extensions-policy"
1416+
},
1417+
{
1418+
"source_path_from_root": "/docs/core/testing/unit-testing-platform-extensions-test-reports.md",
1419+
"redirect_url": "/dotnet/core/testing/microsoft-testing-platform-extensions-test-reports"
1420+
},
1421+
{
1422+
"source_path_from_root": "/docs/core/testing/unit-testing-platform-extensions-vstest-bridge.md",
1423+
"redirect_url": "/dotnet/core/testing/microsoft-testing-platform-extensions-vstest-bridge"
1424+
},
1425+
{
1426+
"source_path_from_root": "/docs/core/testing/unit-testing-platform-extensions.md",
1427+
"redirect_url": "/dotnet/core/testing/microsoft-testing-platform-extensions"
1428+
},
1429+
{
1430+
"source_path_from_root": "/docs/core/testing/unit-testing-platform-extensions-faq.md",
1431+
"redirect_url": "/dotnet/core/testing/microsoft-testing-platform-extensions-faq"
1432+
},
1433+
{
1434+
"source_path_from_root": "/docs/core/testing/unit-testing-platform-integration-dotnet-test.md",
1435+
"redirect_url": "/dotnet/core/testing/microsoft-testing-platform-integration-dotnet-test"
1436+
},
1437+
{
1438+
"source_path_from_root": "/docs/core/testing/unit-testing-platform-intro.md",
1439+
"redirect_url": "/dotnet/core/testing/microsoft-testing-platform-intro"
1440+
},
1441+
{
1442+
"source_path_from_root": "/docs/core/testing/unit-testing-platform-telemetry.md",
1443+
"redirect_url": "/dotnet/core/testing/microsoft-testing-platform-telemetry"
1444+
},
1445+
{
1446+
"source_path_from_root": "/docs/core/testing/unit-testing-platform-vs-vstest.md",
1447+
"redirect_url": "/dotnet/core/testing/microsoft-testing-platform-vs-vstest"
13601448
}
13611449
]
13621450
}
106 KB
Loading

docs/ai/media/ai-templates/app-ui.png

28 KB
Loading

docs/ai/quickstarts/ai-templates.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
title: Quickstart - Create a .NET AI app using the AI app template
3+
description: Create a .NET AI app to chat with custom data using the AI app template extensions and the Microsoft.Extensions.AI libraries
4+
ms.date: 2/21/2025
5+
ms.topic: quickstart
6+
ms.custom: devx-track-dotnet, devx-track-dotnet-ai
7+
author: alexwolfmsft
8+
ms.author: alexwolf
9+
zone_pivot_groups: meai-targets
10+
---
11+
12+
# Create a .NET AI app to chat with custom data using the AI app template extensions
13+
14+
In this quickstart, you learn how to create a .NET AI app to chat with custom data using the .NET AI app template. The template is designed to streamline the getting started experience for building AI apps with .NET by handling common setup tasks and configurations for you.
15+
16+
:::zone target="docs" pivot="github-models"
17+
18+
[!INCLUDE [ai-templates-github-models](includes/ai-templates-github-models.md)]
19+
20+
:::zone-end
21+
22+
:::zone target="docs" pivot="azure-openai"
23+
24+
[!INCLUDE [ai-templates-azure-openai](includes/ai-templates-azure-openai.md)]
25+
26+
:::zone-end
27+
28+
:::zone target="docs" pivot="openai"
29+
30+
[!INCLUDE [ai-templates-openai](includes/ai-templates-openai.md)]
31+
32+
:::zone-end
33+
34+
:::zone target="docs" pivot="ollama"
35+
36+
[!INCLUDE [ai-templates-ollama](includes/ai-templates-ollama.md)]
37+
38+
:::zone-end
39+
40+
## Run and test the app
41+
42+
1. Select the run button at the top of Visual Studio to launch the app. After a moment, you should see the following UI load in the browser:
43+
44+
:::image type="content" source="../media/ai-templates/app-ui.png" alt-text="A screenshot showing the UI of the .NET AI app template.":::
45+
46+
1. Enter a prompt into the input box such as *"What are some essential tools in the survival kit?"* to ask your AI model a question about the ingested data from the example files.
47+
48+
:::image type="content" source="../media/ai-templates/app-ui-question.png" alt-text="A screenshot showing the conversational UI of the .NET AI app template.":::
49+
50+
The app responds with an answer to the question and provides citations of where it found the data. You can click on one of the citations to be directed to the relevant section of the example files.
51+
52+
## Next steps
53+
54+
- [Generate text and conversations with .NET and Azure OpenAI Completions](/training/modules/open-ai-dotnet-text-completions/)
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
ms.date: 2/21/2025
3+
ms.topic: quickstart
4+
ms.custom: devx-track-dotnet, devx-track-dotnet-ai
5+
author: alexwolfmsft
6+
ms.author: alexwolf
7+
---
8+
9+
## Prerequisites
10+
11+
* .NET 9.0 SDK - [Install the .NET 9.0 SDK](https://dotnet.microsoft.com/download)
12+
* Visual Studio 2022 - [Install Visual Studio 2022](https://visualstudio.microsoft.com/) (optional), or
13+
* Visual Studio Code - [Install Visual Studio Code](https://code.visualstudio.com) (optional)
14+
* With the C# DevKit - [Install C# Dev Kit extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit)
15+
16+
## Install the .NET AI app template
17+
18+
The **AI Chat Web App** template is available as a template package through NuGet. Use the [`dotnet new install`](../../../core/tools/dotnet-new-install.md) command to install the package:
19+
20+
```dotnetcli
21+
dotnet new install Microsoft.Extensions.AI.Templates
22+
```
23+
24+
## Create the .NET AI app
25+
26+
After you install the AI app templates, you can use them to create starter apps through Visual Studio UI, Visual Studio Code, or the .NET CLI.
27+
28+
# [Visual Studio](#tab/visual-studio)
29+
30+
1. Inside Visual Studio, navigate to **File > New > Project**.
31+
1. On the **Create a new project** screen, search for **AI Chat Web App**. Select the matching result and then choose **Next**.
32+
1. On the **Configure your new project** screen, enter the desired name and location for your project and then choose **Next**.
33+
1. On the **Additional information** screen:
34+
- For the **Framework** option, select **.NET 9.0**.
35+
- For the **AI service provider** option, select **Azure OpenAI**.
36+
- Make sure the **Use keyless authentication for Azure services** checkbox is checked.
37+
- For the **Vector store** option, select **Local on-disc (for prototyping)**.
38+
1. Select **Create** to complete the process.
39+
40+
# [Visual Studio Code](#tab/visual-studio-code)
41+
42+
1. Open the command palette in Visual Studio Code.
43+
1. Search for *New project* and select the result called **.NET: New Project**.
44+
1. Filter the project templates list by searching for *AI*.
45+
1. Select **AI Chat Web App** and press <kbd>Enter</kbd>.
46+
47+
> [!NOTE]
48+
> The command palette experience currently only supports the default settings. To configure your AI platform and vector store during template creation, use the Visual Studio or .NET CLI workflows.
49+
50+
# [.NET CLI](#tab/dotnet-cli)
51+
52+
1. In a terminal window, navigate to an empty directory on your device.
53+
1. Create a new app with the `dotnet new` command and the following parameters:
54+
55+
```dotnetcli
56+
dotnet new aichatweb --framework "net9.0" --AIServiceProvider "azureopenai" --VectorStore "local"
57+
```
58+
59+
The .NET CLI creates a new .NET 9.0 app with the configurations you specified.
60+
61+
1. Open the new app in your editor of choice, such as Visual Studio Code.
62+
63+
```dotnetcli
64+
code .
65+
```
66+
67+
---
68+
69+
### Explore the sample app
70+
71+
[!INCLUDE [ai-templates-explore-app](ai-templates-explore-app.md)]
72+
73+
## Create and configure the Azure OpenAI resource
74+
75+
To use the .NET AI templates, you'll need to create and authenticate to an Azure OpenAI service:
76+
77+
1. [Create an Azure OpenAI Service resource](/azure/ai-services/openai/how-to/create-resource?pivots=web-portal) if you don't already have one available.
78+
79+
2. Deploy the `gpt-4o-mini` and `text-embedding-3-small` models to your Azure OpenAI Service resource. When creating those deployments, give them the same names as the models (`gpt-4o-mini` and `text-embedding-3-small`). To learn how to deploy a model, see [Create a resource](/azure/ai-services/openai/how-to/create-resource?pivots=web-portal#deploy-a-model) in the Azure OpenAI docs.
80+
81+
3. The AI template is configured to use Microsoft Entra ID for keyless authentication. Configure the Azure OpenAI resource for keyless authentication:
82+
83+
- In the Azure Portal, navigate to the overview page of your Azure OpenAI resource.
84+
- Select **Access control (IAM)** from the left navigation.
85+
- [Add a role assignment](/azure/developer/ai/keyless-connections) for the `Azure AI Developer` role to your Azure account.
86+
87+
## Configure the app
88+
89+
The **AI Chat Web App** app is almost ready to go as soon as it's created. However, you'll need to provide the endpoint for your Azure OpenAI service for the app to connect to. By default, the app template searches for this value in the project's local .NET user secrets. You can manage user secrets using either the Visual Studio UI or the .NET CLI.
90+
91+
> [!NOTE]
92+
> To avoid authentication errors, make sure you're signed in to Visual Studio or the Azure CLI with a user that's assigned the **Azure AI Developer** role on your Azure OpenAI resource.
93+
94+
# [Visual Studio](#tab/configure-visual-studio)
95+
96+
1. In Visual Studio, right-click on your project in the Solution Explorer and select "Manage User Secrets". This opens a `secrets.json` file where you can store your API keys without them being tracked in source control.
97+
98+
2. Add the following key and value:
99+
100+
```json
101+
{
102+
"AzureOpenAi:Endpoint": "<your-endpoint>"
103+
}
104+
```
105+
106+
# [.NET CLI](#tab/configure-dotnet-cli)
107+
108+
```dotnetcli
109+
dotnet user-secrets set AzureOpenAi:Endpoint <your-azure-openai-endpoint>
110+
```
111+
112+
---
113+
114+
By default, the app template assumes your AI model deployment names are the same as the underlying models. If necessary, update the deployment name parameters to match your `gpt-4o-mini` and `text-embedding-3-small` deployment names:
115+
116+
```csharp
117+
// Update these parameter values to match your Azure OpenAI model deployment names
118+
var chatClient = azureOpenAi.AsChatClient("gpt-4o-mini");
119+
var embeddingGenerator = azureOpenAi.AsEmbeddingGenerator("text-embedding-3-small");
120+
```
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
The sample app you created is a Blazor Interactive Server web app preconfigured with common AI and data services. The app handles the following concerns for you:
2+
3+
- Includes essential `Microsoft.Extensions.AI` packages and other dependencies in the `csproj` file to help you get started working with AI.
4+
- Creates various AI services and registers them for dependency injection in the `Program.cs` file:
5+
- An `IChatClient` service to chat back and forth with the generative AI model
6+
- An `IEmbeddingGenerator` service that's used to generate embeddings, which are essential for vector search functionality
7+
- A `JsonVectorStore` to act as an in-memory vector store
8+
- Registers a SQLite database context service to handle ingesting documents. The app is preconfigured to ingest whatever documents you add to the `Data` folder of the project, including the provided example files.
9+
- Provides a complete chat UI using Blazor components. The UI handles rich formatting for the AI responses and provides features such as citations for response data.

0 commit comments

Comments
 (0)