Skip to content

Commit f72b57f

Browse files
Bump Microsoft.Extensions.VectorData.Abstractions from 9.0.0-preview.1.25161.1 to 9.0.0-preview.1.25229.1 in /docs/ai/quickstarts/snippets/chat-with-data/openai in the dotnet group (#45963)
* Bump Microsoft.Extensions.VectorData.Abstractions Bumps the dotnet group in /docs/ai/quickstarts/snippets/chat-with-data/openai with 1 update: [Microsoft.Extensions.VectorData.Abstractions](https://github.com/microsoft/semantic-kernel). Updates `Microsoft.Extensions.VectorData.Abstractions` from 9.0.0-preview.1.25161.1 to 9.0.0-preview.1.25229.1 - [Release notes](https://github.com/microsoft/semantic-kernel/releases) - [Commits](https://github.com/microsoft/semantic-kernel/commits) --- updated-dependencies: - dependency-name: Microsoft.Extensions.VectorData.Abstractions dependency-version: 9.0.0-preview.1.25229.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dotnet ... Signed-off-by: dependabot[bot] <support@github.com> * fix build errors * use file scoped namespace --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
1 parent 2b0fed3 commit f72b57f

File tree

5 files changed

+25
-27
lines changed

5 files changed

+25
-27
lines changed

docs/ai/quickstarts/build-vector-search-app.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ Complete the following steps to create a .NET console app that can:
7777
dotnet add package Microsoft.SemanticKernel.Connectors.InMemory --prerelease
7878
dotnet add package Microsoft.Extensions.Configuration
7979
dotnet add package Microsoft.Extensions.Configuration.UserSecrets
80+
dotnet add package System.Linq.AsyncEnumerable
8081
```
8182
82-
The following list describes what each package is used for in the `VectorDataAI` app:
83+
The following list describes each package in the `VectorDataAI` app:
8384
8485
- [`Azure.Identity`](https://www.nuget.org/packages/Azure.Identity) provides [`Microsoft Entra ID`](/entra/fundamentals/whatis) token authentication support across the Azure SDK using classes such as `DefaultAzureCredential`.
8586
- [`Azure.AI.OpenAI`](https://www.nuget.org/packages/Azure.AI.OpenAI) is the official package for using OpenAI's .NET library with the Azure OpenAI Service.
@@ -98,9 +99,10 @@ Complete the following steps to create a .NET console app that can:
9899
dotnet add package Microsoft.SemanticKernel.Connectors.InMemory --prerelease
99100
dotnet add package Microsoft.Extensions.Configuration
100101
dotnet add package Microsoft.Extensions.Configuration.UserSecrets
102+
dotnet add package System.Linq.AsyncEnumerable
101103
```
102104
103-
The following list describes what each package is used for in the `VectorDataAI` app:
105+
The following list describes each package in the `VectorDataAI` app:
104106
105107
- [`Microsoft.Extensions.AI.OpenAI`](https://www.nuget.org/packages/Microsoft.Extensions.AI.OpenAI) provides AI abstractions for OpenAI-compatible models or endpoints. This library also includes the official [`OpenAI`](https://www.nuget.org/packages/OpenAI) library for the OpenAI service API as a dependency.
106108
- [`Microsoft.SemanticKernel.Connectors.InMemory`](https://www.nuget.org/packages/Microsoft.SemanticKernel.Connectors.InMemory) provides an in-memory vector store class to hold queryable vector data records.
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
using Microsoft.Extensions.VectorData;
22

3-
namespace VectorDataAI
3+
namespace VectorDataAI;
4+
5+
internal class CloudService
46
{
5-
internal class CloudService
6-
{
7-
[VectorStoreRecordKey]
8-
public int Key { get; set; }
7+
[VectorStoreRecordKey]
8+
public int Key { get; set; }
99

10-
[VectorStoreRecordData]
11-
public string Name { get; set; }
10+
[VectorStoreRecordData]
11+
public string Name { get; set; }
1212

13-
[VectorStoreRecordData]
14-
public string Description { get; set; }
13+
[VectorStoreRecordData]
14+
public string Description { get; set; }
1515

16-
[VectorStoreRecordVector(384, DistanceFunction.CosineSimilarity)]
17-
public ReadOnlyMemory<float> Vector { get; set; }
18-
}
16+
[VectorStoreRecordVector(384, DistanceFunction.CosineSimilarity)]
17+
public ReadOnlyMemory<float> Vector { get; set; }
1918
}

docs/ai/quickstarts/snippets/chat-with-data/openai/CloudService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal class CloudService
1313
[VectorStoreRecordData]
1414
public string Description { get; set; }
1515

16-
[VectorStoreRecordVector(384, DistanceFunction.CosineSimilarity)]
16+
[VectorStoreRecordVector(Dimensions: 384, DistanceFunction = DistanceFunction.CosineSimilarity)]
1717
public ReadOnlyMemory<float> Vector { get; set; }
1818
}
1919
}

docs/ai/quickstarts/snippets/chat-with-data/openai/Program.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,24 +58,20 @@
5858

5959
foreach (CloudService service in cloudServices)
6060
{
61-
service.Vector = await generator.GenerateEmbeddingVectorAsync(service.Description);
61+
service.Vector = await generator.GenerateVectorAsync(service.Description);
6262
await cloudServicesStore.UpsertAsync(service);
6363
}
6464

6565
// Convert a search query to a vector and search the vector store.
6666
string query = "Which Azure service should I use to store my Word documents?";
67-
ReadOnlyMemory<float> queryEmbedding = await generator.GenerateEmbeddingVectorAsync(query);
67+
ReadOnlyMemory<float> queryEmbedding = await generator.GenerateVectorAsync(query);
6868

69-
VectorSearchResults<CloudService> results =
70-
await cloudServicesStore.VectorizedSearchAsync(queryEmbedding, new VectorSearchOptions<CloudService>()
71-
{
72-
Top = 1
73-
});
69+
List<VectorSearchResult<CloudService>> results =
70+
await cloudServicesStore.SearchEmbeddingAsync(queryEmbedding, top: 1).ToListAsync();
7471

75-
await foreach (VectorSearchResult<CloudService> result in results.Results)
72+
foreach (VectorSearchResult<CloudService> result in results)
7673
{
7774
Console.WriteLine($"Name: {result.Record.Name}");
7875
Console.WriteLine($"Description: {result.Record.Description}");
7976
Console.WriteLine($"Vector match score: {result.Score}");
80-
Console.WriteLine();
8177
}

docs/ai/quickstarts/snippets/chat-with-data/openai/VectorDataAI.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="9.4.0-preview.1.25207.5" />
12-
<PackageReference Include="Microsoft.Extensions.VectorData.Abstractions" Version="9.0.0-preview.1.25161.1" />
13-
<PackageReference Include="Microsoft.SemanticKernel.Connectors.InMemory" Version="1.41.0-preview" />
11+
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="9.4.3-preview.1.25230.7" />
12+
<PackageReference Include="Microsoft.Extensions.VectorData.Abstractions" Version="9.0.0-preview.1.25229.1" />
13+
<PackageReference Include="Microsoft.SemanticKernel.Connectors.InMemory" Version="1.48.0-preview" />
1414
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.0-preview.3.25171.5" />
1515
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="10.0.0-preview.3.25171.5" />
16+
<PackageReference Include="System.Linq.AsyncEnumerable" Version="10.0.0-preview.3.25171.5" />
1617
</ItemGroup>
1718

1819
</Project>

0 commit comments

Comments
 (0)