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

Function parse_research_homepage

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

Fetch a personal homepage and derive a homepage-first bootstrap fragment.

(homepage_url: str, use_llm: bool = True)

Source from the content-addressed store, hash-verified

1150
1151
1152def parse_research_homepage(homepage_url: str, use_llm: bool = True) -> Dict[str, Any]:
1153 """Fetch a personal homepage and derive a homepage-first bootstrap fragment."""
1154 candidate_url = _collapse_whitespace(homepage_url)
1155 if not candidate_url:
1156 raise ValueError("empty homepage url")
1157 if "://" not in candidate_url:
1158 candidate_url = f"https://{candidate_url.lstrip('/')}"
1159
1160 response = requests.get(
1161 candidate_url,
1162 headers=SCHOLAR_HEADERS,
1163 timeout=max(5, _get_env_int("PAPERFLOW_HOMEPAGE_TIMEOUT", HOMEPAGE_TIMEOUT_SECONDS)),
1164 )
1165 response.raise_for_status()
1166
1167 homepage_profile = _extract_homepage_sections(response.text)
1168 homepage_profile["url"] = candidate_url
1169
1170 explicit_texts = [
1171 *(homepage_profile.get("sections", {}).get("research_interests", []) or []),
1172 *(homepage_profile.get("sections", {}).get("research", []) or []),
1173 *(homepage_profile.get("keywords") or []),
1174 ]
1175 secondary_texts = [
1176 *(homepage_profile.get("sections", {}).get("about", []) or []),
1177 ]
1178 publication_titles = [
1179 *(homepage_profile.get("sections", {}).get("projects", []) or []),
1180 ]
1181 if homepage_profile.get("description"):
1182 secondary_texts.append(str(homepage_profile["description"]))
1183
1184 parsed_profile = _build_bootstrap_fragment_from_structured_sources(
1185 explicit_texts=explicit_texts,
1186 secondary_texts=secondary_texts,
1187 publication_titles=publication_titles,
1188 use_llm=use_llm,
1189 )
1190
1191 notes: List[str] = []
1192 if explicit_texts:
1193 notes.append("已优先根据个人主页研究方向生成冷启动画像。")
1194 elif secondary_texts:
1195 notes.append("已结合个人主页摘要信息补充冷启动画像。")
1196
1197 return {
1198 "homepage_profile": homepage_profile,
1199 "parsed_profile": parsed_profile,
1200 "direction_explanations": notes,
1201 }
1202
1203
1204def _merge_scholar_page_data(base: Dict[str, Any], incoming: Dict[str, Any], publication_limit: int) -> Dict[str, Any]:

Callers 1

cold_startFunction · 0.85

Calls 6

_collapse_whitespaceFunction · 0.85
getMethod · 0.80
_get_env_intFunction · 0.70
raise_for_statusMethod · 0.45

Tested by

no test coverage detected