Projects
NET library that provides platform developers with a cohesive C# abstraction layer that simplifies interaction with AI services such as Large Language Models (LLMs) and embedding. It supports the seamless integration of AI functionality into .NET applications through a consistent and standardized set of APIs and conventions.
Note: Currently
Still in preview, the library is expected to remain in preview until the .NET 9 release in November 2024 (where feedback needs to be gathered), patiently waiting for the official release from Microsoft!
Project Features
- Unified API: Provides a consistent set of APIs and conventions for integrating AI services into .NET applications.
- Flexibility: Allows .NET library authors to use AI services without being tied to a specific provider, making them available to any provider.
- Ease of Use: Enables .NET developers to experiment with different packages using the same underlying abstractions and maintain a single API throughout the application.
- Componentization: simplifies the addition of new features and facilitates the componentization and testing of applications.
Project role
The class library not only simplifies the integration of AI functionality, but also fosters innovation in the .NET ecosystem. It allows developers to focus more on the business logic and functional implementation of their applications without having to spend a lot of time and effort on the integration and debugging of AI services.
Project NuGet Package
- /packages/
command to install:
dotnet add package --version 9.0.0-preview.9.24556.5
Common Abstractions for AI Services
The IChatClient interface allows the use of a language model, either hosted remotely or running locally. Any .NET package that provides an AI client can implement this interface for seamless integration with the .NET code being used.
public interface IChatClient : IDisposable
{
Task<ChatCompletion> CompleteAsync(...);
IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync(...);
ChatClientMetadata Metadata { get; }
TService? GetService<TService>(object? key = null) where TService : class;
}
OpenAI
using OpenAI;
using ;
IChatClient client =
new OpenAIClient(("OPENAI_API_KEY"))
.AsChatClient(modelId: "gpt-4o-mini");
var response = await ("What is C#?") ;
();
Azure OpenAI
using ;
using ;
using ;
IChatClient client =
new AzureOpenAIClient(
new Uri(("AZURE_OPENAI_ENDPOINT")),
new DefaultAzureCredential())
.AsChatClient(modelId: "gpt-4o-mini");
var response = await ("What is C#?") ;
();
reference article
- /dotnet/introducing-microsoft-extensions-ai-preview
Project source code address
More useful features and characteristics of the project welcome to the project open source address to view 👀, do not forget to give the project a Star support 💖.
- Open source address:/dotnet/extensions
A selection of great projects and frameworks
This project has been included in the C#/.NET/.NET Core Excellent Projects and Frameworks Selection, focusing on the excellent projects and frameworks selection can let you keep abreast of the latest developments and best practices in the field of C#, .NET and .NET Core, and improve the efficiency and quality of development work. The pit has been dug, you are welcome to submit PR recommendations or self-recommendation (so that excellent projects and frameworks are not buried 🤞).
- GitHub open source address:/YSGStudyHards/DotNetGuide/blob/main/docs/DotNet/
- Gitee open source address:/ysgdaydayup/DotNetGuide/blob/main/docs/DotNet/