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

Function _split_direction_clauses

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

Split short bootstrap text into direction-like clauses.

(text: str)

Source from the content-addressed store, hash-verified

1515 topic_weights[direction] = max(topic_weights.get(direction, 0.0), weight)
1516
1517 llm_parse_result: Dict[str, Any] = {
1518 "canonical_directions": [],
1519 "pending_candidates": [],
1520 "explanations": [],
1521 }
1522 if use_llm and not core_directions:
1523 llm_parse_result = _parse_directions_with_llm(text)
1524
1525 llm_directions = list(llm_parse_result.get("canonical_directions", []) or [])
1526 for direction in llm_directions:
1527 direction_key = str(direction.get("name") or "").strip()
1528 if not direction_key:
1529 continue
1530 confidence = float(direction.get("confidence", 0.5) or 0.5)
1531 if direction_key in core_directions:
1532 existing = core_directions[direction_key]
1533 if confidence > existing:
1534 core_directions[direction_key] = confidence
1535 topic_weights[direction_key] = confidence
1536 else:
1537 seeded_weight = min(max(confidence * 0.8, 0.4), 0.5)
1538 core_directions[direction_key] = seeded_weight
1539 topic_weights[direction_key] = seeded_weight
1540
1541 methodology_preferences = _derive_methodology_preferences(text_lower)
1542 taste_profile = _build_taste_profile_from_methodology(methodology_preferences)
1543
1544 return {
1545 "core_directions": core_directions,
1546 "methodology_preferences": methodology_preferences,
1547 "topic_weights": topic_weights,
1548 "interest_vector": generate_interest_vector(core_directions),
1549 "taste_profile": taste_profile,
1550 "inferred_topics": [d.get("name") for d in llm_directions if d.get("name")],
1551 "direction_explanations": list(llm_parse_result.get("explanations", []) or []),
1552 "pending_directions": list(llm_parse_result.get("pending_candidates", []) or []),
1553 "exact_direction_hits": exact_direction_hits,
1554 }
1555
1556
1557def _parse_directions_with_llm(text: str) -> Dict[str, Any]:
1558 """Use the shared canonical direction normalizer as the LLM-backed fallback."""

Callers 1

parse_natural_languageFunction · 0.85

Calls 1

_collapse_whitespaceFunction · 0.85

Tested by

no test coverage detected