langchain-ai / langchain

🦜🔗 Build context-aware reasoning applications
https://python.langchain.com
MIT License
86.02k stars 13.34k forks source link

community[patch]: fix public interface for embeddings module #21650

Closed ringohoffman closed 6 days ago

ringohoffman commented 2 weeks ago

Description

The existing public interface for langchain_community.emeddings is broken. In this file, __all__ is statically defined, but is subsequently overwritten with a dynamic expression, which type checkers like pyright do not support. pyright actually gives the following diagnostic on the line I am requesting we remove:

reportUnsupportedDunderAll:

Operation on "__all__" is not supported, so exported symbol list may be incorrect

Currently, I get the following errors when attempting to use publicablly exported classes in langchain_community.emeddings:

import langchain_community.embeddings

langchain_community.embeddings.HuggingFaceEmbeddings(...)  #  error: "HuggingFaceEmbeddings" is not exported from module "langchain_community.embeddings" (reportPrivateImportUsage)

This is solved easily by removing the dynamic expression.

vercel[bot] commented 2 weeks ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment | Name | Status | Preview | Comments | Updated (UTC) | | :--- | :----- | :------ | :------- | :------ | | **langchain** | ⬜️ Ignored ([Inspect](https://vercel.com/langchain/langchain/3M1JUW2JnMa2ngH7mDH2pvD5ptqN)) | [Visit Preview](https://langchain-git-fork-ringohoffman-fix-langchain-ae85f4-langchain.vercel.app) | | May 21, 2024 11:48pm |
ringohoffman commented 1 week ago

@baskaryan @eyurtsev @hwchase17

baskaryan commented 1 week ago

out of curiosity does from langchain_community.embeddings import HuggingFaceEmbeddings also cause issues?

ringohoffman commented 1 week ago

out of curiosity does from langchain_community.embeddings import HuggingFaceEmbeddings also cause issues?

Yes

Screenshot 2024-05-20 at 17 16 09
ringohoffman commented 6 days ago

@eyurtsev I tried fixing the linting errors that arose in libs/community/tests/integration_tests/embeddings/test_titan_takeoff.py. Should we retry?

ringohoffman commented 6 days ago

Okay I ran mypy locally to be sure it passes now:

$ mypy libs/community/tests/integration_tests/embeddings/test_titan_takeoff.py
Success: no issues found in 1 source file
ringohoffman commented 6 days ago

Are we good to merge? Thanks for the reviews @baskaryan and @eyurtsev!