fix(tui_gateway): restore _content_display_text helper
Bb/gui had dropped the helper but the orchestrator code merged from main still calls it (_inflight_text, _message_preview). Re-add the definition verbatim from main so session.create / _start_inflight_turn don't crash with NameError on first prompt submit.
This commit is contained in:
@@ -2421,6 +2421,36 @@ def _enrich_with_attached_images(user_text: str, image_paths: list[str]) -> str:
|
|||||||
return text or "What do you see in this image?"
|
return text or "What do you see in this image?"
|
||||||
|
|
||||||
|
|
||||||
|
def _content_display_text(content: Any) -> str:
|
||||||
|
if content is None:
|
||||||
|
return ""
|
||||||
|
if isinstance(content, str):
|
||||||
|
return content
|
||||||
|
if isinstance(content, (int, float)):
|
||||||
|
return str(content)
|
||||||
|
if isinstance(content, list):
|
||||||
|
parts = []
|
||||||
|
for part in content:
|
||||||
|
text = _content_display_text(part).strip()
|
||||||
|
if text:
|
||||||
|
parts.append(text)
|
||||||
|
return "\n".join(parts)
|
||||||
|
if isinstance(content, dict):
|
||||||
|
kind = content.get("type")
|
||||||
|
if kind in {"text", "input_text", "output_text"}:
|
||||||
|
return str(content.get("text") or content.get("content") or "")
|
||||||
|
if kind in {"image_url", "input_image", "image"}:
|
||||||
|
return "[image]"
|
||||||
|
if kind in {"input_audio", "audio"}:
|
||||||
|
return "[audio]"
|
||||||
|
if kind:
|
||||||
|
return f"[{kind}]"
|
||||||
|
if "text" in content:
|
||||||
|
return str(content.get("text") or "")
|
||||||
|
return "[structured content]"
|
||||||
|
return str(content)
|
||||||
|
|
||||||
|
|
||||||
def _coerce_message_text(content: Any) -> str:
|
def _coerce_message_text(content: Any) -> str:
|
||||||
"""Render ``message['content']`` as a plain string for transport.
|
"""Render ``message['content']`` as a plain string for transport.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user