Skip to content

Commit 0d3fe88

Browse files
Merge pull request #44029 from dotnet/main
Merge main into live
2 parents d191744 + 091a6ae commit 0d3fe88

File tree

91 files changed

+1119
-1044
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+1119
-1044
lines changed

.github/workflows/profanity-filter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525

2626
- name: Profanity filter
2727
if: ${{ github.actor != 'dependabot[bot]' && github.actor != 'github-actions[bot]' }}
28-
uses: IEvangelist/profanity-filter@8ed64a0b6652c314f0e2519a86ae234c6df63698 # main
28+
uses: IEvangelist/profanity-filter@b51302be6fd09006f6b0a5ec4c573542fc8fa7bf # main
2929
id: profanity-filter
3030
with:
3131
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/scorecards.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ jobs:
6363
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
6464
# format to the repository Actions tab.
6565
- name: "Upload artifact"
66-
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
66+
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
6767
with:
6868
name: SARIF file
6969
path: results.sarif
7070
retention-days: 5
7171

7272
# Upload the results to GitHub's code scanning dashboard.
7373
- name: "Upload to code-scanning"
74-
uses: github/codeql-action/upload-sarif@babb554ede22fd5605947329c4d04d8e7a0b8155 # v3.27.7
74+
uses: github/codeql-action/upload-sarif@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
7575
with:
7676
sarif_file: results.sarif

