Skip to content

Commit c055eca

Browse files
Merge pull request #45372 from dotnet/main
Merge main into live
2 parents 83b143e + 5e2a32f commit c055eca

File tree

44 files changed

+193
-225
lines changed

Some content is hidden

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

44 files changed

+193
-225
lines changed

docs/ai/how-to/snippets/content-filtering/AIContentFiltering.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
<ItemGroup>
1111
<PackageReference Include="Azure.AI.OpenAI" />
12-
<PackageReference Include="Azure.Identity" />
13-
<PackageReference Include="Microsoft.Extensions.AI" Version="9.3.0-preview.1.25114.11" />
14-
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="9.3.0-preview.1.25114.11" />
12+
<PackageReference Include="Azure.Identity" Version="1.13.2" />
13+
<PackageReference Include="Microsoft.Extensions.AI" Version="9.3.0-preview.1.25161.3" />
14+
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="9.3.0-preview.1.25161.3" />
1515
</ItemGroup>
1616

1717
</Project>

docs/ai/how-to/snippets/content-filtering/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{
1212
ChatResponse completion = await client.GetResponseAsync("YOUR_PROMPT");
1313

14-
Console.WriteLine(completion.Message);
14+
Console.WriteLine(completion.Messages.Single());
1515
}
1616
catch (Exception e)
1717
{

docs/ai/quickstarts/evaluate-ai-response.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Complete the following steps to create an MSTest project that connects to your l
9090

9191
- Sets up the <xref:Microsoft.Extensions.AI.Evaluation.ChatConfiguration>.
9292
- Sets the <xref:Microsoft.Extensions.AI.ChatOptions>, including the <xref:Microsoft.Extensions.AI.ChatOptions.Temperature> and the <xref:Microsoft.Extensions.AI.ChatOptions.ResponseFormat>.
93-
- Fetches the response to be evaluated by calling <xref:Microsoft.Extensions.AI.IChatClient.GetResponseAsync(System.Collections.Generic.IList{Microsoft.Extensions.AI.ChatMessage},Microsoft.Extensions.AI.ChatOptions,System.Threading.CancellationToken)>, and stores it in a static variable.
93+
- Fetches the response to be evaluated by calling <xref:Microsoft.Extensions.AI.IChatClient.GetResponseAsync(System.Collections.Generic.IEnumerable{Microsoft.Extensions.AI.ChatMessage},Microsoft.Extensions.AI.ChatOptions,System.Threading.CancellationToken)>, and stores it in a static variable.
9494

9595
1. Add the `GetOllamaChatConfiguration` method, which creates the <xref:Microsoft.Extensions.AI.IChatClient> that the evaluator uses to communicate with the model.
9696

@@ -102,7 +102,7 @@ Complete the following steps to create an MSTest project that connects to your l
102102
103103
This method does the following:
104104
105-
- Invokes the <xref:Microsoft.Extensions.AI.Evaluation.Quality.CoherenceEvaluator> to evaluate the *coherence* of the response. The <xref:Microsoft.Extensions.AI.Evaluation.IEvaluator.EvaluateAsync(System.Collections.Generic.IEnumerable{Microsoft.Extensions.AI.ChatMessage},Microsoft.Extensions.AI.ChatMessage,Microsoft.Extensions.AI.Evaluation.ChatConfiguration,System.Collections.Generic.IEnumerable{Microsoft.Extensions.AI.Evaluation.EvaluationContext},System.Threading.CancellationToken)> method returns an <xref:Microsoft.Extensions.AI.Evaluation.EvaluationResult> that contains a <xref:Microsoft.Extensions.AI.Evaluation.NumericMetric>. A `NumericMetric` contains a numeric value that's typically used to represent numeric scores that fall within a well-defined range.
105+
- Invokes the <xref:Microsoft.Extensions.AI.Evaluation.Quality.CoherenceEvaluator> to evaluate the *coherence* of the response. The <xref:Microsoft.Extensions.AI.Evaluation.IEvaluator.EvaluateAsync(System.Collections.Generic.IEnumerable{Microsoft.Extensions.AI.ChatMessage},Microsoft.Extensions.AI.ChatResponse,Microsoft.Extensions.AI.Evaluation.ChatConfiguration,System.Collections.Generic.IEnumerable{Microsoft.Extensions.AI.Evaluation.EvaluationContext},System.Threading.CancellationToken)> method returns an <xref:Microsoft.Extensions.AI.Evaluation.EvaluationResult> that contains a <xref:Microsoft.Extensions.AI.Evaluation.NumericMetric>. A `NumericMetric` contains a numeric value that's typically used to represent numeric scores that fall within a well-defined range.
106106
- Retrieves the coherence score from the <xref:Microsoft.Extensions.AI.Evaluation.EvaluationResult>.
107107
- Validates the *default interpretation* for the returned coherence metric. Evaluators can include a default interpretation for the metrics they return. You can also change the default interpretation to suit your specific requirements, if needed.
108108
- Validates that no diagnostics are present on the returned coherence metric. Evaluators can include diagnostics on the metrics they return to indicate errors, warnings, or other exceptional conditions encountered during evaluation.

docs/ai/quickstarts/snippets/chat-with-data/azure-openai/CloudService.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
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;
72

83
namespace VectorDataAI
94
{

docs/ai/quickstarts/snippets/chat-with-data/azure-openai/Program.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using Azure.AI.OpenAI;
22
using Azure.Identity;
33
using Microsoft.Extensions.AI;
4-
using Microsoft.Extensions.VectorData;
54
using Microsoft.Extensions.Configuration;
5+
using Microsoft.Extensions.VectorData;
66
using Microsoft.SemanticKernel.Connectors.InMemory;
77
using VectorDataAI;
88

@@ -60,26 +60,26 @@
6060

6161
// Create and populate the vector store
6262
var vectorStore = new InMemoryVectorStore();
63-
var cloudServicesStore = vectorStore.GetCollection<int, CloudService>("cloudServices");
63+
Microsoft.Extensions.VectorData.IVectorStoreRecordCollection<int, CloudService> cloudServicesStore = vectorStore.GetCollection<int, CloudService>("cloudServices");
6464
await cloudServicesStore.CreateCollectionIfNotExistsAsync();
6565

66-
foreach (var service in cloudServices)
66+
foreach (CloudService service in cloudServices)
6767
{
6868
service.Vector = await generator.GenerateEmbeddingVectorAsync(service.Description);
6969
await cloudServicesStore.UpsertAsync(service);
7070
}
7171

7272
// 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);
73+
string query = "Which Azure service should I use to store my Word documents?";
74+
ReadOnlyMemory<float> queryEmbedding = await generator.GenerateEmbeddingVectorAsync(query);
7575

76-
var results = await cloudServicesStore.VectorizedSearchAsync(queryEmbedding, new VectorSearchOptions()
76+
VectorSearchResults<CloudService> results =
77+
await cloudServicesStore.VectorizedSearchAsync(queryEmbedding, new VectorSearchOptions<CloudService>()
7778
{
78-
Top = 1,
79-
VectorPropertyName = "Vector"
79+
Top = 1
8080
});
8181

82-
await foreach (var result in results.Results)
82+
await foreach (VectorSearchResult<CloudService> result in results.Results)
8383
{
8484
Console.WriteLine($"Name: {result.Record.Name}");
8585
Console.WriteLine($"Description: {result.Record.Description}");

docs/ai/quickstarts/snippets/chat-with-data/azure-openai/VectorDataAI.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
<ItemGroup>
1111
<PackageReference Include="Azure.Identity" Version="1.13.2" />
1212
<PackageReference Include="Azure.AI.OpenAI" Version="2.1.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.25078.1" />
15-
<PackageReference Include="Microsoft.SemanticKernel.Connectors.InMemory" Version="1.31.0-preview" />
16-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.2" />
17-
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.2" />
13+
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="9.3.0-preview.1.25161.3" />
14+
<PackageReference Include="Microsoft.Extensions.VectorData.Abstractions" Version="9.0.0-preview.1.25161.1" />
15+
<PackageReference Include="Microsoft.SemanticKernel.Connectors.InMemory" Version="1.41.0-preview" />
16+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.0-preview.1.25080.5" />
17+
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="10.0.0-preview.1.25080.5" />
1818
</ItemGroup>
1919

2020
</Project>

docs/ai/quickstarts/snippets/chat-with-data/openai/CloudService.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
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;
72

83
namespace VectorDataAI
94
{

docs/ai/quickstarts/snippets/chat-with-data/openai/Program.cs

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,77 @@
1-
using Microsoft.Extensions.AI;
2-
using OpenAI;
1+
using System.ClientModel;
2+
using Microsoft.Extensions.AI;
3+
using Microsoft.Extensions.Configuration;
34
using Microsoft.Extensions.VectorData;
45
using Microsoft.SemanticKernel.Connectors.InMemory;
6+
using OpenAI;
57
using VectorDataAI;
6-
using System.ClientModel;
7-
using Microsoft.Extensions.Configuration;
88

99
var cloudServices = new List<CloudService>()
1010
{
11-
new CloudService
12-
{
11+
new() {
1312
Key=0,
1413
Name="Azure App Service",
1514
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."
1615
},
17-
new CloudService
18-
{
16+
new() {
1917
Key=1,
2018
Name="Azure Service Bus",
2119
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."
2220
},
23-
new CloudService
24-
{
21+
new() {
2522
Key=2,
2623
Name="Azure Blob Storage",
2724
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."
2825
},
29-
new CloudService
30-
{
26+
new() {
3127
Key=3,
3228
Name="Microsoft Entra ID",
3329
Description="Manage user identities and control access to your apps, data, and resources.."
3430
},
35-
new CloudService
36-
{
31+
new() {
3732
Key=4,
3833
Name="Azure Key Vault",
3934
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."
4035
},
41-
new CloudService
42-
{
36+
new() {
4337
Key=5,
4438
Name="Azure AI Search",
4539
Description="Information retrieval at scale for traditional and conversational search applications, with security and options for AI enrichment and vectorization."
4640
}
4741
};
4842

49-
// Load the configuration values
50-
var config = new ConfigurationBuilder().AddUserSecrets<Program>().Build();
43+
// Load the configuration values.
44+
IConfigurationRoot config = new ConfigurationBuilder().AddUserSecrets<Program>().Build();
5145
string model = config["ModelName"];
5246
string key = config["OpenAIKey"];
5347

54-
// Create the embedding generator
48+
// Create the embedding generator.
5549
IEmbeddingGenerator<string, Embedding<float>> generator =
5650
new OpenAIClient(new ApiKeyCredential(key))
5751
.AsEmbeddingGenerator(modelId: model);
5852

59-
// Create and populate the vector store
53+
// Create and populate the vector store.
6054
var vectorStore = new InMemoryVectorStore();
61-
var cloudServicesStore = vectorStore.GetCollection<int, CloudService>("cloudServices");
55+
IVectorStoreRecordCollection<int, CloudService> cloudServicesStore = vectorStore.GetCollection<int, CloudService>("cloudServices");
6256
await cloudServicesStore.CreateCollectionIfNotExistsAsync();
6357

64-
foreach (var service in cloudServices)
58+
foreach (CloudService service in cloudServices)
6559
{
6660
service.Vector = await generator.GenerateEmbeddingVectorAsync(service.Description);
6761
await cloudServicesStore.UpsertAsync(service);
6862
}
6963

70-
// Convert a search query to a vector and search the vector store
71-
var query = "Which Azure service should I use to store my Word documents?";
72-
var queryEmbedding = await generator.GenerateEmbeddingVectorAsync(query);
64+
// Convert a search query to a vector and search the vector store.
65+
string query = "Which Azure service should I use to store my Word documents?";
66+
ReadOnlyMemory<float> queryEmbedding = await generator.GenerateEmbeddingVectorAsync(query);
7367

74-
var results = await cloudServicesStore.VectorizedSearchAsync(queryEmbedding, new VectorSearchOptions()
68+
VectorSearchResults<CloudService> results =
69+
await cloudServicesStore.VectorizedSearchAsync(queryEmbedding, new VectorSearchOptions<CloudService>()
7570
{
76-
Top = 1,
77-
VectorPropertyName = "Vector"
71+
Top = 1
7872
});
7973

80-
await foreach (var result in results.Results)
74+
await foreach (VectorSearchResult<CloudService> result in results.Results)
8175
{
8276
Console.WriteLine($"Name: {result.Record.Name}");
8377
Console.WriteLine($"Description: {result.Record.Description}");

docs/ai/quickstarts/snippets/chat-with-data/openai/VectorDataAI.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="9.0.1-preview.1.24570.5" />
12-
<PackageReference Include="Microsoft.Extensions.VectorData.Abstractions" Version="9.0.0-preview.1.25078.1" />
13-
<PackageReference Include="Microsoft.SemanticKernel.Connectors.InMemory" Version="1.31.0-preview" />
14-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.2" />
15-
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.2" />
11+
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="9.3.0-preview.1.25161.3" />
12+
<PackageReference Include="Microsoft.Extensions.VectorData.Abstractions" Version="9.0.0-preview.1.25161.1" />
13+
<PackageReference Include="Microsoft.SemanticKernel.Connectors.InMemory" Version="1.41.0-preview" />
14+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.0-preview.1.25080.5" />
15+
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="10.0.0-preview.1.25080.5" />
1616
</ItemGroup>
1717

1818
</Project>

docs/ai/quickstarts/snippets/function-calling/openai/FunctionCallingAI.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.Extensions.AI" Version="9.3.0-preview.1.25114.11" />
12-
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="9.3.0-preview.1.25114.11" />
13-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.2" />
14-
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.2" />
11+
<PackageReference Include="Microsoft.Extensions.AI" Version="9.3.0-preview.1.25161.3" />
12+
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="9.3.0-preview.1.25161.3" />
13+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.0-preview.1.25080.5" />
14+
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="10.0.0-preview.1.25080.5" />
1515
</ItemGroup>
1616

1717
</Project>

0 commit comments

Comments
 (0)