Skip to content

Commit 25d9021

Browse files
committed
Add initial project files and examples from previous repo.
1 parent 2b80ca3 commit 25d9021

File tree

95 files changed

+3188
-43
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+3188
-43
lines changed

Diff for: .devcontainer/Ollama/devcontainer.json

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/dotnet
3+
{
4+
"name": "C# (.NET) - Ollama",
5+
"image": "mcr.microsoft.com/devcontainers/dotnet:9.0",
6+
"features": {
7+
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
8+
"ghcr.io/devcontainers/features/common-utils:2": {},
9+
"ghcr.io/devcontainers/features/azure-cli:1": {
10+
"installBicep": true,
11+
"version": "latest"
12+
},
13+
"ghcr.io/azure/azure-dev/azd:0": {
14+
"version": "stable"
15+
},
16+
"ghcr.io/prulloac/devcontainer-features/ollama:latest": {},
17+
"sshd": "latest"
18+
},
19+
20+
"customizations": {
21+
"vscode": {
22+
"extensions": [
23+
"GitHub.copilot",
24+
"ms-dotnettools.csdevkit",
25+
"ms-azuretools.vscode-azure-github-copilot"
26+
]
27+
}
28+
},
29+
30+
31+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
32+
"forwardPorts": [17057],
33+
"portsAttributes": {
34+
"17057": {
35+
"protocol": "http"
36+
}
37+
},
38+
39+
// Use 'postCreateCommand' to run commands after the container is created.
40+
"postCreateCommand": "sudo dotnet workload update && sudo dotnet workload install aspire && sudo dotnet workload list && ollama pull all-minilm && ollama pull llama3.2",
41+
"postStartCommand": "",
42+
43+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
44+
"remoteUser": "vscode",
45+
"hostRequirements": {
46+
"memory": "16gb",
47+
"cpus": 4
48+
}
49+
}

Diff for: .devcontainer/devcontainer.json

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/dotnet
3+
{
4+
"name": "C# (.NET)",
5+
"image": "mcr.microsoft.com/devcontainers/dotnet:9.0",
6+
"features": {
7+
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
8+
"ghcr.io/devcontainers/features/common-utils:2": {},
9+
"ghcr.io/devcontainers/features/azure-cli:1": {
10+
"installBicep": true,
11+
"version": "latest"
12+
},
13+
"ghcr.io/azure/azure-dev/azd:0": {
14+
"version": "stable"
15+
},
16+
"sshd": "latest"
17+
},
18+
19+
"customizations": {
20+
"vscode": {
21+
"extensions": [
22+
"GitHub.copilot",
23+
"ms-dotnettools.csdevkit",
24+
"ms-azuretools.vscode-azure-github-copilot"
25+
]
26+
}
27+
},
28+
29+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
30+
"forwardPorts": [17057],
31+
"portsAttributes": {
32+
"17057": {
33+
"protocol": "http"
34+
}
35+
},
36+
37+
// Use 'postCreateCommand' to run commands after the container is created.
38+
"postCreateCommand": "sudo dotnet workload update && sudo dotnet workload install aspire && sudo dotnet workload list && sudo dotnet dev-certs https --trust ",
39+
"postStartCommand": "",
40+
41+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
42+
"remoteUser": "vscode",
43+
"hostRequirements": {
44+
"memory": "16gb",
45+
"cpus": 4
46+
}
47+
}

Diff for: .gitignore

-2
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ StyleCopReport.xml
8282
*.pgc
8383
*.pgd
8484
*.rsp
85-
# but not Directory.Build.rsp, as it configures directory-level build defaults
86-
!Directory.Build.rsp
8785
*.sbr
8886
*.tlb
8987
*.tli

Diff for: 01-IntroToGenAI/images/ai-toolkit-extension.png

348 KB
Loading

Diff for: 01-IntroToGenAI/images/meai-architecture-diagram.png

97.9 KB
Loading

Diff for: 01-IntroToGenAI/images/prompty-extension.png

15.1 KB
Loading

Diff for: 01-IntroToGenAI/images/prompty-preview.png

