Skip to content

Commit 7e49f14

Browse files
Merge pull request #43438 from dotnet/main
Merge main into live
2 parents 4eb00d2 + ebc69da commit 7e49f14

File tree

14 files changed

+233
-19
lines changed

14 files changed

+233
-19
lines changed

docs/ai/ai-extensions.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
title: Unified AI building blocks for .NET
3+
description: Learn how to develop with unified AI building blocks for .NET using Microsoft.Extensions.AI and Microsoft.Extensions.AI.Abstractions libraries
4+
ms.date: 11/04/2024
5+
ms.topic: quickstart
6+
ms.custom: devx-track-dotnet, devx-track-dotnet-ai
7+
author: alexwolfmsft
8+
ms.author: alexwolf
9+
---
10+
11+
# Unified AI building blocks for .NET using Microsoft.Extensions.AI
12+
13+
The .NET ecosystem provides abstractions for integrating AI services into .NET applications and libraries using the [`Microsoft.Extensions.AI`](https://www.nuget.org/packages/Microsoft.Extensions.AI) and [`Microsoft.Extensions.AI.Abstractions`](https://www.nuget.org/packages/Microsoft.Extensions.AI.Abstractions) libraries. The .NET team also enhanced the core `Microsoft.Extensions.*` libraries with these abstractions for .NET Generative AI applications and libraries. In the sections ahead, you learn:
14+
15+
- Core concepts and capabilities of the `Microsoft.Extensions.AI` libraries.
16+
- How to work with AI abstractions in your apps and the benefits they offer.
17+
- Essential AI middleware concepts.
18+
19+
## What is the Microsoft.Extensions.AI library?
20+
21+
`Microsoft.Extensions.AI` is a set of core .NET libraries created in collaboration with developers across the .NET ecosystem, including Semantic Kernel. These libraries provide a unified layer of C# abstractions for interacting with AI services, such as small and large language models (SLMs and LLMs), embeddings, and middleware.
22+
23+
:::image type="content" source="media/ai-extensions/meai-architecture-diagram.png" alt-text="An architectural diagram of the AI extensions libraries.":::
24+
25+
`Microsoft.Extensions.AI` provides abstractions that can be implemented by various services, all adhering to the same core concepts. This library is not intended to provide APIs tailored to any specific provider's services. The goal of `Microsoft.Extensions.AI` is to act as a unifying layer within the .NET ecosystem, enabling developers to choose their preferred frameworks and libraries while ensuring seamless integration and collaboration across the ecosystem.
26+
27+
## Work with abstractions for common AI services
28+
29+
AI capabilities are rapidly evolving, with patterns emerging for common functionality:
30+
31+
- Chat features to conversationally prompt an AI for information or data analysis.
32+
- Embedding generation to integrate with vector search capabilities.
33+
- Tool calling to integrate with other services, platforms, or code.
34+
35+
The `Microsoft.Extensions.AI` library provides abstractions for these types of tasks, so developers can focus on coding against conceptual AI capabilities rather than specific platforms or provider implementations. Unified abstractions are crucial for developers to work effectively across different sources.
36+
37+
For example, the `IChatClient` interface allows consumption of language models from various providers, whether you're connecting to an Azure OpenAI service or running a local Ollama installation. Any .NET package that provides an AI client can implement the `IChatClient` interface, enabling seamless integration with consuming .NET code:
38+
39+
```csharp
40+
IChatClient client =
41+
    environment.IsDevelopment ?
42+
    new OllamaChatClient(...) :
43+
    new AzureAIInferenceChatClient(...);
44+
```
45+
46+
Then, regardless of the provider you're using, you can send requests as follows:
47+
48+
```csharp
49+
var response = await chatClient.CompleteAsync(
50+
      "Translate the following text into Pig Latin: I love .NET and AI");
51+
52+
Console.WriteLine(response.Message);
53+
```
54+
55+
These abstractions allow for idiomatic C# code for various scenarios with minimal code changes, whether you're using different services for development and production, addressing hybrid scenarios, or exploring other service providers.
56+
57+
Library authors who implement these abstractions make their clients interoperable with the broader `Microsoft.Extensions.AI` ecosystem. Service-specific APIs remain accessible if needed, allowing consumers to code against the standard abstractions and pass through to proprietary APIs only when required.
58+
59+
`Microsoft.Extensions.AI` provides implementations for the following services through additional packages:
60+
61+
- [OpenAI](https://aka.ms/meai-openai-nuget)
62+
- [Azure OpenAI](https://aka.ms/meai-openai-nuget)
63+
- [Azure AI Inference](https://aka.ms/meai-azaiinference-nuget)
64+
- [Ollama](https://aka.ms/meai-ollama-nuget)
65+
66+
In the future, implementations of these `Microsoft.Extensions.AI` abstractions will be part of the respective client libraries rather than requiring installation of additional packages.
67+
68+
## Middleware implementations for AI services
69+
70+
Connecting to and using AI services is just one aspect of building robust applications. Production-ready applications require additional features like telemetry, logging, and tool calling capabilities. The `Microsoft.Extensions.AI` abstractions enable you to easily integrate these components into your applications using familiar patterns.
71+
72+
The following sample demonstrates how to register an OpenAI `IChatClient`. `IChatClient` allows you to attach the capabilities in a consistent way across various providers.
73+
74+
```csharp
75+
app.Services.AddChatClient(builder => builder
76+
    .UseLogging()
77+
.UseFunctionInvocation()
78+
.UseDistributedCache()   
79+
.UseOpenTelemetry()
80+
    .Use(new OpenAIClient(...)).AsChatClient(...));
81+
```
82+
83+
The capabilities demonstrated in this snippet are included in the `Microsoft.Extensions.AI` library, but they are only a small subset of the capabilities that can be layered in with this approach. .NET developers are able to expose many types of middleware to create powerful AI functionality.
84+
85+
## Build with Microsoft.Extensions.AI
86+
87+
You can start building with `Microsoft.Extensions.AI` in the following ways:
88+
89+
- **Library Developers**: If you own libraries that provide clients for AI services, consider implementing the interfaces in your libraries. This allows users to easily integrate your NuGet package via the abstractions.
90+
- **Service Consumers**: If you're developing libraries that consume AI services, use the abstractions instead of hardcoding to a specific AI service. This approach gives your consumers the flexibility to choose their preferred service.
91+
- **Application Developers**: Use the abstractions to simplify integration into your apps. This enables portability across models and services, facilitates testing and mocking, leverages middleware provided by the ecosystem, and maintains a consistent API throughout your app, even if you use different services in different parts of your application.
92+
- **Ecosystem Contributors**: If you're interested in contributing to the ecosystem, consider writing custom middleware components.
93+
To get started, see the samples in the [dotnet/ai-samples](https://aka.ms/meai-samples) GitHub repository.
94+
95+
For an end-to-end sample using `Microsoft.Extensions.AI`, see [eShopSupport](https://github.com/dotnet/eShopSupport).
96+
97+
## Next steps
98+
99+
- [Build an AI chat app with .NET](./quickstarts/get-started-openai.md)
100+
- [Quickstart - Summarize text using Azure AI chat app with .NET](./quickstarts/quickstart-openai-summarize-text.md)

docs/ai/dotnet-ai-ecosystem.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ The .NET ecosystem provides many powerful tools, libraries, and services to deve
1313
> [!IMPORTANT]
1414
> Not all of the SDKs and services presented in this doc are maintained by Microsoft. When considering an SDK, make sure to evaluate its quality, licensing, support, and compatibility to ensure they meet your requirements.
1515
16+
## Microsoft.Extensions.AI library for .NET
17+
18+
[`Microsoft.Extensions.AI`](ai-extensions.md) is a set of core .NET libraries created in collaboration with developers across the .NET ecosystem, including Semantic Kernel. These libraries provide a unified layer of C# abstractions for interacting with AI services, such as small and large language models (SLMs and LLMs), embeddings, and middleware.
19+
20+
`Microsoft.Extensions.AI` provides abstractions that can be implemented by various services, all adhering to the same core concepts. This library is not intended to provide APIs tailored to any specific provider's services. The goal of `Microsoft.Extensions.AI` is to act as a unifying layer within the .NET ecosystem, enabling developers to choose their preferred frameworks and libraries while ensuring seamless integration and collaboration across the ecosystem.
21+
1622
## Semantic Kernel for .NET
1723

1824
[Semantic Kernel](semantic-kernel-dotnet-overview.md) is an open-source SDK that enables AI integration and orchestration capabilities in your .NET apps. This SDK is generally the recommended AI orchestration tool for .NET apps that use one or more AI services in combination with other APIs or web services, data stores, and custom code. Semantic Kernel benefits enterprise developers in the following ways:
97.9 KB
Loading

docs/ai/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ items:
55
href: get-started/dotnet-ai-overview.md
66
- name: Ecosystem tools and SDKs
77
href: dotnet-ai-ecosystem.md
8+
- name: Microsoft.Extensions.AI building blocks
9+
href: ai-extensions.md
810
- name: Learning resources and samples
911
href: azure-ai-for-dotnet-developers.md
1012
- name: What is Semantic Kernel?

docs/azure/includes/dotnet-all.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@
9393
| Schema Registry | NuGet [1.4.0](https://www.nuget.org/packages/Azure.Data.SchemaRegistry/1.4.0) | [docs](/dotnet/api/overview/azure/Data.SchemaRegistry-readme) | GitHub [1.4.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Data.SchemaRegistry_1.4.0/sdk/schemaregistry/Azure.Data.SchemaRegistry/) |
9494
| Schema Registry - Avro | NuGet [1.0.1](https://www.nuget.org/packages/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro/1.0.1) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro-readme) | GitHub [1.0.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro_1.0.1/sdk/schemaregistry/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro/) |
9595
| Service Bus | NuGet [7.18.2](https://www.nuget.org/packages/Azure.Messaging.ServiceBus/7.18.2) | [docs](/dotnet/api/overview/azure/Messaging.ServiceBus-readme) | GitHub [7.18.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Messaging.ServiceBus_7.18.2/sdk/servicebus/Azure.Messaging.ServiceBus/) |
96-
| Storage - Blobs | NuGet [12.22.2](https://www.nuget.org/packages/Azure.Storage.Blobs/12.22.2)<br>NuGet [12.23.0-beta.2](https://www.nuget.org/packages/Azure.Storage.Blobs/12.23.0-beta.2) | [docs](/dotnet/api/overview/azure/Storage.Blobs-readme) | GitHub [12.22.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs_12.22.2/sdk/storage/Azure.Storage.Blobs/)<br>GitHub [12.23.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs_12.23.0-beta.2/sdk/storage/Azure.Storage.Blobs/) |
97-
| Storage - Blobs Batch | NuGet [12.19.1](https://www.nuget.org/packages/Azure.Storage.Blobs.Batch/12.19.1)<br>NuGet [12.20.0-beta.2](https://www.nuget.org/packages/Azure.Storage.Blobs.Batch/12.20.0-beta.2) | [docs](/dotnet/api/overview/azure/Storage.Blobs.Batch-readme) | GitHub [12.19.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs.Batch_12.19.1/sdk/storage/Azure.Storage.Blobs.Batch/)<br>GitHub [12.20.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs.Batch_12.20.0-beta.2/sdk/storage/Azure.Storage.Blobs.Batch/) |
98-
| Storage - Blobs ChangeFeed | NuGet [12.0.0-preview.51](https://www.nuget.org/packages/Azure.Storage.Blobs.ChangeFeed/12.0.0-preview.51) | [docs](/dotnet/api/overview/azure/Storage.Blobs.ChangeFeed-readme?view=azure-dotnet-preview&amp;preserve-view=true) | GitHub [12.0.0-preview.51](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs.ChangeFeed_12.0.0-preview.51/sdk/storage/Azure.Storage.Blobs.ChangeFeed/) |
99-
| Storage - Files Data Lake | NuGet [12.20.1](https://www.nuget.org/packages/Azure.Storage.Files.DataLake/12.20.1)<br>NuGet [12.21.0-beta.2](https://www.nuget.org/packages/Azure.Storage.Files.DataLake/12.21.0-beta.2) | [docs](/dotnet/api/overview/azure/Storage.Files.DataLake-readme) | GitHub [12.20.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.DataLake_12.20.1/sdk/storage/Azure.Storage.Files.DataLake/)<br>GitHub [12.21.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.DataLake_12.21.0-beta.2/sdk/storage/Azure.Storage.Files.DataLake/) |
100-
| Storage - Files Share | NuGet [12.20.1](https://www.nuget.org/packages/Azure.Storage.Files.Shares/12.20.1)<br>NuGet [12.21.0-beta.2](https://www.nuget.org/packages/Azure.Storage.Files.Shares/12.21.0-beta.2) | [docs](/dotnet/api/overview/azure/Storage.Files.Shares-readme) | GitHub [12.20.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.Shares_12.20.1/sdk/storage/Azure.Storage.Files.Shares/)<br>GitHub [12.21.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.Shares_12.21.0-beta.2/sdk/storage/Azure.Storage.Files.Shares/) |
101-
| Storage - Queues | NuGet [12.20.1](https://www.nuget.org/packages/Azure.Storage.Queues/12.20.1)<br>NuGet [12.21.0-beta.2](https://www.nuget.org/packages/Azure.Storage.Queues/12.21.0-beta.2) | [docs](/dotnet/api/overview/azure/Storage.Queues-readme) | GitHub [12.20.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Queues_12.20.1/sdk/storage/Azure.Storage.Queues/)<br>GitHub [12.21.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Queues_12.21.0-beta.2/sdk/storage/Azure.Storage.Queues/) |
96+
| Storage - Blobs | NuGet [12.23.0](https://www.nuget.org/packages/Azure.Storage.Blobs/12.23.0) | [docs](/dotnet/api/overview/azure/Storage.Blobs-readme) | GitHub [12.23.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs_12.23.0/sdk/storage/Azure.Storage.Blobs/) |
97+
| Storage - Blobs Batch | NuGet [12.20.0](https://www.nuget.org/packages/Azure.Storage.Blobs.Batch/12.20.0) | [docs](/dotnet/api/overview/azure/Storage.Blobs.Batch-readme) | GitHub [12.20.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs.Batch_12.20.0/sdk/storage/Azure.Storage.Blobs.Batch/) |
98+
| Storage - Blobs ChangeFeed | NuGet [12.0.0-preview.52](https://www.nuget.org/packages/Azure.Storage.Blobs.ChangeFeed/12.0.0-preview.52) | [docs](/dotnet/api/overview/azure/Storage.Blobs.ChangeFeed-readme?view=azure-dotnet-preview&amp;preserve-view=true) | GitHub [12.0.0-preview.52](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs.ChangeFeed_12.0.0-preview.52/sdk/storage/Azure.Storage.Blobs.ChangeFeed/) |
99+
| Storage - Files Data Lake | NuGet [12.21.0](https://www.nuget.org/packages/Azure.Storage.Files.DataLake/12.21.0) | [docs](/dotnet/api/overview/azure/Storage.Files.DataLake-readme) | GitHub [12.21.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.DataLake_12.21.0/sdk/storage/Azure.Storage.Files.DataLake/) |
100+
| Storage - Files Share | NuGet [12.21.0](https://www.nuget.org/packages/Azure.Storage.Files.Shares/12.21.0) | [docs](/dotnet/api/overview/azure/Storage.Files.Shares-readme) | GitHub [12.21.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Files.Shares_12.21.0/sdk/storage/Azure.Storage.Files.Shares/) |
101+
| Storage - Queues | NuGet [12.21.0](https://www.nuget.org/packages/Azure.Storage.Queues/12.21.0) | [docs](/dotnet/api/overview/azure/Storage.Queues-readme) | GitHub [12.21.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Queues_12.21.0/sdk/storage/Azure.Storage.Queues/) |
102102
| Synapse - AccessControl | NuGet [1.0.0-preview.5](https://www.nuget.org/packages/Azure.Analytics.Synapse.AccessControl/1.0.0-preview.5) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.AccessControl-readme?view=azure-dotnet-preview&amp;preserve-view=true) | GitHub [1.0.0-preview.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.AccessControl_1.0.0-preview.5/sdk/synapse/Azure.Analytics.Synapse.AccessControl/) |
103103
| Synapse - Artifacts | NuGet [1.0.0-preview.20](https://www.nuget.org/packages/Azure.Analytics.Synapse.Artifacts/1.0.0-preview.20) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.Artifacts-readme?view=azure-dotnet-preview&amp;preserve-view=true) | GitHub [1.0.0-preview.20](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.Artifacts_1.0.0-preview.20/sdk/synapse/Azure.Analytics.Synapse.Artifacts/) |
104104
| Synapse - Managed Private Endpoints | NuGet [1.0.0-beta.5](https://www.nuget.org/packages/Azure.Analytics.Synapse.ManagedPrivateEndpoints/1.0.0-beta.5) | [docs](/dotnet/api/overview/azure/Analytics.Synapse.ManagedPrivateEndpoints-readme?view=azure-dotnet-preview&amp;preserve-view=true) | GitHub [1.0.0-beta.5](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Analytics.Synapse.ManagedPrivateEndpoints_1.0.0-beta.5/sdk/synapse/Azure.Analytics.Synapse.ManagedPrivateEndpoints/) |
@@ -122,7 +122,7 @@
122122
| Functions extension for Azure Tables | NuGet [1.3.2](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Tables/1.3.2) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.Tables-readme) | GitHub [1.3.2](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.WebJobs.Extensions.Tables_1.3.2/sdk/tables/Microsoft.Azure.WebJobs.Extensions.Tables/) |
123123
| Key Encryptor for .NET Data Protection | NuGet [1.2.4](https://www.nuget.org/packages/Azure.Extensions.AspNetCore.DataProtection.Keys/1.2.4) | [docs](/dotnet/api/overview/azure/Extensions.AspNetCore.DataProtection.Keys-readme) | GitHub [1.2.4](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Extensions.AspNetCore.DataProtection.Keys_1.2.4/sdk/extensions/Azure.Extensions.AspNetCore.DataProtection.Keys/) |
124124
| Secrets Configuration Provider for .NET | NuGet [1.3.2](https://www.nuget.org/packages/Azure.Extensions.AspNetCore.Configuration.Secrets/1.3.2) | [docs](/dotnet/api/overview/azure/Extensions.AspNetCore.Configuration.Secrets-readme) | GitHub [1.3.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Extensions.AspNetCore.Configuration.Secrets_1.3.2/sdk/extensions/Azure.Extensions.AspNetCore.Configuration.Secrets/) |
125-
| Storage - Common | NuGet [12.21.1](https://www.nuget.org/packages/Azure.Storage.Common/12.21.1)<br>NuGet [12.22.0-beta.2](https://www.nuget.org/packages/Azure.Storage.Common/12.22.0-beta.2) | [docs](/dotnet/api/overview/azure/Storage.Common-readme) | GitHub [12.21.1](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Common_12.21.1/sdk/storage/Azure.Storage.Common/)<br>GitHub [12.22.0-beta.2](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Common_12.22.0-beta.2/sdk/storage/Azure.Storage.Common/) |
125+
| Storage - Common | NuGet [12.22.0](https://www.nuget.org/packages/Azure.Storage.Common/12.22.0) | [docs](/dotnet/api/overview/azure/Storage.Common-readme) | GitHub [12.22.0](https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Common_12.22.0/sdk/storage/Azure.Storage.Common/) |
126126
| WebJobs Extensions - Event Grid | NuGet [3.4.2](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.EventGrid/3.4.2) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.EventGrid-readme) | GitHub [3.4.2](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.WebJobs.Extensions.EventGrid_3.4.2/sdk/eventgrid/Microsoft.Azure.WebJobs.Extensions.EventGrid/) |
127127
| WebJobs Extensions - Event Hubs | NuGet [6.3.5](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.EventHubs/6.3.5) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.EventHubs-readme) | GitHub [6.3.5](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.WebJobs.Extensions.EventHubs_6.3.5/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/) |
128128
| WebJobs Extensions - Service Bus | NuGet [5.16.4](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.ServiceBus/5.16.4) | [docs](/dotnet/api/overview/azure/Microsoft.Azure.WebJobs.Extensions.ServiceBus-readme) | GitHub [5.16.4](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.WebJobs.Extensions.ServiceBus_5.16.4/sdk/servicebus/Microsoft.Azure.WebJobs.Extensions.ServiceBus/) |

0 commit comments

Comments
 (0)