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

Function _extract_assistant_text

uncommon_route/proxy.py:590–608  ·  view source on GitHub ↗
(content: bytes)

Source from the content-addressed store, hash-verified

588
589
590def _extract_assistant_text(content: bytes) -> str:
591 try:
592 data = json.loads(content)
593 except Exception:
594 return ""
595 choices = data.get("choices") or []
596 if not choices:
597 return ""
598 message = choices[0].get("message") or {}
599 text = message.get("content", "")
600 if isinstance(text, str):
601 return text
602 if isinstance(text, list):
603 parts: list[str] = []
604 for item in text:
605 if isinstance(item, dict) and item.get("type") == "text":
606 parts.append(item.get("text", ""))
607 return "\n".join(parts)
608 return str(text)
609
610
611def _normalize_reasoning_content_chunk(raw: bytes) -> bytes:

Callers 1

_run_taskMethod · 0.85

Calls 2

getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected