MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / normalize_message_text

Function normalize_message_text

uncommon_route/normalize.py:47–56  ·  view source on GitHub ↗
(message: dict[str, Any])

Source from the content-addressed store, hash-verified

45
46
47def normalize_message_text(message: dict[str, Any]) -> str:
48 content = message.get("content", "")
49 if isinstance(content, str):
50 text = content
51 elif isinstance(content, list):
52 text = " ".join(p for p in (_flatten_block(b) for b in content) if p)
53 else:
54 text = "" if content is None else str(content)
55 text = _WHITESPACE_RUN.sub(" ", text).strip()
56 return text
57
58
59def normalize_messages_to_hashes(messages: list[dict[str, Any]]) -> list[str]:

Calls 2

_flatten_blockFunction · 0.85
getMethod · 0.45