--- title: HF Agents Course Final Agent emoji: 🕵️‍♂️ colorFrom: indigo colorTo: blue sdk: gradio sdk_version: 5.49.1 app_file: app.py pinned: false hf_oauth: true hf_oauth_expiration_minutes: 480 short_description: Smolagents CodeAgent for the HF Agents Course certificate tags: - agent - smolagents - agents-course --- # 🕵️‍♂️ Hugging Face Agents Course — Final Agent A production-ready AI agent built with Hugging Face **`smolagents`**. | Piece | What it does | | --- | --- | | `CodeAgent` | Writes short Python actions to call tools | | `InferenceClientModel` | Free Hub inference (`Qwen/Qwen2.5-Coder-32B-Instruct`) | | Tools | Web search, visit webpage, calculator, text summarizer | | Gradio UI | Chat tab + Unit 4 certificate evaluation / submit tab | | `submit_answers.py` | Local CLI that submits scores without needing a Space | > **Note on model class names:** older tutorials mentioned `HuggingFaceHubServerModel` / `HfApiModel`. > In current `smolagents`, that Hub backend is called **`InferenceClientModel`**. > **Important (2026):** Creating new **Gradio Spaces** on Hugging Face now requires a **PRO** plan (or an eligible older account for ZeroGPU). > If you cannot create a Space, use the **local runner** below — it still submits to the official Unit 4 leaderboard. Public code: https://huggingface.co/shazaaad/agents-course-final-agent --- ## What you need for the certificate To earn the **Certificate of Completion** you must score **≥ 30%** on the Unit 4 GAIA subset leaderboard. 1. Run the agent (Space **or** local `submit_answers.py`). 2. Submit answers to the scoring API. 3. Check your score on the [student leaderboard](https://huggingface.co/spaces/agents-course/Students_leaderboard). Also complete **Unit 1** and **one use-case assignment** as required by the course. --- ## Set up your Hugging Face API token (`HF_TOKEN`) ### A) On a Hugging Face Space (if you have PRO / eligible ZeroGPU) 1. Open your Space → **Settings** → **Variables and secrets**. 2. Add secret `HF_TOKEN` = your token from [https://huggingface.co/settings/tokens](https://huggingface.co/settings/tokens). ### B) On your computer (works without Spaces PRO) 1. Create a token at [https://huggingface.co/settings/tokens](https://huggingface.co/settings/tokens). 2. Copy `.env.example` → `.env` and paste: ```env HF_TOKEN=hf_your_token_here ``` Or run: `hf auth login` --- ## Run locally (4 steps) 1. Open a terminal in this project folder. 2. Create & activate a virtual environment: ```bash python -m venv .venv ``` - Windows PowerShell: `.venv\Scripts\Activate.ps1` - macOS / Linux: `source .venv/bin/activate` 3. Install dependencies: ```bash pip install -r requirements.txt ``` 4. Add your token, then either: **Chat UI** ```bash python app.py ``` **Certificate submission (recommended if you have no Space)** ```bash python submit_answers.py ``` Open the local URL Gradio prints (usually `http://127.0.0.1:7860`) when using `app.py`. --- ## Push to a Hugging Face Space (if your account allows Gradio) 1. Create a Space at [https://huggingface.co/new-space](https://huggingface.co/new-space) (Gradio + CPU basic / ZeroGPU). 2. Upload `app.py`, `requirements.txt`, and `README.md`. 3. Add secret `HF_TOKEN`. 4. Open **Certificate Evaluation** → Log in → Submit. 5. Score **≥ 30%** → claim your certificate. ### Optional: push with CLI ```bash hf upload YOUR_USERNAME/YOUR_SPACE_NAME . --repo-type space ``` --- ## Project files ``` hf-agents-course-final/ ├── app.py # Agent + Gradio UI (chat + certificate submit) ├── submit_answers.py # Local leaderboard submission (no Space needed) ├── requirements.txt # Python packages ├── README.md # This file ├── .env.example # Template for local HF_TOKEN └── .gitignore ``` Good luck — you’ve got this! 🎓