mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-29 18:46:59 +00:00
fix(weixin): preserve voice transcript origin
This commit is contained in:
parent
cf6ff8cd30
commit
368d3488d2
2 changed files with 47 additions and 0 deletions
|
|
@ -979,6 +979,18 @@ def _extract_text(item_list: List[Dict[str, Any]]) -> str:
|
|||
# gibberish). Return empty so the central STT pipeline in
|
||||
# ``gateway/run.py`` produces the body from the downloaded
|
||||
# audio instead.
|
||||
voice_item = item.get("voice_item") or {}
|
||||
if not (voice_item.get("media") or {}):
|
||||
# No raw audio to download — Weixin supplied only its own
|
||||
# speech-to-text result. Use it, but preserve the voice
|
||||
# origin so the agent can distinguish this from text the
|
||||
# user typed (#65022).
|
||||
voice_text = str(voice_item.get("text") or "")
|
||||
if voice_text:
|
||||
return (
|
||||
"[Voice transcription provided by Weixin]\n"
|
||||
f"{voice_text}"
|
||||
)
|
||||
continue
|
||||
return ""
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,41 @@ def _make_adapter() -> WeixinAdapter:
|
|||
)
|
||||
|
||||
|
||||
class TestWeixinInboundVoiceTranscript:
|
||||
def test_voice_transcript_keeps_voice_origin_marker(self):
|
||||
item_list = [
|
||||
{
|
||||
"type": weixin.ITEM_VOICE,
|
||||
"voice_item": {"text": "帮我查一下今天天气"},
|
||||
}
|
||||
]
|
||||
|
||||
assert weixin._extract_text(item_list) == (
|
||||
"[Voice transcription provided by Weixin]\n"
|
||||
"帮我查一下今天天气"
|
||||
)
|
||||
|
||||
def test_typed_text_remains_unmarked(self):
|
||||
item_list = [
|
||||
{
|
||||
"type": weixin.ITEM_TEXT,
|
||||
"text_item": {"text": "帮我查一下今天天气"},
|
||||
}
|
||||
]
|
||||
|
||||
assert weixin._extract_text(item_list) == "帮我查一下今天天气"
|
||||
|
||||
def test_empty_voice_transcript_keeps_empty_fallback(self):
|
||||
item_list = [
|
||||
{
|
||||
"type": weixin.ITEM_VOICE,
|
||||
"voice_item": {"text": ""},
|
||||
}
|
||||
]
|
||||
|
||||
assert weixin._extract_text(item_list) == ""
|
||||
|
||||
|
||||
class TestWeixinFormatting:
|
||||
def test_format_message_preserves_markdown(self):
|
||||
adapter = _make_adapter()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue