使用 Qwen 3 构建多代理图书作家
Write 20k word book from 3-5 words.
从 3-5 个词撰写 20k 字书籍。
Today, we are building an Agentic workflow that writes a 20k-word book from a 3-5 word book title.
今天,我们正在构建一个 Agentic workflow,它能从一个 3-5 个词的书名生成一本 20k 字的书籍。
Tech stack:
技术栈:
- Firecrawl for web scraping.
- Firecrawl 用于网页抓取。
- CrewAI for orchestration.
- CrewAI 用于编排。
- Ollama to serve Qwen 3 locally.
- Ollama 用于本地服务 Qwen 3。
- LightningAI for development and hosting.
- LightningAI 用于开发和托管。
Here's our workflow:
这是我们的工作流程:

- Using Firecrawl, Outline Crew scrapes data related to the book title and decides the chapter count and titles.
- 使用 Firecrawl,Outline Crew 抓取与书籍标题相关的数据,并决定章节数量和标题。
- Multiple writer Crews work in parallel to write one chapter each.
- 多个作家 Crews 并行工作,每个写一章。
- Combine all chapters to get the book.
- 将所有章节组合起来得到书籍。
The code is available in this Studio: Book writer flow. You can run it without any installations by reproducing our environment below:
代码在这个 Studio 中可用:Book writer flow。您可以无需任何安装,通过复制下面的环境来运行它:

Let’s implement this!
让我们来实现这个!
Scraping tool - SERP API
抓取工具 - SERP API
Books demand research. Thus, we'll use Firecrawl’s SERP API to scrape data.
书籍创作需要研究。因此,我们将使用 Firecrawl’s SERP API 来抓取数据。

Tool usage:
工具使用:
- Outline Crew → to research the book title and prepare an outline.
- Outline Crew → 研究书籍标题并准备大纲。
- Writer Crew → to research the chapter title and write it.
- Writer Crew → 研究章节标题并撰写它。
Set up Qwen 3 locally
本地设置 Qwen 3
We'll serve Qwen 3 locally through Ollama.
我们将通过 Ollama 在本地提供 Qwen 3。

To do this:
要做到这一点:
- First, we download it locally.
- 首先,我们将其下载到本地。
- Next, we define it with the CrewAI's LLM class.
- 接下来,我们使用 CrewAI 的 LLM 类定义它。
Outline Crew
Outline Crew
This Crew has two Agents:
这个 Crew 有两个 Agents:

- Research Agent → Uses the Firecrawl scraping tool to scrape data related to the book's title and prepare insights.
- Research Agent → 使用 Firecrawl 抓取工具抓取与书籍标题相关的数据并准备见解。
- Outline Agent → Uses the insights to output total chapters and titles as Pydantic output.
- Outline Agent → 使用这些洞见输出总章节数和标题,作为 Pydantic 输出。
Writer Crew
Writer Crew
This Crew has two Agents:
这个 Crew 有两个 Agents:

- Research ...