diff --git a/docs/ai/quickstarts/build-vector-search-app.md b/docs/ai/quickstarts/build-vector-search-app.md index 303818e451c12..8d29515b4f2ff 100644 --- a/docs/ai/quickstarts/build-vector-search-app.md +++ b/docs/ai/quickstarts/build-vector-search-app.md @@ -77,9 +77,10 @@ Complete the following steps to create a .NET console app that can: dotnet add package Microsoft.SemanticKernel.Connectors.InMemory --prerelease dotnet add package Microsoft.Extensions.Configuration dotnet add package Microsoft.Extensions.Configuration.UserSecrets + dotnet add package System.Linq.AsyncEnumerable ``` - The following list describes what each package is used for in the `VectorDataAI` app: + The following list describes each package in the `VectorDataAI` app: - [`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`. - [`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: dotnet add package Microsoft.SemanticKernel.Connectors.InMemory --prerelease dotnet add package Microsoft.Extensions.Configuration dotnet add package Microsoft.Extensions.Configuration.UserSecrets + dotnet add package System.Linq.AsyncEnumerable ``` - The following list describes what each package is used for in the `VectorDataAI` app: + The following list describes each package in the `VectorDataAI` app: - [`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. - [`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. diff --git a/docs/ai/quickstarts/snippets/chat-with-data/azure-openai/CloudService.cs b/docs/ai/quickstarts/snippets/chat-with-data/azure-openai/CloudService.cs index 13d3936c3dc99..5356337146ef4 100644 --- a/docs/ai/quickstarts/snippets/chat-with-data/azure-openai/CloudService.cs +++ b/docs/ai/quickstarts/snippets/chat-with-data/azure-openai/CloudService.cs @@ -1,19 +1,18 @@ using Microsoft.Extensions.VectorData; -namespace VectorDataAI +namespace VectorDataAI; + +internal class CloudService { - internal class CloudService - { - [VectorStoreRecordKey] - public int Key { get; set; } + [VectorStoreRecordKey] + public int Key { get; set; } - [VectorStoreRecordData] - public string Name { get; set; } + [VectorStoreRecordData] + public string Name { get; set; } - [VectorStoreRecordData] - public string Description { get; set; } + [VectorStoreRecordData] + public string Description { get; set; } - [VectorStoreRecordVector(384, DistanceFunction.CosineSimilarity)] - public ReadOnlyMemory Vector { get; set; } - } + [VectorStoreRecordVector(384, DistanceFunction.CosineSimilarity)] + public ReadOnlyMemory Vector { get; set; } } diff --git a/docs/ai/quickstarts/snippets/chat-with-data/openai/CloudService.cs b/docs/ai/quickstarts/snippets/chat-with-data/openai/CloudService.cs index 13d3936c3dc99..d4d058e8b8f8f 100644 --- a/docs/ai/quickstarts/snippets/chat-with-data/openai/CloudService.cs +++ b/docs/ai/quickstarts/snippets/chat-with-data/openai/CloudService.cs @@ -13,7 +13,7 @@ internal class CloudService [VectorStoreRecordData] public string Description { get; set; } - [VectorStoreRecordVector(384, DistanceFunction.CosineSimilarity)] + [VectorStoreRecordVector(Dimensions: 384, DistanceFunction = DistanceFunction.CosineSimilarity)] public ReadOnlyMemory Vector { get; set; } } } diff --git a/docs/ai/quickstarts/snippets/chat-with-data/openai/Program.cs b/docs/ai/quickstarts/snippets/chat-with-data/openai/Program.cs index e3fb7cd88cf7a..042987331b192 100644 --- a/docs/ai/quickstarts/snippets/chat-with-data/openai/Program.cs +++ b/docs/ai/quickstarts/snippets/chat-with-data/openai/Program.cs @@ -58,24 +58,20 @@ foreach (CloudService service in cloudServices) { - service.Vector = await generator.GenerateEmbeddingVectorAsync(service.Description); + service.Vector = await generator.GenerateVectorAsync(service.Description); await cloudServicesStore.UpsertAsync(service); } // Convert a search query to a vector and search the vector store. string query = "Which Azure service should I use to store my Word documents?"; -ReadOnlyMemory queryEmbedding = await generator.GenerateEmbeddingVectorAsync(query); +ReadOnlyMemory queryEmbedding = await generator.GenerateVectorAsync(query); -VectorSearchResults results = - await cloudServicesStore.VectorizedSearchAsync(queryEmbedding, new VectorSearchOptions() - { - Top = 1 - }); +List> results = + await cloudServicesStore.SearchEmbeddingAsync(queryEmbedding, top: 1).ToListAsync(); -await foreach (VectorSearchResult result in results.Results) +foreach (VectorSearchResult result in results) { Console.WriteLine($"Name: {result.Record.Name}"); Console.WriteLine($"Description: {result.Record.Description}"); Console.WriteLine($"Vector match score: {result.Score}"); - Console.WriteLine(); } diff --git a/docs/ai/quickstarts/snippets/chat-with-data/openai/VectorDataAI.csproj b/docs/ai/quickstarts/snippets/chat-with-data/openai/VectorDataAI.csproj index 1dc474c719eb3..62bcadf35ed6a 100644 --- a/docs/ai/quickstarts/snippets/chat-with-data/openai/VectorDataAI.csproj +++ b/docs/ai/quickstarts/snippets/chat-with-data/openai/VectorDataAI.csproj @@ -8,11 +8,12 @@ - - - + + + +