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

[ENH]: LangchainJS Embedding Function #2945

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

tazarov
Copy link
Contributor

@tazarov tazarov commented Oct 13, 2024

Description of changes

Addresses an issue raised as part of #2129

Summarize the changes made by this PR.

  • New functionality
    • New LangchainJS EF that allows Chroma users to take advantage of LC Embeddings and vice versa akin to chromadb/utils/embedding_functions/chroma_langchain_embedding_function.py

Test plan

How are these changes tested?

  • Tests pass locally with yarn test for js

Documentation Changes

Added the new EF to embeddings integrations

Copy link

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

Copy link
Contributor Author

tazarov commented Oct 13, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @tazarov and the rest of your teammates on Graphite Graphite

@@ -47,7 +47,7 @@
"dist"
],
"scripts": {
"test": "jest --runInBand",
"test": "NODE_OPTIONS=--experimental-vm-modules jest --runInBand",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious why this option is needed now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's JS weirdness for you. We have circular import here chroma -> langchain-chroma -> chroma, so when the tests run, unless ESM modules (which is enabled with the --experimenta-vm-modules) are specified, we get an error from langchain-chroma that chromadb is not installed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm I don't think --experimental-vm-modules is related to esm, do you have a link to the docs? and if there's a circular import is that something users will run into?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here's the official Jest info on the use of the flag with ESM modules - https://jestjs.io/docs/ecmascript-modules

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh I see, jest itself switches modes if the flag is enabled
will users run into this or is this limited to our tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My experiments showed that a third party project importing both LC and Chroma will not need to add the flag. However the test was a simple vanilla JS script, let me test with jest itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EF Embedding Functions JavaScript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants