# 第七章 提示词链与任务分解

当面对复杂的工作流程时，单个提示词往往无法满足需求。提示词链技术通过将多个提示词调用串联起来，使前一个调用的输出成为后一个调用的输入，从而实现更复杂的自动化任务。

提示词链的核心思想是“分而治之”——将一个大型、复杂的任务分解为多个小型、可管理的子任务，每个子任务由专门设计的提示词处理。这种方法不仅提高了每个步骤的准确性，还使整个流程更加可控和可调试。

本章将介绍任务分解的方法论、链式模式的设计原则，以及如何在实践中构建可靠的多步骤工作流。

***

## 本章目标

* 理解本章核心概念与适用场景
* 掌握可复用的提示词/工作流模式
* 能将方法迁移到自己的任务中

## 先修知识

* 建议先阅读上一章或同等基础内容
* 如涉及代码示例，具备基本编程与 API 调用常识

## 本章内容

* [7.1 复杂任务的分解艺术](/prompt_engineering_guide/di-er-bu-fen-he-xin-ji-shu-pian/07_prompt_chaining/7.1_task_decomposition.md)
* [7.2 提示词链的设计模式](/prompt_engineering_guide/di-er-bu-fen-he-xin-ji-shu-pian/07_prompt_chaining/7.2_chaining_patterns.md)
* [7.3 上下文传递与状态管理](/prompt_engineering_guide/di-er-bu-fen-he-xin-ji-shu-pian/07_prompt_chaining/7.3_context_passing.md)
* [7.4 实战案例：构建多步骤工作流](/prompt_engineering_guide/di-er-bu-fen-he-xin-ji-shu-pian/07_prompt_chaining/7.4_case_study.md)
* [7.5 多轮对话管理](/prompt_engineering_guide/di-er-bu-fen-he-xin-ji-shu-pian/07_prompt_chaining/7.5_multi_turn_dialogue.md)
  * [7.5.1 对话历史管理的深度指南](/prompt_engineering_guide/di-er-bu-fen-he-xin-ji-shu-pian/07_prompt_chaining/7.5_multi_turn_dialogue/7.5_1_dialogue_best_practices.md)
* [7.6 本章实战练习](/prompt_engineering_guide/di-er-bu-fen-he-xin-ji-shu-pian/07_prompt_chaining/7.6_practice.md)
* [本章小结](/prompt_engineering_guide/di-er-bu-fen-he-xin-ji-shu-pian/07_prompt_chaining/summary.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yeasy.gitbook.io/prompt_engineering_guide/di-er-bu-fen-he-xin-ji-shu-pian/07_prompt_chaining.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