413 KB
Loading

Diff for: 01-IntroToGenAI/images/semantic-kernel-core.png

255 KB
Loading

Diff for: 01-IntroToGenAI/images/semantic-kernel-full-loop.png

1010 KB
Loading

Diff for: 01-IntroToGenAI/images/semantic-kernel.png

74.6 KB
Loading

Diff for: 01-IntroToGenAI/images/transformer-archtecture.png

193 KB
Loading

Diff for: 01-IntroToGenAI/readme.md

+224
Large diffs are not rendered by default.
166 KB
Loading

Diff for: 02-SettingUp.NETDev/images/creating-codespace.png

36.7 KB
Loading
13.5 KB
Loading
157 KB
Binary file not shown.

Diff for: 02-SettingUp.NETDev/images/github-models-webapge.png

166 KB
Loading

Diff for: 02-SettingUp.NETDev/images/hero.webp

174 KB
Binary file not shown.
34.1 KB
Loading
38 KB
Loading

Diff for: 02-SettingUp.NETDev/images/settings-github.png

7.57 KB
Loading
24.4 KB
Loading

Diff for: 02-SettingUp.NETDev/images/token-generate-github.png

13.1 KB
Loading

Diff for: 02-SettingUp.NETDev/images/tokens-classic-github.png

9.25 KB
Loading

Diff for: 02-SettingUp.NETDev/readme.md

