Based on the provided code and the Chroma repository context, there are several issues to fix:
Client Initialization:
The ChromaClient initialization is incorrect. According to the docs, for persistent storage you should use PersistentClient. Also, the constructor doesn't take an object with path.
Collection Retrieval:
The getCollection call syntax is incorrect. It shouldn't be an object with COLLECTION_NAME.
Changed ChromaClient to PersistentClient for persistent storage
Fixed the getCollection call syntax to use the string directly instead of an object
Fixed parameter names in the query call to use camelCase instead of snake_case (JavaScript convention)
query_embeddings → queryEmbeddings
n_results → nResults
Alternatively, if you want to use the HTTP client mode instead of direct persistence:
First start the Chroma server:
bash
chroma run --path /path/to/db
Then modify the client initialization to:
javascript
this.client = new chromadb.HttpClient({
host: "localhost",
port: 8000
});
The repository context shows that these are the two main ways to use Chroma - either with a persistent client or via HTTP client-server mode. Choose the one that best fits your needs.
Note: Make sure you have the correct version of the chromadb package installed. The functionality shown here is based on recent versions of Chroma. If you're using an older version, you may need to update.