Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions src/ProjectTemplates/GeneratedContent.targets
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
Specifies external packages that get referenced in generated template content.
-->
<PropertyGroup>
<TemplatePackageVersion_Aspire>9.4.0</TemplatePackageVersion_Aspire>
<TemplatePackageVersion_Aspire_Preview>9.4.0-preview.1.25378.8</TemplatePackageVersion_Aspire_Preview>
<TemplatePackageVersion_AzureAIOpenAI>2.3.0-beta.1</TemplatePackageVersion_AzureAIOpenAI>
<TemplatePackageVersion_Aspire>9.5.0</TemplatePackageVersion_Aspire>
<TemplatePackageVersion_Aspire_Preview>9.5.0-preview.1.25474.7</TemplatePackageVersion_Aspire_Preview>
<TemplatePackageVersion_AzureAIOpenAI>2.3.0-beta.2</TemplatePackageVersion_AzureAIOpenAI>
<TemplatePackageVersion_AzureAIProjects>1.0.0-beta.9</TemplatePackageVersion_AzureAIProjects>
<TemplatePackageVersion_AzureIdentity>1.14.0</TemplatePackageVersion_AzureIdentity>
<TemplatePackageVersion_AzureSearchDocuments>11.6.1</TemplatePackageVersion_AzureSearchDocuments>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "Microsoft",
"classifications": [ "Common", "AI", "Web", "Blazor", ".NET Aspire" ],
"classifications": [ "Common", "AI", "Web", "Blazor", "Aspire" ],
"identity": "Microsoft.Extensions.AI.Templates.WebChat.CSharp",
"name": "AI Chat Web App",
"description": "A project template for creating an AI chat application, which uses retrieval-augmented generation (RAG) to chat with your own data.",
Expand Down Expand Up @@ -177,7 +177,7 @@
"displayName": "Use Aspire orchestration",
"datatype": "bool",
"defaultValue": "false",
"description": "Create the project as a distributed application using .NET Aspire."
"description": "Create the project as a distributed application using Aspire."
},
"IsAspire": {
"type": "computed",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>
<UserSecretsId>b2f4f5e9-1083-472c-8c3b-f055ac67ba54</UserSecretsId>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21000",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22000"
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21000",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22000"
}
},
"http": {
Expand All @@ -21,8 +21,8 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19000",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20000"
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19000",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20000"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@

namespace Microsoft.Extensions.Hosting;

// Adds common .NET Aspire services: service discovery, resilience, health checks, and OpenTelemetry.
// Adds common Aspire services: service discovery, resilience, health checks, and OpenTelemetry.
// This project should be referenced by each service project in your solution.
// To learn more about using this project, see https://aka.ms/dotnet/aspire/service-defaults
public static class Extensions
{
private const string HealthEndpointPath = "/health";
private const string AlivenessEndpointPath = "/alive";

public static TBuilder AddServiceDefaults<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
builder.ConfigureOpenTelemetry();
Expand Down Expand Up @@ -77,7 +80,12 @@ public static TBuilder ConfigureOpenTelemetry<TBuilder>(this TBuilder builder) w
.WithTracing(tracing =>
{
tracing.AddSource(builder.Environment.ApplicationName)
.AddAspNetCoreInstrumentation()
.AddAspNetCoreInstrumentation(tracing =>
// Exclude health check requests from tracing
tracing.Filter = context =>
!context.Request.Path.StartsWithSegments(HealthEndpointPath)
&& !context.Request.Path.StartsWithSegments(AlivenessEndpointPath)
)
// Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package)
//.AddGrpcClientInstrumentation()
.AddHttpClientInstrumentation()
Expand Down Expand Up @@ -124,10 +132,10 @@ public static WebApplication MapDefaultEndpoints(this WebApplication app)
if (app.Environment.IsDevelopment())
{
// All health checks must pass for app to be considered ready to accept traffic after starting
app.MapHealthChecks("/health");
app.MapHealthChecks(HealthEndpointPath);

// Only health checks tagged with the "live" tag must pass for app to be considered alive
app.MapHealthChecks("/alive", new HealthCheckOptions
app.MapHealthChecks(AlivenessEndpointPath, new HealthCheckOptions
{
Predicate = r => r.Tags.Contains("live")
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ public async Task IngestDataAsync(IIngestionSource source)
var deletedDocuments = await source.GetDeletedDocumentsAsync(documentsForSource);
foreach (var deletedDocument in deletedDocuments)
{
logger.LogInformation("Removing ingested data for {documentId}", deletedDocument.DocumentId);
logger.LogInformation("Removing ingested data for {DocumentId}", deletedDocument.DocumentId);
await DeleteChunksForDocumentAsync(deletedDocument);
await documentsCollection.DeleteAsync(deletedDocument.Key);
}

var modifiedDocuments = await source.GetNewOrModifiedDocumentsAsync(documentsForSource);
foreach (var modifiedDocument in modifiedDocuments)
{
logger.LogInformation("Processing {documentId}", modifiedDocument.DocumentId);
logger.LogInformation("Processing {DocumentId}", modifiedDocument.DocumentId);
await DeleteChunksForDocumentAsync(modifiedDocument);

await documentsCollection.UpsertAsync(modifiedDocument);
Expand All @@ -54,7 +54,7 @@ async Task DeleteChunksForDocumentAsync(IngestedDocument document)
{
var documentId = document.DocumentId;
var chunksToDelete = await chunksCollection.GetAsync(record => record.DocumentId == documentId, int.MaxValue).ToListAsync();
if (chunksToDelete.Any())
if (chunksToDelete.Count != 0)
{
await chunksCollection.DeleteAsync(chunksToDelete.Select(r => r.Key));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,38 +84,8 @@ Note: Ollama and Docker are excellent open source products, but are not maintain
#### ---#if (IsAzureOpenAI || UseAzureAISearch)
## Using Azure Provisioning

The project is set up to automatically provision Azure resources, but local configuration is configured. For detailed instructions, see the [Local Provisioning documentation](https://learn.microsoft.com/dotnet/aspire/azure/local-provisioning#configuration).
The project is set up to automatically provision Azure resources. When running the app for the first time, you will be prompted to provide Azure configuration values. For detailed instructions, see the [Local Provisioning documentation](https://learn.microsoft.com/dotnet/aspire/azure/local-provisioning#configuration).

#### ---#if (hostIdentifier == "vs")
Configure local provisioning for this project using .NET User Secrets:

1. In Visual Studio, right-click on the ChatWithCustomData-CSharp.AppHost project in the Solution Explorer and select "Manage User Secrets".
2. This opens a `secrets.json` file where you can store your API keys without them being tracked in source control. Add the following configuration:

```json
{
"Azure": {
"SubscriptionId": "<Your subscription id>",
"AllowResourceGroupCreation": true,
"ResourceGroup": "<Valid resource group name>",
"Location": "<Valid Azure location>"
}
}
```

#### ---#else
From the command line, configure local provisioning for this project using .NET User Secrets by running the following commands:

```sh
cd ChatWithCustomData-CSharp.AppHost
dotnet user-secrets set Azure:SubscriptionId "<Your subscription id>"
dotnet user-secrets set Azure:AllowResourceGroupCreation "true"
dotnet user-secrets set Azure:ResourceGroup "<Valid resource group name>"
dotnet user-secrets set Azure:Location "<Valid Azure location>"
```
#### ---#endif

Make sure to replace placeholder values with real configuration values.
#### ---#endif
#### ---#if (UseQdrant)

Expand Down Expand Up @@ -143,9 +113,9 @@ Note: Qdrant and Docker are excellent open source products, but are not maintain

## 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.
Several 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.
See [Troubleshoot untrusted localhost certificate in Aspire](https://learn.microsoft.com/dotnet/aspire/troubleshooting/untrusted-localhost-certificate) for more information.

# Updating JavaScript dependencies

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,8 @@ This incompatibility can be addressed by upgrading to Docker Desktop 4.41.1. See

## Using Azure Provisioning

The project is set up to automatically provision Azure resources, but local configuration is configured. For detailed instructions, see the [Local Provisioning documentation](https://learn.microsoft.com/dotnet/aspire/azure/local-provisioning#configuration).
The project is set up to automatically provision Azure resources. When running the app for the first time, you will be prompted to provide Azure configuration values. For detailed instructions, see the [Local Provisioning documentation](https://learn.microsoft.com/dotnet/aspire/azure/local-provisioning#configuration).

From the command line, configure local provisioning for this project using .NET User Secrets by running the following commands:

```sh
cd aichatweb.AppHost
dotnet user-secrets set Azure:SubscriptionId "<Your subscription id>"
dotnet user-secrets set Azure:AllowResourceGroupCreation "true"
dotnet user-secrets set Azure:ResourceGroup "<Valid resource group name>"
dotnet user-secrets set Azure:Location "<Valid Azure location>"
```

Make sure to replace placeholder values with real configuration values.

# Running the application

Expand All @@ -47,9 +36,9 @@ Make sure to replace placeholder values with real configuration values.

## 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.
Several 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.
See [Troubleshoot untrusted localhost certificate in Aspire](https://learn.microsoft.com/dotnet/aspire/troubleshooting/untrusted-localhost-certificate) for more information.

# Updating JavaScript dependencies

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:9999",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:9999"
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:9999",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:9999"
}
},
"http": {
Expand All @@ -21,8 +21,8 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:9999",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:9999"
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:9999",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:9999"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<Sdk Name="Aspire.AppHost.Sdk" Version="9.4.0" />
<Sdk Name="Aspire.AppHost.Sdk" Version="9.5.0" />

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>
<UserSecretsId>secret</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.4.0" />
<PackageReference Include="Aspire.Hosting.Azure.Search" Version="9.4.0" />
<PackageReference Include="Aspire.Hosting.Azure.CognitiveServices" Version="9.4.0" />
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.5.0" />
<PackageReference Include="Aspire.Hosting.Azure.Search" Version="9.5.0" />
<PackageReference Include="Aspire.Hosting.Azure.CognitiveServices" Version="9.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@

namespace Microsoft.Extensions.Hosting;

// Adds common .NET Aspire services: service discovery, resilience, health checks, and OpenTelemetry.
// Adds common Aspire services: service discovery, resilience, health checks, and OpenTelemetry.
// This project should be referenced by each service project in your solution.
// To learn more about using this project, see https://aka.ms/dotnet/aspire/service-defaults
public static class Extensions
{
private const string HealthEndpointPath = "/health";
private const string AlivenessEndpointPath = "/alive";

public static TBuilder AddServiceDefaults<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
builder.ConfigureOpenTelemetry();
Expand Down Expand Up @@ -64,7 +67,12 @@ public static TBuilder ConfigureOpenTelemetry<TBuilder>(this TBuilder builder) w
.WithTracing(tracing =>
{
tracing.AddSource(builder.Environment.ApplicationName)
.AddAspNetCoreInstrumentation()
.AddAspNetCoreInstrumentation(tracing =>
// Exclude health check requests from tracing
tracing.Filter = context =>
!context.Request.Path.StartsWithSegments(HealthEndpointPath)
&& !context.Request.Path.StartsWithSegments(AlivenessEndpointPath)
)
// Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package)
//.AddGrpcClientInstrumentation()
.AddHttpClientInstrumentation()
Expand Down Expand Up @@ -111,10 +119,10 @@ public static WebApplication MapDefaultEndpoints(this WebApplication app)
if (app.Environment.IsDevelopment())
{
// All health checks must pass for app to be considered ready to accept traffic after starting
app.MapHealthChecks("/health");
app.MapHealthChecks(HealthEndpointPath);

// Only health checks tagged with the "live" tag must pass for app to be considered alive
app.MapHealthChecks("/alive", new HealthCheckOptions
app.MapHealthChecks(AlivenessEndpointPath, new HealthCheckOptions
{
Predicate = r => r.Tags.Contains("live")
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ public async Task IngestDataAsync(IIngestionSource source)
var deletedDocuments = await source.GetDeletedDocumentsAsync(documentsForSource);
foreach (var deletedDocument in deletedDocuments)
{
logger.LogInformation("Removing ingested data for {documentId}", deletedDocument.DocumentId);
logger.LogInformation("Removing ingested data for {DocumentId}", deletedDocument.DocumentId);
await DeleteChunksForDocumentAsync(deletedDocument);
await documentsCollection.DeleteAsync(deletedDocument.Key);
}

var modifiedDocuments = await source.GetNewOrModifiedDocumentsAsync(documentsForSource);
foreach (var modifiedDocument in modifiedDocuments)
{
logger.LogInformation("Processing {documentId}", modifiedDocument.DocumentId);
logger.LogInformation("Processing {DocumentId}", modifiedDocument.DocumentId);
await DeleteChunksForDocumentAsync(modifiedDocument);

await documentsCollection.UpsertAsync(modifiedDocument);
Expand All @@ -49,7 +49,7 @@ async Task DeleteChunksForDocumentAsync(IngestedDocument document)
{
var documentId = document.DocumentId;
var chunksToDelete = await chunksCollection.GetAsync(record => record.DocumentId == documentId, int.MaxValue).ToListAsync();
if (chunksToDelete.Any())
if (chunksToDelete.Count != 0)
{
await chunksCollection.DeleteAsync(chunksToDelete.Select(r => r.Key));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.AI.OpenAI" Version="2.3.0-beta.1" />
<PackageReference Include="Aspire.Azure.AI.OpenAI" Version="9.4.0-preview.1.25378.8" />
<PackageReference Include="Azure.AI.OpenAI" Version="2.3.0-beta.2" />
<PackageReference Include="Aspire.Azure.AI.OpenAI" Version="9.5.0-preview.1.25474.7" />
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="9.10.0" />
<PackageReference Include="Microsoft.Extensions.AI" Version="9.10.0" />
<PackageReference Include="Microsoft.SemanticKernel.Core" Version="1.61.0" />
<PackageReference Include="PdfPig" Version="0.1.10" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
<PackageReference Include="Aspire.Azure.Search.Documents" Version="9.4.0" />
<PackageReference Include="Aspire.Azure.Search.Documents" Version="9.5.0" />
<PackageReference Include="Microsoft.SemanticKernel.Connectors.AzureAISearch" Version="1.61.0-preview" />
</ItemGroup>

Expand Down
Loading
Loading