.openpublishing.redirection.machine-learning.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
"redirect_url": "/dotnet/machine-learning/how-does-mldotnet-work",
1010
"redirect_document_id": true
1111
},
12+
{
13+
"source_path_from_root": "/docs/machine-learning/how-does-mldotnet-work.md",
14+
"redirect_url": "/dotnet/machine-learning/mldotnet-api",
15+
"redirect_document_id": true
16+
},
1217
{
1318
"source_path_from_root": "/docs/machine-learning/how-to-guides/consuming-model-ml-net.md",
1419
"redirect_url": "/dotnet/machine-learning/how-to-guides/save-load-machine-learning-models-ml-net",
@@ -80,6 +85,11 @@
8085
"source_path_from_root": "/docs/machine-learning/resources/what-is-mldotnet.md",
8186
"redirect_url": "/dotnet/machine-learning/how-does-mldotnet-work"
8287
},
88+
{
89+
"source_path_from_root": "/docs/machine-learning/resources/index.md",
90+
"redirect_url": "/dotnet/machine-learning/resources/glossary",
91+
"redirect_document_id": true
92+
},
8393
{
8494
"source_path_from_root": "/docs/machine-learning/tutorials/ml-cli.md",
8595
"redirect_url": "/dotnet/machine-learning/tutorials/sentiment-analysis-cli",

docs/ai/quickstarts/includes/prerequisites-azure-openai.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.topic: include
77

88
## Prerequisites
99

10-
- .NET 8 SDK - [Install the .NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0).
10+
- .NET 8.0 SDK or higher - [Install the .NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0).
1111
- An Azure subscription - [Create one for free](https://azure.microsoft.com/free).
1212
- Access to [Azure OpenAI service](/azure/ai-services/openai/overview#how-do-i-get-access-to-azure-openai).
1313
- Azure Developer CLI (Optional) - [Install or update the Azure Developer CLI](/azure/developer/azure-developer-cli/install-azd).

docs/ai/quickstarts/includes/prerequisites-openai.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ ms.topic: include
77

88
## Prerequisites
99

10-
- .NET 8.0 SDK - [Install the .NET 8.0 SDK](https://dotnet.microsoft.com/download/dotnet/8.0).
10+
- .NET 8.0 SDK or higher - [Install the .NET 8.0 SDK](https://dotnet.microsoft.com/download/dotnet/8.0).
1111
- An [API key from OpenAI](https://platform.openai.com/docs/quickstart/account-setup) so you can run this sample.
12-
- 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`.

docs/ai/quickstarts/quickstart-ai-chat-with-data.md

Lines changed: 112 additions & 138 deletions
Large diffs are not rendered by default.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Microsoft.Extensions.VectorData;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace VectorDataAI
9+
{
10+
internal class CloudService
11+
{
12+
[VectorStoreRecordKey]
13+
public int Key { get; set; }
14+
15+
[VectorStoreRecordData]
16+
public string Name { get; set; }
17+
18+
[VectorStoreRecordData]
19+
public string Description { get; set; }
20+
21+
[VectorStoreRecordVector(384, DistanceFunction.CosineSimilarity)]
22+
public ReadOnlyMemory<float> Vector { get; set; }
23+
}
24+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
using Azure.AI.OpenAI;
2+
using Azure.Identity;
3+
using Microsoft.Extensions.AI;
4+
using Microsoft.Extensions.VectorData;
5+
using Microsoft.Extensions.Configuration;
6+
using Microsoft.SemanticKernel.Connectors.InMemory;
7+
using VectorDataAI;
8+
9+
var cloudServices = new List<CloudService>()
10+
{
11+
new CloudService
12+
{
13+
Key=0,
14+
Name="Azure App Service",
15+
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."
16+
},
17+
new CloudService
18+
{
19+
Key=1,
20+
Name="Azure Service Bus",
21+
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."
22+
},
23+
new CloudService
24+
{
25+
Key=2,
26+
Name="Azure Blob Storage",
27+
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."
28+
},
29+
new CloudService
30+
{
31+
Key=3,
32+
Name="Microsoft Entra ID",
33+
Description="Manage user identities and control access to your apps, data, and resources.."
34+
},
35+
new CloudService
36+
{
37+
Key=4,
38+
Name="Azure Key Vault",
39+
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."
40+
},
41+
new CloudService
42+
{
43+
Key=5,
44+
Name="Azure AI Search",
45+
Description="Information retrieval at scale for traditional and conversational search applications, with security and options for AI enrichment and vectorization."
46+
}
47+
};
48+
49+
// Load the configuration values
50+
var config = new ConfigurationBuilder().AddUserSecrets<Program>().Build();
51+
string endpoint = config["AZURE_OPENAI_ENDPOINT"];
52+
string model = config["AZURE_OPENAI_GPT_NAME"];
53+
54+
// Create the embedding generator
55+
IEmbeddingGenerator<string, Embedding<float>> generator =
56+
new AzureOpenAIClient(
57+
new Uri(endpoint),
58+
new DefaultAzureCredential())
59+
.AsEmbeddingGenerator(modelId: model);
60+
61+
// Create and populate the vector store
62+
var vectorStore = new InMemoryVectorStore();
63+
var cloudServicesStore = vectorStore.GetCollection<int, CloudService>("cloudServices");
64+
await cloudServicesStore.CreateCollectionIfNotExistsAsync();
65+
66+
foreach (var service in cloudServices)
67+
{
68+
service.Vector = await generator.GenerateEmbeddingVectorAsync(service.Description);
69+
await cloudServicesStore.UpsertAsync(service);
70+
}
71+
72+
// Convert a search query to a vector and search the vector store
73+
var query = "Which Azure service should I use to store my Word documents?";
74+
var queryEmbedding = await generator.GenerateEmbeddingVectorAsync(query);
75+
76+
var results = await cloudServicesStore.VectorizedSearchAsync(queryEmbedding, new VectorSearchOptions()
77+
{
78+
Top = 1,
79+
VectorPropertyName = "Vector"
80+
});
81+
82+
await foreach (var result in results.Results)
83+
{
84+
Console.WriteLine($"Name: {result.Record.Name}");
85+
Console.WriteLine($"Description: {result.Record.Description}");
86+
Console.WriteLine($"Vector match score: {result.Score}");
87+
Console.WriteLine();
88+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Azure.Identity" Version="1.13.1" />
12+
<PackageReference Include="Azure.AI.OpenAI" Version="2.0.0" />
13+
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="9.0.1-preview.1.24570.5" />
14+
<PackageReference Include="Microsoft.Extensions.VectorData.Abstractions" Version="9.0.0-preview.1.24523.1" />
15+
<PackageReference Include="Microsoft.SemanticKernel.Connectors.InMemory" Version="1.31.0-preview" />
16+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
17+
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.0" />
18+
</ItemGroup>
19+
20+
</Project>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Microsoft.Extensions.VectorData;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace VectorDataAI
9+
{
10+
internal class CloudService
11+
{
12+
[VectorStoreRecordKey]
13+
public int Key { get; set; }
14+
15+
[VectorStoreRecordData]
16+
public string Name { get; set; }
17+
18+
[VectorStoreRecordData]
19+
public string Description { get; set; }
20+
21+
[VectorStoreRecordVector(384, DistanceFunction.CosineSimilarity)]
22+
public ReadOnlyMemory<float> Vector { get; set; }
23+
}
24+
}

0 commit comments

Comments
 (0)