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

Function _normalize_content

uncommon_route/signals/embedding.py:30–42  ·  view source on GitHub ↗

Normalize message content — handles string and list formats.

(content: Any)

Source from the content-addressed store, hash-verified

28MIN_CONFIDENCE_TO_VOTE = 0.3
29
30def _normalize_content(content: Any) -> str:
31 """Normalize message content — handles string and list formats."""
32 if isinstance(content, str):
33 return content
34 if isinstance(content, list):
35 parts = []
36 for part in content:
37 if isinstance(part, dict) and part.get("type") == "text":
38 parts.append(part.get("text", ""))
39 elif isinstance(part, str):
40 parts.append(part)
41 return " ".join(parts)
42 return str(content) if content else ""
43
44
45def _extract_last_user_message(messages: list[dict[str, Any]]) -> str:

Callers 6

load_featuresFunction · 0.90
load_splitFunction · 0.90
load_splitFunction · 0.90
_extract_agent_stateFunction · 0.85

Calls 2

getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected