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

Function _seed_profile_from_baseline_pdf

agents/coldstart-agent/main.py:530–557  ·  view source on GitHub ↗

Initialize an empty profile from the configured baseline PDF.

(profile: Dict[str, Any], user_id: str)

Source from the content-addressed store, hash-verified

528
529
530def _seed_profile_from_baseline_pdf(profile: Dict[str, Any], user_id: str) -> Optional[str]:
531 """Initialize an empty profile from the configured baseline PDF."""
532 if profile.get("core_directions"):
533 return None
534
535 baseline_pdf_path = resolve_baseline_pdf_path(user_id)
536 if not baseline_pdf_path:
537 return None
538
539 result = parse_paper_for_coldstart(baseline_pdf_path)
540 for direction in result.get("research_directions", []):
541 direction_key = direction.get("name", "").lower().replace(" ", "-")
542 confidence = min(float(direction.get("confidence", 0.0)), PDF_DIRECTION_WEIGHT_CAP)
543 if direction_key and confidence > 0:
544 profile["core_directions"][direction_key] = round(confidence, 4)
545 profile["topic_weights"][direction_key] = round(confidence, 4)
546
547 for key, value in (result.get("methodology_preferences") or {}).items():
548 if value:
549 profile["methodology_preferences"][key] = True
550
551 for topic in result.get("inferred_topics", []):
552 topic_key = topic.lower().replace(" ", "-")
553 if topic_key and topic_key not in profile["topic_weights"]:
554 profile["topic_weights"][topic_key] = 0.35
555
556 _apply_full_text_methodology_hints(profile, result)
557 return baseline_pdf_path
558
559
560def _empty_parsed_profile_fragment() -> Dict[str, Any]:

Callers 1

cold_startFunction · 0.85

Calls 4

getMethod · 0.80

Tested by

no test coverage detected