+184
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
2+
<div align="center">
3+
<h1>Generative AI Fundamentals for .NET</h1>
4+
<h2>Lesson 2: Setting Up the Environment</h2>
5+
<p><em>Transform GitHub Codespaces into a powerful .NET development machine</em></p>
6+
</div>
7+
8+
> 💡 **Quick Summary**: Follow this comprehensive guide to deploy your ideal .NET + AI development environment. Whether you're a seasoned developer or just starting out, we'll help you build a robust setup for creating amazing applications.
9+
10+
---
11+
12+
**What you'll achieve:**
13+
- ⚡ Lightning-fast development environment with GitHub Codepaces
14+
- 🛠️ Industry-standard tools configuration with .devcontainer
15+
- 🎯 Everything ready for immediate coding
16+
17+
Let's dive in and set up your development environment! 🏃‍♂️
18+
19+
**Index**
20+
21+
1. [Lesson Intro video](#intro-video)
22+
1. [Understanding GitHub Codespaces](#understanding-github-codespaces)
23+
1. [Pre-Flight Check: Setting up GitHub Access Tokens](#pre-flight-check-setting-up-github-access-tokens)
24+
1. [Taking Off with AI 🚀](#taking-off-with-ai-)
25+
1. [Running the Solution in Your Codespace](#running-the-solution-in-your-codespace)
26+
1. [Conclusions and Resources](#conclusions-and-resources)
27+
28+
---
29+
30+
## Intro Video
31+
32+
[![Watch the video](../images/02-videocover.jpg)](https://microsoft-my.sharepoint.com/:v:/p/brunocapuano/ERTkzBSAfKJEiLw2HLnzHnkBMEbpk17hniaVfr8lCm6how?e=gWOr33&nav=eyJyZWZlcnJhbEluZm8iOnsicmVmZXJyYWxBcHAiOiJTdHJlYW1XZWJBcHAiLCJyZWZlcnJhbFZpZXciOiJTaGFyZURpYWxvZy1MaW5rIiwicmVmZXJyYWxBcHBQbGF0Zm9ybSI6IldlYiIsInJlZmVycmFsTW9kZSI6InZpZXcifX0%3D)
33+
34+
## Understanding GitHub Codespaces and Models
35+
36+
GitHub is an Platform for Developers, with world-leading tooling, integration, and AI Capabilities, for this course, we are going to use GitHub Codespaces and GitHub Models.
37+
38+
GitHub Codespaces is a cloud-powered development environment that enables developers to code from anywhere. Allowing you to seamlessly integrates with GitHub repositories, providing an effortless way to develop, commit, and deploy code.
39+
40+
GitHub Models is an easy alternative to deploy, integrate, and frictionless way to add Generative Artificial Intelligence into your projects. With multiple families of models, like GPT from OpenAI and Phi Family from Microsoft Research, allowing for quick prototyping for projects in the GitHub ecosystem.
41+
42+
![Codespaces Image](./images/hero.webp)
43+
44+
### Infrastructure and Performance
45+
46+
At its core, each codespace operates on a dedicated virtual machine, ensuring isolated and reproducible development environments. These environments are engineered for rapid bootup times and can be extensively customized through devcontainer configurations, allowing developers to maintain their preferred tools and settings.
47+
48+
The platform operates on a transparent pricing model based on compute and storage consumption. For developers using GitHub Free accounts, the service includes [120 core-hours monthly and 15GB of storage](https://github.blog/changelog/2022-11-09-codespaces-for-free-and-pro-accounts/) at no cost. Premium tiers offer expanded resources to match growing development needs.
49+
50+
![Image Showing Codespaces options for VMs](./images/features-river-breakout.webp)
51+
52+
### Configure any environment with .devcontainer
53+
54+
The **.devcontainer configuration** in GitHub Codespaces acts as your environment's blueprint, defining everything from the base Docker image to Visual Studio Code extensions and settings. This allows that every developer working on your project has identical tools, dependencies, and configurations, effectively eliminating the "it works on my machine" syndrome. Through simple JSON configuration files, you can specify your preferred development environment, including specific versions of .NET, runtime dependencies, and essential VS Code extensions.
55+
56+
A .devcontainer setup involves defining a `devcontainer.json` file and, optionally, a Dockerfile. The configuration file supports a wide range of customization options, from port forwarding rules to post-creation commands, enabling you to automate environment setup tasks and maintain consistency across your development team. This approach not only streamlines the development process but also ensures that your environment remains reproducible and version-controlled alongside your codebase.
57+
58+
![Image demonstrating Devcontainers](./images/configure-dev-container.png)
59+
60+
> 💡 **Pro Tip**: Configure your devcontainer with your most-used tools and extensions to create a consistent development experience across all your projects. [Learn more about devcontainers here!](https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/adding-a-dev-container-configuration/introduction-to-dev-containers)
61+
62+
### Learn and Test AI Models with GitHub Models
63+
64+
**GitHub Models** provides an intuitive way to experiment with various AI models directly within your development environment. This feature allows developers to test and interact with different models, understanding their capabilities and limitations before implementation. Through a simple interface, you can explore model responses, evaluate performance, and determine the best fit for your application requirements. Hosted within GitHub's infrastructure, these models offer reliable access and consistent performance, making them ideal for development and testing phases.
65+
66+
![Image for GitHub Models page, demonstrating multiple Generative Ai models](./images/github-models-webapge.png)
67+
68+
---
69+
70+
## Pre-Flight Check: Setting Up GitHub Access Tokens
71+
72+
Before diving into generative AI development, we need to configure essential security credentials that will enable our Codespace to interact with GitHub Models and execute our applications securely.
73+
74+
### Creating a Personal Access Token
75+
76+
1. Navigate to GitHub Settings:
77+
78+
- Click your profile picture in the top-right corner
79+
- Select **Settings** from the dropdown menu
80+
81+
![GitHub Settings](./images/settings-github.png)
82+
83+
2. Access Developer Settings:
84+
85+
- Scroll down the left sidebar
86+
- Click on **Developer settings** (usually at the bottom)
87+
88+
![Developer Settings](./images/developer-settings-github.png)
89+
90+
3. Generate a New Token:
91+
92+
- Select **Personal access tokens****Tokens (classic)**
93+
94+
![Adding the Tokens(classic)](./images/tokens-classic-github.png)
95+
96+
- Click **Generate new token (classic)**
97+
98+
![Create your Token](./images/token-generate-github.png)
99+
100+
- Under "Note", provide a descriptive name (e.g., "AI-Development-Token")
101+
- Set an expiration date (recommended: 7 days for security best practices)
102+
- There is no need adding any permissions to this token.
103+
104+
> 💡 **Security Tip**: Always use the minimum required scope and shortest practical expiration time for your access tokens. This follows the principle of least privilege and helps maintain your account's tokens safe.
105+
106+
## Taking Off with AI 🚀
107+
108+
Let's dive into practical implementations with three powerful AI demonstrations that showcase different approaches to AI integration.
109+
110+
### Demo Overview
111+
112+
1. **AI API Answer with Phi 3.5**
113+
- Experience Microsoft's Phi 3.5 language model
114+
- See real-time AI responses in action and the API integration patterns
115+
116+
2. **Semantic Kernel Implementation**
117+
- Learn Microsoft's powerful AI orchestration framework
118+
- Explore complex AI patterns and workflows in the next lessons
119+
120+
3. **Local Llama Integration**
121+
- Experience edge computing with AI running in your Codespace
122+
- Understand local vs. cloud AI tradeoffs
123+
124+
### Setting Up Your Development Environment
125+
126+
Let's create your AI-powered workspace using GitHub Codespaces:
127+
128+
1. Navigate to the repository's main page
129+
2. Click the "Code" dropdown button
130+
3. Access "Codespaces"
131+
4. Select "..." (three dots) and choose "New with options"
132+
133+
![Creating a Codespace with custom options](./images/creating-codespace.png)
134+
135+
### Choosing Your Development Container
136+
137+
Select from two optimized configurations:
138+
139+
**Option 1: Standard .NET Environment** : With a Faster startup time and with the core .NET development tools. This environment does not include Ollama capabilities.
140+
141+
**Option 2: .NET with Ollama**: It has a slowet start-up time, five minutes on average, however, you will be able to run all the demos and experiment with Ollama.
142+
143+
![Selecting your development container configuration](./images/select-container-codespace.png)
144+
145+
> 💡 **Pro Tip**: Choose the Ollama configuration if you plan to experiment with local model execution.
146+
147+
## Running the Solution in Your Codespace
148+
149+
Once your Codespace is fully loaded and configured, follow these steps to execute the demo applications:
150+
151+
1. **Access the Solution Explorer**
152+
153+
- Locate the Solution Explorer in the left sidebar
154+
- If collapsed, click the Explorer icon (usually the top icon)
155+
- The solution structure should be visible, containing all projects
156+
157+
![Solution Explorer in Codespaces](./images/solution-explorer-codespaces.png)
158+
159+
2. **Launch the Debug Session**
160+
161+
- Right-click on the Solution node to be run, in the Explorer
162+
- Navigate to "Debug" in the context menu
163+
- Select "Start New Instance"
164+
165+
![Initiating Debug Mode](./images/run-solution-codespaces.png)
166+
167+
> ⚠️ **Note**: If you encounter any build errors, ensure all required dependencies are properly restored by running `dotnet restore` in the terminal.
168+
169+
## Conclusions and resources
170+
171+
### Additional Resources
172+
173+
> ⚠️ **Note**: If you encounter any issues, open an issue in the repository.
174+
175+
- [GitHub Codespaces Documentation](https://docs.github.com/en/codespaces)
176+
- [GitHub Models Documentation](https://docs.github.com/en/github-models/prototyping-with-ai-models)
177+
178+
### Next Steps
179+
180+
Next, we'll explore how to create your first AI application using these tools.
181+
182+
<p align="center">
183+
<a href="../03-CoreGenerativeAITechniques/readme.md">Go to Chapter 3</a>
184+
</p>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<RootNamespace>BasicChat_01MEAI</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Microsoft.Extensions.AI" Version="9.0.1-preview.1.24570.5" />
13+
<PackageReference Include="Microsoft.Extensions.AI.AzureAIInference" Version="9.0.1-preview.1.24570.5" />
14+
</ItemGroup>
15+
16+
</Project>

Diff for: 02-SettingUp.NETDev/src/BasicChat-01MEAI/Program.cs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Azure;
2+
using Azure.AI.Inference;
3+
using Microsoft.Extensions.AI;
4+
5+
IChatClient client = new ChatCompletionsClient(
6+
endpoint: new Uri("https://models.inference.ai.azure.com"),
7+
new AzureKeyCredential(Environment.GetEnvironmentVariable("GITHUB_TOKEN")))
8+
.AsChatClient("Phi-3.5-MoE-instruct");
9+
10+
var response = await client.CompleteAsync("What is AI?");
11+
12+
Console.WriteLine(response.Message);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<RootNamespace>BasicChat_02SK</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
</Project>

Diff for: 02-SettingUp.NETDev/src/BasicChat-02SK/Program.cs

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// See https://aka.ms/new-console-template for more information
2+
Console.WriteLine("Hello, World!");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<RootNamespace>BasicChat_03Ollama</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Microsoft.Extensions.AI.Ollama" Version="9.0.1-preview.1.24570.5" />
13+
</ItemGroup>
14+
15+
</Project>
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using Microsoft.Extensions.AI;
2+
3+
IChatClient client =
4+
new OllamaChatClient(new Uri("http://localhost:11434/"), "llama3.2");
5+
6+
var response = await client.CompleteAsync("What is AI?");
7+
8+
Console.WriteLine(response.Message);

Diff for: 02-SettingUp.NETDev/src/GetingReadySamples.sln

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35514.174
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicChat-01MEAI", "BasicChat-01MEAI\BasicChat-01MEAI.csproj", "{F924B9FC-D806-4350-BEC8-C0D4BB9E7C6D}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicChat-02SK", "BasicChat-02SK\BasicChat-02SK.csproj", "{4AFB8C74-0293-4BD8-94B5-97C44F345D3E}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicChat-03Ollama", "BasicChat-03Ollama\BasicChat-03Ollama.csproj", "{9E9C9E85-02AD-42B5-BC4E-C69AF390BA46}"
11+
EndProject
12+
Global
13+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
14+
Debug|Any CPU = Debug|Any CPU
15+
Release|Any CPU = Release|Any CPU
16+
EndGlobalSection
17+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18+
{F924B9FC-D806-4350-BEC8-C0D4BB9E7C6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+
{F924B9FC-D806-4350-BEC8-C0D4BB9E7C6D}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+
{F924B9FC-D806-4350-BEC8-C0D4BB9E7C6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
21+
{F924B9FC-D806-4350-BEC8-C0D4BB9E7C6D}.Release|Any CPU.Build.0 = Release|Any CPU
22+
{4AFB8C74-0293-4BD8-94B5-97C44F345D3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{4AFB8C74-0293-4BD8-94B5-97C44F345D3E}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{4AFB8C74-0293-4BD8-94B5-97C44F345D3E}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{4AFB8C74-0293-4BD8-94B5-97C44F345D3E}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{9E9C9E85-02AD-42B5-BC4E-C69AF390BA46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{9E9C9E85-02AD-42B5-BC4E-C69AF390BA46}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{9E9C9E85-02AD-42B5-BC4E-C69AF390BA46}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{9E9C9E85-02AD-42B5-BC4E-C69AF390BA46}.Release|Any CPU.Build.0 = Release|Any CPU
30+
EndGlobalSection
31+
GlobalSection(SolutionProperties) = preSolution
32+
HideSolutionNode = FALSE
33+
EndGlobalSection
34+
EndGlobal
1.34 MB
Loading

Diff for: 03-CoreGenerativeAITechniques/images/Audio.png

1.34 MB
Loading

Diff for: 03-CoreGenerativeAITechniques/images/Chat.png

1.34 MB
Loading

Diff for: 03-CoreGenerativeAITechniques/images/Functions.png

1.34 MB
Loading

Diff for: 03-CoreGenerativeAITechniques/images/RAG.png

1.34 MB
Loading

Diff for: 03-CoreGenerativeAITechniques/images/Vision.png

1.34 MB
Loading
1.46 MB
Loading

Diff for: 03-CoreGenerativeAITechniques/images/skmaps.png

242 KB
Loading

0 commit comments

Comments
 (0)