mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-29 18:46:59 +00:00
fix(qqbot): stop routing file uploads through STT pipeline
The _is_voice_content_type() heuristic matched audio file extensions (.wav, .mp3, .ogg, etc.) even when the QQ Bot API explicitly reported content_type='file'. This caused files sent via QQ's file-transfer feature to be routed through the speech-to-text pipeline instead of being saved as regular attachments. The QQ Bot API already distinguishes voice messages (content_type= 'voice') from file uploads (content_type='file'), so filename-based extension sniffing is unnecessary and harmful. Removed the _VOICE_EXTENSIONS fallback; now only content_type is checked. Closes #XXXX
This commit is contained in:
parent
73e193c03d
commit
b74c033ca1
1 changed files with 10 additions and 18 deletions
|
|
@ -1807,25 +1807,17 @@ class QQAdapter(BasePlatformAdapter):
|
|||
|
||||
@staticmethod
|
||||
def _is_voice_content_type(content_type: str, filename: str) -> bool:
|
||||
"""Check if an attachment is a voice/audio message."""
|
||||
"""Check if an attachment is a voice/audio message.
|
||||
|
||||
Only trust ``content_type`` — the QQ Bot API explicitly distinguishes
|
||||
voice messages (``content_type="voice"``) from file uploads
|
||||
(``content_type="file"``). Filename-extension sniffing is intentionally
|
||||
omitted: files sent via QQ's file-transfer feature can have audio
|
||||
extensions (e.g. ``.wav``, ``.mp3``) but must **not** be routed through
|
||||
the STT pipeline.
|
||||
"""
|
||||
ct = content_type.strip().lower()
|
||||
fn = filename.strip().lower()
|
||||
if ct == "voice" or ct.startswith("audio/"):
|
||||
return True
|
||||
_VOICE_EXTENSIONS = (
|
||||
".silk",
|
||||
".amr",
|
||||
".mp3",
|
||||
".wav",
|
||||
".ogg",
|
||||
".m4a",
|
||||
".aac",
|
||||
".speex",
|
||||
".flac",
|
||||
)
|
||||
if any(fn.endswith(ext) for ext in _VOICE_EXTENSIONS):
|
||||
return True
|
||||
return False
|
||||
return ct == "voice" or ct.startswith("audio/")
|
||||
|
||||
def _qq_media_headers(self) -> Dict[str, str]:
|
||||
"""Return Authorization headers for QQ multimedia CDN downloads.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue