Bhanu Prakash Gopularam
Add LangGraph GAIA agent with Gemini and tools; update README
84d8d95
|
Raw History Blame Contribute Delete
2.46 kB

A newer version of the Gradio SDK is available: 6.33.0

Upgrade
metadata
title: Template Final Assignment
emoji: 🕵🏻‍♂️
colorFrom: indigo
colorTo: indigo
sdk: gradio
sdk_version: 5.25.2
app_file: app.py
pinned: false
hf_oauth: true
hf_oauth_expiration_minutes: 480

GAIA Agent (HF Agents Course Final Assignment)

A LangGraph ReAct agent (Gemini + tools) that answers the GAIA questions served by the course scoring API and submits the answers.

How it works (per question)

  1. app.py fetches all questions from /questions and loops over them.
  2. If a question has an attachment, it is downloaded from /files/{task_id} and its local path is appended to the question.
  3. The question goes to the LangGraph agent in agent.py: assistant (Gemini) <-> tools loop, guided by system_prompt.txt.
  4. The agent picks tools as needed: web search (Tavily), Wikipedia, arXiv, webpage fetch, YouTube transcript, file reader (csv/xlsx/pdf/txt), Python executor, image analysis, audio transcription.
  5. When done, the model writes FINAL ANSWER: ...; only the text after it is kept (exact-match grading).
  6. Failed calls are retried up to 3 times; all answers are POSTed to /submit and the score is shown.

Run on the Hugging Face Space

  1. Space Settings -> Variables and secrets, add secrets: GEMINI_API_KEY, TAVILY_API_KEY, HF_TOKEN.
  2. Open the Space, click Sign in with Hugging Face, then Run Evaluation & Submit All Answers. It takes several minutes.

Run locally from scratch

git clone https://huggingface.co/spaces/bhanuprakashg/Final_Assignment_Template
cd Final_Assignment_Template

python3 -m venv .venv            # create environment
source .venv/bin/activate        # activate it (Windows: .venv\Scripts\activate)
pip install -r requirements.txt  # install dependencies

cat > .env <<'EOF2'
GEMINI_API_KEY=your_gemini_key
TAVILY_API_KEY=your_tavily_key
HF_TOKEN=your_hf_token
EOF2

python agent.py   # quick agent smoke test
python app.py     # start the Gradio UI at http://127.0.0.1:7860

Note: the OAuth login is mocked locally (needs huggingface-cli login); real submission is easiest from the Space.

Files

  • app.py - Gradio UI, question fetching, file download, submission
  • agent.py - LangGraph agent, tools, answer extraction
  • system_prompt.txt - GAIA answer-format prompt
  • requirements.txt - dependencies (.env is gitignored; never commit keys)