This document provides comprehensive guidance for AI assistants working with this repository.
Generative AI for Beginners is a Microsoft-sponsored, 21-lesson open-source curriculum teaching the fundamentals of building Generative AI applications. The course includes both conceptual lessons ("Learn") and hands-on coding lessons ("Build") with examples in Python and TypeScript.
Repository URL: https://github.com/microsoft/generative-ai-for-beginners
/
├── 00-course-setup/ # Course setup and prerequisites
├── 01-introduction-to-genai/ # Introduction to Generative AI and LLMs
├── 02-exploring-and-comparing-different-llms/
├── 03-using-generative-ai-responsibly/
├── 04-prompt-engineering-fundamentals/
├── 05-advanced-prompts/
├── 06-text-generation-apps/ # Building text generation applications
├── 07-building-chat-applications/
├── 08-building-search-applications/
├── 09-building-image-applications/
├── 10-building-low-code-ai-applications/
├── 11-integrating-with-function-calling/
├── 12-designing-ux-for-ai-applications/
├── 13-securing-ai-applications/
├── 14-the-generative-ai-application-lifecycle/
├── 15-rag-and-vector-databases/
├── 16-open-source-models/ # Hugging Face models
├── 17-ai-agents/
├── 18-fine-tuning/
├── 19-slm/ # Small Language Models (Phi-3)
├── 20-mistral/ # Mistral models
├── 21-meta/ # Meta/Llama models
├── .devcontainer/ # GitHub Codespaces configuration
├── .github/workflows/ # CI/CD workflows for markdown validation
├── docs/ # Additional documentation
├── images/ # Repository-level images
├── presentations/ # Presentation materials
└── translations/ # Root-level translations (cn, es-mx, ja-jp, ko, pt-br, tw)
Each lesson folder follows this pattern:
XX-lesson-name/
├── README.md # Main lesson content
├── images/ # Lesson-specific images
├── translations/ # Translated versions (cn, es-mx, ja-jp, ko, pt-br, tw)
│ └── {locale}/README.md
├── python/ # Python code samples
│ ├── aoai-assignment.ipynb # Azure OpenAI notebook
│ ├── oai-assignment.ipynb # OpenAI API notebook
│ ├── githubmodels-assignment.ipynb # GitHub Models notebook
│ └── *.py # Python scripts
├── typescript/ # TypeScript code samples
└── dotnet/ # .NET code samples (some lessons)
- Python 3.x - Primary language for code samples
- TypeScript - Alternative implementations
- .NET/C# - Some lesson implementations
- Jupyter Notebooks (.ipynb) - Interactive code samples
Python (requirements.txt):
openai>=0.28.0
python-dotenv==1.0.0
azure-ai-inference
tiktoken
numpy==1.24.2
pandas==1.5.3
matplotlib==3.7.0
ipywidgets==7.7.1
tqdm==4.66.3
Node.js (package.json):
{
"@azure-rest/ai-inference": "^1.0.0-beta.2",
"@azure/core-auth": "^1.8.0",
"openai": "^4.10.0"
}- Azure OpenAI Service - Primary provider (files:
aoai-*.py,aoai-*.ipynb) - OpenAI API - Direct OpenAI access (files:
oai-*.py,oai-*.ipynb) - GitHub Models - GitHub Marketplace models (files:
githubmodels-*.py,githubmodels-*.ipynb) - Hugging Face - Open-source models (Lesson 16)
The repository includes .devcontainer/devcontainer.json for zero-configuration setup:
- Image:
mcr.microsoft.com/devcontainers/universal:2 - Auto-installs Python dependencies from
requirements.txt - Pre-configured VS Code extensions: Python, Jupyter
# Clone repository
git clone https://github.com/microsoft/generative-ai-for-beginners
cd generative-ai-for-beginners
# Install Python dependencies
pip install -r requirements.txt
# Install Node.js dependencies (for TypeScript samples)
npm installCopy .env.copy to .env and configure:
# OpenAI Provider
OPENAI_API_KEY='<your-key>'
# Azure OpenAI
AZURE_OPENAI_API_VERSION='2024-02-01'
AZURE_OPENAI_API_KEY='<your-key>'
AZURE_OPENAI_ENDPOINT='<your-endpoint>'
AZURE_OPENAI_DEPLOYMENT='<deployment-name>'
AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT='<embeddings-deployment>'
# Hugging Face
HUGGING_FACE_API_KEY='<your-token>'from openai import AzureOpenAI
import os
import dotenv
dotenv.load_dotenv()
client = AzureOpenAI(
azure_endpoint=os.environ["AZURE_OPENAI_ENDPOINT"],
api_key=os.environ['AZURE_OPENAI_API_KEY'],
api_version="2024-02-01"
)
deployment = os.environ['AZURE_OPENAI_DEPLOYMENT']
messages = [{"role": "user", "content": "Your prompt here"}]
completion = client.chat.completions.create(model=deployment, messages=messages)
print(completion.choices[0].message.content)import { OpenAIClient, AzureKeyCredential } from "@azure/openai";
import * as dotenv from "dotenv";
dotenv.config();
const client = new OpenAIClient(
process.env.AZURE_OPENAI_ENDPOINT || '',
new AzureKeyCredential(process.env.AZURE_OPENAI_API_KEY || '')
);CRITICAL: All markdown files must follow these rules (enforced by CI):
-
Tracking IDs Required: All URLs and relative paths must include
?WT.mc_id=academic-105485-koreystor&WT.mc_id=academic-105485-koreyst<!-- Correct --> [Link](./path/to/file.md?WT.mc_id=academic-105485-koreyst) [External](https://example.com?WT.mc_id=academic-105485-koreyst) <!-- Incorrect --> [Link](./path/to/file.md)
-
Relative Paths: Must start with
./or../<!-- Correct --> [Next Lesson](../01-introduction-to-genai/README.md?WT.mc_id=academic-105485-koreyst) <!-- Incorrect --> [Next Lesson](01-introduction-to-genai/README.md)
-
No Locale in URLs: Remove country-specific locale prefixes
<!-- Correct --> https://learn.microsoft.com/azure/... <!-- Incorrect --> https://learn.microsoft.com/en-us/azure/...
-
Image Storage: All images must be in the
./images/folder of the relevant lesson -
Image Naming: Use English characters, numbers, and dashes only
- Human translations only - no machine translation
- Submit complete lesson translations (all files) in a single PR
- Supported locales:
cn,es-mx,ja-jp,ko,pt-br,tw
Triggered on PRs modifying .md or .ipynb files:
- check-broken-paths - Validates relative links work
- check-paths-tracking - Ensures relative paths have tracking IDs
- check-urls-tracking - Ensures URLs have tracking IDs
- check-urls-locale - Ensures URLs don't have country locale
- check-broken-urls - Validates external URLs are accessible
lock.yml- Locks stale issuesstale.yml- Marks inactive issues/PRs as stalewelcome-pr.yml- Welcomes new contributorswelcome-issue.yml- Welcomes new issue reporters
- Fork First: Always fork the repository before making changes
- Separate PRs: Submit separate PRs for different types of changes (bug fixes vs. docs)
- Sync Before PR: Ensure your local main matches the upstream main
- CLA Required: Contributors must agree to the Microsoft CLA
- All links include tracking ID (
?WT.mc_id=academic-105485-koreyst) - Relative paths start with
./or../ - No country locale in URLs
- Images stored in
./images/folder - Images have descriptive English names with dashes
# Start Jupyter locally
jupyter notebook
# Or use JupyterHub
jupyterhubcd 06-text-generation-apps/python
python aoai-app.pycd 06-text-generation-apps/typescript/recipe-app
npm install
npx ts-node src/main.tsnpm run convert # Uses docsify-to-pdf| Pattern | Description | Example |
|---|---|---|
aoai-*.py/ipynb |
Azure OpenAI implementation | aoai-assignment.ipynb |
oai-*.py/ipynb |
OpenAI API implementation | oai-assignment.ipynb |
githubmodels-*.py/ipynb |
GitHub Models implementation | githubmodels-assignment.ipynb |
*-solution.* |
Solution/answer files | aoai-solution.py |
*-assignment.* |
Exercise files | aoai-assignment.ipynb |
| File | Purpose |
|---|---|
README.md |
Main course overview and lesson index |
CONTRIBUTING.md |
Contribution guidelines and PR workflow |
CODE_OF_CONDUCT.md |
Microsoft Open Source Code of Conduct |
SECURITY.md |
Security policy and vulnerability reporting |
.env.copy |
Template for environment variables |
requirements.txt |
Python dependencies |
package.json |
Node.js dependencies and scripts |
- Always add tracking IDs when creating or modifying links
- Check workflow requirements before suggesting markdown changes
- Respect the lesson structure - keep code in appropriate subfolders
- Test relative links - ensure they work from the file's location
- Preserve multilingual content - translations are maintained separately
- Use appropriate API client based on file naming convention
- Environment variables - never hardcode API keys; always use dotenv pattern