{"record":{"id":"7dab41d3786335b3","repo":"janhq/jan","slug":"llamacpp-extension-not-available","errorCode":null,"errorMessage":"llamacpp extension not available","messagePattern":"llamacpp extension not available","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"extensions/rag-extension/src/index.ts","lineNumber":545,"sourceCode":"  async parseDocument(path: string, type?: string): Promise<string> {\n    return await ragApi.parseDocument(path, type || 'application/octet-stream')\n  }\n\n  async embed(texts: string[]): Promise<number[][]> {\n    if (!texts || texts.length === 0) return []\n    return this.embedTexts(texts)\n  }\n\n  // Locally implement embedding logic (previously in embeddings-extension)\n  private async embedTexts(texts: string[]): Promise<number[][]> {\n    const llm = window.core?.extensionManager.getByName(\n      '@janhq/llamacpp-extension'\n    ) as AIEngine & {\n      embed?: (\n        texts: string[]\n      ) => Promise<{ data: Array<{ embedding: number[]; index: number }> }>\n    }\n    if (!llm?.embed) throw new Error('llamacpp extension not available')\n    const res = await llm.embed(texts)\n    const data: Array<{ embedding: number[]; index: number }> = res?.data || []\n    const out: number[][] = new Array(texts.length)\n    for (const item of data) {\n      out[item.index] = item.embedding\n    }\n    return out\n  }\n}\n","sourceCodeStart":527,"sourceCodeEnd":555,"githubUrl":"https://github.com/janhq/jan/blob/fad3f12a147d138388a66f0d92a02b2675f65294/extensions/rag-extension/src/index.ts#L527-L555","documentation":"Thrown by RAGExtension.embedTexts() when the llamacpp extension cannot be resolved by name (@janhq/llamacpp-extension) OR is present but does not expose an embed() method. Embeddings are delegated entirely to llamacpp, so RAG retrieval is impossible without it. The guard fires before any network/embed call.","triggerScenarios":"Calling rag.embed(texts) or any RAG retrieval path with no llamacpp-extension loaded; llamacpp-extension loaded but its embed() was stripped or not yet initialized; extension name changed in a refactor.","commonSituations":"llamacpp-extension disabled or failed to start; running on a build that ships inference without embedding support; no embedding model configured so the extension omits embed().","solutions":["Enable @janhq/llamacpp-extension and confirm it is registered (getByName returns it).","Load/configure an embedding model so embed() is exposed by the extension.","Update llamacpp-extension to a version that implements embed().","Guard retrieval calls and disable RAG features gracefully when embeddings are unavailable."],"exampleFix":"// before\nconst vec = await rag.embed(texts)\n\n// after\nconst llm = window.core?.extensionManager.getByName('@janhq/llamacpp-extension') as any\nif (!llm?.embed) {\n  throw new Error('Enable llamacpp-extension and load an embedding model to use RAG')\n}\nconst vec = await rag.embed(texts)","handlingStrategy":"type-guard","validationCode":"const llm = window.core?.extensionManager.getByName('@janhq/llamacpp-extension') as any\nif (!llm?.embed) {\n  // disable RAG retrieval, or prompt to enable the extension / load an embedding model\n}","typeGuard":"function hasEmbed(llm: unknown): llm is { embed: (t: string[]) => Promise<any> } {\n  return !!llm && typeof (llm as any).embed === 'function'\n}","tryCatchPattern":null,"preventionTips":["Load an embedding model before enabling RAG.","Confirm llamacpp-extension is enabled and registered.","Disable RAG features gracefully when embeddings are unavailable."],"tags":["rag","embeddings","llamacpp","extension"],"backgroundTag":null,"analyzedSha":"fad3f12a147d138388a66f0d92a02b2675f65294","analyzedAt":"2026-08-12T20:33:47.516Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}