Spaces:
Sleeping
Sleeping
Miguel Figueiredo Marques
Claude Opus 4.8
Build GAIA agent (LangGraph + Groq) with tools and file handling
87033aa |
Download INSTRUCTIONS.md from miguelkmarques/Final_Assignment: direct link, hf CLI and curl.
- Browser
- Download file 3.82 kB
-
https://huggingface.co/spaces/miguelkmarques/Final_Assignment/resolve/main/INSTRUCTIONS.md
- Command line
-
hf download hf://spaces/miguelkmarques/Final_Assignment/INSTRUCTIONS.md
-
curl -L -o INSTRUCTIONS.md https://huggingface.co/spaces/miguelkmarques/Final_Assignment/resolve/main/INSTRUCTIONS.md
3.82 kB
| # GAIA Agent — Setup & Run Instructions | |
| A self-contained LangGraph + Groq agent for the Hugging Face Agents Course Unit 4 final | |
| assignment. Goal: score **≥ 30% (6 / 20)** on the GAIA question subset to earn the certificate. | |
| ## What's in here | |
| | File | Purpose | | |
| |---|---| | |
| | `app.py` | The Gradio app + the agent (LangGraph ↔ Groq, 7 tools, file handling). | | |
| | `requirements.txt` | Python dependencies. | | |
| | `.env.example` | Template for local API keys. Copy to `.env`. | | |
| **Agent tools:** `web_search` (Tavily), `wiki_search`, `arxiv_search`, `run_python` | |
| (math/dates/data, pandas & numpy preloaded), `read_file` (text/CSV/Excel), | |
| `transcribe_audio` (Groq Whisper), `analyze_image` (Groq vision). | |
| Questions with attachments are auto-downloaded from `/files/{task_id}` and their local | |
| path is injected into the prompt so the agent can read/transcribe/analyze them. | |
| ## 1. Get the two free API keys | |
| - **Groq** (the LLM): https://console.groq.com → API Keys | |
| - **Tavily** (web search): https://app.tavily.com → API key | |
| ## 2. Test locally | |
| This machine blocks system-wide `pip` (PEP 668 "externally-managed-environment"), so use a | |
| virtual environment: | |
| ```bash | |
| cd Final_Assignment_Template | |
| python3 -m venv .venv | |
| ./.venv/bin/pip install -r requirements.txt | |
| cp .env.example .env # then paste your keys into .env | |
| ``` | |
| **Smoke-test the agent** (no HF login needed — uses your keys from `.env`): | |
| ```bash | |
| ./.venv/bin/python -c "from app import BasicAgent; print(BasicAgent()('What is the capital of France?'))" | |
| ``` | |
| **Launch the full Gradio UI locally** (optional). The HF login button requires your machine | |
| to be HF-authenticated, so first set a token, then run: | |
| ```bash | |
| export HF_TOKEN=hf_your_token_here # from https://huggingface.co/settings/tokens | |
| ./.venv/bin/python app.py # opens http://localhost:7860 | |
| ``` | |
| > Note: `requirements.txt` pins `gradio[oauth]` (needed for the login button) and the Gradio | |
| > UI is built lazily inside `build_demo()`, so `import app` works for testing without | |
| > triggering OAuth. | |
| ## 3. Deploy to a public Hugging Face Space (required for the certificate) | |
| The submission link must point to a **public** Space repo, or the score won't count. | |
| 1. Create a new **Gradio** Space (or "Duplicate" the template space) and push these files. | |
| 2. In the Space's **Settings → Secrets**, add: | |
| - `GROQ_API_KEY` | |
| - `TAVILY_API_KEY` | |
| 3. Open the Space, click **Login** with the HF button, then | |
| **Run Evaluation & Submit All Answers**. A full run takes several minutes. | |
| ## Configuration (optional) | |
| Set these as env vars / Space secrets to override defaults: | |
| | Variable | Default | Notes | | |
| |---|---|---| | |
| | `GROQ_MODEL` | `llama-3.3-70b-versatile` | Main reasoning + tool-calling model. | | |
| | `GROQ_VISION_MODEL` | `meta-llama/llama-4-scout-17b-16e-instruct` | Image questions. Update if retired. | | |
| | `PER_QUESTION_DELAY` | `3` | Seconds between questions. Raise to `15` if rate-limited. | | |
| ## Troubleshooting | |
| - **Rate-limit / 429 errors:** Groq free tier has a tokens-per-minute cap. The agent | |
| retries with backoff, but if runs still fail, raise `PER_QUESTION_DELAY`. | |
| - **Vision tool errors:** if Groq retires the vision model, set `GROQ_VISION_MODEL` to a | |
| current vision-capable model id from the Groq console. | |
| - **Low score:** 30% is the pass bar, not a ceiling. Audio/image questions are best-effort. | |
| Improving search quality and adding question-specific reasoning is where extra points come from. | |
| ## How the answer format works | |
| GAIA grades by exact match. The system prompt forces every answer to end with | |
| `FINAL ANSWER: [x]`, and `extract_final_answer()` in `app.py` parses the text after it. | |
| `x` must be a number (no commas/units), as-few-words-as-possible string (no articles or | |
| abbreviations), or a comma-separated list with one space after each comma. | |