mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-10 08:32:09 +00:00
fix(tui-gateway): restore _content_display_text helper lost in main merge
The May 27 merge of origin/main into bb/gui re-introduced two callers of
_content_display_text (in _inflight_text and _history_to_messages) but
dropped the helper definition itself, leaving an unresolved reference.
NameError fires on every user message via _start_inflight_turn ->
_inflight_text, taking down both the TUI and the desktop (which share
this gateway backend) the moment input is dispatched.
Restores the helper verbatim from main (commit 36c99af37) -- pure
structured-content text extractor, no other dependencies.
This commit is contained in:
parent
02d26981d3
commit
a3df95e76d
1 changed files with 30 additions and 0 deletions
|
|
@ -2581,6 +2581,36 @@ def _coerce_seed_history(value: Any) -> list[dict]:
|
|||
return history
|
||||
|
||||
|
||||
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 _inflight_text(value: Any) -> str:
|
||||
return _content_display_text(value).strip()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue