From 1537c55c047c07c187228c605b85cc2167d72e30 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 12 Mar 2025 12:21:46 +0000 Subject: [PATCH 1/2] Bump the dotnet group Bumps the dotnet group in /docs/ai/quickstarts/snippets/chat-with-data/openai with 3 updates: [Microsoft.Extensions.Configuration](https://github.com/dotnet/runtime), [Microsoft.Extensions.Configuration.UserSecrets](https://github.com/dotnet/runtime) and [Microsoft.Extensions.VectorData.Abstractions](https://github.com/microsoft/semantic-kernel). Updates `Microsoft.Extensions.Configuration` from 9.0.2 to 9.0.3 - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v9.0.2...v9.0.3) Updates `Microsoft.Extensions.Configuration` from 9.0.2 to 9.0.3 - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v9.0.2...v9.0.3) Updates `Microsoft.Extensions.Configuration.UserSecrets` from 9.0.2 to 9.0.3 - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v9.0.2...v9.0.3) Updates `Microsoft.Extensions.VectorData.Abstractions` from 9.0.0-preview.1.25078.1 to 9.0.0-preview.1.25161.1 - [Release notes](https://github.com/microsoft/semantic-kernel/releases) - [Commits](https://github.com/microsoft/semantic-kernel/compare/vectordata-dotnet-9.0.0-preview.1.25078.1...vectordata-dotnet-9.0.0-preview.1.25161.1) --- updated-dependencies: - dependency-name: Microsoft.Extensions.Configuration dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dotnet - dependency-name: Microsoft.Extensions.Configuration dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dotnet - dependency-name: Microsoft.Extensions.Configuration.UserSecrets dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dotnet - dependency-name: Microsoft.Extensions.VectorData.Abstractions dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dotnet ... Signed-off-by: dependabot[bot] --- .../snippets/chat-with-data/openai/VectorDataAI.csproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 919c7cd1242cc..3269b9890a7ab 100644 --- a/docs/ai/quickstarts/snippets/chat-with-data/openai/VectorDataAI.csproj +++ b/docs/ai/quickstarts/snippets/chat-with-data/openai/VectorDataAI.csproj @@ -9,10 +9,10 @@ - + - - + + From f471a3b3212cefb65058224f022662be88f0c4b6 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Mon, 17 Mar 2025 14:59:42 -0700 Subject: [PATCH 2/2] fix build errors --- .../chat-with-data/openai/CloudService.cs | 5 -- .../snippets/chat-with-data/openai/Program.cs | 52 ++++++++----------- .../chat-with-data/openai/VectorDataAI.csproj | 8 +-- 3 files changed, 27 insertions(+), 38 deletions(-) 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 281536280814a..13d3936c3dc99 100644 --- a/docs/ai/quickstarts/snippets/chat-with-data/openai/CloudService.cs +++ b/docs/ai/quickstarts/snippets/chat-with-data/openai/CloudService.cs @@ -1,9 +1,4 @@ using Microsoft.Extensions.VectorData; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace VectorDataAI { 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 49ede09c7c558..1fa80110f388a 100644 --- a/docs/ai/quickstarts/snippets/chat-with-data/openai/Program.cs +++ b/docs/ai/quickstarts/snippets/chat-with-data/openai/Program.cs @@ -1,83 +1,77 @@ -using Microsoft.Extensions.AI; -using OpenAI; +using System.ClientModel; +using Microsoft.Extensions.AI; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.VectorData; using Microsoft.SemanticKernel.Connectors.InMemory; +using OpenAI; using VectorDataAI; -using System.ClientModel; -using Microsoft.Extensions.Configuration; var cloudServices = new List() { - new CloudService - { + new() { Key=0, Name="Azure App Service", Description="Host .NET, Java, Node.js, and Python web applications and APIs in a fully managed Azure service. You only need to deploy your code to Azure. Azure takes care of all the infrastructure management like high availability, load balancing, and autoscaling." }, - new CloudService - { + new() { Key=1, Name="Azure Service Bus", Description="A fully managed enterprise message broker supporting both point to point and publish-subscribe integrations. It's ideal for building decoupled applications, queue-based load leveling, or facilitating communication between microservices." }, - new CloudService - { + new() { Key=2, Name="Azure Blob Storage", Description="Azure Blob Storage allows your applications to store and retrieve files in the cloud. Azure Storage is highly scalable to store massive amounts of data and data is stored redundantly to ensure high availability." }, - new CloudService - { + new() { Key=3, Name="Microsoft Entra ID", Description="Manage user identities and control access to your apps, data, and resources.." }, - new CloudService - { + new() { Key=4, Name="Azure Key Vault", Description="Store and access application secrets like connection strings and API keys in an encrypted vault with restricted access to make sure your secrets and your application aren't compromised." }, - new CloudService - { + new() { Key=5, Name="Azure AI Search", 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(); +// Load the configuration values. +IConfigurationRoot config = new ConfigurationBuilder().AddUserSecrets().Build(); string model = config["ModelName"]; string key = config["OpenAIKey"]; -// Create the embedding generator +// Create the embedding generator. IEmbeddingGenerator> generator = new OpenAIClient(new ApiKeyCredential(key)) .AsEmbeddingGenerator(modelId: model); -// Create and populate the vector store +// Create and populate the vector store. var vectorStore = new InMemoryVectorStore(); -var cloudServicesStore = vectorStore.GetCollection("cloudServices"); +IVectorStoreRecordCollection cloudServicesStore = vectorStore.GetCollection("cloudServices"); await cloudServicesStore.CreateCollectionIfNotExistsAsync(); -foreach (var service in cloudServices) +foreach (CloudService service in cloudServices) { service.Vector = await generator.GenerateEmbeddingVectorAsync(service.Description); await cloudServicesStore.UpsertAsync(service); } -// Convert a search query to a vector and search the vector store -var query = "Which Azure service should I use to store my Word documents?"; -var queryEmbedding = await generator.GenerateEmbeddingVectorAsync(query); +// 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); -var results = await cloudServicesStore.VectorizedSearchAsync(queryEmbedding, new VectorSearchOptions() +VectorSearchResults results = + await cloudServicesStore.VectorizedSearchAsync(queryEmbedding, new VectorSearchOptions() { - Top = 1, - VectorPropertyName = "Vector" + Top = 1 }); -await foreach (var result in results.Results) +await foreach (VectorSearchResult result in results.Results) { Console.WriteLine($"Name: {result.Record.Name}"); Console.WriteLine($"Description: {result.Record.Description}"); 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 3269b9890a7ab..29aece214d449 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,11 @@ - + - - - + + +