Skip to content

Commit a9ebec9

Browse files
authored
Upgrade to .NET 8.0 GA bits - all packages (#243)
- Remove unused `Directory.Build.props` - Upgrade to .NET 8.0 GA bits and other packages - Correct Azure Search usage (APIs renamed) - Remove unused `using` - Fix formatting Closes #239
1 parent 5baf79b commit a9ebec9

File tree

9 files changed

+69
-78
lines changed

9 files changed

+69
-78
lines changed

app/Directory.Packages.props

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,43 @@
55
<ItemGroup>
66
<PackageVersion Include="Azure.AI.FormRecognizer" Version="4.1.0" />
77
<PackageVersion Include="Azure.AI.OpenAI" Version="1.0.0-beta.8" />
8-
<PackageVersion Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.2.2" />
9-
<PackageVersion Include="Azure.Identity" Version="1.10.2" />
10-
<PackageVersion Include="Azure.Search.Documents" Version="11.5.0-beta.5" />
11-
<PackageVersion Include="Azure.Storage.Blobs" Version="12.18.0" />
12-
<PackageVersion Include="Azure.Storage.Files.Shares" Version="12.16.0" />
13-
<PackageVersion Include="Azure.Storage.Queues" Version="12.16.0" />
14-
<PackageVersion Include="Blazor.LocalStorage.WebAssembly" Version="8.0.0-rc.2.23480.2" />
15-
<PackageVersion Include="Blazor.SessionStorage.WebAssembly" Version="8.0.0-rc.2.23480.2" />
16-
<PackageVersion Include="Blazor.SpeechRecognition.WebAssembly" Version="8.0.0-rc.2.23480.2" />
17-
<PackageVersion Include="Blazor.SpeechSynthesis.WebAssembly" Version="8.0.0-rc.2.23480.2" />
18-
<PackageVersion Include="bunit" Version="1.24.10" />
8+
<PackageVersion Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.3.0" />
9+
<PackageVersion Include="Azure.Identity" Version="1.10.4" />
10+
<PackageVersion Include="Azure.Search.Documents" Version="11.5.1" />
11+
<PackageVersion Include="Azure.Storage.Blobs" Version="12.19.1" />
12+
<PackageVersion Include="Azure.Storage.Files.Shares" Version="12.17.1" />
13+
<PackageVersion Include="Azure.Storage.Queues" Version="12.17.1" />
14+
<PackageVersion Include="Blazor.LocalStorage.WebAssembly" Version="8.0.0" />
15+
<PackageVersion Include="Blazor.SessionStorage.WebAssembly" Version="8.0.0" />
16+
<PackageVersion Include="Blazor.SpeechRecognition.WebAssembly" Version="8.0.0" />
17+
<PackageVersion Include="Blazor.SpeechSynthesis.WebAssembly" Version="8.0.0" />
18+
<PackageVersion Include="bunit" Version="1.25.3" />
1919
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
2020
<PackageVersion Include="Markdig" Version="0.33.0" />
2121
<PackageVersion Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0-beta3" />
22-
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0-rc.2.23480.2" />
23-
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.0-rc.2.23480.2" />
24-
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0-rc.2.23480.2" />
22+
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0" />
23+
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.0" />
24+
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0" />
2525
<PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.Storage" Version="6.2.0" />
26-
<PackageVersion Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.15.1" />
27-
<PackageVersion Include="Microsoft.Azure.Functions.Worker" Version="1.19.0" />
28-
<PackageVersion Include="Microsoft.Extensions.Azure" Version="1.7.0" />
29-
<PackageVersion Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="8.0.0-rc.2.23480.2" />
30-
<PackageVersion Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0-rc.2.23479.6" />
31-
<PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="8.0.0-rc.2.23479.6" />
32-
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.0-rc.2.23479.6" />
33-
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0-rc.2.23479.6" />
34-
<PackageVersion Include="Microsoft.ML" Version="2.0.1" />
35-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
26+
<PackageVersion Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.16.2" />
27+
<PackageVersion Include="Microsoft.Azure.Functions.Worker" Version="1.20.0" />
28+
<PackageVersion Include="Microsoft.Extensions.Azure" Version="1.7.1" />
29+
<PackageVersion Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="8.0.0" />
30+
<PackageVersion Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
31+
<PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="8.0.0" />
32+
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.0" />
33+
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
34+
<PackageVersion Include="Microsoft.ML" Version="3.0.0" />
35+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
3636
<PackageVersion Include="Microsoft.SemanticKernel" Version="0.24.230918.1-preview" />
3737
<PackageVersion Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
38-
<PackageVersion Include="MudBlazor" Version="6.11.0" />
38+
<PackageVersion Include="MudBlazor" Version="6.11.1" />
3939
<PackageVersion Include="PdfSharpCore" Version="1.3.62" />
40-
<PackageVersion Include="Pinecone.NET" Version="1.3.0" />
40+
<PackageVersion Include="Pinecone.NET" Version="1.3.2" />
4141
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
4242
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
4343
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
44-
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.3" />
45-
<PackageVersion Include="xunit" Version="2.5.2" />
44+
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.4" />
45+
<PackageVersion Include="xunit" Version="2.6.2" />
4646
</ItemGroup>
4747
</Project>

app/app.sln

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1212
.editorconfig = .editorconfig
1313
..\.gitignore = ..\.gitignore
1414
..\.github\workflows\azure-dev.yml = ..\.github\workflows\azure-dev.yml
15-
Directory.Build.props = Directory.Build.props
1615
Directory.Packages.props = Directory.Packages.props
1716
..\.github\workflows\dotnet-build.yml = ..\.github\workflows\dotnet-build.yml
1817
..\LICENSE = ..\LICENSE

app/backend/Extensions/SearchClientExtensions.cs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,22 @@ internal static async Task<SupportingContentRecord[]> QueryDocumentsAsync(
1818
var useSemanticRanker = overrides?.SemanticRanker ?? false;
1919
var useSemanticCaptions = overrides?.SemanticCaptions ?? false;
2020

21-
SearchOptions searchOption = useSemanticRanker
21+
SearchOptions searchOptions = useSemanticRanker
2222
? new SearchOptions
2323
{
2424
Filter = filter,
2525
QueryType = SearchQueryType.Semantic,
26-
QueryLanguage = "en-us",
27-
QuerySpeller = "lexicon",
28-
SemanticConfigurationName = "default",
26+
SemanticSearch = new()
27+
{
28+
SemanticConfigurationName = "default",
29+
QueryCaption = new(useSemanticCaptions
30+
? QueryCaptionType.Extractive
31+
: QueryCaptionType.None),
32+
},
33+
// TODO: Find if these options are assignable
34+
//QueryLanguage = "en-us",
35+
//QuerySpeller = "lexicon",
2936
Size = top,
30-
QueryCaption = useSemanticCaptions ? QueryCaptionType.Extractive : QueryCaptionType.None,
3137
}
3238
: new SearchOptions
3339
{
@@ -38,19 +44,18 @@ internal static async Task<SupportingContentRecord[]> QueryDocumentsAsync(
3844
if (embedding != null && overrides?.RetrievalMode != "Text")
3945
{
4046
var k = useSemanticRanker ? 50 : top;
41-
var vectorQuery = new RawVectorQuery
47+
var vectorQuery = new VectorizedQuery(embedding)
4248
{
4349
// if semantic ranker is enabled, we need to set the rank to a large number to get more
4450
// candidates for semantic reranking
4551
KNearestNeighborsCount = useSemanticRanker ? 50 : top,
46-
Vector = embedding,
4752
};
4853
vectorQuery.Fields.Add("embedding");
49-
searchOption.VectorQueries.Add(vectorQuery);
54+
searchOptions.VectorSearch.Queries.Add(vectorQuery);
5055
}
5156

5257
var searchResultResponse = await searchClient.SearchAsync<SearchDocument>(
53-
query, searchOption, cancellationToken);
58+
query, searchOptions, cancellationToken);
5459
if (searchResultResponse.Value is null)
5560
{
5661
throw new InvalidOperationException("fail to get search result");
@@ -77,7 +82,7 @@ internal static async Task<SupportingContentRecord[]> QueryDocumentsAsync(
7782
{
7883
if (useSemanticCaptions)
7984
{
80-
var docs = doc.Captions.Select(c => c.Text);
85+
var docs = doc.SemanticSearch.Captions.Select(c => c.Text);
8186
contentValue = string.Join(" . ", docs);
8287
}
8388
else
@@ -98,6 +103,6 @@ internal static async Task<SupportingContentRecord[]> QueryDocumentsAsync(
98103
}
99104
}
100105

101-
return sb.ToArray();
106+
return [.. sb];
102107
}
103108
}

app/backend/GlobalUsings.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
global using System.Diagnostics;
44
global using System.Runtime.CompilerServices;
5-
global using System.Text;
65
global using System.Text.Json;
76
global using Azure.AI.FormRecognizer.DocumentAnalysis;
87
global using Azure.AI.OpenAI;

app/functions/EmbedFunctions/Program.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Microsoft. All rights reserved.
22

33
using Azure.AI.OpenAI;
4-
using Microsoft.Extensions.DependencyInjection;
54

65
var host = new HostBuilder()
76
.ConfigureServices(services =>

app/functions/EmbedFunctions/Services/AzureSearchEmbedService.cs

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) Microsoft. All rights reserved.
22

33
using Azure.AI.OpenAI;
4-
using Google.Protobuf.WellKnownTypes;
5-
using Microsoft.Extensions.Options;
64

75
namespace EmbedFunctions.Services;
86

@@ -61,48 +59,45 @@ public async Task CreateSearchIndexAsync(string searchIndexName)
6159
VectorSearch = new()
6260
{
6361
Algorithms =
64-
{
65-
new HnswVectorSearchAlgorithmConfiguration(vectorSearchConfigName)
66-
},
62+
{
63+
new HnswAlgorithmConfiguration(vectorSearchConfigName)
64+
},
6765
Profiles =
68-
{
69-
new VectorSearchProfile(vectorSearchProfile, vectorSearchConfigName)
70-
}
66+
{
67+
new VectorSearchProfile(vectorSearchProfile, vectorSearchConfigName)
68+
}
7169
},
7270
Fields =
73-
{
74-
new SimpleField("id", SearchFieldDataType.String) { IsKey = true },
75-
new SearchableField("content") { AnalyzerName = LexicalAnalyzerName.EnMicrosoft },
76-
new SimpleField("category", SearchFieldDataType.String) { IsFacetable = true },
77-
new SimpleField("sourcepage", SearchFieldDataType.String) { IsFacetable = true },
78-
new SimpleField("sourcefile", SearchFieldDataType.String) { IsFacetable = true },
79-
new SearchField("embedding", SearchFieldDataType.Collection(SearchFieldDataType.Single))
8071
{
81-
VectorSearchDimensions = 1536,
82-
IsSearchable = true,
83-
VectorSearchProfile = vectorSearchProfile,
84-
}
85-
},
86-
SemanticSettings = new SemanticSettings
72+
new SimpleField("id", SearchFieldDataType.String) { IsKey = true },
73+
new SearchableField("content") { AnalyzerName = LexicalAnalyzerName.EnMicrosoft },
74+
new SimpleField("category", SearchFieldDataType.String) { IsFacetable = true },
75+
new SimpleField("sourcepage", SearchFieldDataType.String) { IsFacetable = true },
76+
new SimpleField("sourcefile", SearchFieldDataType.String) { IsFacetable = true },
77+
new SearchField("embedding", SearchFieldDataType.Collection(SearchFieldDataType.Single))
78+
{
79+
VectorSearchDimensions = 1536,
80+
IsSearchable = true,
81+
VectorSearchProfileName = vectorSearchProfile,
82+
}
83+
},
84+
SemanticSearch = new()
8785
{
8886
Configurations =
89-
{
90-
new SemanticConfiguration("default", new PrioritizedFields
9187
{
92-
ContentFields =
88+
new SemanticConfiguration("default", new()
9389
{
94-
new SemanticField
90+
ContentFields =
9591
{
96-
FieldName = "content"
92+
new SemanticField("content")
9793
}
98-
}
99-
})
100-
}
94+
})
95+
}
10196
}
10297
};
10398

