ext_for_mime (platforms/media_cache.py)

hermes-agent · gateway/platforms/media_cache.py · python · MIT
voice

Maps MIME types to file extensions and caches media bytes for gateway adapters.

# Source: https://github.com/NousResearch/hermes-agent | License: MIT | Copyright 2025 Nous Research
# Provided via justclaw.it.com; keep this notice with the code.
"""Shared mime↔extension dispatch for inbound (downloaded) platform media.

Adapters historically hand-rolled divergent mime→extension maps on purpose (BlueBubbles
coerces ``image/heic`` to ``.jpg`` for vision tools; WhatsApp Cloud pins ``audio/ogg`` to
``.ogg`` for the STT extension whitelist). This module owns the agreed-upon union tables
plus lookup helpers taking per-adapter ``overrides`` (and ``use_defaults``/``use_mimetypes``
toggles) so each adapter's historical output stays byte-identical —
``tests/gateway/test_media_cache.py`` pins those outputs as the contract.
"""

from __future__ import annotations

import mimetypes

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key