deep-research README

The project's README from github.com/dzhng/deep-research. As one markdown file: README.md.

Open Deep Research

An AI-powered research assistant that performs iterative, deep research on any topic by combining search engines, web scraping, and large language models.

The goal of this repo is to provide the simplest implementation of a deep research agent - e.g. an agent that can refine its research direction over time and deep dive into a topic. Goal is to keep the repo size at <500 LoC so it is easy to understand and build on top of.

If you like this project, please consider starring it and giving me a follow on X/Twitter. This project is created by Duet.

How It Works

flowchart TB
    subgraph Input
        Q[User Query]
        B[Breadth Parameter]
        D[Depth Parameter]
    end

    DR[Deep Research] -->
    SQ[SERP Queries] -->
    PR[Process Results]

    subgraph Results[Results]
        direction TB
        NL((Learnings))
        ND((Directions))
    end

    PR --> NL
    PR --> ND

    DP{depth > 0?}

    RD["Next Direction:
    - Prior Goals
    - New Questions
    - Learnings"]

    MR[Markdown Report]

    %% Main Flow
    Q & B & D --> DR

    %% Results to Decision
    NL & ND --> DP

    %% Circular Flow
    DP -->|Yes| RD
    RD -->|New Context| DR

    %% Final Output
    DP -->|No| MR

    %% Styling
    classDef input fill:#7bed9f,stroke:#2ed573,color:black
    classDef process fill:#70a1ff,stroke:#1e90ff,color:black
    classDef recursive fill:#ffa502,stroke:#ff7f50,color:black
    classDef output fill:#ff4757,stroke:#ff6b81,color:black
    classDef results fill:#a8e6cf,stroke:#3b7a57,color:black

    class Q,B,D input
    class DR,SQ,PR process
    class DP,RD recursive
    class MR output
    class NL,ND results

Features

Requirements

Setup

Node.js

  1. Clone the repository
  2. Install dependencies:
npm install
  1. Set up environment variables in a .env.local file:
FIRECRAWL_KEY="your_firecrawl_key"
# If you want to use your self-hosted Firecrawl, add the following below:
# FIRECRAWL_BASE_URL="http://localhost:3002"

OPENAI_KEY="your_openai_key"

To use local LLM, comment out OPENAI_KEY and instead uncomment OPENAI_ENDPOINT and OPENAI_MODEL:

Docker

  1. Clone the repository

  2. Rename .env.example to .env.local and set your API keys

  3. Run docker build -f Dockerfile

  4. Run the Docker image:

docker compose up -d
  1. Execute npm run docker in the docker service:
docker exec -it deep-research npm run docker

Usage

Run the research assistant:

npm start

You'll be prompted to:

  1. Enter your research query
  2. Specify research breadth (recommended: 3-10, default: 4)
  3. Specify research depth (recommended: 1-5, default: 2)
  4. Answer follow-up questions to refine the research direction

The system will then:

  1. Generate and execute search queries
  2. Process and analyze search results
  3. Recursively explore deeper based on findings
  4. Generate a comprehensive markdown report

The final report will be saved as report.md or answer.md in your working directory, depending on which modes you selected.

Concurrency

If you have a paid version of Firecrawl or a local version, feel free to increase the ConcurrencyLimit by setting the CONCURRENCY_LIMIT environment variable so it runs faster.

If you have a free version, you may sometimes run into rate limit errors, you can reduce the limit to 1 (but it will run a lot slower).

DeepSeek R1

Deep research performs great on R1! We use Fireworks as the main provider for the R1 model. To use R1, simply set a Fireworks API key:

FIREWORKS_KEY="api_key"

The system will automatically switch over to use R1 instead of o3-mini when the key is detected.

Custom endpoints and models

There are 2 other optional env vars that lets you tweak the endpoint (for other OpenAI compatible APIs like OpenRouter or Gemini) as well as the model string.

OPENAI_ENDPOINT="custom_endpoint"
CUSTOM_MODEL="custom_model"

How It Works

  1. Initial Setup

    • Takes user query and research parameters (breadth & depth)
    • Generates follow-up questions to understand research needs better
  2. Deep Research Process

    • Generates multiple SERP queries based on research goals
    • Processes search results to extract key learnings
    • Generates follow-up research directions
  3. Recursive Exploration

    • If depth > 0, takes new research directions and continues exploration
    • Each iteration builds on previous learnings
    • Maintains context of research goals and findings
  4. Report Generation

    • Compiles all findings into a comprehensive markdown report
    • Includes all sources and references
    • Organizes information in a clear, readable format

Community implementations

Python: https://github.com/Finance-LLMs/deep-research-python

License

MIT License - feel free to use and modify as needed.

deep-research (dzhng/deep-research)

Searching Database…

这是什么?一个由 AI 驱动的研究助手,会对任何话题进行迭代式深挖:它把搜索引擎、网页抓取和大语言模型结合起来,并在研究过程中不断调整研究方向。
这是我要运行的应用,还是加到我自己项目里的库?这是一个可以直接运行的 TypeScript 应用,不是库:npm start 会启动一个命令行研究会话,npm run api 则会启动一个 Express API 服务器。代码刻意保持得很精简,方便你在它基础上继续开发。
怎么把它跑起来?克隆仓库,运行 npm install,把你的 API 密钥放进 .env.local 文件,然后运行 npm start 用命令行界面,或运行 npm run api 启动服务器。需要 Node.js 22。
运行之前需要准备什么?需要 Node.js 22.x 以及若干 API 密钥:大语言模型调用通过 Vercel AI SDK 走 OpenAI 和 Fireworks 适配器,网页抓取还需要一个 Firecrawl 密钥。
上手之前有什么坑需要知道?作者的目标是做一个尽可能简单的深度研究代理,而不是打磨好的成品——目前还没有测试套件(测试脚本只是个占位符),所以你拿到的是一个适合扩展的精简代码库。
它在 Windows 和 Mac 上能跑吗,还是只有 Linux 能用?它就是一个普通的 Node.js 应用,凡是 Node 22 能跑的地方都能运行——macOS、Windows 或 Linux 都行。
能在自己的服务器上运行吗?可以——仓库自带 Dockerfile 和 docker-compose 配置,你可以在任何服务器上以容器方式自托管运行。
它需要一直联网吗?是的——每一步都要走云服务:网页搜索、Firecrawl 抓取,以及大语言模型 API 调用,所以没有离线模式。
我可以在自己的项目里自由使用和修改它吗?可以——它采用 MIT 许可证,可以自由使用和修改,商用也没问题;只是注意它调用的大语言模型和抓取 API 可能各自产生费用。
最终输出的结果长什么样?一份完整的 markdown 报告,汇总所有研究发现,附上全部来源和参考资料,并以清晰易读的结构组织所有内容。
它怎么决定下一步研究什么?它会循环进行:每一轮都根据之前学到的东西确定新的研究方向,并始终保持对研究目标和已发现内容的上下文,从而能随时间深入钻研一个话题。
有 Python 版本吗?有——README 里列出了社区实现的版本,其中包括这个代理的 Python 版本,所以你不必被 TypeScript 绑死。
Creator
dzhng
Size
0.1 MB
Stars
19.8K
Updated
CommitApr 11
Age
1y
Commits · 90 Days