chapters.ts - 书籍章节数据
概述
定义提示词工程书籍的章节结构,包含6个部分、26个章节。
数据模型
Chapter 接口
interface Chapter {
slug: string; // URL 标识符
title: string; // 章节标题
part: string; // 所属部分名称
partNumber: number; // 部分编号
chapterNumber: number; // 章节编号
description?: string; // 章节描述
}
Part 接口
interface Part {
number: number; // 部分编号
title: string; // 部分标题
slug: string; // URL 标识符
chapters: Chapter[]; // 章节列表
}
书籍结构
| 部分 | 标题 | 章节数 | 内容范围 |
|---|---|---|---|
| 0 | Introduction | 3 | 前言、历史、介绍 |
| I | Foundations | 3 | AI 模型理解、提示词结构、核心原则 |
| II | Techniques | 6 | 各种提示词技术 |
| III | Advanced Strategies | 6 | 高级策略和技巧 |
| IV | Best Practices | 3 | 最佳实践 |
| V | Use Cases | 6 | 实际应用案例 |
| VI | Conclusion | 1 | 未来展望 |
章节列表
Part 0: Introduction
- 00a-preface - 前言(作者的话)
- 00b-history - Awesome ChatGPT Prompts 的历史
- 00c-introduction - 什么是提示词工程
Part I: Foundations
- 01-understanding-ai-models - 理解 AI 模型
- 02-anatomy-of-effective-prompt - 有效提示词的结构
- 03-core-prompting-principles - 核心提示词原则
Part II: Techniques
- 04-role-based-prompting - 基于角色的提示词
- 05-structured-output - 结构化输出
- 06-chain-of-thought - 思维链
- 07-few-shot-learning - 少样本学习
- 08-iterative-refinement - 迭代优化
- 09-json-yaml-prompting - JSON 和 YAML 提示词
Part III: Advanced Strategies
- 10-system-prompts-personas - 系统提示词和角色
- 11-prompt-chaining - 提示词链
- 12-handling-edge-cases - 处理边界情况
- 13-multimodal-prompting - 多模态提示词
- 14-context-engineering - 上下文工程(RAG、MCP等)
- 25-agents-and-skills - 智能体和技能
Part IV: Best Practices
- 15-common-pitfalls - 常见陷阱
- 16-ethics-responsible-use - 伦理和负责任使用
- 17-prompt-optimization - 提示词优化
Part V: Use Cases
- 18-writing-content - 写作和内容创作
- 19-programming-development - 编程和开发
- 20-education-learning - 教育和学习
- 21-business-productivity - 商业和生产力
- 22-creative-arts - 创意艺术
- 23-research-analysis - 研究和分析
Part VI: Conclusion
- 24-future-of-prompting - 提示词的未来
工具函数
getAllChapters
export function getAllChapters(): Chapter[]
获取所有章节(平铺数组)。
getChapterBySlug
export function getChapterBySlug(slug: string): Chapter | undefined
根据 slug 获取指定章节。
getAdjacentChapters
export function getAdjacentChapters(slug: string): { prev?: Chapter; next?: Chapter }
获取指定章节的上一章和下一章,用于导航。
使用示例
import {
parts,
getAllChapters,
getChapterBySlug,
getAdjacentChapters
} from '@/lib/book/chapters';
// 获取所有章节
const allChapters = getAllChapters();
// 获取特定章节
const chapter = getChapterBySlug('06-chain-of-thought');
// 获取上一章和下一章
const { prev, next } = getAdjacentChapters('06-chain-of-thought');
// 遍历所有部分
parts.forEach(part => {
console.log(`${part.number}: ${part.title}`);
part.chapters.forEach(ch => {
console.log(` ${ch.chapterNumber}: ${ch.title}`);
});
});
URL 结构
章节页面使用 /book/{slug} 的 URL 结构:
/book/00c-introduction/book/06-chain-of-thought/book/24-future-of-prompting