GPT Researcher README
assafelovic/gpt-researcher · Apache-2.0 · 源码版本 9d39a2f8
上手导读
安装与准备
配置检索和模型服务,从一个范围较小的问题开始。
试用示例
做竞品调研前,把问题限定成可核验的时间范围、对象和指标,再让工具收集材料并据此起草报告。
🔎 GPT Researcher
GPT Researcher 是首个开放的深度研究代理,可针对任意任务开展网络与本地研究。
代理可以生成详细、正式且客观的研究报告,并提供自定义选项,专注于相关资源、结构框架和经验报告。GPT Researcher 早已不止于 RAG:规划代理与执行代理将每个任务拆解为研究问题,决策模型只保留真正有助于回答问题的上下文,多代理工作流协调各专业代理完成从规划到发布的全过程,递归深度研究则从广度和深度两方面探索主题。研究并行执行,因此快速、稳定、可靠,并能减少错误信息。
我们的使命是利用人工智能的力量,为个人和组织提供准确、客观和事实的信息。
为什么选择GPT Researcher?
- 人工研究要形成客观结论可能需要数周时间,耗费大量资源和精力。
- 基于过时信息训练的 LLM 会产生幻觉,难以胜任当下的研究任务。
- 当前的 LLM 存在 token 限制,不足以生成长篇研究报告。
- 现有服务的网络资源有限,容易导致错误信息和肤浅的结果。
- 只选用部分网络资源可能给研究任务带来偏见。
演示
作为 Claude Skill 安装
通过将 GPT Researcher 安装为 Claude Skill,扩展 Claude 的深度研究能力:
npx skills add assafelovic/gpt-researcher
安装后,Claude 即可在对话中直接使用 GPT Researcher 的深度研究能力。
架构
核心思想是使用“计划者”和“执行”代理:计划者生成研究问题,执行代理收集相关信息,最后由发布者将所有发现汇总为一份完整的研究报告。
步骤:
- 根据研究查询创建特定任务的代理。
- 生成一组研究问题,共同形成对该任务的客观意见。
- 使用爬虫代理为每个问题收集信息。
- 对每个资源进行汇总并跟踪其来源。
- 过滤并聚合所有摘要,生成最终研究报告。
教程
特性
- 📝 基于网络与本地文档生成详细的研究报告。
- 🖼️ 智能抓取并筛选报告配图。
- 🍌 使用 Google Gemini(Nano Banana)生成 AI 内联配图。
- 📜 生成超过 2,000 字的详细报告。
- 🌐 汇总 20 多个网络资源,形成客观结论。
- 🎯 通过 Jev 进行智能上下文过滤,默认无需 API 密钥或 embeddings。
- 🖥️ 提供轻量(HTML/CSS/JS)与生产级(NextJS + Tailwind)两种前端。
- 🔍 支持 JavaScript 渲染的网页抓取。
- 📂 在整个研究过程中维护记忆与上下文。
- 📄 将报告导出为 PDF、Word 等格式。
📖 文档
请参阅文档了解:
- 安装与设置指南
- 配置与自定义选项
- 操作指南示例
- 完整 API 参考
⚙️ 快速开始
安装
-
安装 Python 3.12 或更高版本。指南。
-
克隆项目并进入目录:
git clone https://github.com/assafelovic/gpt-researcher.git cd gpt-researcher -
通过导出或写入
.env文件设置 API 密钥。export OPENAI_API_KEY={Your OpenAI API Key here} export TAVILY_API_KEY={Your Tavily API Key here}
(可选)如需增强追踪与可观测性,还可以设置:
# export LANGCHAIN_TRACING_V2=true # export LANGCHAIN_API_KEY={Your LangChain API Key here}
如使用自定义的 OpenAI 兼容 API(如本地模型、其他提供商),还可以设置:
export OPENAI_BASE_URL={Your custom API base URL here} -
安装依赖并启动服务器:
pip install -r requirements.txt python -m uvicorn main:app --reload
访问 http://localhost:8000 即可开始。
其他安装方式(如 Poetry 或虚拟环境)请参阅快速开始页面。
以 PIP 包运行
pip install gpt-researcher
示例用法:
... from gpt_researcher import GPTResearcher query = "why is Nvidia stock going up?" researcher = GPTResearcher(query=query) # Conduct research on the given query research_result = await researcher.conduct_research() # Write the report report = await researcher.write_report() ...
更多示例与配置请参阅 PIP 文档页面。
🔧 MCP 客户端
GPT Researcher 支持 MCP 集成,可连接 GitHub 仓库、数据库和自定义 API 等专用数据源,让数据源研究与网络搜索结合使用。
export RETRIEVER=tavily,mcp # Enable hybrid web + MCP research
from gpt_researcher import GPTResearcher import asyncio import os async def mcp_research_example(): # Enable MCP with web search os.environ["RETRIEVER"] = "tavily,mcp" researcher = GPTResearcher( query="What are the top open source web research agents?", mcp_configs=[ { "name": "github", "command": "npx", "args": ["-y", "@modelcontextprotocol/server-github"], "env": {"GITHUB_TOKEN": os.getenv("GITHUB_TOKEN")} } ] ) research_result = await researcher.conduct_research() report = await researcher.write_report() return report
完整的 MCP 文档与高级示例请访问 MCP 集成指南。
🍌 内联图像生成
GPT Researcher 可使用 Google 的 Gemini 模型(Nano Banana)自动生成并在研究报告中嵌入 AI 创建的插图。
# Enable in your .env file
IMAGE_GENERATION_ENABLED=true
GOOGLE_API_KEY=your_google_api_key
IMAGE_GENERATION_MODEL=models/gemini-2.5-flash-image启用后,系统将:
- 分析研究上下文,识别可视化机会
- 在研究阶段预生成 2-3 张相关图像
- 在撰写报告时将它们内联嵌入
图像以与 GPT Researcher UI 一致的深色模式风格生成,呈现带青色点缀的专业信息图美学。
详情请参阅文档中的图像生成。
✨ 深度研究
GPT Researcher 现已包含深度研究(Deep Research)——一种高级递归研究工作流,以智能体的方式在深度和广度上探索主题。该功能采用树状探索模式,在深入研究子主题的同时保持对研究主题的全局视野。
- 🌳 树状探索,深度与广度可配置
- ⚡️ 并发处理,更快出结果
- 🤝 跨研究分支的智能上下文管理
- ⏱️ 每次深度研究约 5 分钟
- 💰 每次研究成本约 $0.4(使用 o3-mini、reasoning effort 设为 "high")
详情请参阅文档中的深度研究。
🎯 使用 Jev 的智能上下文过滤
每次研究都会抓取数十个页面,而每个页面中只有一部分内容有助于回答问题。在内容进入 LLM 之前,GPT Researcher 会决定保留哪些段落。默认使用 TypeSafe 的 Jev——该模型评估的是每个段落对问题的实际用处,而不是词语或 embedding 的相似度。
在相同成本下,Jev 的上下文相关性比 embeddings 高 59%(保留段落相关率 73% vs 46%)。我们在 28 个研究任务上对各种方案做了基准测试:重放同一批抓取来源,只更换过滤器:
| 上下文过滤器 | 保留的相关段落 | 与 embeddings 正面对比 | 过滤耗时 | 每份报告成本 | 依赖 |
|---|---|---|---|---|---|
| Jev(默认) | 73% | 15 胜 · 10 平 · 3 负 | 1.7s | $0.115 | TYPESAFE_API_KEY |
| 关键词(回退) | 51% | 14 胜 · 8 平 · 6 负 | 0.02s | $0.116 | 无 |
| Embeddings | 46% | — | 1.0s | $0.117 | 一个 embedding 提供商 |
| 不过滤 | — | 13 胜 · 11 平 · 4 负 | — | $0.192 | 无 |
无论使用哪种过滤器,撰写报告约需 45 秒,因此过滤器只影响总耗时中的过滤环节。对开放式问题不做过滤会写出覆盖面最广的报告,但成本高出 65%。
无需任何配置。 设置了 TYPESAFE_API_KEY 时使用 Jev;未设置或 Jev 调用失败时,GPT Researcher 回退到本地运行的关键词(BM25)排序,无需 API 密钥、模型或 embeddings。Embeddings 仍可作为选项使用。
export TYPESAFE_API_KEY=... # use Jev (the default when a key is set) export CONTEXT_FILTER=auto # auto | jev | keyword | embeddings | none
方法论、注意事项与复现方式请参阅 Context Filter 文档与完整基准测试。
使用 Docker 运行
步骤 1 - 安装 Docker
步骤 2 - 复制
.env.example文件,在其中填入你的 API 密钥,并将文件保存为.env
步骤 3 - 在 docker-compose 文件中注释掉你不想通过 Docker 运行的服务。
docker-compose up --build
如果不行,尝试去掉连字符运行:
docker compose up --build
步骤 4 - 默认情况下(如果你没有修改 docker-compose 文件),此流程将启动 2 个进程:
- 运行在 localhost:8000 的 Python 服务器
- 运行在 localhost:3000 的 React 应用
在任何浏览器访问 localhost:3000,开始研究吧!
📄 基于本地文档的研究
你可以让 GPT Researcher 基于本地文档执行研究任务。目前支持的文件格式有:PDF、纯文本、CSV、Excel、Markdown、PowerPoint 和 Word 文档。
步骤 1:设置环境变量 DOC_PATH,指向文档所在的文件夹。
export DOC_PATH="./my-docs"
步骤 2:
- 如果你运行的是 localhost:8000 上的前端应用,只需在 "Report Source" 下拉选项中选择 "My Documents"。
- 如果你通过 PIP 包运行 GPT Researcher,在实例化
GPTResearcher类时将report_source参数设为 "local"(代码示例见此)。
🤖 MCP 服务器
我们的 MCP 服务器已迁移至独立仓库:gptr-mcp。
GPT Researcher MCP 服务器让 Claude 等 AI 应用能够执行深度研究。虽然 LLM 应用可以通过 MCP 访问网络搜索工具,但 GPT Researcher MCP 能带来更深入、更可靠的研究结果。
特性:
- 为 AI 助手提供深度研究能力
- 优化上下文使用,信息质量更高
- 推理更完善,结果更全面
- 集成 Claude Desktop
详细的安装与使用说明请访问官方仓库。
👪 多代理助手
随着 AI 从提示工程和 RAG 演进到多代理系统,我们很高兴推出基于 LangGraph 和 AG2 构建的多代理助手。
借助多代理框架,通过多个具备专业技能的代理协作,研究过程的深度与质量都能显著提升。本项目展示了由多个 AI 代理组成的团队如何就给定主题协同开展研究,从规划到发布。
一次运行平均可生成 5-6 页的研究报告,支持 PDF、Docx 和 Markdown 等多种格式。
请点击这里查看,或前往我们的文档了解 LangGraph 与 AG2 的更多信息。
🔍 可观测性
GPT Researcher 支持 LangSmith 以增强链路追踪和可观测性,特别适用于调试和优化复杂的多智能体工作流。
要开启追踪:
- 设置以下环境变量:
export LANGCHAIN_TRACING_V2=true export LANGCHAIN_API_KEY=您的_API_KEY export LANGCHAIN_PROJECT="gpt-researcher"
- 正常运行研究任务。所有基于 LangGraph 的智能体交互将自动被追踪,并可在您的 LangSmith 控制台中查看可视化结果。
🖥️ 前端应用
GPT Researcher 现已提供增强版前端,改善用户体验并简化研究流程。前端提供:
- 直观的研究查询输入界面
- 研究任务实时进度跟踪
- 研究结果的交互式展示
- 可自定义设置,打造个性化研究体验
提供两种部署方式:
- 由 FastAPI 提供服务的轻量静态前端
- 功能丰富的 NextJS 应用
详细的设置说明与前端功能信息请参阅文档页面。
🚀 贡献
我们非常欢迎贡献!如果你有兴趣,请查看贡献指南。
如果你有兴趣加入我们的使命,请查看我们的 路线图 页面,并通过我们的 Discord 社区 联系我们。
✉️ 支持 / 联系我们
🛡 免责声明
本项目 GPT Researcher 是一个实验性应用程序,按“现状”提供,不含任何明示或暗示的保证。我们基于 Apache 2 许可证共享代码,仅用于学术目的。本文内容不构成任何学术建议,也不建议在学术或研究论文中使用。
我们对客观研究主张的看法:
- GPT Researcher 的主要目标是减少错误和有偏见的事实。如何做到?我们假设抓取的网站越多,出现错误数据的可能性就越小。通过在每次研究中抓取多个网站并选择出现频率最高的信息,这些信息全部出错的概率极低。
- 我们的目标不是消除偏见,而是尽可能减少偏见。作为一个社区,我们在这里探索最有效的人机/LLM 交互方式。
- 在研究过程中,人们也容易产生偏见,因为大多数人对自己研究的课题已有自己的看法。这个工具会搜罗多种观点,并均匀地解释各种不同的视角,而有偏见的人是绝对读不到这些观点的。
原作者与许可证
文档来自 assafelovic/gpt-researcher 的上述提交,保留原文并调整了站内排版与链接。
查看仓库许可证原文 ↗ Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.


