Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f1bf561
Update chat template dependencies
MackinnonBuck Apr 10, 2025
0cf84cd
Update test snapshots
MackinnonBuck Apr 10, 2025
2760c6a
Update Aspire version
MackinnonBuck Apr 10, 2025
c237e98
Revert Aspire + update CommunityToolkit.Aspire
MackinnonBuck Apr 11, 2025
7e8e3c8
Merge branch 'main' into mbuck/template-version-update
MackinnonBuck Apr 11, 2025
4c0cbec
Open README in VS after project creation
MackinnonBuck Apr 11, 2025
61fc8fe
Add Known Issue to Aspire README for Qdrant
jeffhandley Apr 14, 2025
814292e
Update survey template URL
jeffhandley Apr 14, 2025
ce20e62
Set the Project Template package version to -preview.2
jeffhandley Apr 14, 2025
5dc64a1
Update template baseline
jeffhandley Apr 14, 2025
6e54257
Update template pinned versions
jozkee Apr 15, 2025
fa2f5d7
Do not append template args to snapshot names
jeffhandley Apr 15, 2025
246d017
Fix vector store index in the README. Add an AzureAISearch template t…
jeffhandley Apr 15, 2025
146d47a
Add a note to the Aspire README for trusting the development certificate
jeffhandley Apr 15, 2025
095b5bd
Use AddOpenAIClient for OpenAI and AddAzureOpenAIClient for Azure OpenAI
jeffhandley Apr 15, 2025
e8fb578
Remove duplicated using System.ClientModel
jozkee Apr 15, 2025
28e9922
Update Aspire README to specify the exception thrown for the known issue
jeffhandley Apr 16, 2025
f17d83b
Augment the Aspire README for more Docker notes for Ollama and Qdrant
jeffhandley Apr 16, 2025
65db551
Fix Microsoft.Extensions.Http.Resilience warnings with separate pinne…
jeffhandley Apr 16, 2025
c301be0
Merge branch 'mbuck/template-version-update' of https://github.com/do…
jeffhandley Apr 16, 2025
abf2b41
Merge branch 'main' into mbuck/template-version-update
jeffhandley Apr 16, 2025
5e8ae22
Update test baseline for: Rename EmbeddingGeneratorExtensions.Generat…
jeffhandley Apr 16, 2025
bb0e614
Add --managed-identity to the template developer README
jeffhandley Apr 16, 2025
790b784
Merge branch 'main' into mbuck/template-version-update
jeffhandley Apr 16, 2025
4b6e9d7
Apply the Ollama timeout recommendation in the template code
jeffhandley Apr 16, 2025
73ca9d7
Call http.RemoveAllResilienceHandlers before adding the handler
jeffhandley Apr 16, 2025
333faa0
Update template test baseline
jeffhandley Apr 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,19 @@
<!-- AI templates -->
<AspireVersion>9.1.0</AspireVersion>
<AspireAzureAIOpenAIVersion>9.1.0-preview.1.25121.10</AspireAzureAIOpenAIVersion>
<AzureAIProjectsVersion>1.0.0-beta.3</AzureAIProjectsVersion>
<AzureAIProjectsVersion>1.0.0-beta.6</AzureAIProjectsVersion>
<AzureAIOpenAIVersion>2.2.0-beta.4</AzureAIOpenAIVersion>
<AzureIdentityVersion>1.13.2</AzureIdentityVersion>
<AzureSearchDocumentsVersion>11.6.0</AzureSearchDocumentsVersion>
<CommunityToolkitAspireHostingOllamaVersion>9.2.2-beta.236</CommunityToolkitAspireHostingOllamaVersion>
<CommunityToolkitAspireHostingSqliteVersion>9.2.2-beta.236</CommunityToolkitAspireHostingSqliteVersion>
<CommunityToolkitAspireMicrosoftEntityFrameworkCoreSqliteVersion>9.2.2-beta.236</CommunityToolkitAspireMicrosoftEntityFrameworkCoreSqliteVersion>
<CommunityToolkitAspireOllamaSharpVersion>9.2.2-beta.236</CommunityToolkitAspireOllamaSharpVersion>
<MicrosoftExtensionsServiceDiscoveryVersion>9.1.0</MicrosoftExtensionsServiceDiscoveryVersion>
<MicrosoftSemanticKernelConnectorsAzureAISearchVersion>1.41.0-preview</MicrosoftSemanticKernelConnectorsAzureAISearchVersion>
<MicrosoftSemanticKernelConnectorsQdrantVersion>1.41.0-preview</MicrosoftSemanticKernelConnectorsQdrantVersion>
<MicrosoftSemanticKernelCoreVersion>1.41.0</MicrosoftSemanticKernelCoreVersion>
<OllamaSharpVersion>5.1.9</OllamaSharpVersion>
<CommunityToolkitAspireHostingOllamaVersion>9.3.1-beta.260</CommunityToolkitAspireHostingOllamaVersion>
<CommunityToolkitAspireHostingSqliteVersion>9.3.1-beta.260</CommunityToolkitAspireHostingSqliteVersion>
<CommunityToolkitAspireMicrosoftEntityFrameworkCoreSqliteVersion>9.3.1-beta.260</CommunityToolkitAspireMicrosoftEntityFrameworkCoreSqliteVersion>
<CommunityToolkitAspireOllamaSharpVersion>9.3.1-beta.260</CommunityToolkitAspireOllamaSharpVersion>
<MicrosoftExtensionsServiceDiscoveryVersion>9.2.0</MicrosoftExtensionsServiceDiscoveryVersion>
<MicrosoftSemanticKernelConnectorsAzureAISearchVersion>1.45.0-preview</MicrosoftSemanticKernelConnectorsAzureAISearchVersion>
<MicrosoftSemanticKernelConnectorsQdrantVersion>1.45.0-preview</MicrosoftSemanticKernelConnectorsQdrantVersion>
<MicrosoftSemanticKernelCoreVersion>1.45.0</MicrosoftSemanticKernelCoreVersion>
<OllamaSharpVersion>5.1.12</OllamaSharpVersion>
<OpenTelemetryVersion>1.9.0</OpenTelemetryVersion>
<PdfPigVersion>0.1.9</PdfPigVersion>
<SystemLinqAsyncVersion>6.0.1</SystemLinqAsyncVersion>
Expand Down
18 changes: 10 additions & 8 deletions src/ProjectTemplates/GeneratedContent.targets
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,24 @@
<Target Name="ComputeGeneratedContentProperties">
<PropertyGroup>
<!-- Define optional pinned versions of certain dependencies. -->
<TemplatePinnedRepoPackagesVersion>9.3.0-preview.1.25161.3</TemplatePinnedRepoPackagesVersion>
<TemplatePinnedMicrosoftEntityFrameworkCoreSqliteVersion>9.0.3</TemplatePinnedMicrosoftEntityFrameworkCoreSqliteVersion>
<TemplatePinnedRepoPackagesVersion>9.4.0</TemplatePinnedRepoPackagesVersion>
<TemplatePinnedRepoAIPackagesVersion>9.4.0-preview.1.25207.5</TemplatePinnedRepoAIPackagesVersion>
<TemplatePinnedMicrosoftEntityFrameworkCoreSqliteVersion>9.0.4</TemplatePinnedMicrosoftEntityFrameworkCoreSqliteVersion>

