mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-01 12:02:05 +00:00
fix(moa): handle dict/str message shape in MoA response extraction
Sibling of #15795's context_compressor fix. agent/moa_loop.py used the same response.choices[0].message.content access; while wrapped in try/except (so no crash), a dict/str-shaped message silently returned empty. Coerce defensively so the content is actually extracted.
This commit is contained in:
parent
9dc6dc062f
commit
fe355d0a27
1 changed files with 8 additions and 2 deletions
|
|
@ -354,8 +354,14 @@ def _extract_text(response: Any) -> str:
|
|||
except Exception:
|
||||
pass
|
||||
try:
|
||||
content = response.choices[0].message.content
|
||||
return (content or "").strip()
|
||||
message = response.choices[0].message
|
||||
if isinstance(message, dict):
|
||||
content = message.get("content")
|
||||
else:
|
||||
content = getattr(message, "content", message)
|
||||
if not isinstance(content, str):
|
||||
content = str(content) if content else ""
|
||||
return content.strip()
|
||||
except Exception:
|
||||
return ""
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue