Skip to content

A comprehensive demonstration showcasing the evolution of AI integration patterns in .NET, from raw HTTP API calls to sophisticated stateful agents.

License

Notifications You must be signed in to change notification settings

selaromdotnet/dotnet-ai-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

╔══════════════════════════════════════════════════════════════════════════════╗ ║ ║ ║ 🤖 AI AGENTS DEMO - PROGRESSIVE AI INTEGRATION IN .NET ║ ║ ║ ║ Presented at: Cyber RGV - October 8, 2025 ║ ║ By: Josh Morales (SelAromDotNet) ║ ║ ║ ║ 📚 Complete Presentation Resources: ║ ║ https://link.content360.io/dotnet2025oct ║ ║ ║ ║ 💬 Join Rio Grande Valley .NET User Group: ║ ║ https://rgvdevs.net ║ ║ Collaborate, learn, and join more sessions like this! ║ ║ ║ ╚══════════════════════════════════════════════════════════════════════════════╝


# AI Agents Demo - Progressive AI Integration in .NET

A comprehensive demonstration showcasing the evolution of AI integration patterns in .NET, from raw HTTP API calls to sophisticated stateful agents.

## 🎯 What You'll Learn

This repository demonstrates five progressive approaches to integrating AI into .NET applications:

1. **Demo 1: Direct API Calls** — The "Hard Way" - Raw HTTP requests to AI providers
2. **Demo 2: Semantic Kernel** — Provider abstraction and prompt orchestration
3. **Demo 3: Extensions.AI with DI** — Configuration-driven provider switching
4. **Demo 4: AutoGen** — Tool-enabled collaboration with function calling
5. **Demo 5: Agent Framework** — Stateful agents with persistent memory and tools

## 🚀 Quick Start

### Prerequisites
- .NET 8.0 SDK or later
- OpenAI API Key
- (Optional) Google Gemini API Key (used in Demo 1, simulated in Demo 3)

### Setup

1. Clone the repository
   ```bash
   git clone https://github.com/selaromdotnet/dotnet-ai-demo.git
   cd AIAgentsDemo
  1. Configure API keys in each demo project

    # Copy the example config and edit it (do not check into source control!)
    cp appsettings.example.json appsettings.json
    # Windows: copy appsettings.example.json appsettings.json
  2. Run any demo

    dotnet run --project src/Demo1.DirectAPI
    dotnet run --project src/Demo2.SemanticKernel
    dotnet run --project src/Demo3.ExtensionsAI
    dotnet run --project src/Demo4.AutoGen
    dotnet run --project src/Demo5.AgentFramework

📚 Demo Overview

Demo 1: Direct API Calls (The "Hard Way")

Location: src/Demo1.DirectAPI/

  • Raw HTTP requests to OpenAI and Gemini using HttpClient
  • Provider-specific JSON structures and authentication
  • Pain Point: Each provider requires custom code
  • Limitation: Doesn't scale—manual work for every new provider

See Demo 1 README


Demo 2: Semantic Kernel (The "Smart Way")

Location: src/Demo2.SemanticKernel/

  • Uses Microsoft Semantic Kernel for provider abstraction
  • Creates reusable prompt functions and orchestration
  • Two-step AI workflow: analysis → response generation
  • Limitation: Provider choice configured in code (requires rebuild)

See Demo 2 README


Demo 3: Configuration + DI (The "Enterprise Way")

Location: src/Demo3.ExtensionsAI/

  • Dependency Injection with Microsoft.Extensions.AI
  • Configuration-driven provider selection via appsettings.json
  • Runtime provider switching without code changes
  • A/B testing, cost optimization, disaster recovery patterns
  • Limitation: AI hallucinates data it cannot access

See Demo 3 README


Demo 4: AutoGen (The "Collaborative Way")

Location: src/Demo4.AutoGen/

  • Agent with C# tool/function calling via AutoGen
  • Real data access eliminates hallucinations
  • Function middleware for tool registration
  • Limitation: Stateless by default—no conversation memory

See Demo 4 README


Demo 5: Agent Framework (The "Stateful Way")

Location: src/Demo5.AgentFramework/

  • Stateful agents with AgentThread for persistent memory
  • Multi-turn conversations with context retention
  • Auto tool invocation with dependency injection
  • Thread serialization for conversation persistence
  • Strongly-typed function returns for reliable AI parsing
  • Achievement: Production-ready pattern addressing all prior limitations

See Demo 5 README

🎨 Features

  • ✨ Colored console output for better visualization
  • 🔧 Standalone projects—run any demo independently
  • ⚙️ Consistent appsettings.json schema across demos
  • 📖 Educational narratives highlighting tradeoffs and limitations
  • 🚀 Progressive complexity from basics to production patterns

📦 Package Dependencies

  • Microsoft.SemanticKernel 1.65.0 (Demos 2, 3, 5)
  • Microsoft.SemanticKernel.Connectors.OpenAI 1.65.0 (Demos 2, 3, 5)
  • Microsoft.Extensions.Configuration 8.0.x (All demos)
  • Microsoft.Extensions.Hosting 8.0.1 (Demo 3)
  • Microsoft.Extensions.AI 9.0.0-preview.9.24507.7 (Demo 3)
  • Microsoft.Extensions.AI.OpenAI 9.0.0-preview.9.24507.7 (Demo 3)
  • AutoGen 0.2.3 (Demo 4)
  • AutoGen.OpenAI 0.2.3 (Demo 4)
  • Microsoft.Agents.AI (Demo 5)

🤝 Contributing

Contributions welcome! Please open a Pull Request with your improvements.

📄 License

MIT License

⭐ Support

If you find this helpful, please give it a star on GitHub!


Happy Learning! 🎉

From the Rio Grande Valley .NET Community

About

A comprehensive demonstration showcasing the evolution of AI integration patterns in .NET, from raw HTTP API calls to sophisticated stateful agents.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages