{"record":{"id":"685d75e5e47292fc","repo":"CherryHQ/cherry-studio","slug":"the-local-embedding-model-is-not-fully-downloaded","errorCode":null,"errorMessage":"the local embedding model is not fully downloaded","messagePattern":"the local embedding model is not fully downloaded","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/ai/provider/custom/localEmbedding/localEmbeddingRuntime.ts","lineNumber":15,"sourceCode":"import { application } from '@application'\nimport type { EmbeddingModelDir } from '@main/ai/inference/inferenceProtocol'\nimport { LOCAL_MODELS } from '@main/ai/inference/localModelCatalog'\nimport { localEmbeddingDownloadService } from '@main/services/localModel'\n\n/**\n * The cached model's directory, for loading it straight off disk. Resolving it here — from\n * the download service's own on-disk probe — rather than handing the worker a list of mirror\n * revisions to try means a missing cache fails in the main process with a clear message,\n * instead of surfacing as a transformers.js resolution error per candidate.\n */\nexport function currentModelDir(): EmbeddingModelDir {\n  const modelDir = localEmbeddingDownloadService.completeCacheDir()\n  if (!modelDir) {\n    throw new Error('the local embedding model is not fully downloaded')\n  }\n  return modelDir\n}\n\n/**\n * Embed texts on the inference worker (off the main thread). Pooling and\n * normalization run inside the worker; this is a thin main-process entry point.\n * Model files must already be downloaded; inference never fetches missing files.\n */\nexport async function embedTexts(texts: string[], signal?: AbortSignal): Promise<number[][]> {\n  if (texts.length === 0) return []\n  return application\n    .get('EmbeddingInferenceService')\n    .embed(texts, currentModelDir(), LOCAL_MODELS.embedding.dtype, signal)\n}\n","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/CherryHQ/cherry-studio/blob/726446b54cd69ffe51a276638672f6d95ca0768c/src/main/ai/provider/custom/localEmbedding/localEmbeddingRuntime.ts#L1-L31","documentation":"Thrown by `currentModelDir()` when `localEmbeddingDownloadService.completeCacheDir()` returns null — i.e. the embedding model files are not fully present on disk. The runtime resolves the cache directory up front (rather than letting transformers.js discover missing files per candidate) so a missing cache fails in the main process with a clear message instead of an opaque worker resolution error.","triggerScenarios":"Calling `embedTexts` (or otherwise resolving the model dir) before the download finished, or after a partial/interrupted download left the cache incomplete.","commonSituations":"Knowledge-base indexing started before the model download completed; the download was interrupted (app quit, network drop); disk corruption or manual deletion of cache files; insufficient disk space aborted the download.","solutions":["Trigger and await the embedding model download before indexing (use `localEmbeddingDownloadService`).","Check disk space and re-download if the cache is partial.","Gate the embedding UI on download completion so requests cannot start early."],"exampleFix":"// before\nawait embedTexts(texts) // throws if not downloaded\n// after\nif (!localEmbeddingDownloadService.completeCacheDir()) {\n  await localEmbeddingDownloadService.ensureDownloaded()\n}\nawait embedTexts(texts)","handlingStrategy":"validation","validationCode":"if (!localEmbeddingDownloadService.completeCacheDir()) {\n  throw new Error('Embedding model not downloaded — trigger the download before indexing')\n}","typeGuard":"const isEmbeddingModelReady = (): boolean =>\n  localEmbeddingDownloadService.completeCacheDir() != null","tryCatchPattern":null,"preventionTips":["Gate indexing on download completion in the UI","Trigger ensureDownloaded() before first embedTexts call","Re-download if disk space was tight during the first attempt"],"tags":["download","local-embedding","cache","model-files"],"backgroundTag":null,"analyzedSha":"726446b54cd69ffe51a276638672f6d95ca0768c","analyzedAt":"2026-08-12T17:30:37.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}