mm-cache-client
mm-cache-client is a tiny async Python client for the mm-cache service.
Install
pip install mm-cache-client==0.0.3
Usage
from mm_cache_client import MMCacheClient, MMCacheConfig
async with MMCacheClient(MMCacheConfig(base_url="http://mm-cache:8080")) as cache:
hit = await cache.resolve(
model="moonshotai/Kimi-K2.5",
content_type="image_url",
url="https://example.com/cat.png",
)
if hit is not None:
mm_hash = hit.mm_hash
mm_kwargs = hit.mm_kwargs
Plugin fast path:
sha = MMCacheClient.alias_sha(
model=model_id,
content_type="image_url",
url=url,
)
hit = await cache.resolve_sha(model=model_id, sha=sha)
if hit is not None:
return hit.mm_hash, hit.mm_kwargs
Presigned URL churn:
hit = await cache.get_payload(model=model_name, mm_hash=mm_hash)
if hit is not None:
mm_kwargs = hit.mm_kwargs
Resolve or compute on miss:
from mm_cache_client import CacheHit
async def encode() -> CacheHit:
return CacheHit(mm_hash=mm_hash, mm_kwargs=mm_kwargs)
hit = await cache.resolve_or_call(
model=model_name,
content_type="image_url",
url=url,
on_miss=encode,
)
API
alias_sha(model, content_type, url)BASETEN_MM_HASH_HEADERMMCacheClient.alias_sha(model=..., content_type=..., url=...)MMCacheClient.resolve(...)MMCacheClient.resolve_or_call(...)MMCacheClient.resolve_sha(...)MMCacheClient.resolve_alias(...)MMCacheClient.get_payload(...)MMCacheClient.put_resolve(...)MMCacheClient.put_sha(...)MMCacheClient.put_payload(...)
Integration patterns
image_encoder_plugin:
sha = MMCacheClient.alias_sha(model=model_id, content_type="image_url", url=url)
hit = await cache.resolve_sha(model=model_id, sha=sha)
if hit is not None:
return hit.mm_hash, hit.mm_kwargs
Encoder backend:
hit = await cache.resolve(model=model_id, content_type="image_url", url=url)
if hit is not None:
return hit.mm_hash, hit.mm_kwargs
hit = await cache.get_payload(model=model_id, mm_hash=mm_hash)
if hit is not None:
return hit.mm_hash, hit.mm_kwargs
See:
examples/plugin_integration.pyexamples/encoder_integration.py
Metadata
Release files for mm-cache-client 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mm_cache_client-0.0.3.tar.gz | 6.1 kB | Without provenance | Details for mm_cache_client-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mm_cache_client-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for mm_cache_client-0.0.3-py3-none-any.whl |
Total release size: 10.3 kB
Release files / mm_cache_client-0.0.3.tar.gz
| Download URL | mm_cache_client-0.0.3.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7c89fc3042d2d20caaa016a9954a152e13a5a2840b74dbf2406ae951d6b2c24f
|
|
BLAKE2b-256 checksum How to use checksums |
c8690498fe08f849934b6f4f49bbec23c62b2982eca73612e200bf19999e2840
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / mm_cache_client-0.0.3-py3-none-any.whl
| Download URL | mm_cache_client-0.0.3-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1a3e9f121506e5989a249e5dd3fab48360835878bec2d79322f4dd6ada6fc0c0
|
|
BLAKE2b-256 checksum How to use checksums |
398c0dfa442b9a24673f55f61cd38b35d26890a1549e2ecf8f3cd50f9744a85a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for mm-cache-client 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.