ext_for_mime (platforms/media_cache.py)

Hermes-CN-Core · gateway/platforms/media_cache.py · python · MIT
voice

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

# Source: https://github.com/Eynzof/Hermes-CN-Core | 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
imp

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

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

Get a free API key