{"record":{"id":"e510138bcd599757","repo":"janhq/jan","slug":"llamacpp-extension-not-available-embedding","errorCode":null,"errorMessage":"llamacpp extension not available","messagePattern":"llamacpp extension not available","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/src/browser/extensions/engines/embedding.ts","lineNumber":39,"sourceCode":" */\nexport function getEmbeddingEngine(\n  extensionName: string = EMBEDDING_ENGINE_EXTENSION\n): (AIEngine & EmbeddingEngine) | undefined {\n  const engine = lookup(extensionName)\n  return isEmbeddingEngine(engine) ? engine : undefined\n}\n\n/**\n * Embeds `texts` and returns the vectors positionally.\n *\n * The response is keyed by `index` rather than ordered, so the result is\n * scattered back into place; a caller that trusted response order would\n * silently mismatch vectors to chunks.\n */\nexport async function embedTexts(texts: string[]): Promise<number[][]> {\n  if (!texts.length) return []\n  const engine = lookup(EMBEDDING_ENGINE_EXTENSION)\n  if (!canEmbed(engine)) throw new Error('llamacpp extension not available')\n\n  const res = await engine.embed(texts)\n  const out: number[][] = new Array(texts.length)\n  for (const item of res?.data ?? []) {\n    out[item.index] = item.embedding\n  }\n  return out\n}\n","sourceCodeStart":21,"sourceCodeEnd":48,"githubUrl":"https://github.com/janhq/jan/blob/7205d770c1e097c3daf35a911176410e93bc5564/core/src/browser/extensions/engines/embedding.ts#L21-L48","documentation":"embedTexts() in core/src/browser/extensions/engines/embedding.ts throws this when no embedding engine is registered under the EMBEDDING_ENGINE_EXTENSION lookup key, or the found engine lacks an embed() capability (canEmbed returns false). The core embedder depends on the llamacpp extension being installed and ready; without it there is no way to compute embeddings, so the call fails fast instead of returning garbage vectors.","triggerScenarios":"Calling embedTexts(), or any dependent path (queryEmb, embed, embeddings), before the llamacpp extension is registered/activated; the extension was uninstalled or failed to load; the registered engine does not implement embed().","commonSituations":"Fresh Jan install where the llamacpp extension has not finished bootstrapping; embedding queries run at app startup before provisioning completes; the extension was disabled or removed; running in a browser/core-only test environment where extensions never register.","solutions":["Ensure the llamacpp extension is installed and enabled so it registers the EMBEDDING_ENGINE_EXTENSION provider","Wait for provisioning/bootstrap (e.g. ensureProvisioned) to complete before calling embedTexts","Reinstall or repair the llamacpp extension if it failed to load","Check that the extension's embed() capability is properly advertised to core"],"exampleFix":"// before\nconst vectors = await embedTexts(chunks)\n// after\nawait ensureProvisioned()\nconst vectors = await embedTexts(chunks)","handlingStrategy":"try-catch","validationCode":"// before calling\nconst engine = lookup(EMBEDDING_ENGINE_EXTENSION)\nif (!engine || !canEmbed(engine)) throw new SkipEmbeddingError()\nawait embedTexts(texts)","typeGuard":"const isEmbedEngine = (e: unknown): e is { embed(texts: string[]): Promise<{ data: { index: number; embedding: number[] }[] }> } =>\n  !!e && typeof (e as any).embed === 'function'","tryCatchPattern":"try {\n  const vectors = await embedTexts(texts)\n} catch (e) {\n  if (e.message === 'llamacpp extension not available') {\n    await ensureProvisioned(); retryOrDegrade(e)\n  } else throw e\n}","preventionTips":["Gate embedding calls behind extension-readiness checks","Initialize/provision extensions before first use","Surface a UI state when the embedding engine is missing","Test in environments where the extension is absent"],"tags":["embedding","extension-not-available","initialization-order"],"backgroundTag":"missing-dependency","analyzedSha":"7205d770c1e097c3daf35a911176410e93bc5564","analyzedAt":"2026-09-17T14:27:30.100Z","contentChangedAt":"2026-09-17T14:27:30.100Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}