Spaces:
Runtime error
Runtime error
Update README.md
Browse files
README.md
CHANGED
|
@@ -12,4 +12,179 @@ hf_oauth: true
|
|
| 12 |
hf_oauth_expiration_minutes: 480
|
| 13 |
---
|
| 14 |
|
| 15 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
hf_oauth_expiration_minutes: 480
|
| 13 |
---
|
| 14 |
|
| 15 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
| 16 |
+
|
| 17 |
+
Super Agent - Advanced Q&A Chatbot
|
| 18 |
+
๐ Introduction
|
| 19 |
+
GAIA Agent is a sophisticated AI-powered chatbot system designed to handle complex questions and tasks through an intuitive Q&A interface. Built on top of the GAIA benchmark framework, this agent combines advanced reasoning, code execution, web search, document processing, and multimodal understanding capabilities. The system features both a user-friendly chatbot interface and a comprehensive evaluation runner for benchmark testing.
|
| 20 |
+
|
| 21 |
+
๐ Key Features
|
| 22 |
+
๐ Multi-Modal Search: Web search, Wikipedia, and arXiv paper search
|
| 23 |
+
๐ป Code Execution: Support for Python, Bash, SQL, C, and Java
|
| 24 |
+
๐ผ๏ธ Image Processing: Analysis, transformation, OCR, and generation
|
| 25 |
+
๐ Document Processing: PDF, CSV, Excel, and text file analysis
|
| 26 |
+
๐ File Upload Support: Handle multiple file types with drag-and-drop
|
| 27 |
+
๐งฎ Mathematical Operations: Complete set of mathematical tools
|
| 28 |
+
๐ฌ Conversational Interface: Natural chat-based interaction
|
| 29 |
+
๐ Evaluation System: Automated benchmark testing and submission
|
| 30 |
+
๐๏ธ Project Structure
|
| 31 |
+
gaia-agent/
|
| 32 |
+
โโโ app.py # Main Q&A chatbot interface
|
| 33 |
+
โโโ evaluation_app.py # GAIA benchmark evaluation runner
|
| 34 |
+
โโโ agent.py # Core agent implementation with tools
|
| 35 |
+
โโโ code_interpreter.py # Multi-language code execution
|
| 36 |
+
โโโ image_processing.py # Image processing utilities
|
| 37 |
+
โโโ system_prompt.txt # System prompt for the agent
|
| 38 |
+
โโโ requirements.txt # Python dependencies
|
| 39 |
+
โโโ metadata.jsonl # GAIA benchmark metadata
|
| 40 |
+
โโโ explore_metadata.ipynb # Data exploration notebook
|
| 41 |
+
โโโ README.md # This file
|
| 42 |
+
๐ ๏ธ Tool Categories
|
| 43 |
+
๐ Browser & Search Tools
|
| 44 |
+
Wikipedia Search: Search Wikipedia with up to 2 results
|
| 45 |
+
Web Search: Tavily-powered web search with up to 3 results
|
| 46 |
+
arXiv Search: Academic paper search with up to 3 results
|
| 47 |
+
๐ป Code Interpreter Tools
|
| 48 |
+
Multi-Language Execution: Python, Bash, SQL, C, Java support
|
| 49 |
+
Plot Generation: Matplotlib visualization support
|
| 50 |
+
DataFrame Analysis: Pandas data processing
|
| 51 |
+
Error Handling: Comprehensive error reporting
|
| 52 |
+
๐งฎ Mathematical Tools
|
| 53 |
+
Basic Operations: Add, subtract, multiply, divide
|
| 54 |
+
Advanced Functions: Modulus, power, square root
|
| 55 |
+
Complex Numbers: Support for complex number operations
|
| 56 |
+
๐ Document Processing Tools
|
| 57 |
+
File Operations: Save, read, and download files
|
| 58 |
+
CSV Analysis: Pandas-based data analysis
|
| 59 |
+
Excel Processing: Excel file analysis and processing
|
| 60 |
+
OCR: Extract text from images using Tesseract
|
| 61 |
+
๐ผ๏ธ Image Processing & Generation Tools
|
| 62 |
+
Image Analysis: Size, color, and property analysis
|
| 63 |
+
Transformations: Resize, rotate, crop, flip, adjust brightness/contrast
|
| 64 |
+
Drawing Tools: Add shapes, text, and annotations
|
| 65 |
+
Image Generation: Create gradients, noise patterns, and simple graphics
|
| 66 |
+
Image Combination: Stack and combine multiple images
|
| 67 |
+
๐ฏ How to Use
|
| 68 |
+
Q&A Chatbot Interface (app.py)
|
| 69 |
+
Start the Chatbot:
|
| 70 |
+
|
| 71 |
+
python app.py
|
| 72 |
+
Access the Interface:
|
| 73 |
+
|
| 74 |
+
Open http://localhost:7860 in your browser
|
| 75 |
+
Upload files (images, documents, CSV, etc.) if needed
|
| 76 |
+
Ask questions in natural language
|
| 77 |
+
Get comprehensive answers with tool usage
|
| 78 |
+
Supported Interactions:
|
| 79 |
+
|
| 80 |
+
Text Questions: "What is the capital of France?"
|
| 81 |
+
Math Problems: "Calculate the square root of 144"
|
| 82 |
+
Code Requests: "Write a Python function to sort a list"
|
| 83 |
+
Image Analysis: Upload an image and ask "What do you see?"
|
| 84 |
+
Data Analysis: Upload a CSV and ask "What are the trends?"
|
| 85 |
+
Web Search: "What are the latest AI developments?"
|
| 86 |
+
Evaluation Runner (evaluation_app.py)
|
| 87 |
+
Run the Evaluation:
|
| 88 |
+
|
| 89 |
+
python evaluation_app.py
|
| 90 |
+
Benchmark Testing:
|
| 91 |
+
|
| 92 |
+
Log in with your Hugging Face account
|
| 93 |
+
Click "Run Evaluation & Submit All Answers"
|
| 94 |
+
Monitor progress as the agent processes GAIA benchmark questions
|
| 95 |
+
View results and scores automatically
|
| 96 |
+
๐ง Technical Architecture
|
| 97 |
+
LangGraph State Machine
|
| 98 |
+
START โ Retriever โ Assistant โ Tools โ Assistant
|
| 99 |
+
โ โ
|
| 100 |
+
โโโโโโโโโโโโโโโโ
|
| 101 |
+
Retriever Node: Searches vector database for similar questions
|
| 102 |
+
Assistant Node: LLM processes question with available tools
|
| 103 |
+
Tools Node: Executes selected tools (web search, code, etc.)
|
| 104 |
+
Conditional Routing: Dynamically routes between assistant and tools
|
| 105 |
+
Vector Database Integration
|
| 106 |
+
Supabase Vector Store: Stores GAIA benchmark Q&A pairs
|
| 107 |
+
Semantic Search: Finds similar questions for context
|
| 108 |
+
HuggingFace Embeddings: sentence-transformers/all-mpnet-base-v2
|
| 109 |
+
Multi-Modal File Support
|
| 110 |
+
Images: JPG, PNG, GIF, BMP, WebP
|
| 111 |
+
Documents: PDF, DOC, DOCX, TXT, MD
|
| 112 |
+
Data: CSV, Excel, JSON
|
| 113 |
+
Code: Python, Bash, SQL, C, Java
|
| 114 |
+
โ๏ธ Installation & Setup
|
| 115 |
+
1. Clone Repository
|
| 116 |
+
git clone https://github.com/fisherman611/gaia-agent.git
|
| 117 |
+
cd gaia-agent
|
| 118 |
+
2. Install Dependencies
|
| 119 |
+
pip install -r requirements.txt
|
| 120 |
+
3. Environment Variables
|
| 121 |
+
Create a .env file with your API keys:
|
| 122 |
+
|
| 123 |
+
SUPABASE_URL=your_supabase_url
|
| 124 |
+
SUPABASE_SERVICE_ROLE_KEY=your_supabase_key
|
| 125 |
+
GROQ_API_KEY=your_groq_api_key
|
| 126 |
+
TAVILY_API_KEY=your_tavily_api_key
|
| 127 |
+
HUGGINGFACEHUB_API_TOKEN=your_hf_token
|
| 128 |
+
LANGSMITH_API_KEY=your_langsmith_key
|
| 129 |
+
|
| 130 |
+
LANGSMITH_TRACING=true
|
| 131 |
+
LANGSMITH_PROJECT=ai_agent_course
|
| 132 |
+
LANGSMITH_ENDPOINT=https://api.smith.langchain.com
|
| 133 |
+
4. Database Setup (Supabase)
|
| 134 |
+
Execute this SQL in your Supabase database:
|
| 135 |
+
|
| 136 |
+
-- Enable pgvector extension
|
| 137 |
+
CREATE EXTENSION IF NOT EXISTS vector;
|
| 138 |
+
|
| 139 |
+
-- Create match function for documents2 table
|
| 140 |
+
CREATE OR REPLACE FUNCTION public.match_documents_2(
|
| 141 |
+
query_embedding vector(768)
|
| 142 |
+
)
|
| 143 |
+
RETURNS TABLE(
|
| 144 |
+
id bigint,
|
| 145 |
+
content text,
|
| 146 |
+
metadata jsonb,
|
| 147 |
+
embedding vector(768),
|
| 148 |
+
similarity double precision
|
| 149 |
+
)
|
| 150 |
+
LANGUAGE sql STABLE
|
| 151 |
+
AS $$
|
| 152 |
+
SELECT
|
| 153 |
+
id,
|
| 154 |
+
content,
|
| 155 |
+
metadata,
|
| 156 |
+
embedding,
|
| 157 |
+
1 - (embedding <=> query_embedding) AS similarity
|
| 158 |
+
FROM public.documents2
|
| 159 |
+
ORDER BY embedding <=> query_embedding
|
| 160 |
+
LIMIT 10;
|
| 161 |
+
$$;
|
| 162 |
+
|
| 163 |
+
-- Grant permissions
|
| 164 |
+
GRANT EXECUTE ON FUNCTION public.match_documents_2(vector) TO anon, authenticated;
|
| 165 |
+
๐ Running the Application
|
| 166 |
+
Chatbot Interface
|
| 167 |
+
python app.py
|
| 168 |
+
Access at: http://localhost:7860
|
| 169 |
+
|
| 170 |
+
Evaluation Runner
|
| 171 |
+
python evaluation_app.py
|
| 172 |
+
Access at: http://localhost:7860
|
| 173 |
+
|
| 174 |
+
Live Demo
|
| 175 |
+
Try it online: Hugging Face Space
|
| 176 |
+
|
| 177 |
+
๐ Resources
|
| 178 |
+
GAIA Benchmark
|
| 179 |
+
Hugging Face Agents Course
|
| 180 |
+
LangGraph Documentation
|
| 181 |
+
Supabase Vector Store
|
| 182 |
+
๐ค Contributing
|
| 183 |
+
Contributions are welcome! Areas for improvement:
|
| 184 |
+
|
| 185 |
+
New Tools: Add specialized tools for specific domains
|
| 186 |
+
UI Enhancements: Improve the chatbot interface
|
| 187 |
+
Performance: Optimize response times and accuracy
|
| 188 |
+
Documentation: Expand examples and use cases
|
| 189 |
+
๐ License
|
| 190 |
+
This project is licensed under the MIT License.
|