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

Function _content_to_text

uncommon_route/composition.py:561–571  ·  view source on GitHub ↗
(content: Any)

Source from the content-addressed store, hash-verified

559
560
561def _content_to_text(content: Any) -> str | None:
562 if content is None:
563 return None
564 if isinstance(content, str):
565 return content
566 if isinstance(content, (dict, list)):
567 try:
568 return json.dumps(content, ensure_ascii=False, separators=(",", ":"))
569 except Exception:
570 return str(content)
571 return str(content)
572
573
574def _estimate_messages_tokens(messages: list[dict[str, Any]]) -> int:

Callers 4

_compose_deterministicFunction · 0.85
_messages_to_transcriptFunction · 0.85
_latest_user_textFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected