From 9e7c6ab57ab44895f9c627ce4d5a6b3016498acb Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Thu, 21 Aug 2025 10:22:10 -0400 Subject: [PATCH 1/8] Add instructions for configuring .NET Aspire --- .../includes/ai-templates-github-models.md | 55 ++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/docs/ai/quickstarts/includes/ai-templates-github-models.md b/docs/ai/quickstarts/includes/ai-templates-github-models.md index a2a207a89f4e8..61b229fc565b7 100644 --- a/docs/ai/quickstarts/includes/ai-templates-github-models.md +++ b/docs/ai/quickstarts/includes/ai-templates-github-models.md @@ -88,7 +88,57 @@ To authenticate to GitHub models from your code, you'll need to create a GitHub ## Configure the app -The **AI Chat Web App** app is almost ready to go as soon as it's created. However, you'll need to configure the app to use the personal access token you setup for GitHub Modelsfor. 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. +The **AI Chat Web App** app is almost ready to go as soon as it's created. However, you'll need to configure the app to use the personal access token you setup for GitHub Models. 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. + +## [Visual Studio](#tab/configure-visual-studio) + +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. + +2. Add the following key and value: + + ```json + { + "GitHubModels:Token": "" + } + ``` + +## [.NET CLI](#tab/configure-dotnet-cli) + +1. Open a terminal window set to the root of your project. +1. Running the `dotnet user-secrets set` command to set the user secret: + +```dotnetcli +dotnet user-secrets set GitHubModels:Token +``` + +--- + +### .NET Aspire configuration + +To use the AIChatWeb template with .NET Aspire orchestration, add the following configurations: + +# [Visual Studio](#tab/configure-visual-studio-aspire) + +1. In Visual Studio, right-click on your `*.AppHost` 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. + +2. Add the following key and value: + + ```json + { + "ConnectionStrings:openai": "Endpoint=https://models.inference.ai.azure.com;Key=YOUR-API-KEY" + } + ``` + +# [.NET CLI](#tab/configure-dotnet-cli-aspire) + +1. Open a terminal window set to the root of your `*.AppHost` project. +1. Running the `dotnet user-secrets set` command to set the user secret: + +```dotnetcli +dotnet user-secrets set ConnectionStrings:openai "Endpoint=https://models.inference.ai.azure.com;Key=" +``` + +--- # [Visual Studio](#tab/configure-visual-studio) @@ -104,6 +154,9 @@ The **AI Chat Web App** app is almost ready to go as soon as it's created. Howev # [.NET CLI](#tab/configure-dotnet-cli) +1. Open a terminal window set to the root of your project. +1. Running the `dotnet user-secrets set` command to set the user secret: + ```dotnetcli dotnet user-secrets set GitHubModels:Token ``` From 85315e4bf7491933b376d1939f1347d463807a9a Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Thu, 21 Aug 2025 10:32:46 -0400 Subject: [PATCH 2/8] fixes --- .../includes/ai-templates-github-models.md | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/docs/ai/quickstarts/includes/ai-templates-github-models.md b/docs/ai/quickstarts/includes/ai-templates-github-models.md index 66a07b446bcc3..0e5d964615674 100644 --- a/docs/ai/quickstarts/includes/ai-templates-github-models.md +++ b/docs/ai/quickstarts/includes/ai-templates-github-models.md @@ -8,10 +8,10 @@ ms.author: alexwolf ## Prerequisites -* .NET 9.0 SDK - [Install the .NET 9.0 SDK](https://dotnet.microsoft.com/download) -* Visual Studio 2022 - [Install Visual Studio 2022](https://visualstudio.microsoft.com/) (optional), or -* Visual Studio Code - [Install Visual Studio Code](https://code.visualstudio.com) (optional) - * With the C# DevKit - [Install C# Dev Kit extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit) +* [.NET 9.0 SDK](https://dotnet.microsoft.com/download) +* One of the following IDEs (optional): + * [Visual Studio 2022](https://visualstudio.microsoft.com/) + * [Visual Studio Code](https://code.visualstudio.com) with [C# Dev Kit](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit) ## Install the .NET AI app template @@ -79,16 +79,20 @@ The sample app you created is a Blazor Interactive Server web app preconfigured ## Configure access to GitHub Models -To authenticate to GitHub models from your code, you'll need to create a GitHub personal access token: +To authenticate to GitHub models from your code, you'll need to [create a GitHub personal access token](https://docs.github.com/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token): -1. Navigate to the **Personal access tokens** page of your GitHub account settings. +1. Navigate to the **Personal access tokens** page of your GitHub account settings under **Developer Settings**. 1. Select **Generate new token**. -1. Enter a **Token name** and then select **Generate token** at the bottom of the page. +1. Enter a name for the token, and under **Permissions**, set **Models** to **Access: Read-only**. +1. Select **Generate token** at the bottom of the page. 1. Copy the token for use in the steps ahead. ## Configure the app -The **AI Chat Web App** app is almost ready to go as soon as it's created. However, you'll need to configure the app to use the personal access token you setup for GitHub Models. 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. +The **AI Chat Web App** app is almost ready to go as soon as it's created. However, you need to configure the app to use the personal access token you set up for GitHub Models. 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. + +> [!NOTE] +> If you enabled .NET Aspire for your app, skip to the [.NET Aspire configuration](#dotnet-aspire-configuration) section. ## [Visual Studio](#tab/configure-visual-studio) @@ -104,9 +108,6 @@ The **AI Chat Web App** app is almost ready to go as soon as it's created. Howev ## [.NET CLI](#tab/configure-dotnet-cli) -1. Open a terminal window set to the root of your project. -1. Running the `dotnet user-secrets set` command to set the user secret: - ```dotnetcli dotnet user-secrets set GitHubModels:Token ``` @@ -139,3 +140,10 @@ dotnet user-secrets set ConnectionStrings:openai "Endpoint=https://models.infere ``` --- + +By default, the app template uses the `gpt-4o-mini` and `text-embedding-3-small` models. To try other models, update the name parameters in `Program.cs`: + + ```csharp + var chatClient = ghModelsClient.AsChatClient("gpt-4o-mini"); + var embeddingGenerator = ghModelsClient.AsEmbeddingGenerator("text-embedding-3-small"); + ``` \ No newline at end of file From f081a52e44cfe46208b0cb27bd82c165881df121 Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Thu, 21 Aug 2025 10:35:34 -0400 Subject: [PATCH 3/8] fix lint --- docs/ai/quickstarts/includes/ai-templates-github-models.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ai/quickstarts/includes/ai-templates-github-models.md b/docs/ai/quickstarts/includes/ai-templates-github-models.md index 0e5d964615674..2770f085ceeca 100644 --- a/docs/ai/quickstarts/includes/ai-templates-github-models.md +++ b/docs/ai/quickstarts/includes/ai-templates-github-models.md @@ -146,4 +146,4 @@ By default, the app template uses the `gpt-4o-mini` and `text-embedding-3-small` ```csharp var chatClient = ghModelsClient.AsChatClient("gpt-4o-mini"); var embeddingGenerator = ghModelsClient.AsEmbeddingGenerator("text-embedding-3-small"); - ``` \ No newline at end of file + ``` From 10dc65d6348c64f875fab053b249fc3c0fd8ce69 Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Thu, 21 Aug 2025 10:39:40 -0400 Subject: [PATCH 4/8] fix link --- docs/ai/quickstarts/includes/ai-templates-github-models.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ai/quickstarts/includes/ai-templates-github-models.md b/docs/ai/quickstarts/includes/ai-templates-github-models.md index 2770f085ceeca..d24e5a0541992 100644 --- a/docs/ai/quickstarts/includes/ai-templates-github-models.md +++ b/docs/ai/quickstarts/includes/ai-templates-github-models.md @@ -92,7 +92,7 @@ To authenticate to GitHub models from your code, you'll need to [create a GitHub The **AI Chat Web App** app is almost ready to go as soon as it's created. However, you need to configure the app to use the personal access token you set up for GitHub Models. 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. > [!NOTE] -> If you enabled .NET Aspire for your app, skip to the [.NET Aspire configuration](#dotnet-aspire-configuration) section. +> If you enabled .NET Aspire for your app, skip to the [.NET Aspire configuration](#net-aspire-configuration) section. ## [Visual Studio](#tab/configure-visual-studio) From 9991b4d7e4570a41e1ec8f91faa1da3364805965 Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Thu, 21 Aug 2025 10:44:25 -0400 Subject: [PATCH 5/8] fix formatting --- .../includes/ai-templates-github-models.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/ai/quickstarts/includes/ai-templates-github-models.md b/docs/ai/quickstarts/includes/ai-templates-github-models.md index d24e5a0541992..d128f195a3cdb 100644 --- a/docs/ai/quickstarts/includes/ai-templates-github-models.md +++ b/docs/ai/quickstarts/includes/ai-templates-github-models.md @@ -118,7 +118,7 @@ dotnet user-secrets set GitHubModels:Token To use the AIChatWeb template with .NET Aspire orchestration, add the following configurations: -# [Visual Studio](#tab/configure-visual-studio-aspire) +## [Visual Studio](#tab/configure-visual-studio-aspire) 1. In Visual Studio, right-click on your `*.AppHost` 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. @@ -130,14 +130,15 @@ To use the AIChatWeb template with .NET Aspire orchestration, add the following } ``` -# [.NET CLI](#tab/configure-dotnet-cli-aspire) +## [.NET CLI](#tab/configure-dotnet-cli-aspire) 1. Open a terminal window set to the root of your `*.AppHost` project. + 1. Running the `dotnet user-secrets set` command to set the user secret: -```dotnetcli -dotnet user-secrets set ConnectionStrings:openai "Endpoint=https://models.inference.ai.azure.com;Key=" -``` + ```dotnetcli + dotnet user-secrets set ConnectionStrings:openai "Endpoint=https://models.inference.ai.azure.com;Key=" + ``` --- From 15126a0444437850f64715a985de6f1a6b671d18 Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Thu, 21 Aug 2025 10:56:33 -0400 Subject: [PATCH 6/8] fixes --- .../includes/ai-templates-github-models.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/ai/quickstarts/includes/ai-templates-github-models.md b/docs/ai/quickstarts/includes/ai-templates-github-models.md index d128f195a3cdb..e075e31eeeea9 100644 --- a/docs/ai/quickstarts/includes/ai-templates-github-models.md +++ b/docs/ai/quickstarts/includes/ai-templates-github-models.md @@ -102,14 +102,18 @@ The **AI Chat Web App** app is almost ready to go as soon as it's created. Howev ```json { - "GitHubModels:Token": "" + "GitHubModels:Token": "" } ``` ## [.NET CLI](#tab/configure-dotnet-cli) +1. Open a terminal window set to the root of your project. + +1. Run the `dotnet user-secrets set` command to set the user secret: + ```dotnetcli -dotnet user-secrets set GitHubModels:Token +dotnet user-secrets set GitHubModels:Token ``` --- @@ -120,13 +124,13 @@ To use the AIChatWeb template with .NET Aspire orchestration, add the following ## [Visual Studio](#tab/configure-visual-studio-aspire) -1. In Visual Studio, right-click on your `*.AppHost` 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. +1. Right-click on your `*.AppHost` 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. 2. Add the following key and value: ```json { - "ConnectionStrings:openai": "Endpoint=https://models.inference.ai.azure.com;Key=YOUR-API-KEY" + "ConnectionStrings:openai": "Endpoint=https://models.inference.ai.azure.com;Key=" } ``` @@ -134,10 +138,10 @@ To use the AIChatWeb template with .NET Aspire orchestration, add the following 1. Open a terminal window set to the root of your `*.AppHost` project. -1. Running the `dotnet user-secrets set` command to set the user secret: +1. Run the `dotnet user-secrets set` command to set the user secret: ```dotnetcli - dotnet user-secrets set ConnectionStrings:openai "Endpoint=https://models.inference.ai.azure.com;Key=" + dotnet user-secrets set ConnectionStrings:openai "Endpoint=https://models.inference.ai.azure.com;Key=" ``` --- From d1cfd4c3265e96d2eb655eb407220ccacc77d431 Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Thu, 21 Aug 2025 11:05:30 -0400 Subject: [PATCH 7/8] fix issues --- .../includes/ai-templates-github-models.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/ai/quickstarts/includes/ai-templates-github-models.md b/docs/ai/quickstarts/includes/ai-templates-github-models.md index e075e31eeeea9..c4dd11102e93f 100644 --- a/docs/ai/quickstarts/includes/ai-templates-github-models.md +++ b/docs/ai/quickstarts/includes/ai-templates-github-models.md @@ -89,14 +89,14 @@ To authenticate to GitHub models from your code, you'll need to [create a GitHub ## Configure the app -The **AI Chat Web App** app is almost ready to go as soon as it's created. However, you need to configure the app to use the personal access token you set up for GitHub Models. 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. +The **AI Chat Web App** is almost ready to go as soon as it's created. However, you need to configure the app to use the personal access token you set up for GitHub Models. 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. > [!NOTE] > If you enabled .NET Aspire for your app, skip to the [.NET Aspire configuration](#net-aspire-configuration) section. ## [Visual Studio](#tab/configure-visual-studio) -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. +1. 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. 2. Add the following key and value: @@ -112,15 +112,15 @@ The **AI Chat Web App** app is almost ready to go as soon as it's created. Howev 1. Run the `dotnet user-secrets set` command to set the user secret: -```dotnetcli -dotnet user-secrets set GitHubModels:Token -``` + ```dotnetcli + dotnet user-secrets set GitHubModels:Token + ``` --- ### .NET Aspire configuration -To use the AIChatWeb template with .NET Aspire orchestration, add the following configurations: +To use the **AI Chat Web App** template with .NET Aspire orchestration, add the following configurations: ## [Visual Studio](#tab/configure-visual-studio-aspire) From f2fed681ecbbca220039455fd74820e5bc0cb72e Mon Sep 17 00:00:00 2001 From: Alex Wolf Date: Fri, 22 Aug 2025 08:48:51 -0400 Subject: [PATCH 8/8] fix header --- docs/ai/quickstarts/includes/ai-templates-github-models.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/ai/quickstarts/includes/ai-templates-github-models.md b/docs/ai/quickstarts/includes/ai-templates-github-models.md index c4dd11102e93f..2baf9cf885d35 100644 --- a/docs/ai/quickstarts/includes/ai-templates-github-models.md +++ b/docs/ai/quickstarts/includes/ai-templates-github-models.md @@ -122,7 +122,7 @@ The **AI Chat Web App** is almost ready to go as soon as it's created. However, To use the **AI Chat Web App** template with .NET Aspire orchestration, add the following configurations: -## [Visual Studio](#tab/configure-visual-studio-aspire) +#### [Visual Studio](#tab/configure-visual-studio-aspire) 1. Right-click on your `*.AppHost` 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. @@ -134,7 +134,7 @@ To use the **AI Chat Web App** template with .NET Aspire orchestration, add the } ``` -## [.NET CLI](#tab/configure-dotnet-cli-aspire) +#### [.NET CLI](#tab/configure-dotnet-cli-aspire) 1. Open a terminal window set to the root of your `*.AppHost` project.