MCPcopy Index your code
hub / github.com/CommonstackAI/UncommonRoute / _extract_text

Function _extract_text

scripts/build_seed_index.py:13–26  ·  view source on GitHub ↗

Normalize message content — handles both string and list formats.

(content)

Source from the content-addressed store, hash-verified

11
12
13def _extract_text(content) -> str:
14 """Normalize message content — handles both string and list formats."""
15 if isinstance(content, str):
16 return content
17 if isinstance(content, list):
18 # OpenAI multi-part format: [{"type": "text", "text": "..."}, ...]
19 parts = []
20 for part in content:
21 if isinstance(part, dict) and part.get("type") == "text":
22 parts.append(part.get("text", ""))
23 elif isinstance(part, str):
24 parts.append(part)
25 return " ".join(parts)
26 return str(content) if content else ""
27
28
29def main():

Callers 1

mainFunction · 0.85

Calls 2

getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected