Skip to content

About

Hands-on practical prompt engineering workshop material for building real AI and web apps.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Practical Prompt Engineering Workshop

Objective

By the end, you can write prompts that work inside a real app. You will split a prompt into clear parts and keep user data apart from your rules. You will get data back in a shape your code can trust. You will also chain prompts, route requests and cache a long prompt to cut its cost.

There are 14 short notebooks. Each one starts with a problem, then shows the fix.

Who it is for

  • Developers who call a model from code and need answers they can parse.
  • Technical product managers who write, review or test prompts for a feature.
  • Anyone who has typed into a chat box and wants the same skill in code.

Not for you if you have never run a Python cell, or if you want to train or fine-tune a model. This workshop only changes the words you send.

Before you start

  • uv. It installs Python 3.11 and every package for you.
  • make and git.
  • An Anthropic API key from the Claude Console. To use another provider, see Switch provider.
  • Each notebook makes a few small calls. A run stops once it spends $1. Set SPEND_CAP_USD in .env to change that.

Run it

  1. Clone the repo and set it up.
git clone https://github.com/learnwithparam/practical-prompt-engineering-workshop.git
cd practical-prompt-engineering-workshop
make setup

Expect: Created .env. Paste your ANTHROPIC_API_KEY into it., then Ready. Next: make run.

  1. Open .env and paste your key after ANTHROPIC_API_KEY=.

Expect: the line reads ANTHROPIC_API_KEY=sk-ant-... with your own key. Git never sees this file.

  1. Run the offline check. It needs no key.
make check

Expect: check: 0 problems.

  1. Start JupyterLab.
make run

Expect: a link that starts with http://localhost:8888/lab. Open it in your browser.

  1. Open 01-basic-prompting.ipynb and run the cells from the top.

Expect: the first cell prints Ready to plan trips with: and a model name. The next cell prints a trip plan. If the key is missing, it stops with No key found. Run: cp env.example .env then paste your key into it.

  1. Optional: run it in Docker instead of step 4.
make up

Expect: Running at http://localhost:8888. Run make down to stop it.

The picture

The parts of a good prompt, sent through llm.chat, come back as text, data or cached tokens.

Every lesson builds a prompt from a few parts. It sends the prompt with llm.chat. The reply holds plain text, or checked data when you pass a schema.

flowchart LR
  Cell[Notebook cell] -- prompt, system, schema --> Chat[llm.chat in llm.py]
  Env[.env with key and model] --> Chat
  Chat -- LiteLLM --> Model[Claude or another provider]
  Model --> Reply[Reply: text, data, cached_tokens]
  Reply --> Cell
Loading

llm.py is the only file that talks to a model. It reads .env, picks the model, sends the request and counts the cost.

A real run from notebook 05. Asking for JSON in words breaks the code, and a schema fixes it.

A real run from notebook 05. Asking for JSON in words breaks the code, and a schema fixes it

Lessons

# Notebook What you build
01 The Basics of Prompting A Napa Valley trip planner with context, task and format
02 Being Clear and Direct Short answers with no fluff, and a forced choice
03 Roles and Personas A grumpy student, a logic expert and a strict math teacher
04 Separate Data from Instructions A safer email rewriter that keeps user text in tags
05 Formatting Output Haikus in tags, then as checked data with schema=
06 Chain of Thought (Reasoning) A riddle solver that shows its steps
07 Teaching by Example (Few-Shot) A parent bot and an email sorter taught by examples
08 Avoiding Hallucinations A question bot that says "I don't know" and quotes its proof
09 Building Complex Prompts TravelBot, a game referee, and a cached rule book
10 Building Workflows (Chaining) A self-check step and a story editor pipeline
11 Complex Structured Output A Green Bites order reader with nested schemas
12 Routing and Orchestration A hotel assistant that routes guests to experts
13 Reflection and Iterative Refinement A restaurant review that a writer drafts and an editor fixes
14 Prompt Optimization (Metaprompting) A helper that rewrites lazy prompts into strong ones

Switch provider

The notebooks use Claude Haiku (anthropic/claude-haiku-5-5) by default. To use another model, set two lines in .env: the model id and that provider's key. For example:

LITELLM_MODEL=gemini/<model id>
GEMINI_API_KEY=your-key

env.example lists more providers. Any model id that LiteLLM knows will work for the plain text lessons.

Two lessons need more from the model. Chapters 5 and 11 pass schema=, so the model must support structured output. Chapter 9 marks a block with cache_control. Other providers cache in their own way, so cached_tokens may stay at 0 there.

Where to go next

Take the free course built on these notebooks: Prompt Engineering Crash Course.

About

Hands-on practical prompt engineering workshop material for building real AI and web apps.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages