--- title: GAIA Agent with Deep Research emoji: 🔍 colorFrom: blue colorTo: purple sdk: gradio sdk_version: "5.25.2" app_file: app.py pinned: false hf_oauth: true hf_oauth_expiration_minutes: 480 license: mit --- # GAIA Agent with Deep Research An intelligent agent built with LangGraph for the GAIA Benchmark, featuring multi-source research capabilities. ## 🌟 Features - **Multi-Source Research**: Combines Wikipedia, Web Search, and Academic papers - **RAG Enhancement**: Uses vector database for few-shot learning - **Tool Orchestration**: Smart tool selection based on question type - **Optimized System Prompt**: Guides the agent to choose appropriate tools ## 🚀 Quick Start ### 1. Install Dependencies ```bash pip install -r requirements.txt ``` ### 2. Configure API Keys Create a `.env` file: ```bash HUGGINGFACEHUB_API_TOKEN=your_hf_token TAVILY_API_KEY=your_tavily_key ``` ### 3. Setup Vector Database ```bash python setup_chromadb.py ``` ### 4. Run the Agent ```bash python app.py ``` ## 📁 Project Structure ``` hf_submission/ ├── agent.py # Main agent implementation ├── deep_research_tool.py # Multi-source research tool ├── app.py # Gradio UI ├── system_prompt.txt # Optimized system prompt ├── setup_chromadb.py # Vector DB initialization ├── requirements.txt # Dependencies └── metadata.jsonl # Training data ``` ## 🔧 Configuration ### Choosing LLM Provider Edit `agent.py` line 147: ```python graph = build_graph(provider="huggingface") # or "groq", "google" ``` ### Adjusting Deep Research Edit `deep_research_tool.py`: ```python # Change search sources WikipediaLoader(query=query, load_max_docs=2) # Adjust max_docs TavilySearchResults(max_results=10) # Adjust max_results ArxivLoader(query=query, load_max_docs=5) # Adjust max_docs # Change content length "content": doc.page_content[:2000] # Adjust truncation ``` ## 🎯 How It Works ### Agent Architecture ``` START → Retriever → Assistant → Tools → Assistant → END ↓ ↓ ↓ Vector DB LLM Decision Execute ``` ### Tool Selection Strategy The agent automatically selects tools based on question type: - **Complex topics** → `deep_research` (multi-source verification) - **Simple facts** → `wiki_search` (quick lookup) - **Recent events** → `web_search` (latest info) - **Academic topics** → `arxiv_search` (papers) - **Calculations** → math tools (multiply, add, etc.) ### Deep Research Process 1. **Multi-Source Search**: Queries Wikipedia, Web, and Arxiv in parallel 2. **Deduplication**: Removes redundant information using content hashing 3. **Formatting**: Creates structured report with source attribution ## 📊 Example Usage ```python from agent import build_graph from langchain_core.messages import HumanMessage # Build agent graph = build_graph(provider="huggingface") # Ask question question = "What is quantum computing and its applications?" result = graph.invoke({"messages": [HumanMessage(content=question)]}) # Get answer print(result["messages"][-1].content) ``` ## 🛠️ Advanced Features ### System Prompt The optimized system prompt (`system_prompt.txt`) guides the agent to: - Choose appropriate tools for different question types - Prioritize `deep_research` for complex topics - Cross-validate important information - Cite sources when possible ### Vector Database (RAG) Uses ChromaDB to store past questions and answers: - Provides few-shot examples to the agent - Improves accuracy on similar questions - Automatically populated from `metadata.jsonl` ## 🎓 Educational Resources This project includes comprehensive documentation: - Architecture deep dive - Tool calling mechanism explained - Deep research tutorial - Integration guide (See full project repository for detailed docs) ## 📝 License MIT ## 🤝 Contributing This is an educational project for the GAIA Benchmark. Feel free to: - Report issues - Suggest improvements - Share your results ## 📮 Contact For questions or feedback, please open an issue on the repository. --- **Built with**: LangGraph, LangChain, HuggingFace, ChromaD