Function: modelSourceToCache()
ts
function modelSourceToCache(
hook: TransformersJsModelSource,
env?: {
remoteHost?: string;
remotePathTemplate?: string;
},
): TransformersCacheLike;Defined in: src/batteries/llm/transformers_js/model_source.ts:95
Wrap a TransformersJsModelSource hook into a Web-Cache-API-compatible object suitable for env.customCache. match parses the key, calls the hook, and normalizes the result: Uint8Array → new Response(bytes); string/Response pass through; undefined/throw → fall through. put is a no-op (served files are never re-cached — toCacheResponse is false for them).
Parameters
| Parameter | Type | Description |
|---|---|---|
hook | TransformersJsModelSource | The consumer's resolver. |
env | { remoteHost?: string; remotePathTemplate?: string; } | Host/template for key parsing (defaults to the library defaults). |
env.remoteHost? | string | - |
env.remotePathTemplate? | string | - |
Returns
TransformersCacheLike