diff --git a/docs/ai/quickstarts/build-vector-search-app.md b/docs/ai/quickstarts/build-vector-search-app.md index 8d29515b4f2ff..70a469a21be4b 100644 --- a/docs/ai/quickstarts/build-vector-search-app.md +++ b/docs/ai/quickstarts/build-vector-search-app.md @@ -145,16 +145,16 @@ Complete the following steps to create a .NET console app that can: ## Add the app code -1. Add a new class named **CloudService** to your project with the following properties: +1. Add a new class named `CloudService` to your project with the following properties: :::code language="csharp" source="snippets/chat-with-data/azure-openai/CloudService.cs" ::: In the preceding code: - The C# attributes provided by `Microsoft.Extensions.VectorData` influence how each property is handled when used in a vector store. - - The **Vector** property stores a generated embedding that represents the semantic meaning of the **Name** and **Description** for vector searches. + - The `Vector` property stores a generated embedding that represents the semantic meaning of the `Name` and `Description` for vector searches. -1. In the **Program.cs** file, add the following code to create a data set that describes a collection of cloud services: +1. In the `Program.cs` file, add the following code to create a data set that describes a collection of cloud services: :::code language="csharp" source="snippets/chat-with-data/azure-openai/program.cs" id="DataSet"::: @@ -191,7 +191,7 @@ Complete the following steps to create a .NET console app that can: dotnet run ``` - The app prints out the top result of the vector search, which is the cloud service that is most relevant to the original query. You can modify the query to try different search scenarios. + The app prints out the top result of the vector search, which is the cloud service that's most relevant to the original query. You can modify the query to try different search scenarios. :::zone target="docs" pivot="azure-openai" 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 5356337146ef4..93ed6d200d47f 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 @@ -13,6 +13,6 @@ 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/azure-openai/Program.cs b/docs/ai/quickstarts/snippets/chat-with-data/azure-openai/Program.cs index 9ca7b08c26b91..3be4e3eddc2bc 100644 --- a/docs/ai/quickstarts/snippets/chat-with-data/azure-openai/Program.cs +++ b/docs/ai/quickstarts/snippets/chat-with-data/azure-openai/Program.cs @@ -64,7 +64,7 @@ foreach (CloudService service in cloudServices) { - service.Vector = await generator.GenerateEmbeddingVectorAsync(service.Description); + service.Vector = await generator.GenerateVectorAsync(service.Description); await cloudServicesStore.UpsertAsync(service); } // @@ -72,19 +72,15 @@ // // 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/azure-openai/VectorDataAI.csproj b/docs/ai/quickstarts/snippets/chat-with-data/azure-openai/VectorDataAI.csproj index 682198480e815..ef078811f8ccd 100644 --- a/docs/ai/quickstarts/snippets/chat-with-data/azure-openai/VectorDataAI.csproj +++ b/docs/ai/quickstarts/snippets/chat-with-data/azure-openai/VectorDataAI.csproj @@ -1,20 +1,22 @@ - + Exe - net8.0 + net9.0 enable enable + 5981f38c-e59c-46cc-80bb-463f8c3f1691 - - - + + + +