fix: pass pdf_path to normalizer for data provenance
- Add pdfPath to extraction results in parse_session - Pass pdf_path to normalizer functions in generate_ppt - Fix 'missing PDF hash' validation error
This commit is contained in:
parent
eef8fc0892
commit
91579d54a0
@ -138,6 +138,7 @@ def parse_session(session_id):
|
||||
result = asyncio.run(orchestrator.extract_plan(filepath, plan_type))
|
||||
extractions.append({
|
||||
"pdfName": file_info.get("name", ""),
|
||||
"pdfPath": filepath,
|
||||
"planType": result.plan_type,
|
||||
"status": result.status,
|
||||
"productName": result.product_name,
|
||||
@ -149,6 +150,7 @@ def parse_session(session_id):
|
||||
logger.error(f"PDF 解析失败 [{file_info.get('name', '')}]: {e}", exc_info=True)
|
||||
extractions.append({
|
||||
"pdfName": file_info.get("name", ""),
|
||||
"pdfPath": filepath,
|
||||
"planType": plan_type,
|
||||
"status": "error",
|
||||
"productName": "unknown",
|
||||
@ -275,9 +277,11 @@ def generate_ppt(session_id):
|
||||
|
||||
# 取第一个成功的提取结果
|
||||
ext_data = None
|
||||
pdf_path = None
|
||||
for ext in extractions:
|
||||
if ext.get("status") in ("success", "cached") and ext.get("data"):
|
||||
ext_data = ext["data"]
|
||||
pdf_path = ext.get("pdfPath")
|
||||
break
|
||||
|
||||
if not ext_data:
|
||||
@ -289,13 +293,13 @@ def generate_ppt(session_id):
|
||||
|
||||
plan_type = ext_data.get("product_type", "savings")
|
||||
if plan_type == "ci":
|
||||
normalized = normalize_ci_plan(ext_data)
|
||||
normalized = normalize_ci_plan(ext_data, pdf_path)
|
||||
issues = validate_formal_ci_plan(normalized)
|
||||
elif plan_type == "iul":
|
||||
normalized = normalize_iul_plan(ext_data)
|
||||
normalized = normalize_iul_plan(ext_data, pdf_path)
|
||||
issues = validate_formal_iul_plan(normalized)
|
||||
else:
|
||||
normalized = normalize_savings_plan(ext_data)
|
||||
normalized = normalize_savings_plan(ext_data, pdf_path)
|
||||
issues = validate_formal_savings_plan(normalized)
|
||||
|
||||
# 检查是否有阻断性错误
|
||||
|
||||
Loading…
Reference in New Issue
Block a user