跳转到主内容

使用CLI运行

此命令行界面 (CLI) 工具可让您使用 GPTResearcher 类生成研究报告。它提供了一种简单的方法来对各种主题进行研究并生成不同类型的报告。

安装

  1. 克隆仓库

    git clone https://github.com/yourusername/gpt-researcher.git
    cd gpt-researcher
  2. 安装所需的依赖项

    pip install -r requirements.txt
  3. 设置您的环境变量:在项目根目录中创建一个 .env 文件,并添加您的 API 密钥或其他必要的配置。

使用

使用 CLI 的基本语法是

python cli.py "<query>" --report_type <report_type> [--tone <tone>]

参数

  • query (必需):您想要调查的研究问题。
  • --report_type (必需):要生成的报告类型。选项包括
    • research_report: 摘要 - 简短快速 (约 2 分钟)
    • detailed_report: 详细报告 - 深入且耗时较长 (约 5 分钟)
    • resource_report (资源报告)
    • outline_report (大纲报告)
    • custom_report (自定义报告)
    • subtopic_report (子主题报告)
  • --tone (可选):报告的语气。默认为“objective”(客观)。选项包括
    • objective: 公正、无偏见的呈现
    • formal: 符合学术标准,使用复杂的语言
    • analytical: 批判性评估和审视
    • persuasive: 有说服力的观点
    • informative: 清晰全面的信息
    • explanatory: 阐明复杂概念
    • descriptive: 详细的描绘
    • critical: 判断有效性和相关性
    • comparative: 并列不同的理论
    • speculative: 探索假设
    • reflective: 个人见解
    • narrative: 基于故事的呈现
    • humorous: 轻松有趣的
    • optimistic: 突出积极方面
    • pessimistic: 关注挑战

示例

  1. 生成一份关于气候变化的快速研究报告

    python cli.py "What are the main causes of climate change?" --report_type research_report
  2. 创建一份关于人工智能的详细报告,采用分析性语气

    python cli.py "The impact of artificial intelligence on job markets" --report_type detailed_report --tone analytical
  3. 生成一份关于可再生能源的大纲报告,采用说服性语气

    python cli.py "Renewable energy sources and their potential" --report_type outline_report --tone persuasive

输出

生成的报告将作为 Markdown 文件保存在 outputs 目录中。文件名将是一个唯一的 UUID。

注意

  • 执行时间可能会因查询的复杂性和所请求的报告类型而异。
  • 请确保您已在 .env 文件中设置了必要的 API 密钥和权限,以确保工具正常运行。
  • 所有语气选项都应以小写形式提供。