10499
logger?.LogInformation(
105-
"Creating '{searchIndexName}' search index", searchIndexName);
100+
"Creating '{searchIndexName}' search index", searchIndexName);
106101

107102
await searchIndexClient.CreateIndexAsync(index);
108103
}

app/functions/EmbedFunctions/Services/EmbeddingAggregateService.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// Copyright (c) Microsoft. All rights reserved.
22

3-
using System.IO;
4-
53
namespace EmbedFunctions.Services;
64

75
public sealed class EmbeddingAggregateService(

app/prepdocs/PrepareDocs/GlobalUsings.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@
44
global using System.CommandLine.Invocation;
55
global using System.CommandLine.Parsing;
66
global using System.Linq;
7-
global using System.Net;
8-
global using System.Text;
97
global using System.Text.RegularExpressions;
108
global using Azure;
119
global using Azure.AI.FormRecognizer.DocumentAnalysis;
1210
global using Azure.Identity;
1311
global using Azure.Search.Documents;
1412
global using Azure.Search.Documents.Indexes;
15-
global using Azure.Search.Documents.Indexes.Models;
1613
global using Azure.Search.Documents.Models;
1714
global using Azure.Storage.Blobs;
1815
global using Azure.Storage.Blobs.Models;

app/prepdocs/PrepareDocs/Program.Clients.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33

44
using EmbedFunctions.Services;
5-
using Microsoft.Extensions.Logging;
65

76
internal static partial class Program
87
{

0 commit comments

Comments
 (0)