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

Allow ChromaClient to be initialized outside Chroma Vector Store #211

Closed
shripadk opened this issue Mar 4, 2023 · 3 comments
Closed

Allow ChromaClient to be initialized outside Chroma Vector Store #211

shripadk opened this issue Mar 4, 2023 · 3 comments

Comments

@shripadk
Copy link

shripadk commented Mar 4, 2023

While trying out Chroma integration I stumbled upon the following error:

Error: Please install chromadb as a dependency with, e.g. `npm install -S chromadb`

Even though I had already installed chromadb.

When I dug into the source, I was surprised to see that ChromaClient is being required and initialized directly here: https://github.com/hwchase17/langchainjs/blob/main/langchain/src/vectorstores/chroma.ts#L10-L15

This doesn't work well with cli tools like tsx.

Any reason why this is the case? Why can't we just pass our own initialized ChromaClient to fromDocuments? Also, this would cause an issue when ChromaDB has a different basePath and is hosted on a remote machine as currently there is no way to configure parameters that are passed to ChromaClient.

This is already being done with PineconeStore where we pass in the index initialized outside the PineconeStore itself.

Keeping the API consistent with PineconeStore, my suggestion would be to have this function signature for fromDocuments (and fromTexts too):

static fromDocuments(
  client: ChromaClient,
  docs: Document[],
  embeddings: Embeddings,
  collectionName?: string,
  url?: string
): Promise<Chroma>;

And of course remove the need to initialize ChromaClient directly and let us pass the initialized client instead.

@shripadk
Copy link
Author

shripadk commented Mar 4, 2023

I am currently doing it this way though I prefer using Chroma.fromDocuments instead:

const client = new ChromaClient();

const chroma = new Chroma(
  {
    collectionName,
    numDimensions,
  },
  embeddings,
  client
);

await chroma.addDocuments(docs);

@nfcampos
Copy link
Collaborator

nfcampos commented Mar 5, 2023

hi @shripadk thanks, this was something we missed when converting the library to ESM, thanks for pointing it out, fixing it here #220

@shripadk
Copy link
Author

shripadk commented Mar 5, 2023

@nfcampos Thank you!

@nfcampos nfcampos closed this as completed Mar 6, 2023
jacoblee93 added a commit that referenced this issue Oct 9, 2024
* Adds web entrypoint

* Update prebuilt to pass config

* Add env tests

* Add to CI

* Fix

* Update CI condition

* Fix docs build

* Adds tracing unit test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants