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

Function format_profile_card

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

Format the cold-start profile confirmation card in the PDF-inspired layout.

(profile: Dict[str, Any], user_id: str = "user_001")

Source from the content-addressed store, hash-verified

1645
1646
1647def _build_taste_profile_from_methodology(methodology_preferences: Dict[str, Any]) -> Dict[str, List[str]]:
1648 """Convert methodology preferences into the existing taste-profile schema."""
1649 taste_profile = {
1650 "preferred_work_type": [],
1651 "dispreferred_work_type": [],
1652 }
1653
1654 data_pref = methodology_preferences.get("preference_data_driven_over_theory")
1655 if data_pref is True:
1656 taste_profile["preferred_work_type"].append("empirical")
1657 elif data_pref is False:
1658 taste_profile["preferred_work_type"].append("theoretical")
1659
1660 systematic_pref = methodology_preferences.get("preference_systematic_work_over_incremental")
1661 if systematic_pref is True:
1662 taste_profile["preferred_work_type"].append("systematic")
1663 taste_profile["dispreferred_work_type"].append("incremental")
1664 elif systematic_pref is False:
1665 taste_profile["dispreferred_work_type"].append("systematic")
1666
1667 if methodology_preferences.get("preference_open_source_code"):
1668 taste_profile["preferred_work_type"].append("open_source")
1669
1670 if methodology_preferences.get("preference_bio_science_application"):
1671 taste_profile["preferred_work_type"].append("applied")
1672
1673 return taste_profile
1674
1675
1676def generate_interest_vector(core_directions: Dict[str, float]) -> List[float]:
1677 """Generate a deterministic pseudo-vector from the detected directions."""
1678 try:
1679 target_dim = max(1, int(str(os.environ.get("EMBEDDING_DIMENSIONS", "768")).strip()))
1680 except ValueError:
1681 target_dim = 768
1682
1683 direction_str = "_".join(sorted(core_directions.keys()))
1684 hash_bytes = hashlib.sha256(direction_str.encode()).digest()
1685 vector = []
1686
1687 for index in range(target_dim):
1688 byte_index = index % 32
1689 sign = 1 if (hash_bytes[byte_index] & (1 << (index % 8))) else -1
1690 value = sign * ((hash_bytes[byte_index] >> (index % 8)) & 1)
1691 vector.append(float(value))
1692
1693 norm = sum(value * value for value in vector) ** 0.5
1694 if norm > 0:
1695 vector = [value / norm for value in vector]
1696
1697 return vector
1698
1699
1700def format_profile_card(profile: Dict[str, Any], user_id: str = "user_001") -> str:
1701 """Format the cold-start profile confirmation card in the PDF-inspired layout."""
1702 profile_stage = "持续学习" if profile.get("core_directions") else "冷启动"
1703 lines = [
1704 f"📋 你的学术画像(v0.1 - {profile_stage})",

Callers 1

cold_startFunction · 0.85

Calls 2

getMethod · 0.80
translate_directionFunction · 0.70

Tested by

no test coverage detected