# Setup · your course workspace ## First exercise: get the files onto your computer The course supports **Windows, macOS, and Linux**. We check setup and access together with the instructor; you can prepare early if you wish. 1. Download the [course archive (.zip)](https://www.idiap.ch/~wdroz/lifescience_course/aiforlifescience.zip) and **extract it**. 2. Open the extracted course folder in your code editor. 3. Find `pyproject.toml`, `examples`, and `.env.example` inside that folder. This is the **course folder**: the starting place for our commands. **Checkpoint:** open `examples/01_pydanticai_chat.py` in the editor. --- # Choose your terminal ## Use the shell for your operating system | Computer | Open | Course shell | | --- | --- | --- | | Windows | Search Start for **PowerShell** | PowerShell | | macOS | Search Spotlight for **Terminal** | zsh (the usual default) | | Linux | Open **Terminal** from the applications menu | bash | An editor's terminal also works: choose the matching shell profile. On Windows, select **PowerShell** if the editor opens Command Prompt. The course's `uv` and Python commands are the same in all three shells. Only instructions marked with an operating system differ. **New to the command line?** See the visual [Terminal basics for Windows and macOS](terminal_basics.html) reference. --- # Find your place in the terminal ## A terminal runs commands in the current folder | Command | What it does | | --- | --- | | `pwd` | Shows the current folder | | `cd '...'` | Changes folder; replace `...` with your course folder's full path | | `ls` | Lists the files and folders here | Example paths: replace `student` and the folder location with your own. | Computer | Example command | | --- | --- | | Windows | `cd 'C:\Users\student\Downloads\aiforlifescience'` | | macOS | `cd '/Users/student/Downloads/aiforlifescience'` | | Linux | `cd '/home/student/Downloads/aiforlifescience'` | Keep the quotes for spaces. Press **Enter** after each command. **Checkpoint:** `ls` shows `pyproject.toml` and `examples`. --- # Keyboard shortcuts for the lab ## Saving, pasting, and stopping are different actions | Action | Windows | macOS | Linux | | --- | --- | --- | --- | | Save in the editor | Ctrl+S | Command+S | Ctrl+S | | Paste in the terminal | Ctrl+V in Windows Terminal | Command+V | Ctrl+Shift+V in GNOME Terminal | | Stop the running app | Ctrl+C | **Control+C** | Ctrl+C | Use the application's **Paste** menu if a shortcut differs in your editor or terminal. Paste one command at a time, inspect it, then press **Enter**. **On a Mac:** stopping the app uses the Control key, even though saving uses Command. --- # Install uv once ## uv prepares Python and the libraries our app needs **Windows · PowerShell** ```powershell winget install --id=astral-sh.uv -e ``` **macOS · Terminal (zsh) / Linux · Terminal (bash)** ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` Installers download and run code. Review the source and instructions in the [official uv installation guide](https://docs.astral.sh/uv/getting-started/installation/) before running them. **Checkpoint:** reopen your terminal; `uv --version` prints `uv` and a version number. **Mac installation or shell-file permission issue?** See [macOS uv troubleshooting](macos_uv.html). --- # Intel Mac · prepare a dependency build ## Complete this before `uv sync` The course's `cryptography` dependency needs a **source build on Intel Macs**. In macOS Terminal, install Apple's command-line tools and wait for them to finish: ```bash xcode-select --install ``` With [Homebrew](https://brew.sh/) installed, prepare the libraries and compiler: ```bash brew install openssl@3 rust ``` Then continue with `uv sync --group examples`; allow extra time for compilation. An Intel Mac build still needs verification on your machine with the instructor. --- # What uv manages for you ## Prepare the project, then run a program inside it | Command | Purpose | | --- | --- | | `uv sync --group examples` | Prepares the environment and installs the example dependencies | | `uv run --group examples python …` | Runs Python with those dependencies available | | Item in the course folder | Meaning | | --- | --- | | `pyproject.toml` | Required Python version and libraries | | `uv.lock` | Recorded dependency versions for reproducibility | | `.venv` | Local environment created by uv; no manual activation needed | **Coding assistant:** “Explain this command before I run it. What will it change?” --- # Check Python before the chat ## The same commands work on Windows, macOS, and Linux From the course folder, prepare the dependencies; the first run may take several minutes: ```bash uv sync --group examples ``` When the terminal prompt returns, run a small Python instruction: ```bash uv run --group examples python -c "print('Python is ready')" ``` **Expected output:** `Python is ready` This is Python executing your instruction. No model or API key is involved. --- # Connect with your course key ## `.env` holds this app's connection settings In the editor, copy `.env.example` to a new file named exactly **`.env`**, beside `pyproject.toml`. Keep an existing configured `.env`. The template already contains the course endpoint and default model: ```dotenv LLM_BASE_URL=https://api.ppq.ai LLM_MODEL=deepseek/deepseek-v4.1-flash LLM_API_KEY=replace-with-your-instructor-provided-key ``` Replace only the `LLM_API_KEY` value with your individual instructor-supplied key and save. Check that the filename is not `.env.txt`. **After any `.env` change:** save, stop with **Control+C** on all three systems, and launch again. --- # Find files whose names start with a dot ## Keep the exact names `.env.example` and `.env` The editor's file list can show these files even when the file manager hides them. To find the course files from the terminal: | Shell | Command | | --- | --- | | Windows PowerShell | `ls` | | macOS zsh / Linux bash | `ls -a` | These commands list names; they do not print your key. Check that the saved file is **`.env`**, beside `pyproject.toml`, with no `.txt` suffix. **Windows File Explorer:** enable **View → Show → File name extensions**. --- # What your course key provides ## Individual API access through PPQ - You need no PPQ signup or payment to use the supplied key. - The instructor communicates your key's spending allowance and expiration date. - The default model is `deepseek/deepseek-v4.1-flash`; the optional alternative is `openai/gpt-5.6-luna`. Change `LLM_MODEL`, save, and restart to switch. - Use your own subscription or free tier for the coding assistant. Reserve the supplied PPQ key for agents running inside your course code. Keep the key in private settings. Never include it in prompts, screenshots, shared logs, or submissions. --- # Open your first chat ## The terminal runs the app; the browser displays it ```bash uv run --group examples python examples/01_pydanticai_chat.py ``` Leave this terminal open. The app keeps running, so the prompt does not return. Questions and conversation context go through PPQ to the model provider. Open [http://127.0.0.1:7932](http://127.0.0.1:7932) in your browser and ask: > Which canton is Martigny in? **Checkpoint:** the chat displays an answer. You still need to check its claims. To stop the app, return to its terminal and press **Control+C** on Windows, Mac, or Linux. --- # If a setup command fails ## Read the message before trying another command | What you see | First check | | --- | --- | | `uv` is not found or recognized | Reopen the terminal or editor after installation; retry `uv --version` | | No `pyproject.toml`, or Python cannot open the script | Use `pwd` and `ls`; check the extracted folder, quoted path, and exact filename case | | Download fails, or a library cannot be imported | Check internet access and the complete error; retry `uv sync --group examples`, then use the full `uv run --group examples …` command | **Coding assistant:** “Here is my command and error, with secrets removed. Explain the likely cause and suggest one reversible check.” --- # If the chat does not work ## Use the terminal output to locate the problem | What you see | First check | | --- | --- | | Browser cannot connect, or the interface does not load | Check the app is still running and the address is `http://127.0.0.1:7932`; check internet access for the interface's first load | | `Address already in use` | A previous app may still be running; stop your earlier instance with Ctrl+C in its terminal, then retry | If the interface opens but PPQ rejects a question, check the terminal message using the next slide. --- # If PPQ rejects a request ## Check the cause before sending another question | Terminal message | First check | | --- | --- | | Missing setting or authentication failure | Check the `.env` filename and location; replace the key placeholder with your supplied key, save, and restart | | Model unknown or unavailable | Use the exact model ID from `.env.example` or the course alternative; save and restart | | Spending limit reached or key expired | Stop retrying and contact the instructor, who manages your allowance and expiry | Share the error with secrets removed. Never send the key itself. **Checkpoint:** one public question returns an answer; review its claims. --- # Come back next session ## Open the same course folder and launch again 1. Open the course folder in the editor and open its terminal. 2. Check `ls` shows `pyproject.toml` and `examples`. 3. From Day 02 / Week 02 onward, start every session by running `uv run scripts/update.py`. 4. Start the app and open its browser address: ```bash uv run --group examples python examples/01_pydanticai_chat.py ``` After changing an instruction or `.env`: **save, Ctrl+C, run again, then start a new chat**. Installed uv and a saved `.env` can be reused. The updater shows progress and preserves your work. Review any incoming course copies it saves in `.course-updates/`; keep `.course-update.json` in the folder. Continue with [Week 1 · your first PydanticAI chat](week_01.html).