Before the session
Prepare your laptop: your RAM, Python, and the practice folder
In this lesson you get your laptop ready for the workshop: you know how much memory you have, you have Python working, and you have a practice folder with the sample data and the library the code uses.
Before you start, six ideas you'll use throughout the session. If you're coming from the terminal agents workshop, you already know the first two: skim them.
Six ideas before you start
1. What a terminal is
The terminal is a window where you type commands instead of clicking. Inside it runs a program called the shell that reads what you type and runs it: on Mac it's usually zsh, on Linux bash, and on Windows we use PowerShell. They're like dialects: the idea is the same, but some words change. That's why below there's one block for Mac/Linux and another for Windows.
2. What a command is and what ~ is
A command is a one-line instruction: you type it, press Enter, and the shell runs it. ~ is the shortcut for your home folder (the one with Documents, Downloads, and Desktop). ~/local-model-workshop means "the local-model-workshop folder inside your home folder."
3. What RAM is and why it matters so much today
Your computer has two kinds of storage:
- The disk keeps everything, even when you turn the computer off, but it's slow to look things up in. In the workshop analogy it's the storeroom.
- RAM is where whatever you're using right now goes. It's very fast, but it's much smaller than the disk and it empties when you turn the computer off. In the analogy it's your kitchen.
A language model lives on the disk as a file of several GB, but to answer it has to be fully in RAM. And RAM isn't just for the model: your system, your browser, and the video call also take up their share. That's why this workshop asks for at least 8 GB.
Your 8 GB of RAM, during the session
+------------------------------------------------------------+
| Operating | Browser and | Model | Free for the |
| system | video call | (about 2.5GB)| context |
+------------------------------------------------------------+
already used already used what you add breathing roomIn the workshop analogy: the cook lives in the storeroom (the disk), but to cook they have to come into your kitchen (RAM), and your kitchen already has other furniture in it. Whatever is left free is the space for their worktable (the context).
4. What Python is and what a library is
Python is the language the workshop code is written in. A script is a .py file with instructions; you run it with python name.py. A library is code someone else wrote that you install to use. Today we use just one: openai, the library that builds orders in the API format. Despite the name, it's not just for one company: it works with any server that speaks that format, and LM Studio speaks it.
5. What a virtual environment is
A virtual environment (.venv) is a folder, inside your project, where libraries are installed only for that project. That way you don't mix this workshop's libraries with those of other programs on your computer. You create it once, and in every new terminal you activate it with one line. When it's active, the start of the terminal line says (.venv).
6. The minimum Python to read the workshop code
In the session you won't write code from scratch: you copy it. But you will read it, and for that these pieces help. This example has almost all of them; the comments (whatever comes after #) say what each line does:
# This is a comment: Python ignores it, it's a note for whoever reads
import json # import: brings in code from a library to use it here
name = "Ana" # variable: a name that holds a value; here, a piece of text (string)
amounts = [54.20, 6.50, 61.75] # list: several values in order, inside square brackets
expense = {"category": "food", "amount": 54.20} # dictionary: name: value pairs, inside curly braces
print(expense["category"]) # reads the value stored under "category" and shows it: food
def add_all(values): # def: creates a function called add_all that takes one argument
total = 0 # we start the count at zero
for value in values: # for: repeats the block below once for each value
total = total + value # keeps adding
return total # return: what the function hands back when it finishes
result = add_all(amounts) # we call the function with the list; result holds 122.45
if result > 100: # if: the block below only runs if the condition is true
print(f"You spent {result:.2f}") # f-string: puts a value inside the text, with 2 decimals
try: # try: attempts something that might fail...
data = json.loads("this is not JSON")
except json.JSONDecodeError: # ...and if it fails with this error, instead of crashing, it does this
print("The text was not valid JSON")Two Python rules that surprise people the first time:
- Indentation matters. The lines that go "inside" a
def, afor, anif, or atrystart with four spaces. If you remove them or add extra ones, Python can't tell what goes inside what. That's why it's best to copy the whole code instead of retyping it. - Text goes in quotes.
"food"is text;foodwithout quotes would be the name of a variable.
And a format you'll see a lot: JSON. It's a way of writing data as text so two programs can pass it to each other, and it looks a lot like a Python dictionary: curly braces {} to group "name": value pairs, and square brackets [] for lists. For example, {"category": "home", "amount": 35.0}. Model servers answer in JSON, and in the session you'll ask the model to answer in JSON.
What you'll have at the end
~ (your home folder)
|
+-- local-model-workshop/ <-- the practice folder
|
+-- .venv/ the virtual environment, with the openai library
+-- expenses.csv September expenses (sample data)
+-- requirements.txt the list of libraries the code needsDuring the session you'll add the Python scripts one by one: chat.py, providers.py, measure.py, and agent.py.
Step 1. Check how much RAM you have (and which chip, if you use a Mac)
- Mac: Apple menu, About This Mac. Look at two things: Chip (or Processor) and Memory.
- Windows: Settings > System > About. Look at Installed RAM.
- Linux: in the terminal,
free -h. Look at the total column of the Mem row.
| What you see | What it means for today |
|---|---|
| 16 GB or more | You're comfortable. The workshop model runs with room to spare |
| 8 GB | It's enough for a small model like the workshop's (LM Studio recommends 16 GB for plenty of room). Close tabs and programs you're not using during the session |
| Less than 8 GB | The model won't have room. Follow the session with the cloud part and watch the demo |
| Mac with an Intel chip | LM Studio doesn't work on Intel Macs. Follow the session with the cloud part and watch the demo |
| Mac with an Apple chip (M1 or newer) | It's one of the best machines for running local models |
Step 2. Choose where you'll write: VS Code
Today you'll create Python files, so we recommend Visual Studio Code (VS Code), a free editor: you see your files on the left, the code in the center, and the terminal at the bottom, all in the same window. Download it from code.visualstudio.com and install it with the default options.
+----------------------------------------------------------------+
| VS Code |
+---------------------+------------------------------------------+
| EXPLORER | chat.py |
| | |
| LOCAL-MODEL- | # chat.py: sends a question... |
| WORKSHOP | from openai import OpenAI |
| .venv/ | ... |
| expenses.csv | |
| requirements.txt +------------------------------------------+
| chat.py | TERMINAL |
| | (.venv) $ python chat.py |
+---------------------+------------------------------------------+If you prefer another terminal (your system's, or Warp), that works too. All you need is to be able to create files and run commands in the same folder.
Step 3. Check that you have Python 3.10 or higher
Open a terminal (in VS Code: menu Terminal > New Terminal) and type the line for your system:
Mac and Linux:
python3 --versionWindows (PowerShell):
py --version
If you see Python 3.10 or a higher number (3.11, 3.12, 3.13...), you're ready. If you see a lower number, or an error, install it:
- Mac: download the installer from python.org/downloads and install it with the default options.
- Windows: python.org now offers the Python install manager (python.org/downloads/windows). Install it and, if it asks whether you want to add Python to the PATH, say yes. If you use the classic installer instead, check the "Add python.exe to PATH" box on its first screen. With either one, the
pycommand works. - In both cases, when it finishes, close the terminal, open a new one, and repeat the command.
- Linux (Ubuntu and derivatives):
sudo apt install python3 python3-venv.
Why close and reopen the terminal: the terminal reads the list of available programs (the PATH) only once, when it opens. A new terminal sees what you just installed.
Step 4. Create the practice folder
Copy the block for your system, paste it into the terminal, and press Enter. It creates the folder and the two data files.
On Mac or Linux
# Create the practice folder and go into it
mkdir -p ~/local-model-workshop && cd ~/local-model-workshop
# September expenses: sample data for the session
cat > expenses.csv <<'EOF'
date,description,category,amount
2026-09-01,Groceries at the market,food,54.20
2026-09-02,Bus card top-up,transport,20.00
2026-09-03,Coffee with a friend,Food,6.50
2026-09-05,Internet bill,home,35.00
2026-09-07,Movie tickets,fun,18.00
2026-09-09,Groceries at the market,food,61.75
2026-09-12,Taxi home,Transport,12.40
2026-09-14,Electricity bill,home,42.10
2026-09-18,Lunch near the office,food,11.90
2026-09-21,Concert,fun,45.00
2026-09-25,Bus card top-up,transport,20.00
2026-09-28,Groceries at the market,food,58.30
EOF
# The list of libraries the code needs: just one
cat > requirements.txt <<'EOF'
openai
EOF
# Show what ended up in the folder
lsOn Windows (PowerShell)
# Create the practice folder and go into it
New-Item -ItemType Directory -Force -Path "$HOME\local-model-workshop" | Out-Null
Set-Location "$HOME\local-model-workshop"
# September expenses: sample data for the session
@'
date,description,category,amount
2026-09-01,Groceries at the market,food,54.20
2026-09-02,Bus card top-up,transport,20.00
2026-09-03,Coffee with a friend,Food,6.50
2026-09-05,Internet bill,home,35.00
2026-09-07,Movie tickets,fun,18.00
2026-09-09,Groceries at the market,food,61.75
2026-09-12,Taxi home,Transport,12.40
2026-09-14,Electricity bill,home,42.10
2026-09-18,Lunch near the office,food,11.90
2026-09-21,Concert,fun,45.00
2026-09-25,Bus card top-up,transport,20.00
2026-09-28,Groceries at the market,food,58.30
'@ | Set-Content -Encoding ascii expenses.csv
# The list of libraries the code needs: just one
'openai' | Set-Content -Encoding ascii requirements.txt
# Show what ended up in the folder
ls
What the block does
| Line | What it does |
|---|---|
mkdir -p ~/local-model-workshop (or New-Item ...) | Creates the folder. -p (or -Force) avoids the error if it already exists |
cd ~/local-model-workshop (or Set-Location ...) | Goes into the folder |
cat > expenses.csv <<'EOF' ... EOF | Saves everything between those two lines into expenses.csv, exactly as is |
@' ... '@ | Set-Content ... | The same in PowerShell: a block of text that gets written to the file |
ls | Shows what's in the folder |
It's safe to paste the block twice: it just writes the same files again on top.
About expenses.csv: it's a table in plain text (CSV, comma-separated values), with an odd detail on purpose: some categories are capitalized (Food, Transport). Don't fix it: in part 4 of the session you'll see why it matters.
Open the folder in VS Code
Menu File > Open Folder, go to your home folder, and choose local-model-workshop. If it asks whether you trust the authors, say yes: the folder is yours. On the left you'll see expenses.csv and requirements.txt. Open a terminal with Terminal > New Terminal: it opens already inside the folder.
Step 5. Create the virtual environment and install the library
In the terminal, inside local-model-workshop, paste the block for your system.
On Mac or Linux
# Create the virtual environment in the .venv folder
python3 -m venv .venv
# Activate it: from here on, "python" and "pip" are the project's
source .venv/bin/activate
# Install the libraries in requirements.txt (just openai)
pip install -r requirements.txtOn Windows (PowerShell)
# Create the virtual environment in the .venv folder
py -m venv .venv
# Allow the activation script to run, only in this terminal
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
# Activate it: from here on, "python" and "pip" are the project's
.\.venv\Scripts\Activate.ps1
# Install the libraries in requirements.txt (just openai)
pip install -r requirements.txt
The Set-ExecutionPolicy line is there because Windows, for security, doesn't let unknown PowerShell scripts run. -Scope Process means "only in this window": when you close it, the usual rule comes back.
Check that it worked
With the environment active, the start of the terminal line says (.venv). Type:
python -c "import openai; print(openai.__version__)"If you see a version number, the library is installed. From here on, on every system the command is python (without the 3), because it's the virtual environment's Python.
Every new terminal starts without the environment active. If tomorrow you open another terminal, go into the folder and run only the activation line again (
source .venv/bin/activateon Mac and Linux;Set-ExecutionPolicy ...and.\.venv\Scripts\Activate.ps1on Windows). If you seeModuleNotFoundError: No module named 'openai', that's almost always why.
Check that you're ready
- I know how much RAM I have, and if I use a Mac, that it has an Apple chip.
-
python3 --version(orpy --version) shows 3.10 or higher. -
lsinsidelocal-model-workshopshowsexpenses.csvandrequirements.txt. - With
(.venv)active, the check command shows theopenaiversion.
What if pip install fails?
Check two things. First: that the line starts with (.venv); if it doesn't, the environment isn't active and you need to run the activation line. Second: that you have internet, because pip downloads the library. If it still fails, come as you are: we'll fix it in the first minutes of the session.
Check your understanding
1. The model is on your disk. Why does RAM matter too?
Because to answer, the model has to be fully in RAM, the fast memory for "what's being used right now." The disk only stores it. And RAM is shared with the system, the browser, and the video call.
2. What is the .venv virtual environment for?
To install libraries only for this project, without mixing them with those of other programs on your computer. You create it once and activate it in every new terminal.
3. You open a new terminal, run a script, and see No module named 'openai'. What happened?
The new terminal started without the virtual environment active, and your system's Python doesn't have the library. Go into the folder, run the activation line, and try again.
Summary
- The model lives on the disk but answers from RAM, and you share RAM with everything else: that's why the workshop asks for at least 8 GB. LM Studio doesn't work on Intel Macs.
- You have Python 3.10 or higher, the
local-model-workshopfolder withexpenses.csvandrequirements.txt, and a virtual environment with theopenailibrary. openaiis the library that builds orders in the API format; it works with any server that speaks that format, including LM Studio. Next step: install LM Studio and download the model.