AI Samples for .NET: Integrating AI into Your .NET Applications

Summary
The AI Samples for .NET repository provides a comprehensive collection of samples demonstrating how to integrate artificial intelligence into .NET applications. It features examples using Microsoft.Extensions.AI for unified API access to AI services and Microsoft.Extensions.AI.Evaluation for assessing LLM response quality. This resource is ideal for .NET developers looking to leverage AI, including large language models, in their projects.
Repository Info
Introduction
The dotnet/ai-samples repository is the official home for .NET samples that showcase how to effectively use AI in your .NET applications. Whether you are new to AI or looking to deepen your understanding, this repository offers a structured path to learning, starting from foundational concepts and progressing to more advanced topics. It primarily focuses on Microsoft.Extensions.AI and Microsoft.Extensions.AI.Evaluation, providing practical examples for various AI scenarios.
Microsoft.Extensions.AI
Microsoft.Extensions.AI is a set of core .NET libraries developed in collaboration with the .NET ecosystem, including Semantic Kernel. These libraries offer a unified layer of C# abstractions for interacting with diverse AI services, such as small and large language models (SLMs and LLMs) and embeddings. Key benefits include a consistent API, flexibility to use any AI provider, ease of use for developers, and improved componentization.
Microsoft.Extensions.AI.Evaluation
Microsoft.Extensions.AI.Evaluation provides .NET libraries with tools to evaluate the quality and efficacy of LLM responses in intelligent applications. Built upon the core AI abstractions from Microsoft.Extensions.AI, these libraries help ensure the reliability and performance of your AI-powered features.
Getting Started
To begin exploring the AI samples, you should clone the repository to your local machine. Each sample typically includes its own README.md file with specific instructions for setup and execution.
git clone https://github.com/dotnet/ai-samples.git
cd ai-samples
Ensure you have the necessary .NET SDK installed. Individual samples may require API keys for services like OpenAI or Azure OpenAI, which you will need to configure according to their respective documentation.
Examples and Quickstarts
The repository is rich with practical examples, categorized for easy navigation. Each link points directly to the relevant README.md within the GitHub repository for detailed instructions.
Microsoft.Extensions.AI Implementations
- Abstraction implementations: GitHub Link
- Azure OpenAI: GitHub Link
- OpenAI: GitHub Link
- Azure AI Inference: GitHub Link
- Ollama: GitHub Link
Microsoft.Extensions.AI.Evaluation Examples
- API Usage Examples: GitHub Link
Quickstarts using OpenAI
- Text Summary: Hike Benefits Summary Project
- Chat App: Hiker AI Project
- Function Calling: Hiker AI Pro
Quickstarts using the Azure OpenAI SDK
- Text Summary: Hike Benefits Summary Project
- Chat App: Hiker AI Project
- Function Calling: Hiker AI Pro
Chat Samples
- Customer Support: Customer Support Project
Build 2024 Tutorial
Follow along with the "Infusing your .NET Apps with AI: Practical Tools and Techniques" session from Build 2024. This tutorial covers integrating LLMs and other AI capabilities into .NET applications.
- YouTube Video: Infusing your .NET Apps with AI: Practical Tools and Techniques
- Tutorial steps, with links to both YouTube and GitHub:
- Hello Semantic Kernel: YouTube (3m 0s), GitHub
- Add Chat History: YouTube (5m 40s), GitHub
- Add Plugin - Function Call: YouTube (7m 10s), GitHub
- Add Logging: YouTube (9m 24s), GitHub
- Add Plugin - Bing Search: YouTube (11m 15s), GitHub
- Modify Kernel Behavior with Dependency Injection: YouTube (12m 37s), GitHub
- Using Semantic Kernel in a Web App: YouTube (15m 57s), GitHub
Why Use AI Samples for .NET?
This repository is an invaluable resource for .NET developers for several reasons:
- Practical Learning: Provides hands-on examples to understand and implement AI concepts in C#.
- Unified Abstractions: Showcases
Microsoft.Extensions.AI, which offers a consistent and standard set of APIs for integrating various AI services, reducing complexity. - Flexibility: Demonstrates how to build AI applications that are provider-agnostic, allowing easy switching between different AI services like OpenAI, Azure OpenAI, and Ollama.
- Evaluation Tools: Introduces
Microsoft.Extensions.AI.Evaluationfor robust testing and quality assurance of AI application responses. - Community and Best Practices: Aligns with the .NET ecosystem and promotes best practices for AI integration.
Useful Links
- GitHub Repository: dotnet/ai-samples
- Introducing Microsoft.Extensions.AI Preview blog post: Read the blog post
- Evaluate the quality of your AI applications with ease blog post: Read the blog post
- Build 2024 YouTube Video: Infusing your .NET Apps with AI: Practical Tools and Techniques
- Code of Conduct: The .NET Foundation Code of Conduct