Closed jordanrfrazier closed 3 weeks ago
The issue you're experiencing with the langflow
project, where the backend pulls in unlisted dependencies, particularly for vector store components, seems to stem from the project's approach to dependency management. The project aims to modularize dependencies, especially around vector stores, to allow users the flexibility to choose which components to install. This approach is intended to minimize the installation of unnecessary dependencies for users who do not require support for all vector stores.
To address the problem of unlisted dependencies being required, a solution is to implement conditional imports based on the project's configuration or the presence of specific packages. This would enable the project to dynamically load only the necessary vector store components. Here's a simplified example of how conditional imports can be structured:
vector_store_components = []
try:
from .AstraDB import AstraDBVectorStoreComponent
vector_store_components.append('AstraDBVectorStoreComponent')
except ImportError:
pass
try:
from .Chroma import ChromaComponent
vector_store_components.append('ChromaComponent')
except ImportError:
pass
# Repeat for other vector store components...
__all__ = vector_store_components
In this setup, each vector store component is attempted to be imported within a try
block. If the import is successful, the component is added to the __all__
list. If the import fails (caught by the except ImportError
), the component is skipped. This ensures that only the dependencies actually installed in the user's environment are loaded, mitigating the issue of pulling in unlisted dependencies.
This approach aligns with the project's goal of modularizing dependencies to reduce footprint and avoid unnecessary installations, providing a more flexible and user-friendly setup.
To continue the conversation, mention @dosu.
@ogabrielluiz @anovazzi1 @lucaseduoli can you please provide more information here?
Hey all
Sorry for the delayed response.
This is going to be improved over time but the idea is this:
If you want to have langflow with minimal dependencies and install your own to keep it more lightweight, you do so by installing langflow-base
. The langflow
package installs many more dependencies
We plan on checking which components have their dependencies installed later on so that components that can't run, don't show up on the sidebar.
Thanks Gabriel, that sounds good. I'll close for this knowing that those improvements are planned.
Describe the bug
Overall question: What is the purpose of the dependency separation in
backend/base/langflow
- is it intended as an option for users to import minimal dependencies (w/o frontend) to run in their applications? Can you explain the usage and roadmap a bit further?Bug: The backend pulls in dependencies that are not included (even in extras): https://github.com/langflow-ai/langflow/blob/f9f1d9ba14735ef0adfab779a5ec692ad3aebe0e/src/backend/base/pyproject.toml#L26-L27
For example, if using a vector store component, all vector stores need to be installed to run. https://github.com/langflow-ai/langflow/blob/05cd6e4fd71866b6328ee669b7823def671c1a42/src/backend/base/langflow/components/vectorstores/__init__.py#L13
Browser and Version
To Reproduce Steps to reproduce the behavior: