Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LangChain, chromaDB Chroma.fromDocuments returns TypeError: Cannot read properties of undefined (reading 'data')

I am running a langChain process on a node local server.

On my code :

     // Create docs with a loader
const loader = new TextLoader("Documentation/hello.txt");
const docs = await loader.load();

// Create vector store and index the docs
const vectorStore = await Chroma.fromDocuments(docs, new OpenAIEmbeddings(), {
collectionName: "z-test-collection",
});

// Search for the most similar document
const response = await vectorStore.similaritySearch("hello", 1);

console.log(response);

I get the following error message on

const vectorStore = await Chroma.fromDocuments(docs, new OpenAIEmbeddings(), { collectionName: "z-test-collection", });:

/home/alexandre/projects/langChain/ProcessGPT/node_modules/chromadb/dist/main/index.js:291
        return response.data;
                        ^
TypeError: Cannot read properties of undefined (reading 'data')
at /home/alexandre/projects/langChain/ProcessGPT/node_modules/chromadb/dist/main/index.js:291:29
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async ChromaClient.getOrCreateCollection (/home/alexandre/projects/langChain/ProcessGPT/node_modules/chromadb/dist/main/index.js:286:31)
at async Chroma.ensureCollection (/home/alexandre/projects/langChain/ProcessGPT/node_modules/langchain/dist/vectorstores/chroma.cjs:60:31)
at async Chroma.addVectors (/home/alexandre/projects/langChain/ProcessGPT/node_modules/langchain/dist/vectorstores/chroma.cjs:77:28)
at async Chroma.addDocuments (/home/alexandre/projects/langChain/ProcessGPT/node_modules/langchain/dist/vectorstores/chroma.cjs:52:9)
at async Chroma.fromDocuments (/home/alexandre/projects/langChain/ProcessGPT/node_modules/langchain/dist/vectorstores/chroma.cjs:121:9)
at async testChroma (/home/alexandre/projects/langChain/ProcessGPT/controllers/backendController.js:31:25)

The same error message appears regardless of the situation in which the method is called. Are there other requirements appart from the "npm install -S langchain" and "npm install -S chromadb" ?

Thank you in advance

like image 696
qYUUU Avatar asked Oct 28 '25 13:10

qYUUU


1 Answers

For langchainJS v0.1 you have to install first ChromaDB (build it with docker-compose) as shown in the first step

https://js.langchain.com/v0.1/docs/integrations/vectorstores/chroma/#setup

like image 81
yassine Avatar answered Oct 30 '25 03:10

yassine



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!