Skip to content

hari7261/DeepResearchAgent-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”¬ DeepResearchAgent-AI

Advanced AI-Powered Research Assistant v2.0

πŸš€ Try it Live on Hugging Face Spaces πŸš€

DeepResearchAgent-AIepResearchAgent-AI

πŸš€ Features

  • 🎯 Intelligent Web Search: Uses DuckDuckGo to find the most relevant sources
  • πŸ“Š Advanced Content Analysis: Automatically extracts and processes content from multiple websites
  • πŸ€– AI-Powered Synthesis: Leverages Google's Gemini 2.0 Flash to create comprehensive reports
  • πŸ“„ Professional Reports: Generates both Markdown and beautifully formatted PDF reports
  • 🎨 Modern UI: Sleek, responsive interface with gradient backgrounds and smooth animations
  • πŸ” Secure API Handling: Built-in validation with detailed error messages and troubleshooting
  • ⚑ Fast & Reliable: Automated research in minutes with real-time progress tracking
  • πŸ›‘οΈ Safe File Handling: Automatic filename sanitization for cross-platform compatibility
  • πŸ“± Responsive Design: Works perfectly on desktop, tablet, and mobile devices

πŸ“‹ Prerequisites

  • Python 3.8 or higher
  • Google Gemini API key (get it from AI Studio)
  • Internet connection for web research

πŸ”§ Installation

  1. Clone or download this repository

    git clone <your-repo-url>
    cd hell
  2. Automated Setup (Recommended)

    python setup.py
  3. Manual Setup

    pip install -r requirements.txt
  4. Get your Gemini API key

    • Visit Google AI Studio
    • Create an account or sign in
    • Generate a new API key
    • Copy the complete API key (usually 30-50 characters)
    • Keep this key secure and don't share it publicly

πŸš€ Quick Start

  1. Automated Setup

    python setup.py
  2. Manual Setup

    pip install -r requirements.txt
  3. Run the application

    python app.py
  4. Get your API key

πŸ§ͺ API Key Testing

Before running the main application, you can test your API key independently:

python test_api_key.py

Or test with your API key directly:

python test_api_key.py "your-api-key-here"