<!-- By default, don't use pinned dependency versions. -->
<TemplateUsePinnedRepoPackagesVersion Condition="'$(TemplateUsePinnedRepoPackagesVersion)' == ''">false</TemplateUsePinnedRepoPackagesVersion>
<TemplateUsePinnedMicrosoftEntityFrameworkCoreSqliteVersion Condition="'$(TemplateUsePinnedMicrosoftEntityFrameworkCoreSqliteVersion)' == ''">false</TemplateUsePinnedMicrosoftEntityFrameworkCoreSqliteVersion>
<TemplateUsePinnedPackageVersions Condition="'$(TemplateUsePinnedPackageVersions)' == ''">false</TemplateUsePinnedPackageVersions>

<!-- Apply pinned dependency versions if enabled. -->
<TemplateRepoPackagesVersion Condition="'$(TemplateUsePinnedRepoPackagesVersion)' == 'true'">$(TemplatePinnedRepoPackagesVersion)</TemplateRepoPackagesVersion>
<TemplateMicrosoftEntityFrameworkCoreSqliteVersion Condition="'$(TemplateUsePinnedMicrosoftEntityFrameworkCoreSqliteVersion)' == 'true'">$(TemplatePinnedMicrosoftEntityFrameworkCoreSqliteVersion)</TemplateMicrosoftEntityFrameworkCoreSqliteVersion>
<TemplateRepoPackagesVersion Condition="'$(TemplateUsePinnedPackageVersions)' == 'true'">$(TemplatePinnedRepoPackagesVersion)</TemplateRepoPackagesVersion>
<TemplateRepoAIPackagesVersion Condition="'$(TemplateUsePinnedPackageVersions)' == 'true'">$(TemplatePinnedRepoAIPackagesVersion)</TemplateRepoAIPackagesVersion>
<TemplateMicrosoftEntityFrameworkCoreSqliteVersion Condition="'$(TemplateUsePinnedPackageVersions)' == 'true'">$(TemplatePinnedMicrosoftEntityFrameworkCoreSqliteVersion)</TemplateMicrosoftEntityFrameworkCoreSqliteVersion>

<!-- Fall back on default dependency versions if pinned versions were not applied. -->
<TemplateRepoPackagesVersion Condition="'$(TemplateRepoPackagesVersion)' == ''">$(Version)</TemplateRepoPackagesVersion>
<TemplateRepoAIPackagesVersion Condition="'$(TemplateRepoAIPackagesVersion)' == ''">$(Version)</TemplateRepoAIPackagesVersion>
<TemplateMicrosoftEntityFrameworkCoreSqliteVersion Condition="'$(TemplateMicrosoftEntityFrameworkCoreSqliteVersion)' == ''">$(MicrosoftEntityFrameworkCoreSqliteVersion)</TemplateMicrosoftEntityFrameworkCoreSqliteVersion>

<_TemplateUsingJustBuiltPackages Condition="'$(TemplateRepoPackagesVersion)' == '$(Version)'">true</_TemplateUsingJustBuiltPackages>
<_TemplateUsingJustBuiltPackages Condition="'$(TemplateRepoAIPackagesVersion)' == '$(Version)'">true</_TemplateUsingJustBuiltPackages>

<!-- Specify package version variables used in template content. -->
<GeneratedContentProperties>
Expand All @@ -51,7 +53,7 @@
CommunityToolkitAspireMicrosoftEntityFrameworkCoreSqliteVersion=$(CommunityToolkitAspireMicrosoftEntityFrameworkCoreSqliteVersion);
CommunityToolkitAspireOllamaSharpVersion=$(CommunityToolkitAspireOllamaSharpVersion);
MicrosoftEntityFrameworkCoreSqliteVersion=$(TemplateMicrosoftEntityFrameworkCoreSqliteVersion);
MicrosoftExtensionsAIVersion=$(TemplateRepoPackagesVersion);
MicrosoftExtensionsAIVersion=$(TemplateRepoAIPackagesVersion);
MicrosoftExtensionsHttpResilienceVersion=$(TemplateRepoPackagesVersion);
MicrosoftExtensionsServiceDiscoveryVersion=$(MicrosoftExtensionsServiceDiscoveryVersion);
MicrosoftSemanticKernelConnectorsAzureAISearchVersion=$(MicrosoftSemanticKernelConnectorsAzureAISearchVersion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<PackageTags>dotnet-new;templates;ai</PackageTags>

<Stage>preview</Stage>
<PreReleaseVersionIteration>2</PreReleaseVersionIteration>
<Workstream>AI</Workstream>
<MinCodeCoverage>0</MinCodeCoverage>
<MinMutationScore>0</MinMutationScore>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
"A7D19173-F0AD-4A8D-B8EA-E12DE203E409"
],
"primaryOutputs": [
{
"path": "./README.md"
},
{
"condition": "(!IsAspire)",
"path": "./ChatWithCustomData-CSharp.csproj"
Expand All @@ -41,9 +44,6 @@
{
"condition": "(IsAspire)",
"path": "./ChatWithCustomData-CSharp.Web/ChatWithCustomData-CSharp.Web.csproj"
},
{
"path": "./README.md"
}
],
"sources": [{
Expand Down Expand Up @@ -563,7 +563,7 @@
"manualInstructions": [ ],
"actionId": "84C0DA21-51C8-4541-9940-6CA19AF04EE6",
"args": {
"files": "1"
"files": "0"
},
"continueOnError": true
}],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,25 @@ public static TBuilder AddServiceDefaults<TBuilder>(this TBuilder builder) where

builder.Services.ConfigureHttpClientDefaults(http =>
{
#pragma warning disable EXTEXP0001 // RemoveAllResilienceHandlers is experimental
http.RemoveAllResilienceHandlers();
#pragma warning restore EXTEXP0001

#if (IsOllama)
// Turn on resilience by default
http.AddStandardResilienceHandler(config =>
{
// Extend the HTTP Client timeout for Ollama
config.AttemptTimeout.Timeout = TimeSpan.FromMinutes(3);

// Must be at least double the AttemptTimeout to pass options validation
config.CircuitBreaker.SamplingDuration = TimeSpan.FromMinutes(10);
config.TotalRequestTimeout.Timeout = TimeSpan.FromMinutes(10);
});
#else
// Turn on resilience by default
http.AddStandardResilienceHandler();
#endif

// Turn on service discovery by default
http.AddServiceDiscovery();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<div>
How well is this template working for you? Please take a
<a target="_blank" href="https://aka.ms/dotnet-chat-template-survey">brief survey</a>
<a target="_blank" href="https://aka.ms/dotnet-chat-templatePreview2-survey">brief survey</a>
and tell us what you think.
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@
builder.AddOllamaApiClient("embeddings")
.AddEmbeddingGenerator();
#elif (IsAzureAiFoundry)
#else // IsAzureOpenAI || IsOpenAI || IsGHModels
#else // (IsOpenAI || IsAzureOpenAI || IsGHModels)
#if (IsOpenAI)
var openai = builder.AddOpenAIClient("openai");
#else
var openai = builder.AddAzureOpenAIClient("openai");
#endif
openai.AddChatClient("gpt-4o-mini")
.UseFunctionInvocation()
.UseOpenTelemetry(configure: c =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
using Azure;
#if (UseManagedIdentity)
using Azure.Identity;
#else
using System.ClientModel;
#endif
#endif
#if (IsOllama)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# AI Chat with Custom Data

This project is an AI chat application that demonstrates how to chat with custom data using an AI language model. Please note that this template is currently in an early preview stage. If you have feedback, please take a [brief survey](https://aka.ms/dotnet-chat-template-survey).
This project is an AI chat application that demonstrates how to chat with custom data using an AI language model. Please note that this template is currently in an early preview stage. If you have feedback, please take a [brief survey](https://aka.ms/dotnet-chat-templatePreview2-survey).

>[!NOTE]
> Before running this project you need to configure the API keys or endpoints for the providers you have chosen. See below for details specific to your choices.
Expand Down Expand Up @@ -158,7 +158,7 @@ To use Azure AI Search, you will need an Azure account and an Azure AI Search re
### 1. Create an Azure AI Search Resource
Follow the instructions in the [Azure portal](https://portal.azure.com/) to create an Azure AI Search resource. Note that there is a free tier for the service but it is not currently the default setting on the portal.
Note that if you previously used the same Azure AI Search resource with different model using this project name, you may need to delete your `$$VectorStoreIndexName$$` index using the [Azure portal](https://portal.azure.com/) first before continuing; otherwise, data ingestion may fail due to a vector dimension mismatch.
Note that if you previously used the same Azure AI Search resource with different model using this project name, you may need to delete your `data-ChatWithCustomData-CSharp.Web-ingestion` index using the [Azure portal](https://portal.azure.com/) first before continuing; otherwise, data ingestion may fail due to a vector dimension mismatch.
#### ---#if (UseManagedIdentity)
### 2. Configure Azure AI Search for Keyless Authentication
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# AI Chat with Custom Data

This project is an AI chat application that demonstrates how to chat with custom data using an AI language model. Please note that this template is currently in an early preview stage. If you have feedback, please take a [brief survey](https://aka.ms/dotnet-chat-template-survey).
This project is an AI chat application that demonstrates how to chat with custom data using an AI language model. Please note that this template is currently in an early preview stage. If you have feedback, please take a [brief survey](https://aka.ms/dotnet-chat-templatePreview2-survey).

>[!NOTE]
> Before running this project you need to configure the API keys or endpoints for the providers you have chosen. See below for details specific to your choices.
Expand All @@ -9,6 +9,17 @@ This project is an AI chat application that demonstrates how to chat with custom
### Prerequisites
To use Azure OpenAI or Azure AI Search, you need an Azure account. If you don't already have one, [create an Azure account](https://azure.microsoft.com/free/).

#### ---#endif
#### ---#if (UseQdrant)
### Known Issues

#### Errors After Updating to Aspire Version 9.2.0
This project is not currently compatible with Aspire 9.2.0, and all Aspire package versions are set to 9.1.0. Updating [Aspire.Qdrant.Client](https://www.nuget.org/packages/Aspire.Qdrant.Client) to version 9.2.0 causes an incompatibility with [Microsoft.SemanticKernel.Connectors.Qdrant](https://www.nuget.org/packages/Microsoft.SemanticKernel.Connectors.Qdrant) where different versions of [Qdrant.Client](https://www.nuget.org/packages/Qdrant.Client) are required. Attempting to run the project with `Aspire.Qdrant.Client` version 9.2.0 will result in the following exception:

> System.MissingMethodException: Method not found: 'Qdrant.Client.Grpc.Vectors Qdrant.Client.Grpc.ScoredPoint.get_Vectors()'

Once a version of `Microsoft.SemanticKernel.Connectors.Qdrant` is published with a dependency on `Qdrant.Client` version `>= 1.13.0`, the Aspire packages can also be updated to version 9.2.0.

#### ---#endif
# Configure the AI Model Provider

Expand Down Expand Up @@ -66,28 +77,12 @@ dotnet user-secrets set ConnectionStrings:openai "Key=YOUR-API-KEY"
#### ---#endif
#### ---#if (IsOllama)
## Setting up a local environment for Ollama
This project is configured to run Ollama in a Docker container.

To get started, download, install, and run Docker Desktop from the [official website](https://www.docker.com/). Follow the installation instructions specific to your operating system.

The response time from Ollama depends on your GPU. If you find that default resilience timeout of 10 seconds used by .NET Aspire is timing out for the HTTP call from the web app to the Ollama service, you can update the web app's `Program.cs` to extend the timeout by adding the following below the line which reads `builder.AddServiceDefaults();`:
```csharp
// Extend the HTTP Client timeout for Ollama
builder.Services.ConfigureHttpClientDefaults(http =>
{
#pragma warning disable EXTEXP0001
http.RemoveAllResilienceHandlers();
http.AddStandardResilienceHandler(config =>
{
config.AttemptTimeout.Timeout = TimeSpan.FromMinutes(3);
config.CircuitBreaker.SamplingDuration = TimeSpan.FromMinutes(10); // must be at least double the AttemptTimeout to pass options validation
config.TotalRequestTimeout.Timeout = TimeSpan.FromMinutes(10);
});
#pragma warning restore EXTEXP0001
});
```
This project is configured to run Ollama in a Docker container. Docker Desktop must be installed and running for the project to run successfully. An Ollama container will automatically start when running the application.

Download, install, and run Docker Desktop from the [official website](https://www.docker.com/). Follow the installation instructions specific to your operating system.

Note: Ollama and Docker are excellent open source products, but are not maintained by Microsoft.

#### ---#endif
#### ---#if (IsAzureOpenAI)
## Using Azure OpenAI
Expand Down Expand Up @@ -133,7 +128,7 @@ To use Azure AI Search, you will need an Azure account and an Azure AI Search re
### 1. Create an Azure AI Search Resource
Follow the instructions in the [Azure portal](https://portal.azure.com/) to create an Azure AI Search resource. Note that there is a free tier for the service but it is not currently the default setting on the portal.

Note that if you previously used the same Azure AI Search resource with different model using this project name, you may need to delete your `$$VectorStoreIndexName$$` index using the [Azure portal](https://portal.azure.com/) first before continuing; otherwise, data ingestion may fail due to a vector dimension mismatch.
Note that if you previously used the same Azure AI Search resource with different model using this project name, you may need to delete your `data-ChatWithCustomData-CSharp.Web-ingestion` index using the [Azure portal](https://portal.azure.com/) first before continuing; otherwise, data ingestion may fail due to a vector dimension mismatch.

### 3. Configure API Key and Endpoint
Configure your Azure AI Search API key and endpoint for this project, using .NET User Secrets:
Expand All @@ -159,6 +154,15 @@ Note that if you previously used the same Azure AI Search resource with differen

Make sure to replace `YOUR-DEPLOYMENT-NAME` and `YOUR-API-KEY` with your actual Azure AI Search deployment name and key.
#### ---#endif
#### ---#if (UseQdrant)

## Setting up a local environment for Qdrant
This project is configured to run Qdrant in a Docker container. Docker Desktop must be installed and running for the project to run successfully. A Qdrant container will automatically start when running the application.

Download, install, and run Docker Desktop from the [official website](https://www.docker.com/). Follow the installation instructions specific to your operating system.

Note: Qdrant and Docker are excellent open source products, but are not maintained by Microsoft.
#### ---#endif

# Running the application

Expand All @@ -174,6 +178,12 @@ Make sure to replace `YOUR-DEPLOYMENT-NAME` and `YOUR-API-KEY` with your actual
3. Once installed, Open the `Program.cs` file in the ChatWithCustomData-CSharp.AppHost project.
4. Run the project by clicking the "Run" button in the Debug view.

## Trust the localhost certificate

Several .NET Aspire templates include ASP.NET Core projects that are configured to use HTTPS by default. If this is the first time you're running the project, an exception might occur when loading the Aspire dashboard. This error can be resolved by trusting the self-signed development certificate with the .NET CLI.

See [Troubleshoot untrusted localhost certificate in .NET Aspire](https://learn.microsoft.com/dotnet/aspire/troubleshooting/untrusted-localhost-certificate) for more information.

# Learn More
To learn more about development with .NET and AI, check out the following links:

Expand Down
Loading
Loading