
YAML 文件中使用三重双引号(""")会导致解析失败,因其不符合 YAML 规范;应改用字面量块标量(|)或折叠块标量(>)来安全表示含换行、特殊字符的长文本。
yaml 文件中使用三重双引号(`"""`)会导致解析失败,因其不符合 yaml 规范;应改用字面量块标量(`|`)或折叠块标量(`>`)来安全表示含换行、特殊字符的长文本。
YAML 对字符串格式有严格语法规则,不支持 Python 风格的三重双引号字符串("""...""")。您原始配置中 PROMPT_SUMMARY: """...""" 的写法是非法的——YAML 解析器会将其误判为两个连续的标量(空字符串 "" 后紧跟另一个 " 开头的字符串),从而抛出类似 expected <block end>, but found '<scalar>' 的语法错误。
✅ 正确做法:使用字面量块标量(|)
当需要保留原始换行、缩进和所有字符(包括 \n 字面量本身)时,应使用 |(竖线)开头的字面量块:
WORKFLOW:
EXTRACT_SUMMARIZATION:
PROMPT_SUMMARY: |
Extracting the timestamps of the goals scored by players in a football match using the commentator's description.
The structure of input is:
timestamp => text
timestamp => text
timestamp => text
timestamp => text
The output only consists of timestamps and does not include any text.
Example:
Input:
0:01 => [Applause]
0:04 => Welcome, ladies and gentlemen, to the match between Liverpool and Chelsea.
0:14 => Silva has scored, and the score is 1-0 in favor of Liverpool.
0:20 => So, there has been a foul committed by a Liverpool player.
0:25 => The referee has blown the whistle to end the first half.
0:30 => Chelsea has equalized through Ch.
0:45 => Tr has put Chelsea in the lead.
0:50 => So, the match has...
0:55 => ended, and the victory goes to Chelsea.
Output: 0:14, 0:30, 0:45
This is an incorrect format of output:
0:14 => Silva has scored, and the score is 1-0 in favor of Liverpool.
0:45 => Tr has put Chelsea in the lead.
This is another incorrect format of output:
0:01 => [Applause]
0:04 => 0:14 => 0:25 =>
Do it for the following text:
Input:
{}
Output:⚠️ 注意事项:
- | 后的换行会被自动保留,首行换行符默认被丢弃(可通过 |- 去除末尾空白行,|+ 保留末尾换行);
- 块内无需转义 \n —— 换行即换行,\n 字符串将被原样视为反斜杠 + n;
- 若需在提示中插入变量占位符(如 {}),直接书写即可,YAML 不做预处理,由上层程序(如 Python 的 .format() 或 f-string)动态替换;
- 缩进必须一致(推荐 2 或 4 空格),且块内容需比 | 所在行更深层级缩进,否则解析失败。
? 替代方案:折叠块标量(>)
若希望将多行自动折叠为单行(用空格连接,保留段落间换行),可用 >:
PROMPT_SUMMARY: > Extracting timestamps... The structure is: timestamp => text Output only timestamps. Example: Input: 0:01 => ..., 0:14 => ... Output: 0:14, 0:30
其效果等价于 "Extracting timestamps... The structure is: ... Output: 0:14, 0:30"(内部换行转为空格,段落间保留 \n)。
? 错误避坑清单
- ❌ 禁用 """..."""、'''''' 或连续双引号拼接;
- ❌ 不要在双引号字符串中手动写 \n 期望换行(YAML 会将其当作字面字符);
- ❌ 避免混合空格与 Tab 缩进(YAML 要求纯空格);
- ✅ 建议使用 ruamel.yaml(而非在线校验器)本地验证,避免隐私泄露与过时解析器误报。
正确使用 | 或 > 后,您的 config.yml 即可被主流 YAML 解析器(PyYAML、ruamel.yaml、GitHub Actions 等)无误加载,确保 LLM 提示工程稳定运行。

















