Skip to content

πŸ” Deep Research Agent is an AI-powered research assistant that enhances online research with depth and accuracy, leveraging Google's Gemini API, web scraping, and natural language processing for comprehensive results, and it finally generates a detailed report at the end.

Notifications You must be signed in to change notification settings

DevHammad0/Deep_Research_Agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Deep Research Agent

A sophisticated terminal-based Deep Research Agent built with OpenAI AI Agents SDK, powered by Google's Gemini API and enhanced with Rich CLI formatting. This agent performs thorough research by analyzing queries, browsing the web, and synthesizing insights into clear, well-structured reports.

Project Overview

The Deep Research Agent is an advanced AI-powered research tool that:

  • Breaks down complex research queries into focused search topics
  • Performs intelligent web searches using DuckDuckGo
  • Analyzes and summarizes search results
  • Makes decisions about follow-up research needs
  • Synthesizes findings into comprehensive markdown reports
  • Presents all information with a beautiful terminal interface

Installation

Prerequisites

Setup Instructions

  1. Clone the repository:
git clone https://github.com/DevHammad0/Deep_Research_Agent.git
cd deep_research_agent
  1. Install dependencies using UV:
uv pip install -r requirements.txt
  1. Set up your Gemini API key:
Copy `.env.example` to `.env` and fill in your values:  
- `GEMINI_API_KEY`: Your Google Gemini API key

Project Structure

DEEP_RESEARCH_AGENT/
β”œβ”€β”€ src/
β”‚   └── deep_research_agent/
β”‚       β”œβ”€β”€ research_agents/  # Specialized agent implementations
β”‚       β”‚   β”œβ”€β”€ follow_up_agent.py  # Research completion decisions
β”‚       β”‚   β”œβ”€β”€ query_agents.py  # Query analysis and generation
β”‚       β”‚   β”œβ”€β”€ search_agent.py  # Web content analysis
β”‚       β”‚   └── synthesis_agent.py  # Report generation
β”‚       β”œβ”€β”€ coordinator.py  # Research workflow orchestrator
β”‚       β”œβ”€β”€ main.py  # Entry point
β”‚       β”œβ”€β”€ model_setup.py  # GEMINI model configurations
β”‚       └── models.py  # Data models and types
β”œβ”€β”€ README.md  # Project documentation
β”œβ”€β”€ requirements.txt  # Project dependencies
β”œβ”€β”€ pyproject.toml

Core Components

1. Research Coordinator (coordinator.py)

The central orchestrator that:

  • Manages the research workflow
  • Coordinates between different specialized agents
  • Handles web searches using DuckDuckGo
  • Controls the research iteration process
  • Manages the final report synthesis

2. Specialized Agents

Query Agent (research_agents/query_agents.py)

  • Analyzes the initial research query
  • Breaks down complex topics into searchable components
  • Generates focused search queries
  • Provides reasoning for the query strategy

Search Agent (research_agents/search_agent.py)

  • Processes search results
  • Scrapes and analyzes web content
  • Generates concise summaries of findings
  • Filters out irrelevant information

Follow-up Agent (research_agents/follow_up_agent.py)

  • Evaluates research completeness
  • Decides if more research is needed
  • Generates follow-up queries for gaps in knowledge
  • Provides reasoning for decisions

Synthesis Agent (research_agents/synthesis_agent.py)

  • Combines all research findings
  • Creates structured markdown reports
  • Includes source citations
  • Generates table of contents

How It Works

  1. Query Analysis

    • User inputs a research query
    • Query Agent breaks it down into focused search queries
    • System displays the analysis and generated queries
  2. Research Process

    • Performs DuckDuckGo searches for each query
    • Search Agent analyzes and summarizes each result
    • Progress is displayed in real-time with Rich formatting
  3. Iterative Research

    • Follow-up Agent evaluates findings
    • Decides if more research is needed
    • Generates additional queries if necessary
    • Maximum of 3 research iterations
  4. Report Generation

    • Synthesis Agent combines all findings
    • Creates a structured markdown report
    • Includes citations and sources
    • Presents the final report with Rich formatting

Usage

Run the agent from the terminal:

uv run src/deep_research_agent/main.py

Rich Integration

The project leverages Rich for enhanced terminal output:

  1. Status Updates

    • Real-time progress indicators
    • Colored status messages
    • Spinners for ongoing operations
  2. Content Formatting

    • Markdown rendering for reports
    • Panels for sectioning content
    • Colored output for different types of information
    • Tables for structured data
  3. User Interaction

    • Styled prompts for user input
    • Error messages with appropriate styling
    • Clear visual hierarchy of information

Implementation Insights

  1. Modular Agent Design

    • Each agent has a specific, focused responsibility
    • Clear separation of concerns
    • Easy to extend or modify individual components
  2. Iterative Research Approach

    • Maximum of 3 research iterations
    • Smart decision-making about when to stop
    • Prevents endless research loops
  3. Error Handling

    • Robust web scraping with timeouts
    • Graceful handling of failed requests
    • Clear error messaging
  4. Performance Considerations

    • Text content truncation for large web pages
    • Concurrent processing where possible
    • Efficient text processing with BeautifulSoup

Dependencies

  • openai-agents: Core agent functionality
  • rich: Terminal formatting and UI
  • duckduckgo-search: Web search capability
  • bs4: Web content parsing
  • pydantic: Data validation and modeling
  • requests: HTTP requests
  • python-dotenv: Environment management

About

πŸ” Deep Research Agent is an AI-powered research assistant that enhances online research with depth and accuracy, leveraging Google's Gemini API, web scraping, and natural language processing for comprehensive results, and it finally generates a detailed report at the end.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages