Skip to content
1 min read · 99 words

Function: installModelSource()

ts
function installModelSource(
  env: TransformersEnvLike,
  hook: TransformersJsModelSource,
): () => void;

Defined in: src/batteries/llm/transformers_js/model_source.ts:131

Install a model-source hook on env and return a restore function. Sets useCustomCache = true + customCache, capturing the previous values. The returned restore() puts them back. NOT mutex- guarded on its own — use withModelSource for the scoped, serialized form.

Parameters

ParameterTypeDescription
envTransformersEnvLikeThe transformers.js env object (from await import('@huggingface/transformers')).
hookTransformersJsModelSourceThe resolver to install.

Returns

A function that restores env's prior cache configuration.

() => void