From ab4de36ca914f01677e251b60216a3f64f0b4468 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Mon, 7 Apr 2025 18:25:37 -0700 Subject: [PATCH 1/2] use id instead of range --- docs/ai/quickstarts/build-vector-search-app.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/ai/quickstarts/build-vector-search-app.md b/docs/ai/quickstarts/build-vector-search-app.md index 247205f364e34..ca38b51484e07 100644 --- a/docs/ai/quickstarts/build-vector-search-app.md +++ b/docs/ai/quickstarts/build-vector-search-app.md @@ -154,13 +154,13 @@ Complete the following steps to create a .NET console app that can: 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" range="8-46"::: + :::code language="csharp" source="snippets/chat-with-data/azure-openai/program.cs" id="DataSet"::: 1. Create and configure an `IEmbeddingGenerator` implementation to send requests to an embedding AI model: :::zone target="docs" pivot="azure-openai" - :::code language="csharp" source="snippets/chat-with-data/azure-openai/program.cs" range="48-58"::: + :::code language="csharp" source="snippets/chat-with-data/azure-openai/program.cs" id="EMbeddingGen"::: > [!NOTE] > searches for authentication credentials from your local tooling. If you aren't using the `azd` template to provision the Azure OpenAI resource, you'll need to assign the `Azure AI Developer` role to the account you used to sign in to Visual Studio or the Azure CLI. For more information, see [Authenticate to Azure AI services with .NET](../azure-ai-services-authentication.md). @@ -175,13 +175,13 @@ Complete the following steps to create a .NET console app that can: 1. Create and populate a vector store with the cloud service data. Use the `IEmbeddingGenerator` implementation to create and assign an embedding vector for each record in the cloud service data: - :::code language="csharp" source="snippets/chat-with-data/azure-openai/program.cs" range="61-70"::: + :::code language="csharp" source="snippets/chat-with-data/azure-openai/program.cs" id="VectorStore"::: The embeddings are numerical representations of the semantic meaning for each data record, which makes them compatible with vector search features. 1. Create an embedding for a search query and use it to perform a vector search on the vector store: - :::code language="csharp" source="snippets/chat-with-data/azure-openai/program.cs" range="72-88"::: + :::code language="csharp" source="snippets/chat-with-data/azure-openai/program.cs" id="Search"::: 1. Use the `dotnet run` command to run the app: From 2f4806a5b9ca4deee09041d3dad3dbcd16297610 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Mon, 7 Apr 2025 19:59:27 -0700 Subject: [PATCH 2/2] add snippet file too --- docs/ai/quickstarts/build-vector-search-app.md | 2 +- .../snippets/chat-with-data/azure-openai/Program.cs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/ai/quickstarts/build-vector-search-app.md b/docs/ai/quickstarts/build-vector-search-app.md index ca38b51484e07..a772807e7d592 100644 --- a/docs/ai/quickstarts/build-vector-search-app.md +++ b/docs/ai/quickstarts/build-vector-search-app.md @@ -160,7 +160,7 @@ Complete the following steps to create a .NET console app that can: :::zone target="docs" pivot="azure-openai" - :::code language="csharp" source="snippets/chat-with-data/azure-openai/program.cs" id="EMbeddingGen"::: + :::code language="csharp" source="snippets/chat-with-data/azure-openai/program.cs" id="EmbeddingGen"::: > [!NOTE] > searches for authentication credentials from your local tooling. If you aren't using the `azd` template to provision the Azure OpenAI resource, you'll need to assign the `Azure AI Developer` role to the account you used to sign in to Visual Studio or the Azure CLI. For more information, see [Authenticate to Azure AI services with .NET](../azure-ai-services-authentication.md). 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 9539540f0f698..166223c855b93 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 @@ -6,6 +6,7 @@ using Microsoft.SemanticKernel.Connectors.InMemory; using VectorDataAI; +// var cloudServices = new List() { new CloudService @@ -45,7 +46,9 @@ Description="Information retrieval at scale for traditional and conversational search applications, with security and options for AI enrichment and vectorization." } }; +// +// // Load the configuration values var config = new ConfigurationBuilder().AddUserSecrets().Build(); string endpoint = config["AZURE_OPENAI_ENDPOINT"]; @@ -57,7 +60,9 @@ new Uri(endpoint), new DefaultAzureCredential()) .AsEmbeddingGenerator(modelId: model); +// +// // Create and populate the vector store var vectorStore = new InMemoryVectorStore(); Microsoft.Extensions.VectorData.IVectorStoreRecordCollection cloudServicesStore = vectorStore.GetCollection("cloudServices"); @@ -68,7 +73,9 @@ service.Vector = await generator.GenerateEmbeddingVectorAsync(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); @@ -86,3 +93,4 @@ Console.WriteLine($"Vector match score: {result.Score}"); Console.WriteLine(); } +//