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

Function build_initial_profile

experiments/baselines/scholar_inbox/runner.py:337–366  ·  view source on GitHub ↗
(user_meta: Dict[str, Any], role: Dict[str, Any])

Source from the content-addressed store, hash-verified

335
336
337def build_initial_profile(user_meta: Dict[str, Any], role: Dict[str, Any]) -> Dict[str, Any]:
338 directions: Dict[str, float] = {}
339 direction_terms: List[str] = []
340
341 for key, weight, phrase in (
342 _seed_direction_entries(user_meta.get("seed_directions"))
343 + _seed_direction_entries(role.get("seed_directions"))
344 + _seed_direction_entries(role.get("core_directions"))
345 ):
346 if key:
347 directions[key] = max(directions.get(key, 0.0), weight)
348 direction_terms.extend([key, key.replace("-", " "), phrase])
349
350 description = str(user_meta.get("description") or role.get("description") or "").strip()
351 bootstrap_summary = str(role.get("bootstrap_summary") or "").strip()
352 profile_terms: List[str] = dedupe_strings(
353 direction_terms
354 + parse_string_list(description)
355 + parse_string_list(bootstrap_summary)
356 )
357
358 return {
359 "directions": directions,
360 "terms": profile_terms,
361 "keywords": [],
362 "authors": [],
363 "institutions": [],
364 "description": description,
365 "bootstrap_summary": bootstrap_summary,
366 }
367
368
369def dedupe_strings(values: Iterable[Any]) -> List[str]:

Callers 1

build_user_statesFunction · 0.70

Calls 4

getMethod · 0.80
_seed_direction_entriesFunction · 0.70
dedupe_stringsFunction · 0.70
parse_string_listFunction · 0.70

Tested by

no test coverage detected