Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chroma RAG Example from Documentation Results in Error #7194

Open
5 tasks done
wessankey opened this issue Nov 12, 2024 · 3 comments
Open
5 tasks done

Chroma RAG Example from Documentation Results in Error #7194

wessankey opened this issue Nov 12, 2024 · 3 comments
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@wessankey
Copy link

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain.js documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain.js rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

import { Chroma } from "@langchain/community/vectorstores/chroma";
import { OpenAIEmbeddings } from "@langchain/openai";

const embeddings = new OpenAIEmbeddings({
  model: "text-embedding-3-small",
});

const vectorStore = new Chroma(embeddings, {
  collectionName: "a-test-collection",
  url: "http://localhost:8000",
  collectionMetadata: { "hnsw:space": "cosine" },
});

const documents = [
  {
    pageContent: "The powerhouse of the cell is the mitochondria",
    metadata: { source: "https://example.com" },
  },
  {
    pageContent: "Buildings are made out of brick",
    metadata: { source: "https://example.com" },
  },
];

await vectorStore.addDocuments(documents, { ids: ["1", "2"] });

const retriever = vectorStore.asRetriever({ k: 2 });
await retriever.invoke("biology");

Error Message and Stack Trace (if applicable)

ChromaClientError: Bad request to http://localhost:8000/api/v1/collections/ca57da1e-f666-41a8-b3b8-cce8372c6cdd/query with status: Bad Request
    at chromaFetch (/Users/wessankey/Documents/code/conflence-rag/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]_/node_modules/chromadb/dist/chromadb.mjs:2604:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at Collection.query (/Users/wessankey/Documents/code/conflence-rag/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]_/node_modules/chromadb/dist/chromadb.mjs:2295:12)
    at Chroma.similaritySearchVectorWithScore (/Users/wessankey/Documents/code/conflence-rag/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected]__kioffgpmnh3q2ibstqorthwtay/node_modules/@langchain/community/dist/vectorstores/chroma.js:321:24)
    at async Chroma.similaritySearch (file:///Users/wessankey/Documents/code/conflence-rag/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]_/node_modules/@langchain/core/dist/vectorstores.js:104:25)
    at async VectorStoreRetriever.getRelevantDocuments (file:///Users/wessankey/Documents/code/conflence-rag/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]_/node_modules/@langchain/core/dist/retrievers/index.js:69:29)
    at <anonymous> (/Users/wessankey/Documents/code/conflence-rag/src/chroma-repro.ts:32:1) {
  cause: undefined
}

Description

I'm using LangChain to build a RAG pipeline with a Chroma vector store. The minimal reproducible example provided is a slightly modified version from the documentation.

The error occurs when calling retriever.invoke().

System Info

Node version: 18.16.0
@langchain/community: 0.3.12
@langchain/core: 0.3.17
@langchain/openai: 0.3.12
@chromadb: 1.9.2

Copy link

dosubot bot commented Nov 12, 2024

Hey @wessankey, I'm here to help you with any bugs, questions, and even guide you to become a contributor. Let's squash those bugs together! 🤖

A similar issue was reported in a closed thread titled "Error: Chroma getOrCreateCollection error: Error: TypeError: fetch failed" [1]. The error message you are encountering, "ChromaClientError: Bad request," suggests that there might be an issue with the request being sent to the Chroma service. Here are some steps you can take to troubleshoot and potentially resolve the issue:

  1. Check Chroma Service: Ensure that the Chroma service is running and accessible at the specified URL (http://localhost:8000). You can run Chroma with Docker using the command docker-compose up -d --build after cloning the Chroma repository.

  2. Verify URL and Ports: Double-check that the URL provided to the Chroma class is correct. If the service and your application are on different machines, ensure that the necessary network ports are open and accessible.

  3. Collection Metadata: Review the collectionMetadata you are using. Ensure that the metadata is correctly formatted and supported by the Chroma service.

  4. Check Logs: Look at the logs of the Chroma service for any errors or warnings that might provide more context about the "Bad Request" error.

  5. Document Structure: Ensure that the documents you are adding have the correct structure, with pageContent and metadata fields, as expected by the addDocuments method [2].

  6. Environment Variables: If applicable, ensure that any required environment variables are correctly set.

  7. Update Packages: Make sure all your packages are up to date, as there might have been fixes or improvements in newer versions.

By following these steps, you should be able to identify and resolve the issue causing the "Bad Request" error. If the problem persists, consider isolating the issue by testing each part of the process separately to pinpoint where the error occurs.

To continue talking to Dosu, mention @dosu.

@dosubot dosubot bot added the auto:bug Related to a bug, vulnerability, unexpected error with an existing feature label Nov 12, 2024
@wessankey
Copy link
Author

The code runs successfully when the chromadb dependency is downgraded to 1.5.3

@Mageenz
Copy link

Mageenz commented Nov 15, 2024

The code runs successfully when the chromadb dependency is downgraded to 1.5.3

After chromadb to 1.5.3, there were many errors where modules were not found, even the path and fs modules were not referenced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants