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

Function generate_interest_vector

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

Generate a deterministic pseudo-vector from the detected directions.

(core_directions: Dict[str, float])

Source from the content-addressed store, hash-verified

1621
1622
1623def generate_interest_vector(core_directions: Dict[str, float]) -> List[float]:
1624 """Generate a deterministic pseudo-vector from the detected directions."""
1625 try:
1626 target_dim = max(1, int(str(os.environ.get("EMBEDDING_DIMENSIONS", "768")).strip()))
1627 except ValueError:
1628 target_dim = 768
1629
1630 direction_str = "_".join(sorted(core_directions.keys()))
1631 hash_bytes = hashlib.sha256(direction_str.encode()).digest()
1632 vector = []
1633
1634 for index in range(target_dim):
1635 byte_index = index % 32
1636 sign = 1 if (hash_bytes[byte_index] & (1 << (index % 8))) else -1
1637 value = sign * ((hash_bytes[byte_index] >> (index % 8)) & 1)
1638 vector.append(float(value))
1639
1640 norm = sum(value * value for value in vector) ** 0.5
1641 if norm > 0:
1642 vector = [value / norm for value in vector]
1643
1644 return vector
1645
1646
1647def format_profile_card(profile: Dict[str, Any], user_id: str = "user_001") -> str:

Callers 6

ensure_profile_shapeFunction · 0.85
_trim_bootstrap_profileFunction · 0.85
parse_natural_languageFunction · 0.85
cold_startFunction · 0.85

Calls 2

getMethod · 0.80
encodeMethod · 0.80

Tested by

no test coverage detected