This will help you identify and resolve API key issues before using the main application.

  1. Run the application

    python app.py
  2. Open your browser

    • The application will automatically open in your default browser
    • Or navigate to the URL shown in the terminal (usually http://127.0.0.1:7860)
  3. Start researching

    • Enter your Gemini API key in the designated field
    • Click "πŸ” Validate API Key" to test your key (recommended)
    • Type your research topic (e.g., "Latest developments in AI", "Climate change solutions 2024")
    • Click "πŸš€ Start Deep Research"
    • Wait for the comprehensive report to be generated (1-2 minutes)
    • Download your report in either:
      • πŸ“ Markdown format (.md file)
      • πŸ“„ Professional PDF with formatted layout, branding, and citations

🎨 Modern Interface Features

  • 🎯 Professional Hero Section: Eye-catching gradient header with DeepResearchAgent-AI branding
  • πŸ”‘ Smart API Setup: Collapsible step-by-step guide for API key configuration
  • πŸ“Š Real-time Validation: Instant feedback on API key status with detailed error messages
  • πŸ”„ Progress Tracking: Visual progress indicators during research process
  • πŸ“± Fully Responsive: Optimized for desktop, tablet, and mobile devices
  • 🎨 Modern Glassmorphism: Professional styling with gradients, shadows, and blur effects
  • 🌈 High Contrast: Dark text on light backgrounds for perfect readability
  • ⚑ Fast Loading: Optimized performance with efficient caching

πŸ“ Project Structure

hell/
β”œβ”€β”€ app.py              # Main application with modern UI and PDF generation
β”œβ”€β”€ README.md           # Comprehensive documentation
β”œβ”€β”€ requirements.txt    # All dependencies including PDF generation
└── setup.py           # Automated setup and testing script

πŸ” How It Works

  1. πŸ” Intelligent Search: Uses DuckDuckGo to find the most relevant and recent sources
  2. πŸ“Š Content Processing: Fetches and extracts meaningful content from multiple web pages
  3. πŸ€– AI Analysis: Google's Gemini 2.0 Flash analyzes all gathered information
  4. πŸ“„ Professional Reports: Generates comprehensive reports with:
    • Executive Summary with key findings
    • Detailed Analysis with explanations and examples
    • Real-world Applications and use cases
    • Future Trends and predictions
    • Professional Citations with source links
    • Branded PDF Layout with your platform name and styling

βœ… What's Fixed & Enhanced:

οΏ½ Fixed Issues:

  • βœ… Filename Generation: Now correctly uses topic name instead of report content
  • βœ… File Safety: Proper sanitization of special characters (?, <, >, :, /, , |, *)
  • βœ… UI Visibility: Fixed white text issues with high-contrast dark text on light backgrounds
  • βœ… Responsive Design: Fully responsive layout that works on all devices
  • βœ… Error Handling: Robust error handling for PDF generation and file creation

🎨 UI Enhancements:

  • βœ… Modern Glassmorphism: Professional glass-like effects with blur and transparency
  • βœ… Gradient Backgrounds: Beautiful color gradients throughout the interface
  • βœ… High Contrast Text: Dark text on light backgrounds for perfect readability
  • βœ… Responsive Layout: Adapts seamlessly to different screen sizes
  • βœ… Professional Styling: Enhanced buttons, inputs, and layout components
  • βœ… Status Indicators: Clear success/error messages with color coding

πŸ“„ PDF Features:

  • βœ… Professional Layout: Multi-page PDF with headers, footers, and branding
  • βœ… DeepResearchAgent-AI Branding: Platform name prominently displayed
  • βœ… Organized Sections: Table of contents with proper formatting
  • βœ… Source Citations: Complete bibliography with links
  • βœ… Modern Typography: Professional fonts and color scheme

βš™οΈ Configuration

Environment Variables (Optional)

You can set your Gemini API key as an environment variable:

Windows (PowerShell):

$env:GEMINI_API_KEY="your-api-key-here"

Linux/Mac:

export GEMINI_API_KEY="your-api-key-here"

Customization Options

You can modify the following parameters in app.py:

  • max_results: Number of search results to fetch (default: 10)
  • max_sources: Number of sources to analyze (default: 5)
  • content_length: Maximum content length per source (default: 5000 characters)

πŸ“Š Example Use Cases

  • Academic Research: Gather information on scientific topics
  • Market Analysis: Research industry trends and competitors
  • Technology Updates: Stay current with latest developments
  • Investment Research: Analyze market opportunities
  • Educational Content: Create comprehensive study materials

πŸ› οΈ Dependencies

  • gradio: Web interface framework
  • google-generativeai: Google's Gemini AI API
  • ddgs: Web search functionality (formerly duckduckgo-search)
  • requests: HTTP requests for web scraping
  • beautifulsoup4: HTML parsing and content extraction

⚠️ Important Notes

  • API Limits: Be mindful of your Gemini API usage limits and costs
  • Rate Limiting: The tool includes delays between requests to be respectful to websites
  • Content Length: Content is automatically truncated to avoid token limits
  • Source Quality: The tool filters out low-quality sources automatically

πŸ”’ Security

  • Never share your API key publicly
  • The API key is handled securely and not stored permanently
  • Use environment variables for production deployments

πŸ› Troubleshooting

Common Issues

  1. "No relevant sources found"
    • Try different keywords or a more specific search term
    • Check your internet connection

2. "Invalid API key" or "API key validation failed"

  • βœ… Copy the complete key - make sure you didn't miss any characters
  • βœ… Check for extra spaces at the beginning or end of the key
  • βœ… Try refreshing the AI Studio page and copying the key again
  • βœ… Make sure you're signed in to the correct Google account
  • βœ… Use the test script: python test_api_key.py "your-key"
  • βœ… Try creating a new API key if the current one doesn't work

3. "API quota exceeded"

4. "Network error" or "Connection timeout"

  • Check your internet connection
  • Try again in a few minutes
  • Disable VPN if you're using one
  • Check if Google services are accessible in your region

5. "API key doesn't have required permissions"

  • Regenerate your API key at https://aistudio.google.com/
  • Make sure the API key is enabled for Gemini API
  • Check if your Google Cloud project has the necessary permissions
  1. "Search error: operation timed out"

    • This is usually a temporary network issue
    • Try running the search again
    • Check your internet connection
  2. Import errors with ddgs

    • Make sure you've uninstalled the old duckduckgo-search package
    • Install the new ddgs package: pip install ddgs
    • Run the setup script: python setup.py
  3. Installation issues

    • Make sure you have Python 3.8+ installed
    • Try installing dependencies one by one
    • Use the provided setup script for automated installation
  4. Filename errors or download issues

    • The app automatically sanitizes filenames to remove invalid characters
    • Special characters like ?, <, >, :, /, \, |, * are replaced with underscores
    • Very long research topics are automatically truncated for safe file creation

Getting Help

If you encounter issues:

  1. Check the console output for detailed error messages
  2. Verify all dependencies are installed correctly
  3. Ensure your API key is valid and has sufficient quota

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

🀝 Contributing

Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests.

πŸ“§ Contact

For questions or support, please create an issue in the repository.


Happy Researching! πŸ”βœ¨