How dotnet/ai-samples works
Project Type and Purpose
• This is a “monorepo” of .NET AI samples, not a single running application. It illustrates:
• Core AI abstractions via Microsoft.Extensions.AI
• Provider implementations (Azure OpenAI, OpenAI, Azure AI Inference, Ollama, local LLM)
• Evaluation tooling (Microsoft.Extensions.AI.Evaluation / llm-eval)
• Guided quickstarts and tutorials (semantic-kernel, Azure SDK, OpenAI SDK)
• A standalone chat sample for customer support
• Its goal is educational: show developers how to integrate and evaluate AI services in .NET.
File Structure Analysis
• Top-level “src” contains first-class folders:
• azure-openai-sdk
• build-2024 (Semantic Kernel tutorials)
• chat (CustomerSupport app)
• llm-eval (evaluation core/data/outputs/tests + QACreator/UserStoryCreator)
• local-models (phi3-llama3 local inference)
• microsoft-extensions-ai (abstractions + provider examples + WebAPIs)
• quickstarts (Azure-openai and OpenAI samples + infra Bicep definitions)
• Each folder is a .NET solution or independent csproj; patterns: sample → Program.cs, README.md.
• Configuration files: Bicep and Azure YAML under quickstarts/infra, devcontainer configs, solution files.
Key Architectural Insights from README
• Microsoft.Extensions.AI: core abstractions (chat, embeddings)
• Provider implementations: allow substituting any AI backend
• Evaluation libraries build on top of abstractions
• Tutorials layer demonstrations on top of both abstractions and providers
• Quickstarts include IaC (Bicep) to provision Azure resources
a. Main Components
1. Core Abstraction Layer
– Microsoft.Extensions.AI (abstractions)
2. Provider Implementations
– Azure OpenAI SDK
– OpenAI SDK
– Azure AI Inference
– Ollama
– local-models
3. Evaluation Layer
– Microsoft.Extensions.AI.Evaluation / llm-eval (core, data, outputs, tests)
4. Sample / Tutorial Apps
– Quickstarts (Azure-openai & OpenAI)
– Build-2024 (Semantic Kernel tutorials)
– Chat: CustomerSupport
5. Infrastructure IaC
– Bicep scripts & YAML in quickstarts/infra
6. Dev Environments
– devcontainer definitions (cpu/gpu/ollama variants)
b. Relationships & Data Flow
• Sample Apps → consume → Core Abstractions → call → Provider Implementations → contact → LLM APIs or local runtime
• Evaluation Layer → consumes → Model Outputs → produces → Metrics/Reports
• Quickstarts/Infra IaC → provisions → Azure AI Services → used by Azure-provider samples
• Devcontainer → provides reproducible environment for all samples
c. Architectural Patterns & Principles
• Layered architecture: Abstraction → Implementation → Application
• Inversion of Control / Dependency Injection: swap providers at runtime
• Componentization: each sample is standalone, reusing core libraries
• Monorepo organization for samples by category
d. Relevant Technologies
• .NET 8, C#
• Microsoft.Extensions.AI abstractions
• Azure OpenAI, OpenAI REST SDKs
• Semantic Kernel (build-2024)
• Bicep / Azure Resource Manager (quickstarts/infra)
• Docker / DevContainers