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

Function _build_evidence_cache_key

agents/reading-agent/main.py:3097–3127  ·  view source on GitHub ↗
(
    paper: Dict[str, Any],
    user_profile: Dict[str, Any],
    parsed_pdf: Optional[Dict[str, Any]],
    descriptor: str,
)

Source from the content-addressed store, hash-verified

3095
3096def _build_evidence_cache_key(
3097 paper: Dict[str, Any],
3098 user_profile: Dict[str, Any],
3099 parsed_pdf: Optional[Dict[str, Any]],
3100 descriptor: str,
3101) -> str:
3102 sections = dict((parsed_pdf or {}).get("sections") or {})
3103 preferred_top_k = _preferred_evidence_top_k(user_profile)
3104 payload = {
3105 "paper": {
3106 "id": paper.get("id"),
3107 "title": _clean_text(paper.get("title")),
3108 "arxiv_id": _clean_text(paper.get("arxiv_id")),
3109 "doi": _clean_text(paper.get("doi")),
3110 },
3111 "profile_summary": _summarize_profile_for_embedding(user_profile),
3112 "profile_preferences": user_profile.get("methodology_preferences") or {},
3113 "evidence_version": READING_REPORT_EVIDENCE_VERSION,
3114 "descriptor": descriptor,
3115 "chunk_chars": READING_REPORT_CHUNK_CHARS,
3116 "chunk_overlap": READING_REPORT_CHUNK_OVERLAP,
3117 "top_k": preferred_top_k,
3118 "profile_retrieval_weight": READING_REPORT_PROFILE_RETRIEVAL_WEIGHT,
3119 "pdf": {
3120 "abstract": _clean_text((parsed_pdf or {}).get("abstract")),
3121 "full_text": _clean_text((parsed_pdf or {}).get("full_text")),
3122 "sections": {key: _clean_text(value) for key, value in sections.items()},
3123 },
3124 }
3125 raw = json.dumps(payload, ensure_ascii=False, sort_keys=True)
3126 return hashlib.sha256(raw.encode("utf-8")).hexdigest()
3127
3128
3129def _load_cached_retrieved_evidence(cache_key: str) -> Optional[Dict[str, Any]]:
3130 if not READING_REPORT_EVIDENCE_CACHE_ENABLED:

Callers 1

Calls 5

getMethod · 0.80
encodeMethod · 0.80
_clean_textFunction · 0.70

Tested by

no test coverage detected