{"record":{"id":"2bb8dc63e8061186","repo":"chroma-core/chroma","slug":"failed-to-instantiate-ollama-client","errorCode":null,"errorMessage":"Failed to instantiate Ollama client","messagePattern":"Failed to instantiate Ollama client","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"clients/new-js/packages/ai-embeddings/ollama/src/index.ts","lineNumber":49,"sourceCode":"    } = args;\n    this.url = url;\n    this.model = model;\n  }\n\n  private async import() {\n    if (isBrowser()) {\n      const { Ollama } = await import(\"ollama/browser\");\n      this.client = new Ollama({ host: this.url });\n    } else {\n      const { Ollama } = await import(\"ollama\");\n      this.client = new Ollama({ host: this.url });\n    }\n  }\n\n  public async generate(texts: string[]): Promise<number[][]> {\n    await this.import();\n    if (!this.client) {\n      throw new Error(\"Failed to instantiate Ollama client\");\n    }\n    const response = await this.client.embed({\n      model: this.model,\n      input: texts,\n    });\n    return response.embeddings;\n  }\n\n  public defaultSpace(): EmbeddingFunctionSpace {\n    return \"cosine\";\n  }\n\n  public supportedSpaces(): EmbeddingFunctionSpace[] {\n    return [\"cosine\", \"l2\", \"ip\"];\n  }\n\n  public static buildFromConfig(config: OllamaConfig): OllamaEmbeddingFunction {\n    return new OllamaEmbeddingFunction({","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/clients/new-js/packages/ai-embeddings/ollama/src/index.ts#L31-L67","documentation":"Guard in generate(): the lazy import() of the `ollama` package completed but this.client is still unset — the module loaded yet client construction effectively failed (broken install, browser/Node resolution mismatch, or import silently throwing).","triggerScenarios":"Thrown at clients/new-js/packages/ai-embeddings/ollama/src/index.ts:49 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the `ollama` package is properly installed in the runtime environment","Check the url passed to the Ollama constructor is valid","Wrap the import() call in try/catch to surface the underlying module error"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","contentChangedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}