Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/profanity-filter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

- name: Profanity filter
if: ${{ github.actor != 'dependabot[bot]' && github.actor != 'github-actions[bot]' }}
uses: IEvangelist/profanity-filter@8ed64a0b6652c314f0e2519a86ae234c6df63698 # main
uses: IEvangelist/profanity-filter@b51302be6fd09006f6b0a5ec4c573542fc8fa7bf # main
id: profanity-filter
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/scorecards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ jobs:
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: SARIF file
path: results.sarif
retention-days: 5

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@babb554ede22fd5605947329c4d04d8e7a0b8155 # v3.27.7
uses: github/codeql-action/upload-sarif@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
with:
sarif_file: results.sarif
10 changes: 10 additions & 0 deletions .openpublishing.redirection.machine-learning.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
"redirect_url": "/dotnet/machine-learning/how-does-mldotnet-work",
"redirect_document_id": true
},
{
"source_path_from_root": "/docs/machine-learning/how-does-mldotnet-work.md",
"redirect_url": "/dotnet/machine-learning/mldotnet-api",
"redirect_document_id": true
},
{
"source_path_from_root": "/docs/machine-learning/how-to-guides/consuming-model-ml-net.md",
"redirect_url": "/dotnet/machine-learning/how-to-guides/save-load-machine-learning-models-ml-net",
Expand Down Expand Up @@ -80,6 +85,11 @@
"source_path_from_root": "/docs/machine-learning/resources/what-is-mldotnet.md",
"redirect_url": "/dotnet/machine-learning/how-does-mldotnet-work"
},
{
"source_path_from_root": "/docs/machine-learning/resources/index.md",
"redirect_url": "/dotnet/machine-learning/resources/glossary",
"redirect_document_id": true
},
{
"source_path_from_root": "/docs/machine-learning/tutorials/ml-cli.md",
"redirect_url": "/dotnet/machine-learning/tutorials/sentiment-analysis-cli",
Expand Down
2 changes: 1 addition & 1 deletion docs/ai/quickstarts/includes/prerequisites-azure-openai.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ms.topic: include

## Prerequisites

- .NET 8 SDK - [Install the .NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0).
- .NET 8.0 SDK or higher - [Install the .NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0).
- An Azure subscription - [Create one for free](https://azure.microsoft.com/free).
- Access to [Azure OpenAI service](/azure/ai-services/openai/overview#how-do-i-get-access-to-azure-openai).
- Azure Developer CLI (Optional) - [Install or update the Azure Developer CLI](/azure/developer/azure-developer-cli/install-azd).
3 changes: 1 addition & 2 deletions docs/ai/quickstarts/includes/prerequisites-openai.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ ms.topic: include

## Prerequisites

- .NET 8.0 SDK - [Install the .NET 8.0 SDK](https://dotnet.microsoft.com/download/dotnet/8.0).
- .NET 8.0 SDK or higher - [Install the .NET 8.0 SDK](https://dotnet.microsoft.com/download/dotnet/8.0).
- An [API key from OpenAI](https://platform.openai.com/docs/quickstart/account-setup) so you can run this sample.
- On Windows, PowerShell `v7+` is required. To validate your version, run `pwsh` in a terminal. It should return the current version. If it returns an error, execute the following command: `dotnet tool update --global PowerShell`.
250 changes: 112 additions & 138 deletions docs/ai/quickstarts/quickstart-ai-chat-with-data.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Microsoft.Extensions.VectorData;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VectorDataAI
{
internal class CloudService
{
[VectorStoreRecordKey]
public int Key { get; set; }

[VectorStoreRecordData]
public string Name { get; set; }

[VectorStoreRecordData]
public string Description { get; set; }

[VectorStoreRecordVector(384, DistanceFunction.CosineSimilarity)]
public ReadOnlyMemory<float> Vector { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using Azure.AI.OpenAI;
using Azure.Identity;
using Microsoft.Extensions.AI;
using Microsoft.Extensions.VectorData;
using Microsoft.Extensions.Configuration;
using Microsoft.SemanticKernel.Connectors.InMemory;
using VectorDataAI;

var cloudServices = new List<CloudService>()
{
new CloudService
{
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
{
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
{
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
{
Key=3,
Name="Microsoft Entra ID",
Description="Manage user identities and control access to your apps, data, and resources.."
},
new CloudService
{
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
{
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<Program>().Build();
string endpoint = config["AZURE_OPENAI_ENDPOINT"];
string model = config["AZURE_OPENAI_GPT_NAME"];

// Create the embedding generator
IEmbeddingGenerator<string, Embedding<float>> generator =
new AzureOpenAIClient(
new Uri(endpoint),
new DefaultAzureCredential())
.AsEmbeddingGenerator(modelId: model);

// Create and populate the vector store
var vectorStore = new InMemoryVectorStore();
var cloudServicesStore = vectorStore.GetCollection<int, CloudService>("cloudServices");
await cloudServicesStore.CreateCollectionIfNotExistsAsync();

foreach (var 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);

var results = await cloudServicesStore.VectorizedSearchAsync(queryEmbedding, new VectorSearchOptions()
{
Top = 1,
VectorPropertyName = "Vector"
});

await foreach (var result in results.Results)
{
Console.WriteLine($"Name: {result.Record.Name}");
Console.WriteLine($"Description: {result.Record.Description}");
Console.WriteLine($"Vector match score: {result.Score}");
Console.WriteLine();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.13.1" />
<PackageReference Include="Azure.AI.OpenAI" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="9.0.1-preview.1.24570.5" />
<PackageReference Include="Microsoft.Extensions.VectorData.Abstractions" Version="9.0.0-preview.1.24523.1" />
<PackageReference Include="Microsoft.SemanticKernel.Connectors.InMemory" Version="1.31.0-preview" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.0" />
</ItemGroup>

</Project>
24 changes: 24 additions & 0 deletions docs/ai/quickstarts/snippets/chat-with-data/openai/CloudService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Microsoft.Extensions.VectorData;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VectorDataAI
{
internal class CloudService
{
[VectorStoreRecordKey]
public int Key { get; set; }

[VectorStoreRecordData]
public string Name { get; set; }

[VectorStoreRecordData]
public string Description { get; set; }

[VectorStoreRecordVector(384, DistanceFunction.CosineSimilarity)]
public ReadOnlyMemory<float> Vector { get; set; }
}
}
86 changes: 86 additions & 0 deletions docs/ai/quickstarts/snippets/chat-with-data/openai/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
using Microsoft.Extensions.AI;
using OpenAI;
using Microsoft.Extensions.VectorData;
using Microsoft.SemanticKernel.Connectors.InMemory;
using VectorDataAI;
using System.ClientModel;
using Microsoft.Extensions.Configuration;

var cloudServices = new List<CloudService>()
{
new CloudService
{
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
{
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
{
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
{
Key=3,
Name="Microsoft Entra ID",
Description="Manage user identities and control access to your apps, data, and resources.."
},
new CloudService
{
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
{
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<Program>().Build();
string model = config["ModelName"];
string key = config["OpenAIKey"];

// Create the embedding generator
IEmbeddingGenerator<string, Embedding<float>> generator =
new OpenAIClient(new ApiKeyCredential(key))
.AsEmbeddingGenerator(modelId: model);

// Create and populate the vector store
var vectorStore = new InMemoryVectorStore();
var cloudServicesStore = vectorStore.GetCollection<int, CloudService>("cloudServices");
await cloudServicesStore.CreateCollectionIfNotExistsAsync();

foreach (var 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);

var results = await cloudServicesStore.VectorizedSearchAsync(queryEmbedding, new VectorSearchOptions()
{
Top = 1,
VectorPropertyName = "Vector"
});

await foreach (var result in results.Results)
{
Console.WriteLine($"Name: {result.Record.Name}");
Console.WriteLine($"Description: {result.Record.Description}");
Console.WriteLine($"Vector match score: {result.Score}");
Console.WriteLine();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="9.0.1-preview.1.24570.5" />
<PackageReference Include="Microsoft.Extensions.VectorData.Abstractions" Version="9.0.0-preview.1.24523.1" />
<PackageReference Include="Microsoft.SemanticKernel.Connectors.InMemory" Version="1.31.0-preview" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion docs/ai/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ items:
href: quickstarts/quickstart-openai-summarize-text.md
- name: Build a chat app
href: quickstarts/get-started-openai.md
- name: Create an app to chat about your data
- name: Build a .NET AI vector search app
href: quickstarts/quickstart-ai-chat-with-data.md
- name: Execute a local .NET function
href: quickstarts/quickstart-azure-openai-tool.md
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageReference Include="Moq" Version="[4.20.72]" /> <!-- Context: https://github.com/Azure/azure-sdk-for-net/issues/38111 -->
<PackageReference Include="NSubstitute" Version="5.3.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
1 change: 1 addition & 0 deletions docs/core/compatibility/9.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ If you're migrating an app to .NET 9, the breaking changes listed here might aff
| [API obsoletions with custom diagnostic IDs](core-libraries/9.0/obsolete-apis-with-custom-diagnostics.md) | Source incompatible | (Multiple) |
| [BigInteger maximum length](core-libraries/9.0/biginteger-limit.md) | Behavioral change | Preview 6 |
| [BinaryReader.GetString() returns "\uFFFD" on malformed sequences](core-libraries/9.0/binaryreader.md) | Behavioral change | Preview 7 |
| [C# overload resolution prefers `params` span-type overloads](core-libraries/9.0/params-overloads.md) | Source incompatible | |
| [Creating type of array of System.Void not allowed](core-libraries/9.0/type-instance.md) | Behavioral change | Preview 1 |
| [Default `Equals()` and `GetHashCode()` throw for types marked with `InlineArrayAttribute`](core-libraries/9.0/inlinearrayattribute.md) | Behavioral change | Preview 6 |
| [EnumConverter validates registered types to be enum](core-libraries/9.0/enumconverter.md) | Behavioral change | Preview 7 |
Expand Down
Loading
Loading