MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / _lookup_existing_pdf_report

Function _lookup_existing_pdf_report

agents/reading-agent/main.py:1394–1413  ·  view source on GitHub ↗

Find an already-created PDF reading report by its stable source key.

(
    user_id: str,
    request_metadata: Dict[str, Any],
    fallback_paper: Dict[str, Any],
)

Source from the content-addressed store, hash-verified

1392
1393def _lookup_existing_pdf_report(
1394 user_id: str,
1395 request_metadata: Dict[str, Any],
1396 fallback_paper: Dict[str, Any],
1397) -> Optional[Dict[str, Any]]:
1398 """Find an already-created PDF reading report by its stable source key."""
1399 source_type = _clean_text(request_metadata.get("report_source_type"))
1400 source_key = _clean_text(request_metadata.get("report_source_key"))
1401 if not source_type or not source_key:
1402 return None
1403
1404 report_record = get_recent_created_report_by_source(user_id, source_type, source_key)
1405 if not report_record:
1406 return None
1407 if not _is_report_record_current(report_record):
1408 return None
1409 if not _report_record_matches_language(report_record, request_metadata.get("response_language")):
1410 return None
1411
1412 return _build_reused_doc_entry(fallback_paper, report_record)
1413
1414
1415def _merge_paper_details(base: Dict[str, Any], detail: Dict[str, Any]) -> Dict[str, Any]:
1416 merged = dict(base)

Callers 1

create_reading_reportFunction · 0.85

Calls 6

_build_reused_doc_entryFunction · 0.85
getMethod · 0.80
_clean_textFunction · 0.70

Tested by

no test coverage detected