Spaces:
Runtime error
Download README.md from DATAD2/Final_Assignment_Template: direct link, hf CLI and curl.
- Browser
- Download file 7.49 kB
-
https://huggingface.co/spaces/DATAD2/Final_Assignment_Template/resolve/main/README.md
- Command line
-
hf download hf://spaces/DATAD2/Final_Assignment_Template/README.md
-
curl -L -o README.md https://huggingface.co/spaces/DATAD2/Final_Assignment_Template/resolve/main/README.md
A newer version of the Gradio SDK is available: 6.29.1
title: GAIA Lite
emoji: ๐ค
colorFrom: green
colorTo: blue
sdk: gradio
sdk_version: 5.25.2
app_file: app.py
pinned: false
hf_oauth: true
hf_oauth_expiration_minutes: 480
๐ค GAIA Lite
๐ Introduction
GAIA Lite is a small tool-calling agent for learning LangGraph and for the GAIA / Hugging Face Agents Course homework. It keeps a short tool list, a bounded thinkโact loop, regex answer extraction, and a cached evaluation runner.
๐ Key Features
- ๐ Multi-Modal Search: Web search, Wikipedia, and arXiv paper search
- ๐ป Code Execution: Support for Python, Bash, SQL, C, and Java
- ๐ผ๏ธ Image Processing: Analysis, transformation, OCR, and generation
- ๐ Document Processing: PDF, CSV, Excel, and text file analysis
- ๐ File Upload Support: Handle multiple file types with drag-and-drop
- ๐งฎ Mathematical Operations: Complete set of mathematical tools
- ๐ฌ Conversational Interface: Natural chat-based interaction
- ๐ Evaluation System: Automated benchmark testing and submission
๐๏ธ Project Structure
gaia-lite/
โโโ app.py # Gradio Q&A chatbot
โโโ evaluation_app.py # GAIA eval + cached submit
โโโ agent.py # Tools + LangGraph loop
โโโ extract_answer.py # Parse/normalize FINAL ANSWER
โโโ files_util.py # Attachment download + prompt paths
โโโ code_interpreter.py # Python (and other) code execution
โโโ image_processing.py # Optional image helpers (not wired)
โโโ system_prompt.txt # Agent instructions
โโโ answers_cache.json # Local eval cache (gitignored)
โโโ requirements.txt
โโโ README.md
๐ ๏ธ Tools (kept small on purpose)
The agent binds six tools. Extra math/image-generation helpers were removed from the loop so the model spends less time picking the wrong tool.
web_searchโ Tavily, up to 3 hitswiki_searchโ Wikipedia, up to 2 pagesexecute_pythonโ calculation, pandas, dates, CSV/Excel via codedownload_file_from_urlโ save a remote file locallyread_fileโ preview text, CSV, Excel, PDFextract_text_from_imageโ Tesseract OCR
Vector-store retrieval is off by default. Pass build_graph(use_retriever=True) only if you explicitly want similar-question context.
๐ฏ How to Use
Q&A Chatbot Interface (app.py)
Start the Chatbot:
python app.pyAccess the Interface:
- Open
http://localhost:7860in your browser - Upload files (images, documents, CSV, etc.) if needed
- Ask questions in natural language
- Get comprehensive answers with tool usage
- Open
Supported Interactions:
- Text Questions: "What is the capital of France?"
- Math Problems: "Calculate the square root of 144"
- Code Requests: "Write a Python function to sort a list"
- Image Analysis: Upload an image and ask "What do you see?"
- Data Analysis: Upload a CSV and ask "What are the trends?"
- Web Search: "What are the latest AI developments?"
Evaluation Runner (evaluation_app.py)
Run the Evaluation:
python evaluation_app.pyBenchmark Testing:
- Log in with your Hugging Face account
- Click "Run Evaluation & Submit All Answers"
- Monitor progress as the agent processes GAIA benchmark questions
- View results and scores automatically
๐ง Technical Architecture
LangGraph State Machine
START โ maybe_example โ assistant โ tools
โ โ
โโโโโโโโโโโโโ
- maybe_example: no-op unless
use_retriever=True - assistant: Groq Qwen with tools; after 8 tool rounds or a repeated identical call, it is forced to emit
FINAL ANSWER - tools:
ToolNoderuns the selected Python functions - extract_final_answer: regex parse + light normalization before scoring submit
Evaluation writes answers_cache.json, skips successful tasks on rerun, and submits from cache in a separate button. Attachments use GET /files/{task_id}, with an optional Hugging Face GAIA dataset fallback.
Vector Database Integration
- Supabase Vector Store: Stores GAIA benchmark Q&A pairs
- Semantic Search: Finds similar questions for context
- HuggingFace Embeddings: sentence-transformers/all-mpnet-base-v2
Multi-Modal File Support
- Images: JPG, PNG, GIF, BMP, WebP
- Documents: PDF, DOC, DOCX, TXT, MD
- Data: CSV, Excel, JSON
- Code: Python, Bash, SQL, C, Java
โ๏ธ Installation & Setup
Hugging Face Space secrets (most common crash)
If logs say GROQ_API_KEY is missing, open the Space โ Settings โ Variables and secrets and add at least:
GROQ_API_KEYโ from https://console.groq.com/keysTAVILY_API_KEYโ for web search
Then Restart the Space. Do not put keys in public git.
Local setup
git clone https://github.com/fisherman611/gaia-agent.git gaia-lite
cd gaia-lite
pip install -r requirements.txt
Create a .env file with your API keys:
SUPABASE_URL=your_supabase_url
SUPABASE_SERVICE_ROLE_KEY=your_supabase_key
GROQ_API_KEY=your_groq_api_key
TAVILY_API_KEY=your_tavily_api_key
HUGGINGFACEHUB_API_TOKEN=your_hf_token
LANGSMITH_API_KEY=your_langsmith_key
LANGSMITH_TRACING=true
LANGSMITH_PROJECT=gaia-lite
LANGSMITH_ENDPOINT=https://api.smith.langchain.com
4. Database Setup (Supabase)
Execute this SQL in your Supabase database:
-- Enable pgvector extension
CREATE EXTENSION IF NOT EXISTS vector;
-- Create match function for documents2 table
CREATE OR REPLACE FUNCTION public.match_documents_2(
query_embedding vector(768)
)
RETURNS TABLE(
id bigint,
content text,
metadata jsonb,
embedding vector(768),
similarity double precision
)
LANGUAGE sql STABLE
AS $$
SELECT
id,
content,
metadata,
embedding,
1 - (embedding <=> query_embedding) AS similarity
FROM public.documents2
ORDER BY embedding <=> query_embedding
LIMIT 10;
$$;
-- Grant permissions
GRANT EXECUTE ON FUNCTION public.match_documents_2(vector) TO anon, authenticated;
๐ Running the Application
Chatbot Interface
python app.py
Access at: http://localhost:7860
Evaluation Runner
python evaluation_app.py
Access at: http://localhost:7860
Live Demo
Upstream template Space: fisherman611/gaia-agent
๐ Resources
๐ค Contributing
Contributions are welcome! Areas for improvement:
- New Tools: Add specialized tools for specific domains
- UI Enhancements: Improve the chatbot interface
- Performance: Optimize response times and accuracy
- Documentation: Expand examples and use cases
๐ License
This project is licensed under the MIT License.