fix: map_fields empty-retry + correction prompt field_N guidance
- map_fields: retry with simplified prompt on empty LLM response - correction.md: add explicit guidance for undeclared field_N errors (add <field> declarations + try OCR name replacement) - MAX_RETRY=5 now effective (was overridden by .env:3)
This commit is contained in:
+13
-1
@@ -754,8 +754,20 @@ def map_fields(state: AgentState) -> Dict:
|
||||
)
|
||||
prev_jrxml = state.get("current_jrxml", "")
|
||||
full_text = _generate_with_continuation(llm, prompt, writer, "map_fields")
|
||||
# 空响应重试:有时 LLM 第一轮不输出,换个方式再试一次
|
||||
if not full_text.strip():
|
||||
_node_log.error("map_fields LLM 返回空响应,保留占位字段版本")
|
||||
_node_log.warning("map_fields 第一轮返回空响应,尝试简化 prompt 重试")
|
||||
retry_prompt = (
|
||||
"请将以下 JRXML 中的占位字段名 $F{field_1}, $F{field_2}, ... 替换为 OCR 提取的真实字段名。\n"
|
||||
"规则:根据列顺序映射——$F{field_1} 对应第1列,$F{field_2} 对应第2列,以此类推。\n"
|
||||
"同时更新 <field name=\"...\"> 声明和所有 $F{...} 引用。\n"
|
||||
"只输出完整 JRXML,不要解释。\n\n"
|
||||
f"OCR 字段:\n{fields_text}\n\n"
|
||||
f"JRXML:\n{prev_jrxml}"
|
||||
)
|
||||
full_text = _generate_with_continuation(llm, retry_prompt, writer, "map_fields")
|
||||
if not full_text.strip():
|
||||
_node_log.error("map_fields LLM 重试后仍返回空响应,保留占位字段版本")
|
||||
return state
|
||||
jrxml = _extract_jrxml(full_text)
|
||||
if len(jrxml.strip()) < 200:
|
||||
|
||||
Reference in New Issue
Block a user