Skip to content
1 min read · 116 words

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: Uint8Arraynew 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

ParameterTypeDescription
hookTransformersJsModelSourceThe 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