diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..7ee04e6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,52 @@ +.env +Dockerfile +.dockerignore +.git +.gitignore + +# Python +__pycache__/ +*.py[cod] +*$py.class +*.so +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# Web +node_modules +npm-debug.log +.next + +# IDE +.idea/ +.vscode/ +*.swp +*.swo + +# OS +.DS_Store +Thumbs.db + +# Project specific +conf.yaml +web/ +docs/ +examples/ +assets/ +tests/ +*.log diff --git a/.env.example b/.env.example index cacd6a1..68cca55 100644 --- a/.env.example +++ b/.env.example @@ -2,6 +2,9 @@ DEBUG=True APP_ENV=development +# docker build args +NEXT_PUBLIC_API_URL="http://localhost:8000/api" + # Search Engine, Supported values: tavily (recommended), duckduckgo, brave_search, arxiv SEARCH_API=tavily TAVILY_API_KEY=tvly-xxx diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..839d984 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM ghcr.io/astral-sh/uv:python3.12-bookworm + +# Install uv. +COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv + +WORKDIR /app + +# Copy the application into the container. +COPY . /app + +# Install the application dependencies. +RUN uv sync --frozen --no-cache + +EXPOSE 8000 + +# Run the application. +CMD ["uv", "run", "python", "server.py", "--host", "0.0.0.0", "--port", "8000"] diff --git a/README.md b/README.md index 4fddc8c..d9907ca 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![DeepWiki](https://img.shields.io/badge/DeepWiki-bytedance%2Fdeer--flow-blue.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAyCAYAAAAnWDnqAAAAAXNSR0IArs4c6QAAA05JREFUaEPtmUtyEzEQhtWTQyQLHNak2AB7ZnyXZMEjXMGeK/AIi+QuHrMnbChYY7MIh8g01fJoopFb0uhhEqqcbWTp06/uv1saEDv4O3n3dV60RfP947Mm9/SQc0ICFQgzfc4CYZoTPAswgSJCCUJUnAAoRHOAUOcATwbmVLWdGoH//PB8mnKqScAhsD0kYP3j/Yt5LPQe2KvcXmGvRHcDnpxfL2zOYJ1mFwrryWTz0advv1Ut4CJgf5uhDuDj5eUcAUoahrdY/56ebRWeraTjMt/00Sh3UDtjgHtQNHwcRGOC98BJEAEymycmYcWwOprTgcB6VZ5JK5TAJ+fXGLBm3FDAmn6oPPjR4rKCAoJCal2eAiQp2x0vxTPB3ALO2CRkwmDy5WohzBDwSEFKRwPbknEggCPB/imwrycgxX2NzoMCHhPkDwqYMr9tRcP5qNrMZHkVnOjRMWwLCcr8ohBVb1OMjxLwGCvjTikrsBOiA6fNyCrm8V1rP93iVPpwaE+gO0SsWmPiXB+jikdf6SizrT5qKasx5j8ABbHpFTx+vFXp9EnYQmLx02h1QTTrl6eDqxLnGjporxl3NL3agEvXdT0WmEost648sQOYAeJS9Q7bfUVoMGnjo4AZdUMQku50McDcMWcBPvr0SzbTAFDfvJqwLzgxwATnCgnp4wDl6Aa+Ax283gghmj+vj7feE2KBBRMW3FzOpLOADl0Isb5587h/U4gGvkt5v60Z1VLG8BhYjbzRwyQZemwAd6cCR5/XFWLYZRIMpX39AR0tjaGGiGzLVyhse5C9RKC6ai42ppWPKiBagOvaYk8lO7DajerabOZP46Lby5wKjw1HCRx7p9sVMOWGzb/vA1hwiWc6jm3MvQDTogQkiqIhJV0nBQBTU+3okKCFDy9WwferkHjtxib7t3xIUQtHxnIwtx4mpg26/HfwVNVDb4oI9RHmx5WGelRVlrtiw43zboCLaxv46AZeB3IlTkwouebTr1y2NjSpHz68WNFjHvupy3q8TFn3Hos2IAk4Ju5dCo8B3wP7VPr/FGaKiG+T+v+TQqIrOqMTL1VdWV1DdmcbO8KXBz6esmYWYKPwDL5b5FA1a0hwapHiom0r/cKaoqr+27/XcrS5UwSMbQAAAABJRU5ErkJggg==)](https://deepwiki.com/bytedance/deer-flow) + [English](./README.md) | [简体中文](./README_zh.md) | [日本語](./README_ja.md) | [Deutsch](./README_de.md) @@ -20,6 +21,7 @@ Please visit [our official website](https://deerflow.tech/) for more details. https://github.com/user-attachments/assets/f3786598-1f2a-4d07-919e-8b99dfa1de3e In this demo, we showcase how to use DeerFlow to: + - Seamlessly integrate with MCP services - Conduct the Deep Research process and produce a comprehensive report with images - Create podcast audio based on the generated report @@ -34,13 +36,13 @@ In this demo, we showcase how to use DeerFlow to: --- - ## 📑 Table of Contents - [🚀 Quick Start](#quick-start) - [🌟 Features](#features) - [🏗️ Architecture](#architecture) - [🛠️ Development](#development) +- [🐳 Docker](#docker) - [🗣️ Text-to-Speech Integration](#text-to-speech-integration) - [📚 Examples](#examples) - [❓ FAQ](#faq) @@ -48,12 +50,12 @@ In this demo, we showcase how to use DeerFlow to: - [💖 Acknowledgments](#acknowledgments) - [⭐ Star History](#star-history) - ## Quick Start DeerFlow is developed in Python, and comes with a web UI written in Node.js. To ensure a smooth setup process, we recommend using the following tools: ### Recommended Tools + - **[`uv`](https://docs.astral.sh/uv/getting-started/installation/):** Simplify Python environment and dependency management. `uv` automatically creates a virtual environment in the root directory and installs all required packages for you—no need to manually install Python environments. @@ -64,11 +66,14 @@ DeerFlow is developed in Python, and comes with a web UI written in Node.js. To Install and manage dependencies of Node.js project. ### Environment Requirements + Make sure your system meets the following minimum requirements: + - **[Python](https://www.python.org/downloads/):** Version `3.12+` - **[Node.js](https://nodejs.org/en/download/):** Version `22+` ### Installation + ```bash # Clone the repository git clone https://github.com/bytedance/deer-flow.git @@ -120,6 +125,7 @@ uv run main.py ### Web UI This project also includes a Web UI, offering a more dynamic and engaging interactive experience. + > [!NOTE] > You need to install the dependencies of web UI first. @@ -136,25 +142,27 @@ Open your browser and visit [`http://localhost:3000`](http://localhost:3000) to Explore more details in the [`web`](./web/) directory. - ## Supported Search Engines DeerFlow supports multiple search engines that can be configured in your `.env` file using the `SEARCH_API` variable: - **Tavily** (default): A specialized search API for AI applications - - Requires `TAVILY_API_KEY` in your `.env` file - - Sign up at: https://app.tavily.com/home + + - Requires `TAVILY_API_KEY` in your `.env` file + - Sign up at: https://app.tavily.com/home - **DuckDuckGo**: Privacy-focused search engine - - No API key required + + - No API key required - **Brave Search**: Privacy-focused search engine with advanced features - - Requires `BRAVE_SEARCH_API_KEY` in your `.env` file - - Sign up at: https://brave.com/search/api/ + + - Requires `BRAVE_SEARCH_API_KEY` in your `.env` file + - Sign up at: https://brave.com/search/api/ - **Arxiv**: Scientific paper search for academic research - - No API key required - - Specialized for scientific and academic papers + - No API key required + - Specialized for scientific and academic papers To configure your preferred search engine, set the `SEARCH_API` variable in your `.env` file: @@ -168,64 +176,69 @@ SEARCH_API=tavily ### Core Capabilities - 🤖 **LLM Integration** - - It supports the integration of most models through [litellm](https://docs.litellm.ai/docs/providers). - - Support for open source models like Qwen - - OpenAI-compatible API interface - - Multi-tier LLM system for different task complexities + - It supports the integration of most models through [litellm](https://docs.litellm.ai/docs/providers). + - Support for open source models like Qwen + - OpenAI-compatible API interface + - Multi-tier LLM system for different task complexities ### Tools and MCP Integrations - 🔍 **Search and Retrieval** - - Web search via Tavily, Brave Search and more - - Crawling with Jina - - Advanced content extraction + + - Web search via Tavily, Brave Search and more + - Crawling with Jina + - Advanced content extraction - 🔗 **MCP Seamless Integration** - - Expand capabilities for private domain access, knowledge graph, web browsing and more - - Facilitates integration of diverse research tools and methodologies + - Expand capabilities for private domain access, knowledge graph, web browsing and more + - Facilitates integration of diverse research tools and methodologies ### Human Collaboration - 🧠 **Human-in-the-loop** - - Supports interactive modification of research plans using natural language - - Supports auto-acceptance of research plans + + - Supports interactive modification of research plans using natural language + - Supports auto-acceptance of research plans - 📝 **Report Post-Editing** - - Supports Notion-like block editing - - Allows AI refinements, including AI-assisted polishing, sentence shortening, and expansion - - Powered by [tiptap](https://tiptap.dev/) + - Supports Notion-like block editing + - Allows AI refinements, including AI-assisted polishing, sentence shortening, and expansion + - Powered by [tiptap](https://tiptap.dev/) ### Content Creation - 🎙️ **Podcast and Presentation Generation** - - AI-powered podcast script generation and audio synthesis - - Automated creation of simple PowerPoint presentations - - Customizable templates for tailored content - + - AI-powered podcast script generation and audio synthesis + - Automated creation of simple PowerPoint presentations + - Customizable templates for tailored content ## Architecture DeerFlow implements a modular multi-agent system architecture designed for automated research and code analysis. The system is built on LangGraph, enabling a flexible state-based workflow where components communicate through a well-defined message passing system. ![Architecture Diagram](./assets/architecture.png) + > See it live at [deerflow.tech](https://deerflow.tech/#multi-agent-architecture) The system employs a streamlined workflow with the following components: 1. **Coordinator**: The entry point that manages the workflow lifecycle + - Initiates the research process based on user input - Delegates tasks to the planner when appropriate - Acts as the primary interface between the user and the system 2. **Planner**: Strategic component for task decomposition and planning + - Analyzes research objectives and creates structured execution plans - Determines if enough context is available or if more research is needed - Manages the research flow and decides when to generate the final report 3. **Research Team**: A collection of specialized agents that execute the plan: + - **Researcher**: Conducts web searches and information gathering using tools like web search engines, crawling and even MCP services. - **Coder**: Handles code analysis, execution, and technical tasks using Python REPL tool. - Each agent has access to specific tools optimized for their role and operates within the LangGraph framework + Each agent has access to specific tools optimized for their role and operates within the LangGraph framework 4. **Reporter**: Final stage processor for research outputs - Aggregates findings from the research team @@ -253,7 +266,6 @@ curl --location 'http://localhost:8000/api/tts' \ --output speech.mp3 ``` - ## Development ### Testing @@ -311,6 +323,7 @@ langgraph dev ``` After starting the LangGraph server, you'll see several URLs in the terminal: + - API: http://127.0.0.1:2024 - Studio UI: https://smith.langchain.com/studio/?baseUrl=http://127.0.0.1:2024 - API Docs: http://127.0.0.1:2024/docs @@ -328,11 +341,46 @@ In the Studio UI, you can: 5. Provide feedback during the planning phase to refine research plans When you submit a research topic in the Studio UI, you'll be able to see the entire workflow execution, including: + - The planning phase where the research plan is created - The feedback loop where you can modify the plan - The research and writing phases for each section - The final report generation +## Docker + +You can also run this project with Docker. + +First, you need read the [configuration](#configuration) below. Make sure `.env`, `.conf.yaml` files are ready. + +Second, to build a Docker image of your own web server: + +```bash +docker build -t deer-flow-api . +``` + +Final, start up a docker container running the web server: + +```bash +# Replace deer-flow-api-app with your preferred container name +docker run -d -t -p 8000:8000 --env-file .env --name deer-flow-api-app deer-flow-api + +# stop the server +docker stop deer-flow-api-app +``` + +### Docker Compose (include both backend and frontend) + +DeerFlow provides a docker-compose setup to easily run both the backend and frontend together: + +```bash +# building docker image +docker compose build + +# start the server +docker compose up +``` + ## Examples The following examples demonstrate the capabilities of DeerFlow: @@ -340,35 +388,43 @@ The following examples demonstrate the capabilities of DeerFlow: ### Research Reports 1. **OpenAI Sora Report** - Analysis of OpenAI's Sora AI tool + - Discusses features, access, prompt engineering, limitations, and ethical considerations - [View full report](examples/openai_sora_report.md) 2. **Google's Agent to Agent Protocol Report** - Overview of Google's Agent to Agent (A2A) protocol + - Discusses its role in AI agent communication and its relationship with Anthropic's Model Context Protocol (MCP) - [View full report](examples/what_is_agent_to_agent_protocol.md) 3. **What is MCP?** - A comprehensive analysis of the term "MCP" across multiple contexts + - Explores Model Context Protocol in AI, Monocalcium Phosphate in chemistry, and Micro-channel Plate in electronics - [View full report](examples/what_is_mcp.md) 4. **Bitcoin Price Fluctuations** - Analysis of recent Bitcoin price movements + - Examines market trends, regulatory influences, and technical indicators - Provides recommendations based on historical data - [View full report](examples/bitcoin_price_fluctuation.md) 5. **What is LLM?** - An in-depth exploration of Large Language Models + - Discusses architecture, training, applications, and ethical considerations - [View full report](examples/what_is_llm.md) 6. **How to Use Claude for Deep Research?** - Best practices and workflows for using Claude in deep research + - Covers prompt engineering, data analysis, and integration with other tools - [View full report](examples/how_to_use_claude_deep_research.md) 7. **AI Adoption in Healthcare: Influencing Factors** - Analysis of factors driving AI adoption in healthcare + - Discusses AI technologies, data quality, ethical considerations, economic evaluations, organizational readiness, and digital infrastructure - [View full report](examples/AI_adoption_in_healthcare.md) 8. **Quantum Computing Impact on Cryptography** - Analysis of quantum computing's impact on cryptography + - Discusses vulnerabilities of classical cryptography, post-quantum cryptography, and quantum-resistant cryptographic solutions - [View full report](examples/Quantum_Computing_Impact_on_Cryptography.md) @@ -400,6 +456,7 @@ uv run main.py --help The application now supports an interactive mode with built-in questions in both English and Chinese: 1. Launch the interactive mode: + ```bash uv run main.py --interactive ``` @@ -417,17 +474,19 @@ DeerFlow includes a human in the loop mechanism that allows you to review, edit, 1. **Plan Review**: When human in the loop is enabled, the system will present the generated research plan for your review before execution 2. **Providing Feedback**: You can: + - Accept the plan by responding with `[ACCEPTED]` - Edit the plan by providing feedback (e.g., `[EDIT PLAN] Add more steps about technical implementation`) - The system will incorporate your feedback and generate a revised plan 3. **Auto-acceptance**: You can enable auto-acceptance to skip the review process: + - Via API: Set `auto_accepted_plan: true` in your request 4. **API Integration**: When using the API, you can provide feedback through the `feedback` parameter: ```json { - "messages": [{"role": "user", "content": "What is quantum computing?"}], + "messages": [{ "role": "user", "content": "What is quantum computing?" }], "thread_id": "my_thread_id", "auto_accepted_plan": false, "feedback": "[EDIT PLAN] Include more about quantum algorithms" @@ -464,6 +523,7 @@ We would like to extend our sincere appreciation to the following projects for t These projects exemplify the transformative power of open-source collaboration, and we are proud to build upon their foundations. ### Key Contributors + A heartfelt thank you goes out to the core authors of `DeerFlow`, whose vision, passion, and dedication have brought this project to life: - **[Daniel Walnut](https://github.com/hetaoBackend/)** diff --git a/README_ja.md b/README_ja.md index 4391591..e64663e 100644 --- a/README_ja.md +++ b/README_ja.md @@ -7,9 +7,9 @@ > オープンソースから生まれ、オープンソースに還元する。 -**DeerFlow**(**D**eep **E**xploration and **E**fficient **R**esearch **Flow**)は、オープンソースコミュニティの素晴らしい成果の上に構築されたコミュニティ主導の深層研究フレームワークです。私たちの目標は、言語モデルとウェブ検索、クローリング、Pythonコード実行などの専門ツールを組み合わせながら、これを可能にしたコミュニティに貢献することです。 +**DeerFlow**(**D**eep **E**xploration and **E**fficient **R**esearch **Flow**)は、オープンソースコミュニティの素晴らしい成果の上に構築されたコミュニティ主導の深層研究フレームワークです。私たちの目標は、言語モデルとウェブ検索、クローリング、Python コード実行などの専門ツールを組み合わせながら、これを可能にしたコミュニティに貢献することです。 -詳細については[DeerFlowの公式ウェブサイト](https://deerflow.tech/)をご覧ください。 +詳細については[DeerFlow の公式ウェブサイト](https://deerflow.tech/)をご覧ください。 ## デモ @@ -17,22 +17,22 @@ https://github.com/user-attachments/assets/f3786598-1f2a-4d07-919e-8b99dfa1de3e -このデモでは、DeerFlowの使用方法を紹介しています: -- MCPサービスとのシームレスな統合 +このデモでは、DeerFlow の使用方法を紹介しています: + +- MCP サービスとのシームレスな統合 - 深層研究プロセスの実施と画像を含む包括的なレポートの作成 - 生成されたレポートに基づくポッドキャストオーディオの作成 ### リプレイ例 - [エッフェル塔は世界一高いビルと比べてどれくらい高い?](https://deerflow.tech/chat?replay=eiffel-tower-vs-tallest-building) -- [GitHubで最も人気のあるリポジトリは?](https://deerflow.tech/chat?replay=github-top-trending-repo) +- [GitHub で最も人気のあるリポジトリは?](https://deerflow.tech/chat?replay=github-top-trending-repo) - [南京の伝統料理に関する記事を書く](https://deerflow.tech/chat?replay=nanjing-traditional-dishes) - [賃貸アパートの装飾方法は?](https://deerflow.tech/chat?replay=rental-apartment-decoration) - [公式ウェブサイトでより多くのリプレイ例をご覧ください。](https://deerflow.tech/#case-studies) --- - ## 📑 目次 - [🚀 クイックスタート](#クイックスタート) @@ -46,27 +46,30 @@ https://github.com/user-attachments/assets/f3786598-1f2a-4d07-919e-8b99dfa1de3e - [💖 謝辞](#謝辞) - [⭐ スター履歴](#スター履歴) - ## クイックスタート -DeerFlowはPythonで開発され、Node.jsで書かれたWeb UIが付属しています。スムーズなセットアッププロセスを確保するために、以下のツールの使用をお勧めします: +DeerFlow は Python で開発され、Node.js で書かれた Web UI が付属しています。スムーズなセットアッププロセスを確保するために、以下のツールの使用をお勧めします: ### 推奨ツール + - **[`uv`](https://docs.astral.sh/uv/getting-started/installation/):** - Python環境と依存関係の管理を簡素化します。`uv`はルートディレクトリに自動的に仮想環境を作成し、必要なパッケージをすべてインストールします—Python環境を手動でインストールする必要はありません。 + Python 環境と依存関係の管理を簡素化します。`uv`はルートディレクトリに自動的に仮想環境を作成し、必要なパッケージをすべてインストールします—Python 環境を手動でインストールする必要はありません。 - **[`nvm`](https://github.com/nvm-sh/nvm):** - 複数のNode.jsランタイムバージョンを簡単に管理します。 + 複数の Node.js ランタイムバージョンを簡単に管理します。 - **[`pnpm`](https://pnpm.io/installation):** - Node.jsプロジェクトの依存関係をインストールおよび管理します。 + Node.js プロジェクトの依存関係をインストールおよび管理します。 ### 環境要件 + システムが以下の最小要件を満たしていることを確認してください: + - **[Python](https://www.python.org/downloads/):** バージョン `3.12+` - **[Node.js](https://nodejs.org/en/download/):** バージョン `22+` ### インストール + ```bash # リポジトリをクローン git clone https://github.com/bytedance/deer-flow.git @@ -92,7 +95,7 @@ cp conf.yaml.example conf.yaml brew install marp-cli ``` -オプションで、[pnpm](https://pnpm.io/installation)を使用してWeb UI依存関係をインストール: +オプションで、[pnpm](https://pnpm.io/installation)を使用して Web UI 依存関係をインストール: ```bash cd deer-flow/web @@ -106,9 +109,9 @@ pnpm install > [!注意] > プロジェクトを開始する前に、ガイドを注意深く読み、特定の設定と要件に合わせて構成を更新してください。 -### コンソールUI +### コンソール UI -プロジェクトを実行する最も迅速な方法は、コンソールUIを使用することです。 +プロジェクトを実行する最も迅速な方法は、コンソール UI を使用することです。 ```bash # bashライクなシェルでプロジェクトを実行 @@ -117,9 +120,10 @@ uv run main.py ### Web UI -このプロジェクトにはWeb UIも含まれており、より動的で魅力的なインタラクティブ体験を提供します。 +このプロジェクトには Web UI も含まれており、より動的で魅力的なインタラクティブ体験を提供します。 + > [!注意] -> 先にWeb UIの依存関係をインストールする必要があります。 +> 先に Web UI の依存関係をインストールする必要があります。 ```bash # 開発モードでバックエンドとフロントエンドサーバーの両方を実行 @@ -130,29 +134,31 @@ uv run main.py bootstrap.bat -d ``` -ブラウザを開き、[`http://localhost:3000`](http://localhost:3000)にアクセスしてWeb UIを探索してください。 +ブラウザを開き、[`http://localhost:3000`](http://localhost:3000)にアクセスして Web UI を探索してください。 [`web`](./web/)ディレクトリで詳細を確認できます。 - ## サポートされている検索エンジン -DeerFlowは複数の検索エンジンをサポートしており、`.env`ファイルの`SEARCH_API`変数で設定できます: +DeerFlow は複数の検索エンジンをサポートしており、`.env`ファイルの`SEARCH_API`変数で設定できます: - **Tavily**(デフォルト):AI アプリケーション向けの専門検索 API - - `.env`ファイルに`TAVILY_API_KEY`が必要 - - 登録先:https://app.tavily.com/home + + - `.env`ファイルに`TAVILY_API_KEY`が必要 + - 登録先:https://app.tavily.com/home - **DuckDuckGo**:プライバシー重視の検索エンジン - - APIキー不要 + + - API キー不要 - **Brave Search**:高度な機能を備えたプライバシー重視の検索エンジン - - `.env`ファイルに`BRAVE_SEARCH_API_KEY`が必要 - - 登録先:https://brave.com/search/api/ + + - `.env`ファイルに`BRAVE_SEARCH_API_KEY`が必要 + - 登録先:https://brave.com/search/api/ - **Arxiv**:学術研究用の科学論文検索 - - APIキー不要 - - 科学・学術論文専用 + - API キー不要 + - 科学・学術論文専用 お好みの検索エンジンを設定するには、`.env`ファイルで`SEARCH_API`変数を設定します: @@ -165,93 +171,76 @@ SEARCH_API=tavily ### コア機能 -- 🤖 **LLM統合** - - [litellm](https://docs.litellm.ai/docs/providers)を通じてほとんどのモデルの統合をサポート - - Qwenなどのオープンソースモデルをサポート - - OpenAI互換のAPIインターフェース - - 異なるタスクの複雑さに対応するマルチティアLLMシステム +- 🤖 **LLM 統合** + - [litellm](https://docs.litellm.ai/docs/providers)を通じてほとんどのモデルの統合をサポート + - Qwen などのオープンソースモデルをサポート + - OpenAI 互換の API インターフェース + - 異なるタスクの複雑さに対応するマルチティア LLM システム -### ツールとMCP統合 +### ツールと MCP 統合 - 🔍 **検索と取得** - - Tavily、Brave Searchなどを通じたWeb検索 - - Jinaを使用したクローリング - - 高度なコンテンツ抽出 -- 🔗 **MCPシームレス統合** - - プライベートドメインアクセス、ナレッジグラフ、Webブラウジングなどの機能を拡張 - - 多様な研究ツールと方法論の統合を促進 + - Tavily、Brave Search などを通じた Web 検索 + - Jina を使用したクローリング + - 高度なコンテンツ抽出 + +- 🔗 **MCP シームレス統合** + - プライベートドメインアクセス、ナレッジグラフ、Web ブラウジングなどの機能を拡張 + - 多様な研究ツールと方法論の統合を促進 ### 人間との協力 - 🧠 **人間参加型ループ** - - 自然言語を使用した研究計画の対話的修正をサポート - - 研究計画の自動承認をサポート + + - 自然言語を使用した研究計画の対話的修正をサポート + - 研究計画の自動承認をサポート - 📝 **レポート後編集** - - Notionライクなブロック編集をサポート - - AI支援による洗練、文の短縮、拡張などのAI改良を可能に - - [tiptap](https://tiptap.dev/)を活用 + - Notion ライクなブロック編集をサポート + - AI 支援による洗練、文の短縮、拡張などの AI 改良を可能に + - [tiptap](https://tiptap.dev/)を活用 ### コンテンツ作成 - 🎙️ **ポッドキャストとプレゼンテーション生成** - - AI駆動のポッドキャストスクリプト生成と音声合成 - - シンプルなPowerPointプレゼンテーションの自動作成 - - カスタマイズ可能なテンプレートで個別のコンテンツに対応 - + - AI 駆動のポッドキャストスクリプト生成と音声合成 + - シンプルな PowerPoint プレゼンテーションの自動作成 + - カスタマイズ可能なテンプレートで個別のコンテンツに対応 ## アーキテクチャ -DeerFlowは、自動研究とコード分析のためのモジュラーなマルチエージェントシステムアーキテクチャを実装しています。システムはLangGraph上に構築され、コンポーネントが明確に定義されたメッセージパッシングシステムを通じて通信する柔軟な状態ベースのワークフローを実現しています。 +DeerFlow は、自動研究とコード分析のためのモジュラーなマルチエージェントシステムアーキテクチャを実装しています。システムは LangGraph 上に構築され、コンポーネントが明確に定義されたメッセージパッシングシステムを通じて通信する柔軟な状態ベースのワークフローを実現しています。 ![アーキテクチャ図](./assets/architecture.png) + > [deerflow.tech](https://deerflow.tech/#multi-agent-architecture)でライブで確認できます システムは以下のコンポーネントを含む合理化されたワークフローを採用しています: 1. **コーディネーター**:ワークフローのライフサイクルを管理するエントリーポイント + - ユーザー入力に基づいて研究プロセスを開始 - 適切なタイミングでプランナーにタスクを委託 - ユーザーとシステム間の主要なインターフェースとして機能 2. **プランナー**:タスク分解と計画のための戦略的コンポーネント + - 研究目標を分析し、構造化された実行計画を作成 - 十分なコンテキストが利用可能か、さらなる研究が必要かを判断 - 研究フローを管理し、最終レポート生成のタイミングを決定 3. **研究チーム**:計画を実行する専門エージェントの集合: - - **研究者**:Web検索エンジン、クローリング、さらにはMCPサービスなどのツールを使用してWeb検索と情報収集を行う。 - - **コーダー**:Python REPLツールを使用してコード分析、実行、技術的タスクを処理する。 - 各エージェントは自分の役割に最適化された特定のツールにアクセスでき、LangGraphフレームワーク内で動作する + + - **研究者**:Web 検索エンジン、クローリング、さらには MCP サービスなどのツールを使用して Web 検索と情報収集を行う。 + - **コーダー**:Python REPL ツールを使用してコード分析、実行、技術的タスクを処理する。 + 各エージェントは自分の役割に最適化された特定のツールにアクセスでき、LangGraph フレームワーク内で動作する 4. **レポーター**:研究出力の最終段階プロセッサ - 研究チームの調査結果を集約 - 収集した情報を処理および構造化 - 包括的な研究レポートを生成 -## テキスト読み上げ統合 - -DeerFlowには現在、研究レポートを音声に変換できるテキスト読み上げ(TTS)機能が含まれています。この機能は火山引擎TTS APIを使用して高品質なテキストオーディオを生成します。速度、音量、ピッチなどの特性もカスタマイズ可能です。 - -### TTS APIの使用 - -`/api/tts`エンドポイントからTTS機能にアクセスできます: - -```bash -# curlを使用したAPI呼び出し例 -curl --location 'http://localhost:8000/api/tts' \ ---header 'Content-Type: application/json' \ ---data '{ - "text": "これはテキスト読み上げ機能のテストです。", - "speed_ratio": 1.0, - "volume_ratio": 1.0, - "pitch_ratio": 1.0 -}' \ ---output speech.mp3 -``` - - ## 開発 ### テスト @@ -279,13 +268,13 @@ make lint make format ``` -### LangGraph Studioによるデバッグ +### LangGraph Studio によるデバッグ -DeerFlowはワークフローアーキテクチャとしてLangGraphを使用しています。LangGraph Studioを使用してワークフローをリアルタイムでデバッグおよび可視化できます。 +DeerFlow はワークフローアーキテクチャとして LangGraph を使用しています。LangGraph Studio を使用してワークフローをリアルタイムでデバッグおよび可視化できます。 -#### ローカルでLangGraph Studioを実行 +#### ローカルで LangGraph Studio を実行 -DeerFlowには`langgraph.json`設定ファイルが含まれており、これがLangGraph Studioのグラフ構造と依存関係を定義しています。このファイルはプロジェクトで定義されたワークフローグラフを指し、`.env`ファイルから環境変数を自動的に読み込みます。 +DeerFlow には`langgraph.json`設定ファイルが含まれており、これが LangGraph Studio のグラフ構造と依存関係を定義しています。このファイルはプロジェクトで定義されたワークフローグラフを指し、`.env`ファイルから環境変数を自動的に読み込みます。 ##### Mac @@ -308,16 +297,17 @@ pip install -U "langgraph-cli[inmem]" langgraph dev ``` -LangGraphサーバーを開始すると、端末にいくつかのURLが表示されます: +LangGraph サーバーを開始すると、端末にいくつかの URL が表示されます: + - API: http://127.0.0.1:2024 - Studio UI: https://smith.langchain.com/studio/?baseUrl=http://127.0.0.1:2024 -- APIドキュメント: http://127.0.0.1:2024/docs +- API ドキュメント: http://127.0.0.1:2024/docs -ブラウザでStudio UIリンクを開いてデバッグインターフェースにアクセスします。 +ブラウザで Studio UI リンクを開いてデバッグインターフェースにアクセスします。 -#### LangGraph Studioの使用 +#### LangGraph Studio の使用 -Studio UIでは、次のことができます: +Studio UI では、次のことができます: 1. ワークフローグラフを可視化し、コンポーネントの接続方法を確認 2. 実行をリアルタイムで追跡し、データがシステム内をどのように流れるかを理解 @@ -325,48 +315,112 @@ Studio UIでは、次のことができます: 4. 各コンポーネントの入力と出力を検査して問題をデバッグ 5. 計画段階でフィードバックを提供して研究計画を洗練 -Studio UIで研究トピックを送信すると、次を含む全ワークフロー実行プロセスを見ることができます: +Studio UI で研究トピックを送信すると、次を含む全ワークフロー実行プロセスを見ることができます: + - 研究計画を作成する計画段階 - 計画を修正できるフィードバックループ - 各セクションの研究と執筆段階 - 最終レポート生成 +## Docker + +このプロジェクトは Docker でも実行できます。 + +まず、以下の[設定](#設定)セクションを読んでください。`.env`と`.conf.yaml`ファイルが準備できていることを確認してください。 + +次に、独自の Web サーバーの Docker イメージをビルドします: + +```bash +docker build -t deer-flow-api . +``` + +最後に、Web サーバーを実行する Docker コンテナを起動します: + +```bash +# deer-flow-api-appを希望のコンテナ名に置き換えてください +docker run -d -t -p 8000:8000 --env-file .env --name deer-flow-api-app deer-flow-api + +# サーバーを停止 +docker stop deer-flow-api-app +``` + +### Docker Compose + +このプロジェクトは docker compose でも設定できます: + +```bash +# dockerイメージをビルド +docker compose build + +# サーバーを起動 +docker compose up +``` + +## テキスト読み上げ統合 + +DeerFlow には現在、研究レポートを音声に変換できるテキスト読み上げ(TTS)機能が含まれています。この機能は火山引擎 TTS API を使用して高品質なテキストオーディオを生成します。速度、音量、ピッチなどの特性もカスタマイズ可能です。 + +### TTS API の使用 + +`/api/tts`エンドポイントから TTS 機能にアクセスできます: + +```bash +# curlを使用したAPI呼び出し例 +curl --location 'http://localhost:8000/api/tts' \ +--header 'Content-Type: application/json' \ +--data '{ + "text": "これはテキスト読み上げ機能のテストです。", + "speed_ratio": 1.0, + "volume_ratio": 1.0, + "pitch_ratio": 1.0 +}' \ +--output speech.mp3 +``` + ## 例 -以下の例はDeerFlowの機能を示しています: +以下の例は DeerFlow の機能を示しています: ### 研究レポート -1. **OpenAI Soraレポート** - OpenAIのSora AIツールの分析 +1. **OpenAI Sora レポート** - OpenAI の Sora AI ツールの分析 + - 機能、アクセス方法、プロンプトエンジニアリング、制限、倫理的考慮について議論 - [完全なレポートを見る](examples/openai_sora_report.md) -2. **GoogleのAgent to Agentプロトコルレポート** - GoogleのAgent to Agent(A2A)プロトコルの概要 - - AI エージェント通信における役割と、AnthropicのModel Context Protocol(MCP)との関係について議論 +2. **Google の Agent to Agent プロトコルレポート** - Google の Agent to Agent(A2A)プロトコルの概要 + + - AI エージェント通信における役割と、Anthropic の Model Context Protocol(MCP)との関係について議論 - [完全なレポートを見る](examples/what_is_agent_to_agent_protocol.md) -3. **MCPとは何か?** - 複数のコンテキストにおける「MCP」という用語の包括的分析 - - AIにおけるModel Context Protocol、化学におけるMonocalcium Phosphate、電子工学におけるMicro-channel Plateを探る +3. **MCP とは何か?** - 複数のコンテキストにおける「MCP」という用語の包括的分析 + + - AI における Model Context Protocol、化学における Monocalcium Phosphate、電子工学における Micro-channel Plate を探る - [完全なレポートを見る](examples/what_is_mcp.md) 4. **ビットコイン価格変動** - 最近のビットコイン価格動向の分析 + - 市場動向、規制の影響、テクニカル指標の調査 - 歴史的データに基づく提言 - [完全なレポートを見る](examples/bitcoin_price_fluctuation.md) -5. **LLMとは何か?** - 大規模言語モデルの詳細な探求 +5. **LLM とは何か?** - 大規模言語モデルの詳細な探求 + - アーキテクチャ、トレーニング、応用、倫理的考慮について議論 - [完全なレポートを見る](examples/what_is_llm.md) -6. **Claudeを使った深層研究の方法は?** - 深層研究でのClaudeの使用に関するベストプラクティスとワークフロー +6. **Claude を使った深層研究の方法は?** - 深層研究での Claude の使用に関するベストプラクティスとワークフロー + - プロンプトエンジニアリング、データ分析、他のツールとの統合 - [完全なレポートを見る](examples/how_to_use_claude_deep_research.md) -7. **医療におけるAI採用:影響要因** - 医療におけるAI採用に影響する要因の分析 - - AIテクノロジー、データ品質、倫理的考慮、経済的評価、組織の準備状況、デジタルインフラについて議論 +7. **医療における AI 採用:影響要因** - 医療における AI 採用に影響する要因の分析 + + - AI テクノロジー、データ品質、倫理的考慮、経済的評価、組織の準備状況、デジタルインフラについて議論 - [完全なレポートを見る](examples/AI_adoption_in_healthcare.md) 8. **量子コンピューティングの暗号学への影響** - 量子コンピューティングの暗号学への影響の分析 + - 古典的暗号の脆弱性、ポスト量子暗号学、耐量子暗号ソリューションについて議論 - [完全なレポートを見る](examples/Quantum_Computing_Impact_on_Cryptography.md) @@ -398,11 +452,12 @@ uv run main.py --help アプリケーションは現在、英語と中国語の組み込み質問を使用したインタラクティブモードをサポートしています: 1. インタラクティブモードを開始: + ```bash uv run main.py --interactive ``` -2. 好みの言語(EnglishまたはChinese)を選択 +2. 好みの言語(English または Chinese)を選択 3. 組み込み質問リストから選択するか、独自の質問を提示するオプションを選択 @@ -410,22 +465,26 @@ uv run main.py --help ### 人間参加型ループ -DeerFlowには人間参加型ループメカニズムが含まれており、研究計画を実行する前にレビュー、編集、承認することができます: +DeerFlow には人間参加型ループメカニズムが含まれており、研究計画を実行する前にレビュー、編集、承認することができます: 1. **計画レビュー**:人間参加型ループが有効な場合、システムは実行前に生成された研究計画を表示 2. **フィードバック提供**:次のことができます: + - `[ACCEPTED]`と返信して計画を承認 - フィードバックを提供して計画を編集(例:`[EDIT PLAN] 技術実装に関するステップをさらに追加する`) - システムはフィードバックを統合し、修正された計画を生成 3. **自動承認**:レビュープロセスをスキップするために自動承認を有効にできます: - - API経由:リクエストで`auto_accepted_plan: true`を設定 -4. **API統合**:APIを使用する場合、`feedback`パラメータでフィードバックを提供できます: + - API 経由:リクエストで`auto_accepted_plan: true`を設定 + +4. **API 統合**:API を使用する場合、`feedback`パラメータでフィードバックを提供できます: ```json { - "messages": [{"role": "user", "content": "量子コンピューティングとは何ですか?"}], + "messages": [ + { "role": "user", "content": "量子コンピューティングとは何ですか?" } + ], "thread_id": "my_thread_id", "auto_accepted_plan": false, "feedback": "[EDIT PLAN] 量子アルゴリズムについてもっと含める" @@ -448,27 +507,28 @@ DeerFlowには人間参加型ループメカニズムが含まれており、研 ## ライセンス -このプロジェクトはオープンソースであり、[MITライセンス](./LICENSE)に従っています。 +このプロジェクトはオープンソースであり、[MIT ライセンス](./LICENSE)に従っています。 ## 謝辞 -DeerFlowはオープンソースコミュニティの素晴らしい成果の上に構築されています。DeerFlowを可能にしたすべてのプロジェクトと貢献者に深く感謝します。私たちは確かに巨人の肩の上に立っています。 +DeerFlow はオープンソースコミュニティの素晴らしい成果の上に構築されています。DeerFlow を可能にしたすべてのプロジェクトと貢献者に深く感謝します。私たちは確かに巨人の肩の上に立っています。 以下のプロジェクトに心からの感謝を表します: -- **[LangChain](https://github.com/langchain-ai/langchain)**:彼らの優れたフレームワークは、シームレスな統合と機能性を実現するLLM相互作用とチェーンに力を与えています。 -- **[LangGraph](https://github.com/langchain-ai/langgraph)**:マルチエージェントオーケストレーションへの革新的アプローチは、DeerFlowの複雑なワークフローの実現に不可欠でした。 +- **[LangChain](https://github.com/langchain-ai/langchain)**:彼らの優れたフレームワークは、シームレスな統合と機能性を実現する LLM 相互作用とチェーンに力を与えています。 +- **[LangGraph](https://github.com/langchain-ai/langgraph)**:マルチエージェントオーケストレーションへの革新的アプローチは、DeerFlow の複雑なワークフローの実現に不可欠でした。 これらのプロジェクトはオープンソースコラボレーションの変革力を示しており、その基盤の上に構築できることを誇りに思います。 ### 主要貢献者 + `DeerFlow`の主要な作者に心から感謝します。彼らのビジョン、情熱、献身がこのプロジェクトを実現しました: - **[Daniel Walnut](https://github.com/hetaoBackend/)** - **[Henry Li](https://github.com/magiccube/)** -あなたの揺るぎない取り組みと専門知識がDeerFlowの成功を推進しています。この旅をリードしていただき光栄です。 +あなたの揺るぎない取り組みと専門知識が DeerFlow の成功を推進しています。この旅をリードしていただき光栄です。 ## スター履歴 -[![Star History Chart](https://api.star-history.com/svg?repos=bytedance/deer-flow&type=Date)](https://star-history.com/#bytedance/deer-flow&Date) \ No newline at end of file +[![Star History Chart](https://api.star-history.com/svg?repos=bytedance/deer-flow&type=Date)](https://star-history.com/#bytedance/deer-flow&Date) diff --git a/README_zh.md b/README_zh.md index 550d609..826ebbd 100644 --- a/README_zh.md +++ b/README_zh.md @@ -7,9 +7,9 @@ > 源于开源,回馈开源。 -**DeerFlow**(**D**eep **E**xploration and **E**fficient **R**esearch **Flow**)是一个社区驱动的深度研究框架,它建立在开源社区的杰出工作基础之上。我们的目标是将语言模型与专业工具(如网络搜索、爬虫和Python代码执行)相结合,同时回馈使这一切成为可能的社区。 +**DeerFlow**(**D**eep **E**xploration and **E**fficient **R**esearch **Flow**)是一个社区驱动的深度研究框架,它建立在开源社区的杰出工作基础之上。我们的目标是将语言模型与专业工具(如网络搜索、爬虫和 Python 代码执行)相结合,同时回馈使这一切成为可能的社区。 -请访问[DeerFlow的官方网站](https://deerflow.tech/)了解更多详情。 +请访问[DeerFlow 的官方网站](https://deerflow.tech/)了解更多详情。 ## 演示 @@ -17,22 +17,22 @@ https://github.com/user-attachments/assets/f3786598-1f2a-4d07-919e-8b99dfa1de3e -在此演示中,我们展示了如何使用DeerFlow: -- 无缝集成MCP服务 +在此演示中,我们展示了如何使用 DeerFlow: + +- 无缝集成 MCP 服务 - 进行深度研究过程并生成包含图像的综合报告 - 基于生成的报告创建播客音频 ### 回放示例 - [埃菲尔铁塔与最高建筑相比有多高?](https://deerflow.tech/chat?replay=eiffel-tower-vs-tallest-building) -- [GitHub上最热门的仓库有哪些?](https://deerflow.tech/chat?replay=github-top-trending-repo) +- [GitHub 上最热门的仓库有哪些?](https://deerflow.tech/chat?replay=github-top-trending-repo) - [撰写关于南京传统美食的文章](https://deerflow.tech/chat?replay=nanjing-traditional-dishes) - [如何装饰租赁公寓?](https://deerflow.tech/chat?replay=rental-apartment-decoration) - [访问我们的官方网站探索更多回放示例。](https://deerflow.tech/#case-studies) --- - ## 📑 目录 - [🚀 快速开始](#快速开始) @@ -46,27 +46,30 @@ https://github.com/user-attachments/assets/f3786598-1f2a-4d07-919e-8b99dfa1de3e - [💖 致谢](#致谢) - [⭐ Star History](#star-History) - ## 快速开始 -DeerFlow使用Python开发,并配有用Node.js编写的Web UI。为确保顺利的设置过程,我们推荐使用以下工具: +DeerFlow 使用 Python 开发,并配有用 Node.js 编写的 Web UI。为确保顺利的设置过程,我们推荐使用以下工具: ### 推荐工具 + - **[`uv`](https://docs.astral.sh/uv/getting-started/installation/):** - 简化Python环境和依赖管理。`uv`会自动在根目录创建虚拟环境并为您安装所有必需的包—无需手动安装Python环境。 + 简化 Python 环境和依赖管理。`uv`会自动在根目录创建虚拟环境并为您安装所有必需的包—无需手动安装 Python 环境。 - **[`nvm`](https://github.com/nvm-sh/nvm):** - 轻松管理多个Node.js运行时版本。 + 轻松管理多个 Node.js 运行时版本。 - **[`pnpm`](https://pnpm.io/installation):** - 安装和管理Node.js项目的依赖。 + 安装和管理 Node.js 项目的依赖。 ### 环境要求 + 确保您的系统满足以下最低要求: + - **[Python](https://www.python.org/downloads/):** 版本 `3.12+` - **[Node.js](https://nodejs.org/en/download/):** 版本 `22+` ### 安装 + ```bash # 克隆仓库 git clone https://github.com/bytedance/deer-flow.git @@ -92,7 +95,7 @@ cp conf.yaml.example conf.yaml brew install marp-cli ``` -可选,通过[pnpm](https://pnpm.io/installation)安装Web UI依赖: +可选,通过[pnpm](https://pnpm.io/installation)安装 Web UI 依赖: ```bash cd deer-flow/web @@ -106,9 +109,9 @@ pnpm install > [!注意] > 在启动项目之前,请仔细阅读指南,并更新配置以匹配您的特定设置和要求。 -### 控制台UI +### 控制台 UI -运行项目的最快方法是使用控制台UI。 +运行项目的最快方法是使用控制台 UI。 ```bash # 在类bash的shell中运行项目 @@ -117,9 +120,10 @@ uv run main.py ### Web UI -本项目还包括一个Web UI,提供更加动态和引人入胜的交互体验。 +本项目还包括一个 Web UI,提供更加动态和引人入胜的交互体验。 + > [!注意] -> 您需要先安装Web UI的依赖。 +> 您需要先安装 Web UI 的依赖。 ```bash # 在开发模式下同时运行后端和前端服务器 @@ -130,29 +134,31 @@ uv run main.py bootstrap.bat -d ``` -打开浏览器并访问[`http://localhost:3000`](http://localhost:3000)探索Web UI。 +打开浏览器并访问[`http://localhost:3000`](http://localhost:3000)探索 Web UI。 在[`web`](./web/)目录中探索更多详情。 - ## 支持的搜索引擎 -DeerFlow支持多种搜索引擎,可以在`.env`文件中通过`SEARCH_API`变量进行配置: +DeerFlow 支持多种搜索引擎,可以在`.env`文件中通过`SEARCH_API`变量进行配置: -- **Tavily**(默认):专为AI应用设计的专业搜索API - - 需要在`.env`文件中设置`TAVILY_API_KEY` - - 注册地址:https://app.tavily.com/home +- **Tavily**(默认):专为 AI 应用设计的专业搜索 API + + - 需要在`.env`文件中设置`TAVILY_API_KEY` + - 注册地址:https://app.tavily.com/home - **DuckDuckGo**:注重隐私的搜索引擎 - - 无需API密钥 + + - 无需 API 密钥 - **Brave Search**:具有高级功能的注重隐私的搜索引擎 - - 需要在`.env`文件中设置`BRAVE_SEARCH_API_KEY` - - 注册地址:https://brave.com/search/api/ + + - 需要在`.env`文件中设置`BRAVE_SEARCH_API_KEY` + - 注册地址:https://brave.com/search/api/ - **Arxiv**:用于学术研究的科学论文搜索 - - 无需API密钥 - - 专为科学和学术论文设计 + - 无需 API 密钥 + - 专为科学和学术论文设计 要配置您首选的搜索引擎,请在`.env`文件中设置`SEARCH_API`变量: @@ -165,93 +171,76 @@ SEARCH_API=tavily ### 核心能力 -- 🤖 **LLM集成** - - 通过[litellm](https://docs.litellm.ai/docs/providers)支持集成大多数模型 - - 支持开源模型如Qwen - - 兼容OpenAI的API接口 - - 多层LLM系统适用于不同复杂度的任务 +- 🤖 **LLM 集成** + - 通过[litellm](https://docs.litellm.ai/docs/providers)支持集成大多数模型 + - 支持开源模型如 Qwen + - 兼容 OpenAI 的 API 接口 + - 多层 LLM 系统适用于不同复杂度的任务 -### 工具和MCP集成 +### 工具和 MCP 集成 - 🔍 **搜索和检索** - - 通过Tavily、Brave Search等进行网络搜索 - - 使用Jina进行爬取 - - 高级内容提取 -- 🔗 **MCP无缝集成** - - 扩展私有域访问、知识图谱、网页浏览等能力 - - 促进多样化研究工具和方法的集成 + - 通过 Tavily、Brave Search 等进行网络搜索 + - 使用 Jina 进行爬取 + - 高级内容提取 + +- 🔗 **MCP 无缝集成** + - 扩展私有域访问、知识图谱、网页浏览等能力 + - 促进多样化研究工具和方法的集成 ### 人机协作 - 🧠 **人在环中** - - 支持使用自然语言交互式修改研究计划 - - 支持自动接受研究计划 + + - 支持使用自然语言交互式修改研究计划 + - 支持自动接受研究计划 - 📝 **报告后期编辑** - - 支持类Notion的块编辑 - - 允许AI优化,包括AI辅助润色、句子缩短和扩展 - - 由[tiptap](https://tiptap.dev/)提供支持 + - 支持类 Notion 的块编辑 + - 允许 AI 优化,包括 AI 辅助润色、句子缩短和扩展 + - 由[tiptap](https://tiptap.dev/)提供支持 ### 内容创作 - 🎙️ **播客和演示文稿生成** - - AI驱动的播客脚本生成和音频合成 - - 自动创建简单的PowerPoint演示文稿 - - 可定制模板以满足个性化内容需求 - + - AI 驱动的播客脚本生成和音频合成 + - 自动创建简单的 PowerPoint 演示文稿 + - 可定制模板以满足个性化内容需求 ## 架构 -DeerFlow实现了一个模块化的多智能体系统架构,专为自动化研究和代码分析而设计。该系统基于LangGraph构建,实现了灵活的基于状态的工作流,其中组件通过定义良好的消息传递系统进行通信。 +DeerFlow 实现了一个模块化的多智能体系统架构,专为自动化研究和代码分析而设计。该系统基于 LangGraph 构建,实现了灵活的基于状态的工作流,其中组件通过定义良好的消息传递系统进行通信。 ![架构图](./assets/architecture.png) + > 在[deerflow.tech](https://deerflow.tech/#multi-agent-architecture)上查看实时演示 系统采用了精简的工作流程,包含以下组件: 1. **协调器**:管理工作流生命周期的入口点 + - 根据用户输入启动研究过程 - 在适当时候将任务委派给规划器 - 作为用户和系统之间的主要接口 2. **规划器**:负责任务分解和规划的战略组件 + - 分析研究目标并创建结构化执行计划 - 确定是否有足够的上下文或是否需要更多研究 - 管理研究流程并决定何时生成最终报告 3. **研究团队**:执行计划的专业智能体集合: - - **研究员**:使用网络搜索引擎、爬虫甚至MCP服务等工具进行网络搜索和信息收集。 - - **编码员**:使用Python REPL工具处理代码分析、执行和技术任务。 - 每个智能体都可以访问针对其角色优化的特定工具,并在LangGraph框架内运行 + + - **研究员**:使用网络搜索引擎、爬虫甚至 MCP 服务等工具进行网络搜索和信息收集。 + - **编码员**:使用 Python REPL 工具处理代码分析、执行和技术任务。 + 每个智能体都可以访问针对其角色优化的特定工具,并在 LangGraph 框架内运行 4. **报告员**:研究输出的最终阶段处理器 - 汇总研究团队的发现 - 处理和组织收集的信息 - 生成全面的研究报告 -## 文本转语音集成 - -DeerFlow现在包含一个文本转语音(TTS)功能,允许您将研究报告转换为语音。此功能使用火山引擎TTS API生成高质量的文本音频。速度、音量和音调等特性也可以自定义。 - -### 使用TTS API - -您可以通过`/api/tts`端点访问TTS功能: - -```bash -# 使用curl的API调用示例 -curl --location 'http://localhost:8000/api/tts' \ ---header 'Content-Type: application/json' \ ---data '{ - "text": "这是文本转语音功能的测试。", - "speed_ratio": 1.0, - "volume_ratio": 1.0, - "pitch_ratio": 1.0 -}' \ ---output speech.mp3 -``` - - ## 开发 ### 测试 @@ -279,13 +268,13 @@ make lint make format ``` -### 使用LangGraph Studio进行调试 +### 使用 LangGraph Studio 进行调试 -DeerFlow使用LangGraph作为其工作流架构。您可以使用LangGraph Studio实时调试和可视化工作流。 +DeerFlow 使用 LangGraph 作为其工作流架构。您可以使用 LangGraph Studio 实时调试和可视化工作流。 -#### 本地运行LangGraph Studio +#### 本地运行 LangGraph Studio -DeerFlow包含一个`langgraph.json`配置文件,该文件定义了LangGraph Studio的图结构和依赖关系。该文件指向项目中定义的工作流图,并自动从`.env`文件加载环境变量。 +DeerFlow 包含一个`langgraph.json`配置文件,该文件定义了 LangGraph Studio 的图结构和依赖关系。该文件指向项目中定义的工作流图,并自动从`.env`文件加载环境变量。 ##### Mac @@ -308,16 +297,17 @@ pip install -U "langgraph-cli[inmem]" langgraph dev ``` -启动LangGraph服务器后,您将在终端中看到几个URL: +启动 LangGraph 服务器后,您将在终端中看到几个 URL: + - API: http://127.0.0.1:2024 - Studio UI: https://smith.langchain.com/studio/?baseUrl=http://127.0.0.1:2024 -- API文档: http://127.0.0.1:2024/docs +- API 文档: http://127.0.0.1:2024/docs -在浏览器中打开Studio UI链接以访问调试界面。 +在浏览器中打开 Studio UI 链接以访问调试界面。 -#### 使用LangGraph Studio +#### 使用 LangGraph Studio -在Studio UI中,您可以: +在 Studio UI 中,您可以: 1. 可视化工作流图并查看组件如何连接 2. 实时跟踪执行情况,了解数据如何在系统中流动 @@ -325,48 +315,112 @@ langgraph dev 4. 通过检查每个组件的输入和输出来调试问题 5. 在规划阶段提供反馈以完善研究计划 -当您在Studio UI中提交研究主题时,您将能够看到整个工作流执行过程,包括: +当您在 Studio UI 中提交研究主题时,您将能够看到整个工作流执行过程,包括: + - 创建研究计划的规划阶段 - 可以修改计划的反馈循环 - 每个部分的研究和写作阶段 - 最终报告生成 +## Docker + +您也可以使用 Docker 运行此项目。 + +首先,您需要阅读下面的[配置](#配置)部分。确保`.env`和`.conf.yaml`文件已准备就绪。 + +其次,构建您自己的 Web 服务器 Docker 镜像: + +```bash +docker build -t deer-flow-api . +``` + +最后,启动运行 Web 服务器的 Docker 容器: + +```bash +# 将deer-flow-api-app替换为您首选的容器名称 +docker run -d -t -p 8000:8000 --env-file .env --name deer-flow-api-app deer-flow-api + +# 停止服务器 +docker stop deer-flow-api-app +``` + +### Docker Compose + +您也可以使用 docker compose 设置此项目: + +```bash +# 构建docker镜像 +docker compose build + +# 启动服务器 +docker compose up +``` + +## 文本转语音集成 + +DeerFlow 现在包含一个文本转语音(TTS)功能,允许您将研究报告转换为语音。此功能使用火山引擎 TTS API 生成高质量的文本音频。速度、音量和音调等特性也可以自定义。 + +### 使用 TTS API + +您可以通过`/api/tts`端点访问 TTS 功能: + +```bash +# 使用curl的API调用示例 +curl --location 'http://localhost:8000/api/tts' \ +--header 'Content-Type: application/json' \ +--data '{ + "text": "这是文本转语音功能的测试。", + "speed_ratio": 1.0, + "volume_ratio": 1.0, + "pitch_ratio": 1.0 +}' \ +--output speech.mp3 +``` + ## 示例 -以下示例展示了DeerFlow的功能: +以下示例展示了 DeerFlow 的功能: ### 研究报告 -1. **OpenAI Sora报告** - OpenAI的Sora AI工具分析 +1. **OpenAI Sora 报告** - OpenAI 的 Sora AI 工具分析 + - 讨论功能、访问方式、提示工程、限制和伦理考虑 - [查看完整报告](examples/openai_sora_report.md) -2. **Google的Agent to Agent协议报告** - Google的Agent to Agent (A2A)协议概述 - - 讨论其在AI智能体通信中的作用及其与Anthropic的Model Context Protocol (MCP)的关系 +2. **Google 的 Agent to Agent 协议报告** - Google 的 Agent to Agent (A2A)协议概述 + + - 讨论其在 AI 智能体通信中的作用及其与 Anthropic 的 Model Context Protocol (MCP)的关系 - [查看完整报告](examples/what_is_agent_to_agent_protocol.md) -3. **什么是MCP?** - 对"MCP"一词在多个上下文中的全面分析 - - 探讨AI中的Model Context Protocol、化学中的Monocalcium Phosphate和电子学中的Micro-channel Plate +3. **什么是 MCP?** - 对"MCP"一词在多个上下文中的全面分析 + + - 探讨 AI 中的 Model Context Protocol、化学中的 Monocalcium Phosphate 和电子学中的 Micro-channel Plate - [查看完整报告](examples/what_is_mcp.md) 4. **比特币价格波动** - 最近比特币价格走势分析 + - 研究市场趋势、监管影响和技术指标 - 基于历史数据提供建议 - [查看完整报告](examples/bitcoin_price_fluctuation.md) -5. **什么是LLM?** - 对大型语言模型的深入探索 +5. **什么是 LLM?** - 对大型语言模型的深入探索 + - 讨论架构、训练、应用和伦理考虑 - [查看完整报告](examples/what_is_llm.md) -6. **如何使用Claude进行深度研究?** - 在深度研究中使用Claude的最佳实践和工作流程 +6. **如何使用 Claude 进行深度研究?** - 在深度研究中使用 Claude 的最佳实践和工作流程 + - 涵盖提示工程、数据分析和与其他工具的集成 - [查看完整报告](examples/how_to_use_claude_deep_research.md) -7. **医疗保健中的AI采用:影响因素** - 影响医疗保健中AI采用的因素分析 - - 讨论AI技术、数据质量、伦理考虑、经济评估、组织准备度和数字基础设施 +7. **医疗保健中的 AI 采用:影响因素** - 影响医疗保健中 AI 采用的因素分析 + + - 讨论 AI 技术、数据质量、伦理考虑、经济评估、组织准备度和数字基础设施 - [查看完整报告](examples/AI_adoption_in_healthcare.md) 8. **量子计算对密码学的影响** - 量子计算对密码学影响的分析 + - 讨论经典密码学的漏洞、后量子密码学和抗量子密码解决方案 - [查看完整报告](examples/Quantum_Computing_Impact_on_Cryptography.md) @@ -398,11 +452,12 @@ uv run main.py --help 应用程序现在支持带有英文和中文内置问题的交互模式: 1. 启动交互模式: + ```bash uv run main.py --interactive ``` -2. 选择您偏好的语言(English或中文) +2. 选择您偏好的语言(English 或中文) 3. 从内置问题列表中选择或选择提出您自己问题的选项 @@ -410,22 +465,24 @@ uv run main.py --help ### 人在环中 -DeerFlow包含一个人在环中机制,允许您在执行研究计划前审查、编辑和批准: +DeerFlow 包含一个人在环中机制,允许您在执行研究计划前审查、编辑和批准: 1. **计划审查**:启用人在环中时,系统将在执行前向您展示生成的研究计划 2. **提供反馈**:您可以: + - 通过回复`[ACCEPTED]`接受计划 - 通过提供反馈编辑计划(例如,`[EDIT PLAN] 添加更多关于技术实现的步骤`) - 系统将整合您的反馈并生成修订后的计划 3. **自动接受**:您可以启用自动接受以跳过审查过程: - - 通过API:在请求中设置`auto_accepted_plan: true` -4. **API集成**:使用API时,您可以通过`feedback`参数提供反馈: + - 通过 API:在请求中设置`auto_accepted_plan: true` + +4. **API 集成**:使用 API 时,您可以通过`feedback`参数提供反馈: ```json { - "messages": [{"role": "user", "content": "什么是量子计算?"}], + "messages": [{ "role": "user", "content": "什么是量子计算?" }], "thread_id": "my_thread_id", "auto_accepted_plan": false, "feedback": "[EDIT PLAN] 包含更多关于量子算法的内容" @@ -448,26 +505,27 @@ DeerFlow包含一个人在环中机制,允许您在执行研究计划前审查 ## 许可证 -本项目是开源的,遵循[MIT许可证](./LICENSE)。 +本项目是开源的,遵循[MIT 许可证](./LICENSE)。 ## 致谢 -DeerFlow建立在开源社区的杰出工作基础之上。我们深深感谢所有使DeerFlow成为可能的项目和贡献者。诚然,我们站在巨人的肩膀上。 +DeerFlow 建立在开源社区的杰出工作基础之上。我们深深感谢所有使 DeerFlow 成为可能的项目和贡献者。诚然,我们站在巨人的肩膀上。 我们要向以下项目表达诚挚的感谢,感谢他们的宝贵贡献: -- **[LangChain](https://github.com/langchain-ai/langchain)**:他们卓越的框架为我们的LLM交互和链提供动力,实现了无缝集成和功能。 -- **[LangGraph](https://github.com/langchain-ai/langgraph)**:他们在多智能体编排方面的创新方法对于实现DeerFlow复杂工作流至关重要。 +- **[LangChain](https://github.com/langchain-ai/langchain)**:他们卓越的框架为我们的 LLM 交互和链提供动力,实现了无缝集成和功能。 +- **[LangGraph](https://github.com/langchain-ai/langgraph)**:他们在多智能体编排方面的创新方法对于实现 DeerFlow 复杂工作流至关重要。 这些项目展示了开源协作的变革力量,我们很自豪能够在他们的基础上构建。 ### 核心贡献者 + 衷心感谢`DeerFlow`的核心作者,他们的愿景、热情和奉献使这个项目得以实现: - **[Daniel Walnut](https://github.com/hetaoBackend/)** - **[Henry Li](https://github.com/magiccube/)** -您坚定不移的承诺和专业知识是DeerFlow成功的驱动力。我们很荣幸有您引领这一旅程。 +您坚定不移的承诺和专业知识是 DeerFlow 成功的驱动力。我们很荣幸有您引领这一旅程。 ## Star History diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a67a25c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,36 @@ +services: + backend: + build: + context: . + dockerfile: Dockerfile + container_name: deer-flow-backend + ports: + - "8000:8000" + env_file: + - .env + volumes: + - ./conf.yaml:/app/conf.yaml + restart: unless-stopped + networks: + - deer-flow-network + + frontend: + build: + context: ./web + dockerfile: Dockerfile + args: + - NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL + container_name: deer-flow-frontend + ports: + - "3000:3000" + env_file: + - .env + depends_on: + - backend + restart: unless-stopped + networks: + - deer-flow-network + +networks: + deer-flow-network: + driver: bridge diff --git a/web/.dockerignore b/web/.dockerignore new file mode 100644 index 0000000..86f0b3b --- /dev/null +++ b/web/.dockerignore @@ -0,0 +1,8 @@ +.env +Dockerfile +.dockerignore +node_modules +npm-debug.log +README.md +.next +.git diff --git a/web/Dockerfile b/web/Dockerfile new file mode 100644 index 0000000..3870683 --- /dev/null +++ b/web/Dockerfile @@ -0,0 +1,55 @@ +##### DEPENDENCIES + +FROM node:20-alpine AS deps +RUN apk add --no-cache libc6-compat openssl +WORKDIR /app + + +# Install dependencies based on the preferred package manager + +COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml\* ./ + +RUN \ + if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ + elif [ -f package-lock.json ]; then npm ci; \ + elif [ -f pnpm-lock.yaml ]; then npm install -g pnpm && pnpm i; \ + else echo "Lockfile not found." && exit 1; \ + fi + +##### BUILDER + +FROM node:20-alpine AS builder +WORKDIR /app +ARG NEXT_PUBLIC_API_URL +COPY --from=deps /app/node_modules ./node_modules +COPY . . + +ENV NEXT_TELEMETRY_DISABLED=1 + +RUN \ + if [ -f yarn.lock ]; then SKIP_ENV_VALIDATION=1 yarn build; \ + elif [ -f package-lock.json ]; then SKIP_ENV_VALIDATION=1 npm run build; \ + elif [ -f pnpm-lock.yaml ]; then npm install -g pnpm && SKIP_ENV_VALIDATION=1 pnpm run build; \ + else echo "Lockfile not found." && exit 1; \ + fi + +##### RUNNER + +FROM gcr.io/distroless/nodejs20-debian12 AS runner +WORKDIR /app + +ENV NODE_ENV=production + +ENV NEXT_TELEMETRY_DISABLED=1 + +COPY --from=builder /app/next.config.js ./ +COPY --from=builder /app/public ./public +COPY --from=builder /app/package.json ./package.json + +COPY --from=builder /app/.next/standalone ./ +COPY --from=builder /app/.next/static ./.next/static + +EXPOSE 3000 +ENV PORT=3000 + +CMD ["server.js"] diff --git a/web/README.md b/web/README.md index 77cd7d7..cacc959 100644 --- a/web/README.md +++ b/web/README.md @@ -6,6 +6,26 @@ This is the web UI for [`DeerFlow`](https://github.com/bytedance/deer-flow). +## Quick Start + +### Prerequisites + +- [`DeerFlow`](https://github.com/bytedance/deer-flow) +- Node.js (v22.14.0+) +- pnpm (v10.6.2+) as package manager + +### Configuration + +Create a `.env` file in the project root and configure the following environment variables: + +- `NEXT_PUBLIC_API_URL`: The URL of the deer-flow API. + +It's always a good idea to start with the given example file, and edit the `.env` file with your own values: + +```bash +cp .env.example .env +``` + ## How to Install DeerFlow Web UI uses `pnpm` as its package manager. @@ -37,6 +57,39 @@ You can set the `NEXT_PUBLIC_API_URL` environment variable if you're using a dif NEXT_PUBLIC_API_URL=http://localhost:8000/api ``` +## Docker + +You can also run this project with Docker. + +First, you need read the [configuration](#configuration) below. Make sure `.env` file is ready. + +Second, to build a Docker image of your own web server: + +```bash +docker build --build-arg NEXT_PUBLIC_API_URL=YOUR_DEER-FLOW_API -t deer-flow-web . +``` + +Final, start up a docker container running the web server: + +```bash +# Replace deer-flow-web-app with your preferred container name +docker run -d -t -p 3000:3000 --env-file .env --name deer-flow-web-app deer-flow-web + +# stop the server +docker stop deer-flow-web-app +``` + +### Docker Compose + +You can also setup this project with the docker compose: + +```bash +# building docker image +docker compose build + +# start the server +docker compose up +``` ## License @@ -48,11 +101,12 @@ We extend our heartfelt gratitude to the open source community for their invalua DeerFlow is built upon the foundation of these outstanding projects: In particular, we want to express our deep appreciation for: -* [Next.js](https://nextjs.org/) for their exceptional framework -* [Shadcn](https://ui.shadcn.com/) for their minimalistic components that powers our UI -* [Zustand](https://zustand.docs.pmnd.rs/) for their stunning state management -* [Framer Motion](https://www.framer.com/motion/) for their amazing animation library -* [React Markdown](https://www.npmjs.com/package/react-markdown) for their exceptional markdown rendering and customizability -* Last but not least, special thanks to [SToneX](https://github.com/stonexer) for his great contribution for [token-by-token visual effect](./src/core/rehype/rehype-split-words-into-spans.ts) + +- [Next.js](https://nextjs.org/) for their exceptional framework +- [Shadcn](https://ui.shadcn.com/) for their minimalistic components that powers our UI +- [Zustand](https://zustand.docs.pmnd.rs/) for their stunning state management +- [Framer Motion](https://www.framer.com/motion/) for their amazing animation library +- [React Markdown](https://www.npmjs.com/package/react-markdown) for their exceptional markdown rendering and customizability +- Last but not least, special thanks to [SToneX](https://github.com/stonexer) for his great contribution for [token-by-token visual effect](./src/core/rehype/rehype-split-words-into-spans.ts) These outstanding projects form the backbone of DeerFlow and exemplify the transformative power of open source collaboration. diff --git a/web/docker-compose.yml b/web/docker-compose.yml new file mode 100644 index 0000000..85edc84 --- /dev/null +++ b/web/docker-compose.yml @@ -0,0 +1,12 @@ +services: + deer-flow-web: + build: + context: . + dockerfile: Dockerfile + args: + NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL} + image: deer-flow-web + ports: + - "3000:3000" + env_file: + - .env diff --git a/web/next.config.js b/web/next.config.js index 19e5372..26d4628 100644 --- a/web/next.config.js +++ b/web/next.config.js @@ -34,6 +34,9 @@ const config = { }); return config; }, + + // ... rest of the configuration. + output: "standalone", }; export default config;