fix: escape {field_N} braces in prompt templates to prevent .format() KeyError

$F{field_1} literal text in skeleton_generation/refine_layout/field_mapping
prompts was being parsed as Python .format() placeholder, causing KeyError
on every image-based initial_generation request. Escaped with double braces
so .format() outputs literal {field_1} for the LLM.
This commit is contained in:
2026-05-22 08:12:56 +08:00
parent 339d415322
commit 4dfc418fc5
3 changed files with 6 additions and 6 deletions
+4 -4
View File
@@ -1,10 +1,10 @@
你是一位资深 JasperReports 工程师。当前有一个 JRXML 使用占位字段名($F{field_1}, $F{field_2}, ...),需要替换为从 OCR 提取的真实字段名。 你是一位资深 JasperReports 工程师。当前有一个 JRXML 使用占位字段名($F{{field_1}}, $F{{field_2}}, ...),需要替换为从 OCR 提取的真实字段名。
关键规则: 关键规则:
- 只输出完整修改后的 JRXML 代码,不要解释,不要 markdown 标记。 - 只输出完整修改后的 JRXML 代码,不要解释,不要 markdown 标记。
- 将每个 $F{field_N} 占位符替换为 OCR 提取结果中对应的真实字段名。 - 将每个 $F{{field_N}} 占位符替换为 OCR 提取结果中对应的真实字段名。
- 替换规则:根据列的顺序映射——$F{field_1} 对应第 1 列的 OCR 字段名,$F{field_2} 对应第 2 列,以此类推。 - 替换规则:根据列的顺序映射——$F{{field_1}} 对应第 1 列的 OCR 字段名,$F{{field_2}} 对应第 2 列,以此类推。
- 同时更新 <field name="..."> 声明和所有 $F{...} 表达式中的引用。 - 同时更新 <field name="..."> 声明和所有 $F{{...}} 表达式中的引用。
- 如果 OCR 提取的字段数少于占位字段数,保留多余的占位字段。 - 如果 OCR 提取的字段数少于占位字段数,保留多余的占位字段。
- 不要修改 band 结构、元素位置或大小。 - 不要修改 band 结构、元素位置或大小。
- 确保 JRXML 兼容 JasperReports 7.0.6。 - 确保 JRXML 兼容 JasperReports 7.0.6。
+1 -1
View File
@@ -6,7 +6,7 @@
- 表头行的坐标直接使用采样坐标中 header_row 对应列的 x, y, width, height。 - 表头行的坐标直接使用采样坐标中 header_row 对应列的 x, y, width, height。
- 数据行:根据 first_data_row 的坐标模式,向下插值生成剩余数据行(每行 y 递增行高)。 - 数据行:根据 first_data_row 的坐标模式,向下插值生成剩余数据行(每行 y 递增行高)。
- 标题行(如有)和表尾行:保持其在骨架中的 y 位置大致不变,但调整 x 和 width 与列的采样坐标对齐。 - 标题行(如有)和表尾行:保持其在骨架中的 y 位置大致不变,但调整 x 和 width 与列的采样坐标对齐。
- 不要修改字段名(保持 $F{field_N} 占位名不变)。 - 不要修改字段名(保持 $F{{field_N}} 占位名不变)。
- 不要修改 band 结构。 - 不要修改 band 结构。
- 确保 JRXML 兼容 JasperReports 7.0.6。 - 确保 JRXML 兼容 JasperReports 7.0.6。
+1 -1
View File
@@ -2,7 +2,7 @@
关键规则: 关键规则:
- 只输出 JRXML 代码,不要解释,不要 markdown 标记。 - 只输出 JRXML 代码,不要解释,不要 markdown 标记。
- 使用 $F{field_1}, $F{field_2}, ... 作为占位字段名,并在 <field> 部分声明它们。 - 使用 $F{{field_1}}, $F{{field_2}}, ... 作为占位字段名,并在 <field> 部分声明它们。
- 报表结构必须正确(title, pageHeader, columnHeader, detail, pageFooter 等 band)。 - 报表结构必须正确(title, pageHeader, columnHeader, detail, pageFooter 等 band)。
- 元素位置使用近似值即可,后续会精确调整。 - 元素位置使用近似值即可,后续会精确调整。
- 根元素为 <jasperReport>,包含正确的 xmlns 属性。 - 根元素为 <jasperReport>,包含正确的 xmlns 属性。