This repository contains comprehensive learning materials on prompt engineering techniques and agentic AI workflows. It includes hands-on lessons covering role-based prompting, prompt refinement, chaining prompts for agentic reasoning, implementing LLM feedback loops, and building complete agentic workflow systems with various design patterns.
- Repository Overview
- Prerequisites
- Installation
- Running the Materials
- Course 1: Effective Prompting for LLM Reasoning
- Course 2: Agentic Workflows
- Project Structure
This repository is organized into two main learning tracks:
- Effective Prompting for LLM Reasoning - Foundational prompt engineering techniques including role-based prompting, prompt refinement, prompt chaining, and feedback loops
- Agentic Workflows - Advanced agentic AI patterns including routing, parallelization, evaluator-optimizer patterns, and orchestrator-worker architectures
- Python 3.8+ (Python 3.9 or higher recommended)
- The notebooks have been tested with Python 3.9+ and should work with Python 3.8+
Install all required packages using pip from the requirements file:
pip install -r requirements.txt- openai==2.8.1 - For accessing OpenAI API (or Vocareum API endpoint)
- python-dotenv==1.2.1 - For loading environment variables from .env files
- pydantic>=2.11.0 - For structured data validation (used in prompt chaining lesson)
- pandas>=2.3.0 - For data analysis and visualization (used in prompt chaining lesson)
- numpy>=2.0.0 - Numerical computing library (dependency for pandas)
- json-repair>=0.47.1 - For fixing malformed JSON outputs from LLMs
- numexpr>=2.11.0 - For fast numerical expression evaluation
- jupyter>=1.0.0 - Core Jupyter functionality
- notebook>=7.0.0 - Jupyter Notebook interface
- jupyterlab>=4.0.0 - JupyterLab interface
- ipykernel>=6.25.0 - IPython kernel for Jupyter
- ipython>=8.12.0 - Enhanced interactive Python shell
enum- Enumeration supportjson- JSON parsing and generationos- Operating system interfacetyping- Type hints supporttraceback- Stack trace formatting (used in feedback loops lesson)io- StringIO for output capture (used in feedback loops lesson)contextlib- Context managers for output redirection (used in feedback loops lesson)
The repository contains both Jupyter notebooks (.ipynb) and Python scripts (.py).
Note: If you've installed packages from requirements.txt, Jupyter Notebook and JupyterLab are already installed.
-
Start Jupyter Notebook:
jupyter notebook
-
Navigate to the lesson folder and open the desired
.ipynbfile
-
Start JupyterLab:
jupyter lab
-
Open the notebook from the file browser
- Install the Jupyter extension in VS Code
- Open the notebook file directly in VS Code
- Select a Python kernel when prompted
Navigate to the lesson's demo or exercise folder and run the Python files directly:
python demo.py
# or
python starter.pyBefore running the notebooks, you'll need to configure your API credentials:
- Vocareum API: The notebooks are pre-configured to use the Vocareum API endpoint. Update the API key in each notebook where needed.
- OpenAI API: To use OpenAI's API instead, uncomment the OpenAI client initialization and set your API key as an environment variable:
export OPENAI_API_KEY="your-api-key-here"
Location: effective-prompting-llm-reasoning/
This course provides foundational knowledge on prompt engineering techniques for building intelligent LLM applications.
Location: effective-prompting-llm-reasoning/introduction-to-prompting-for-llm-reasoning-and-planning/
introduction-to-prompting-for-llm-reasoning-and-planning.ipynb- Pre-lesson exercise on workspace organizationmodel-selection.ipynb- Model selection and comparison exercises
This folder contains introductory exercises that demonstrate fundamental prompt engineering concepts. You'll learn to:
- Start with generic prompts and gradually refine them
- Add professional roles to enhance AI responses
- Introduce concrete constraints (time, budget, etc.) to guide AI behavior
- Compare different approaches to prompt engineering
Key Concepts:
- Prompt refinement techniques
- Role-based prompting basics
- Adding constraints and context
- Comparing prompt strategies
Location: effective-prompting-llm-reasoning/role-based-prompting/
lesson-1-role-based-prompting.ipynb
In this lesson, you'll learn to create convincing AI personas by crafting prompts that instruct an LLM to adopt the persona of a historical figure (e.g., Albert Einstein) during interactive Q&A sessions.
Topics Covered:
- Plain Prompt - Baseline without role definition
- Baseline Historical Figure Prompt - Basic role-playing prompt
- Persona-Specific Attributes - Adding personality traits, speech style, expertise, and historical context
- Tone and Style Specifications - Defining conversational tone and linguistic style
- Q&A Session Format - Testing persona consistency with specific questions
- Reflection & Transfer - Evaluating realism and authenticity of AI responses
Learning Outcomes:
- Understand how role-based prompting affects AI behavior
- Learn to create detailed persona specifications
- Master techniques for maintaining persona consistency
- Evaluate the effectiveness of different prompt refinements
Location: effective-prompting-llm-reasoning/prompt-refinement/
lesson-3-prompt-instruction-refinement.ipynb
This lesson teaches you to systematically refine prompts through iterative improvements. You'll work on a practical task: matching recipes to dietary restrictions, learning how to analyze prompt components and improve them.
Topics Covered:
- Setup - Library imports and helper functions
- Sample Recipes and Dietary Restrictions - Working with real-world data
- Initial Prompt and Evaluation - Starting with a basic prompt
- Prompt Component Analysis - Identifying areas for improvement
- Role definition
- Task specification
- Output format
- Context and examples
- Prompt Refinement Iterations - Multiple iterations to improve the prompt
- Adding role and context
- Clarifying task requirements
- Improving output format with explanations
- Adding examples and handling ambiguities
- Testing with Another Recipe - Validating improvements
- Comparison - Comparing initial vs. refined prompts
Key Concepts:
- Prompt component analysis
- Iterative prompt refinement
- Context and example integration
- Handling ambiguous cases
- Structured output formats (JSON)
Learning Outcomes:
- Learn systematic approaches to prompt refinement
- Understand the importance of context and examples
- Master techniques for handling edge cases and ambiguities
- Improve prompt transparency and output quality
Location: effective-prompting-llm-reasoning/prompt-chaining/
lesson-4-chaining-prompts-for-agentic-reasoning.ipynb
This advanced lesson demonstrates how to chain multiple prompts together to create a complex agentic reasoning system. You'll build an automated insurance claim triage system that processes free-form First Notice of Loss (FNOL) reports through multiple stages with validation gates.
Topics Covered:
- Setup - Import libraries and define helper functions
- Sample FNOL Texts - Example insurance claim reports
- Stage I: Information Extraction - Extract structured information from free-form text
- Pydantic models for data validation
- Gate checks for data quality
- Stage II: Severity Assessment - Assess damage severity and estimate costs
- Severity classification (Minor, Moderate, Major)
- Cost estimation within heuristic ranges
- Validation gates for cost ranges
- Stage III: Queue Routing - Route claims to appropriate processing queues
- Routing rules based on severity and damage area
- Queue types:
glass,fast_track,material_damage,total_loss
- Review Outputs - Analyze results using pandas DataFrames
Key Concepts:
- Prompt chaining patterns
- Code-based gate checks
- Structured data validation with Pydantic
- Multi-stage agentic reasoning
- Error handling and validation
- Data pipeline construction
Technologies Used:
- Pydantic for data validation
- Pandas for data analysis
- JSON for structured output
- Enum for type safety
Learning Outcomes:
- Understand how to chain prompts for complex workflows
- Learn to implement validation gates to prevent error cascades
- Master structured data extraction and validation
- Build production-ready prompt chains with error handling
- Create maintainable agentic reasoning systems
Location: effective-prompting-llm-reasoning/llm-feedback-loops/
lesson-5-implementing-llm-feedback-loops.ipynb
This lesson teaches you to implement iterative feedback loops where an LLM generates, tests, and automatically revises Python code based on test results. You'll build a code generation and debugging assistant that uses test-driven development principles to iteratively improve code quality.
Topics Covered:
- Setup - Import libraries and define helper functions for code execution and testing
- Code execution environment with error handling
- Test runner with formatted feedback generation
- Define Task and Test Cases - Create requirements and test cases for a Python function
- Initial Generation - Generate initial code from requirements
- Expand the Test Cases - Add more comprehensive test cases (handling edge cases, new features)
- First Iteration with Feedback - Feed test results back to the LLM for improvement
- Formatting test feedback for the LLM
- Constructing feedback prompts
- Create Feedback Loop - Build an automated loop that iteratively improves code
- Maximum iteration limits
- Early termination when all tests pass
- Tracking iteration history
- Reflection & Transfer - Evaluate the feedback loop approach
Key Concepts:
- Iterative LLM feedback loops
- Test-driven development with LLMs
- Automated code generation and debugging
- Code execution and validation
- Feedback formatting for LLMs
- Iteration management and termination conditions
Technologies Used:
- Code execution with
exec()and namespace management - Error handling with
traceback - Output capture with
io.StringIOandcontextlib - Test case validation and reporting
Learning Outcomes:
- Understand how to create automated feedback loops for LLM code generation
- Learn to integrate test-driven development principles with LLM assistance
- Master techniques for formatting test results as actionable feedback
- Build automated systems that can self-correct and improve
- Create production-ready code generation assistants with validation
- Implement iteration strategies and termination conditions
Location: effective-prompting-llm-reasoning/agentsville-trip-planner/
project_starter.ipynb- Complete trip planning applicationproject_lib.py- Utility functions and helper classesREADME.md- Comprehensive project documentationintelligent-content-curator-exercise.md- Additional advanced exercise
A sophisticated, multi-stage AI assistant that demonstrates advanced LLM reasoning techniques. Build a trip planner that generates personalized itineraries using Chain-of-Thought reasoning and refines them using the ReAct (Reasoning + Acting) pattern with tool integration.
Topics Covered:
- Expert Planner (ItineraryAgent) - Chain-of-Thought reasoning for initial itinerary generation
- Resourceful Assistant (ItineraryRevisionAgent) - ReAct pattern for iterative refinement
- Tool Integration - Calculator, activity lookup, evaluation runner, and final answer tools
- Comprehensive Evaluation - 7 evaluation functions ensuring quality and compliance
- Structured Data Models - Pydantic models for travelers, activities, weather, and itineraries
Key Features:
- Weather-aware activity planning
- Interest-based recommendation system
- Budget compliance validation
- Multi-stage AI orchestration
- Tool-calling agents with ReAct patterns
- Structured JSON output with validation
Learning Outcomes:
- Design multi-stage AI systems
- Master ReAct pattern implementation
- Build tool-using agents
- Implement evaluation pipelines
- Create production-ready AI applications
Technologies Used:
- OpenAI API
- Pydantic for data validation
- json-repair for JSON fixing
- numexpr for calculations
- pandas for data display
Bonus Exercise:
The intelligent-content-curator-exercise.md file provides an advanced follow-up project building an AI-powered content curation system with multi-agent orchestration, research coordination, and quality assessment.
Location: effective-prompting-llm-reasoning/ADDITIONAL_EXERCISES.md
This document contains 20+ additional exercises across 8 categories that combine prompt chaining, prompt refinement, and LLM feedback loops:
- Customer Support & Ticketing - Multi-stage ticket processing, FAQ generation
- Content Moderation & Review - Multi-layer moderation, review quality assessment
- Code Review & Documentation - Automated code review, API documentation generation
- Data Processing & Analysis - Data cleaning pipelines, ETL with error recovery
- E-commerce & Recommendations - Product recommendations, description generation
- Educational & Assessment - Essay grading, adaptive quiz generation
- Healthcare & Triage - Symptom triage, medication adherence
- Legal & Compliance - Contract analysis, privacy policy compliance
Each exercise includes:
- Applied concepts and descriptions
- Learning goals and technical challenges
- Example inputs and expected outputs
- Implementation tips and best practices
Location: agentic_workflows/
This course covers advanced agentic AI workflow patterns and architectures for building production-ready AI systems.
Location: agentic_workflows/lesson-1-Introduction_to_Agentic_Workflows/
demo/demo.py- Demonstration codeexercises/starter/starter.py- Exercise starter codeexercises/solution/solution.py- Solution code
Introduction to the fundamentals of agentic workflows, understanding what makes a system "agentic," and the core components of autonomous AI agents.
Key Concepts:
- What are agentic workflows?
- Components of autonomous agents
- Agent decision-making and planning
- Basic workflow patterns
Location: agentic_workflows/lesson-2-Understanding_Agentic_Workflows/
demo/demo-no-llm.py- Non-LLM workflow demonstrationdemo/demo-llm.py- LLM-based workflow demonstrationexercises/starter/starter.py- Exercise starter codeexercises/solution/solution.py- Solution code
Deep dive into understanding how agentic workflows operate, comparing traditional programmatic workflows with LLM-powered agentic systems.
Key Concepts:
- Programmatic vs. agentic workflows
- LLM integration in workflows
- Decision-making mechanisms
- State management in agents
Location: agentic_workflows/lesson-3-Agentic_Workflow_Modeling/
Learn to model and design agentic workflows, including defining agent capabilities, goals, and constraints.
Key Concepts:
- Workflow modeling techniques
- Agent capability definition
- Goal and constraint specification
- Workflow visualization and planning
Location: agentic_workflows/lesson-4-Agentic_Workflow_Implementation/
demo/demo.py- Implementation demonstration
Hands-on implementation of agentic workflows, translating designs into working code with proper error handling and state management.
Key Concepts:
- Implementation best practices
- Error handling in agents
- State persistence
- Testing agentic systems
Location: agentic_workflows/lesson-5-Agentic_Workflow_Patterns_Prompt_Chaining/
Advanced prompt chaining patterns for building complex multi-step reasoning systems where outputs from one prompt feed into subsequent prompts.
Key Concepts:
- Sequential prompt chaining
- Context preservation across chains
- Error propagation and handling
- Chain optimization techniques
Location: agentic_workflows/lesson-6-Agentic_Workflow_Patterns_Routing/
demo/demo.py- Routing pattern demonstrationexercises/starter/starter.py- Exercise starter codeexercises/solution/solution.py- Solution code
Implement intelligent routing patterns where agents dynamically decide which path or specialized agent to route tasks to based on input analysis.
Key Concepts:
- Dynamic routing logic
- Specialized agent selection
- Routing decision criteria
- Fallback mechanisms
Location: agentic_workflows/lesson-7-Agentic_Workflow_Patterns_Parallelization/
demo/demo.py- Parallelization demonstrationexercises/starter/starter.py- Exercise starter codeexercises/solution/solution.py- Solution code
Learn to parallelize agentic workflows for improved performance, executing independent tasks concurrently and aggregating results.
Key Concepts:
- Parallel task execution
- Result aggregation patterns
- Dependency management
- Performance optimization
Location: agentic_workflows/lesson-8-Agentic_Workflow_Patterns_Evaluator-Optimizer/
demo/demo.py- Evaluator-optimizer demonstrationexercises/starter/starter.py- Exercise starter codeexercises/solution/solution.py- Solution code
Implement the evaluator-optimizer pattern where one agent generates solutions while another evaluates and provides feedback for iterative improvement.
Key Concepts:
- Evaluation criteria design
- Feedback loop implementation
- Iterative optimization
- Convergence strategies
Location: agentic_workflows/lesson-9-Agentic_Workflow_Orchestrator-Workers/
demo/demo_orchestrator.py- Orchestrator pattern demonstrationexercises/starter/starter.py- Exercise starter codeexercises/solution/solution.py- Solution code
Build orchestrator-worker architectures where a central orchestrator agent coordinates multiple specialized worker agents to accomplish complex tasks.
Key Concepts:
- Orchestrator design patterns
- Worker specialization
- Task distribution strategies
- Result coordination
Location: agentic_workflows/lesson-10-Lesson_Overview/
Comprehensive review of all agentic workflow patterns and how to combine them for building sophisticated AI systems.
Location: agentic_workflows/project/
Capstone project applying all learned patterns to build a complete production-ready agentic AI system.
agentic_ai/
β
βββ README.md
βββ .env
βββ .gitignore
β
βββ effective-prompting-llm-reasoning/ # Course 1: Foundational Prompt Engineering
β β
β βββ introduction-to-prompting-for-llm-reasoning-and-planning/
β β βββ introduction-to-prompting-for-llm-reasoning-and-planning.ipynb
β β βββ model-selection.ipynb
β β βββ requirements.txt
β β
β βββ role-based-prompting/
β β βββ lesson-1-role-based-prompting.ipynb
β β
β βββ prompt-refinement/
β β βββ lesson-3-prompt-instruction-refinement.ipynb
β β
β βββ prompt-chaining/
β β βββ lesson-4-chaining-prompts-for-agentic-reasoning.ipynb
β β
β βββ llm-feedback-loops/
β β βββ lesson-5-implementing-llm-feedback-loops.ipynb
β β
β βββ agentsville-trip-planner/ # Capstone Project
β β βββ project_starter.ipynb
β β βββ project_lib.py
β β βββ README.md
β β βββ intelligent-content-curator-exercise.md
β β
β βββ ADDITIONAL_EXERCISES.md # 20+ practice exercises
β
βββ agentic_workflows/ # Course 2: Advanced Agentic Patterns
β
βββ README.md
β
βββ lesson-1-Introduction_to_Agentic_Workflows/
β βββ demo/
β β βββ demo.py
β βββ exercises/
β βββ starter/starter.py
β βββ solution/solution.py
β
βββ lesson-2-Understanding_Agentic_Workflows/
β βββ demo/
β β βββ demo-no-llm.py
β β βββ demo-llm.py
β βββ exercises/
β βββ starter/starter.py
β βββ solution/solution.py
β
βββ lesson-3-Agentic_Workflow_Modeling/
β βββ exercises/
β
βββ lesson-4-Agentic_Workflow_Implementation/
β βββ demo/
β βββ demo.py
β
βββ lesson-5-Agentic_Workflow_Patterns_Prompt_Chaining/
β βββ exercises/
β
βββ lesson-6-Agentic_Workflow_Patterns_Routing/
β βββ demo/
β β βββ demo.py
β βββ exercises/
β βββ starter/starter.py
β βββ solution/solution.py
β
βββ lesson-7-Agentic_Workflow_Patterns_Parallelization/
β βββ demo/
β β βββ demo.py
β βββ exercises/
β βββ starter/starter.py
β βββ solution/solution.py
β
βββ lesson-8-Agentic_Workflow_Patterns_Evaluator-Optimizer/
β βββ demo/
β β βββ demo.py
β βββ exercises/
β βββ starter/starter.py
β βββ solution/solution.py
β
βββ lesson-9-Agentic_Workflow_Orchestrator-Workers/
β βββ demo/
β β βββ demo_orchestrator.py
β βββ exercises/
β βββ starter/starter.py
β βββ solution/solution.py
β
βββ lesson-10-Lesson_Overview/
β
βββ project/ # Capstone Project
- Hands-on Learning: Jupyter notebooks with practical exercises and real-world applications
- Progressive Difficulty: Lessons build from basic prompting to advanced multi-stage systems
- Complete Examples: Runnable code examples with detailed explanations
- Capstone Project: AgentsVille Trip Planner demonstrating ReAct patterns and tool integration
- 20+ Additional Exercises: Practice across 8 domains (healthcare, legal, e-commerce, etc.)
- Validation & Testing: Gate checks and evaluation functions for production systems
- Pattern-Based Learning: Master 5 core agentic workflow patterns
- Python Implementation: Executable Python scripts with starter and solution code
- Demo Code: Working demonstrations of each pattern
- Production Patterns: Learn industry-standard architectures (orchestrator-workers, evaluator-optimizer)
- Scalable Design: Techniques for building robust, production-ready AI systems
- Hands-on Exercises: Practice implementing each pattern independently
- Work Sequentially: Start with the introduction, then progress through lessons 1, 3, 4, and 5
- Experiment Actively: Modify prompts and observe how outputs change
- Complete the Project: The AgentsVille Trip Planner synthesizes all learned concepts
- Explore Exercises: Try additional exercises in domains relevant to your interests
- Pay Attention to Validation: Errors teach important concepts about structured outputs
- Observe Feedback Loops: Watch how iterative improvements work in Lesson 5
- Start with Demos: Run demo code to understand each pattern before implementing
- Complete Starter Exercises: Work through starter.py files before viewing solutions
- Compare Approaches: Review demo-no-llm.py vs demo-llm.py in Lesson 2
- Master One Pattern at a Time: Ensure understanding before moving to the next pattern
- Build Incrementally: Start simple, then add complexity as you gain confidence
- Apply to Projects: Think about how to apply patterns to your own use cases
- Configure API Keys: Set up your OpenAI or Vocareum API access before starting
- Take Notes: Document what works and what doesn't for future reference
- Test Thoroughly: Include edge cases and error scenarios in your experiments
- Read Documentation: Each project has detailed README files - use them
- Join the Community: Share your implementations and learn from others
- API Compatibility: All materials work with both Vocareum API endpoints and OpenAI's API
- Internet Required: Stable internet connection needed for API calls
- API Credits: Some lessons may consume API credits depending on your provider
- Course Organization: Two independent courses that can be taken separately or sequentially
- File Types: Course 1 uses Jupyter notebooks (.ipynb), Course 2 uses Python scripts (.py)
- Prerequisites: Basic Python knowledge recommended; no prior AI/ML experience required
- Complete Course 1 (Effective Prompting) lessons sequentially
- Build the AgentsVille Trip Planner project
- Move to Course 2 (Agentic Workflows) for advanced patterns
- Complete the Agentic Workflows capstone project
- Review Course 1 Introduction and Lesson 1
- Jump to Course 2 to learn workflow patterns
- Return to Course 1 for deeper prompt engineering techniques
- Complete both capstone projects
- Start with AgentsVille Trip Planner (Course 1)
- Learn relevant lessons as needed for the project
- Build the Agentic Workflows capstone project (Course 2)
- Practice with additional exercises from Course 1
By completing this repository, you'll be able to:
- Design and implement sophisticated prompt engineering strategies
- Build multi-stage AI systems with proper validation and error handling
- Create tool-using agents with ReAct patterns
- Implement all major agentic workflow patterns (routing, parallelization, evaluator-optimizer, orchestrator-workers)
- Develop production-ready AI applications with proper evaluation pipelines
- Apply AI techniques across diverse domains (travel, healthcare, e-commerce, legal, etc.)
This is an educational repository. Feel free to:
- Experiment with the code and modify it for your learning
- Create your own variations of exercises
- Share your implementations and insights
- Report issues or suggest improvements
This repository is for educational purposes.
- Clone this repository
- Set up your Python environment and install dependencies
- Configure your API keys
- Choose your learning path
- Start with Course 1's introduction or Course 2's Lesson 1
Happy Learning! πβ¨