langchainjs: new Error("Please install chromadb as a dependency with, e.g. `npm install -S chromadb`") but chromadb existed in node_modules in newer langchain since version 147

My previous code used to be working in 0.0.145,

import { CheerioWebBaseLoader } from "langchain/document_loaders/web/cheerio";
import { RecursiveCharacterTextSplitter } from "langchain/text_splitter";
import { HuggingFaceTransformersEmbeddings } from "langchain/embeddings/hf_transformers

const huggerEmbedding = new HuggingFaceTransformersEmbeddings({
  modelName: "Xenova/all-MiniLM-L6-v2",
});

import { Chroma } from "langchain/vectorstores/chroma";

const loader = new CheerioWebBaseLoader(
  "https://lilianweng.github.io/posts/2023-06-23-agent/"
);
const docs = await loader.load();

const splitter = new RecursiveCharacterTextSplitter({
  chunkOverlap: 0,
  chunkSize: 500,
});

const splitDocuments = await splitter.splitDocuments(docs);

const vectorStore = await Chroma.fromDocuments(splitDocuments, huggerEmbedding, {
  collectionName: "a-test-collection",
  url: "http://localhost:9007", // Optional, will default to this value
  collectionMetadata: {
    "hnsw:space": "cosine",
  }
});

const retrievedDocs = await vectorStore.similaritySearch(
  "What are the approaches to Task Decomposition?"
);

now in newer version, 0.0.147, 0.0.148, 0.0.149(not tested yet but seems to be still wrong) are all getting an errors saying

node_modules/_langchain@0.0.147@langchain/dist/vectorstores/chroma.js:287
            throw new Error("Please install chromadb as a dependency with, e.g. `npm install -S chromadb`");
                  ^
Error: Please install chromadb as a dependency with, e.g. `npm install -S chromadb`
    at Function.imports (file:///Users/xisizhe/Documents/my_projects/langchain/lang147/node_modules/_langchain@0.0.147@langchain/dist/vectorstores/chroma.js:287:19)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Chroma.ensureCollection (file:///Users/xisizhe/Documents/my_projects/langchain/lang147/node_modules/_langchain@0.0.147@langchain/dist/vectorstores/chroma.js:89:42)
    at async Chroma.addVectors (file:///Users/xisizhe/Documents/my_projects/langchain/lang147/node_modules/_langchain@0.0.147@langchain/dist/vectorstores/chroma.js:126:28)
    at async Function.fromDocuments (file:///Users/xisizhe/Documents/my_projects/langchain/lang147/node_modules/_langchain@0.0.147@langchain/dist/vectorstores/chroma.js:262:9)
    at async file:///Users/xisizhe/Documents/my_projects/langchain/lang147/embedding_huggerface2.ts:31:21

however the node_modules has the latest chromadb 1.5.8 , even downgraded to 1.5.3, still output the same error for no reason, any ideas why chromadb package not found ?

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Reactions: 2
  • Comments: 25 (3 by maintainers)

Most upvoted comments

🤖

Hello,

I understand that you’re having an issue with the chromadb dependency in the newer versions of langchainjs. Based on the error message you’re receiving, it seems like the chromadb module is not being found, even though it exists in your node_modules.

From the context provided, there are two similar issues that have been resolved in the past:

  1. Update chroma integration to support 1.5.0: This issue was resolved by merging and releasing a PR. You can check the changes made in this PR to see if they apply to your situation.

  2. Allow ChromaClient to be initialized outside Chroma Vector Store: This issue was resolved by making changes in a commit. You can follow the changes made in the commit #220 to resolve your issue.

If these solutions do not resolve your issue, it might be helpful to check the following:

  • Ensure that chromadb is correctly installed in your project. You can verify this by running npm list chromadb in your project directory. This should return the version of chromadb installed in your project.

  • If chromadb is installed correctly, the issue might be with the way langchainjs is trying to import it. In the newer versions of langchainjs, there might be changes in the way dependencies are handled. You can check the langchainjs documentation or the source code to see if there are any changes in this regard.

  • If the above steps do not help, you might want to consider creating a minimal reproduction of the issue and sharing it. This would help in identifying the exact cause of the issue.

I hope this helps. Let me know if you have any other questions or if there’s anything else I can do to assist you.

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

Ideally, this would be fixed with https://github.com/chroma-core/chroma/pull/1153

Tested with LC@0.0.150

also works with LC@0.0.147 (which I think is what latest flowise is using)

FWIW langchain + chroma seems to work for me with npm

I confirmed with a minimal example that everything should be playing nice together - can folks give this a try?

@jacoblee93 thx for the quick update.

this is from the Chroma discord: https://discord.com/channels/1073293645303795742/1152647545122738286/1153294473690873906

Apparently, if you rhard lock and rollback to Chroma 1.5.6 it will work