-
Notifications
You must be signed in to change notification settings - Fork 7.2k
refactor(core): implement centralized dynamic lazy import system for components #8932
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
base: main
Are you sure you want to change the base?
Conversation
- Introduced a new module `_importing.py` containing the `import_mod` function. - This function dynamically imports attributes from specified modules, enhancing modularity and flexibility in component initialization. - Comprehensive docstring added for clarity on usage and parameters.
- Added dynamic import functionality to various LangFlow components, allowing for lazy loading of attributes on access. - Introduced mapping in each component's to manage imports efficiently. - Enhanced error handling for import failures, providing clearer messages for missing attributes. - Updated method to reflect available attributes for better introspection and tab-completion support. - Comprehensive docstrings added to improve documentation and usability.
…sibility - Introduced integration tests for dynamic import functionality, ensuring components are discoverable and instantiable post-refactor. - Added unit tests for the `_import_utils` module, validating the `import_mod` function's behavior and error handling. - Implemented tests to confirm all component modules are importable and maintain backward compatibility with existing import patterns. - Enhanced performance tests to measure lazy loading efficiency and memory usage during component access. - Ensured that all components have the required attributes for dynamic loading and that circular imports are prevented.
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughA comprehensive refactor introduces a centralized, dynamic lazy import system for all LangFlow components. Each component category now uses module-level Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant MainModule as langflow.components
participant Category as CategoryModule (e.g., openai)
participant ImportUtil as import_mod
participant Component as ComponentClass
User->>MainModule: import Category
MainModule->>Category: (standard import)
User->>Category: getattr(Category, "ComponentName")
Category->>ImportUtil: import_mod("ComponentName", ...)
ImportUtil->>Component: dynamic import
ImportUtil-->>Category: ComponentClass
Category-->>User: return ComponentClass
Possibly related PRs
Suggested labels
Suggested reviewers
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🔭 Outside diff range comments (1)
src/backend/base/langflow/components/langchain_utilities/__init__.py (1)
64-91
: Fix alphabetical ordering in all list.The
__all__
list is not properly alphabetical. According to the coding guidelines, components should be listed alphabetically when adding new components.Apply this diff to fix the alphabetical ordering:
__all__ = [ "CSVAgentComponent", "CharacterTextSplitterComponent", "ConversationChainComponent", "FakeEmbeddingsComponent", "HtmlLinkExtractorComponent", "JsonAgentComponent", + "LangChainHubPromptComponent", "LLMCheckerChainComponent", "LLMMathChainComponent", - "LangChainHubPromptComponent", "LanguageRecursiveTextSplitterComponent", "NaturalLanguageTextSplitterComponent", "OpenAIToolsAgentComponent", "OpenAPIAgentComponent", "RecursiveCharacterTextSplitterComponent", "RetrievalQAComponent", "RunnableExecComponent", "SQLAgentComponent", "SQLDatabaseComponent", "SQLGeneratorComponent", "SelfQueryRetrieverComponent", "SemanticTextSplitterComponent", "SpiderTool", "ToolCallingAgentComponent", "VectorStoreInfoComponent", "VectorStoreRouterAgentComponent", "XMLAgentComponent", ]
🧹 Nitpick comments (8)
src/backend/base/langflow/components/groq/__init__.py (1)
1-35
: LGTM: Solid lazy import implementationThe implementation is correct and follows the established pattern consistently. The lazy loading mechanism, error handling, and caching are all properly implemented.
Consider adding a module docstring for consistency with other component modules:
+"""Groq components for LangFlow.""" + from __future__ import annotationssrc/backend/base/langflow/components/novita/__init__.py (1)
7-8
: Standardize import paths in TYPE_CHECKING blocks across component modules.The implementation is correct, but there's inconsistency in import paths across different component modules in this PR. Some use absolute paths (like this file), while others use relative paths (e.g.,
from .perplexity import PerplexityComponent
). Consider standardizing to relative imports for consistency.- from langflow.components.novita.novita import NovitaModelComponent + from .novita import NovitaModelComponentsrc/backend/base/langflow/components/openrouter/__init__.py (1)
7-8
: Standardize to relative imports in TYPE_CHECKING block.The implementation is correct, but consider using relative imports for consistency with other component modules in this PR.
- from langflow.components.openrouter.openrouter import OpenRouterComponent + from .openrouter import OpenRouterComponentsrc/backend/base/langflow/components/embeddings/__init__.py (1)
11-14
: Verify mapping consistency with alphabetical ordering in all.The
_dynamic_imports
dictionary should maintain the same alphabetical ordering as the__all__
list to ensure consistency. Currently,EmbeddingSimilarityComponent
appears beforeTextEmbedderComponent
in__all__
but the reverse order in_dynamic_imports
._dynamic_imports = { - "EmbeddingSimilarityComponent": "similarity", - "TextEmbedderComponent": "text_embedder", + "EmbeddingSimilarityComponent": "similarity", + "TextEmbedderComponent": "text_embedder", }src/backend/base/langflow/components/__init__.py (1)
258-259
: Consider using the module name from_dynamic_imports
for consistency.The current implementation uses
"__module__"
as the module_name parameter, which differs from other component init.py files that use the actual module name from_dynamic_imports
. While both approaches work, maintaining consistency across the codebase would improve maintainability.- result = import_mod(attr_name, "__module__", __spec__.parent) + result = import_mod(attr_name, _dynamic_imports[attr_name], __spec__.parent)However, since this is importing module names (not component classes), the current approach may be intentional. Please verify the intended behavior.
src/backend/tests/unit/test_import_utils.py (1)
33-33
: Fix typo in test method name.The method name contains a typo: "modibute" should be "attribute".
- def test_import_modibute_from_module(self): + def test_import_attribute_from_module(self):src/backend/tests/integration/test_dynamic_import_integration.py (1)
83-117
: Consider making time-based assertions more robust.The hardcoded time thresholds (0.1s and 2.0s) could cause flaky tests in CI environments or on slower machines. Consider using environment-specific thresholds or comparing relative performance improvements.
+ # Use environment-specific thresholds + import_threshold = float(os.environ.get("LANGFLOW_TEST_IMPORT_THRESHOLD", "0.1")) + access_threshold = float(os.environ.get("LANGFLOW_TEST_ACCESS_THRESHOLD", "2.0")) + # Import time should be very fast (just loading the __init__.py) - assert import_time < 0.1 # Should be well under 100ms + assert import_time < import_threshold, f"Import took {import_time}s, expected < {import_threshold}s" # Test that we can access a component (it may already be cached from previous tests) # This is expected behavior in a test suite where components get cached # Now access a component - this should trigger loading start_time = time.time() chroma_component = vectorstores.ChromaVectorStoreComponent access_time = time.time() - start_time assert chroma_component is not None # Access time should still be reasonable - assert access_time < 2.0 # Should be under 2 seconds + assert access_time < access_threshold, f"Access took {access_time}s, expected < {access_threshold}s"Also add the import at the top:
import sys import time +import os
src/backend/tests/unit/components/test_all_modules_importable.py (1)
285-304
: Consider making the import time assertion more robust.The hardcoded 0.5s threshold could cause flaky tests in CI environments or on slower machines.
def test_large_modules_import_efficiently(self): """Test that large modules with many components import efficiently.""" import time + import os # Test large modules large_modules = ["vectorstores", "processing", "langchain_utilities"] + + # Use environment-specific threshold + import_threshold = float(os.environ.get("LANGFLOW_TEST_MODULE_IMPORT_THRESHOLD", "0.5")) for module_name in large_modules: if module_name in components.__all__: start_time = time.time() module = getattr(components, module_name) import_time = time.time() - start_time # Initial import should be fast (just loading __init__.py) - assert import_time < 0.5, f"Module {module_name} took too long to import: {import_time}s" + assert import_time < import_threshold, f"Module {module_name} took {import_time}s to import, expected < {import_threshold}s" # Should have components available assert hasattr(module, "__all__") assert len(module.__all__) > 0
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (53)
src/backend/base/langflow/components/__init__.py
(1 hunks)src/backend/base/langflow/components/_importing.py
(1 hunks)src/backend/base/langflow/components/aiml/__init__.py
(1 hunks)src/backend/base/langflow/components/amazon/__init__.py
(1 hunks)src/backend/base/langflow/components/anthropic/__init__.py
(1 hunks)src/backend/base/langflow/components/assemblyai/__init__.py
(2 hunks)src/backend/base/langflow/components/azure/__init__.py
(1 hunks)src/backend/base/langflow/components/baidu/__init__.py
(1 hunks)src/backend/base/langflow/components/cleanlab/__init__.py
(1 hunks)src/backend/base/langflow/components/cloudflare/__init__.py
(1 hunks)src/backend/base/langflow/components/cohere/__init__.py
(1 hunks)src/backend/base/langflow/components/composio/__init__.py
(2 hunks)src/backend/base/langflow/components/crewai/__init__.py
(2 hunks)src/backend/base/langflow/components/custom_component/__init__.py
(1 hunks)src/backend/base/langflow/components/datastax/__init__.py
(2 hunks)src/backend/base/langflow/components/deepseek/__init__.py
(1 hunks)src/backend/base/langflow/components/docling/__init__.py
(1 hunks)src/backend/base/langflow/components/embeddings/__init__.py
(1 hunks)src/backend/base/langflow/components/firecrawl/__init__.py
(1 hunks)src/backend/base/langflow/components/groq/__init__.py
(1 hunks)src/backend/base/langflow/components/helpers/__init__.py
(2 hunks)src/backend/base/langflow/components/huggingface/__init__.py
(1 hunks)src/backend/base/langflow/components/ibm/__init__.py
(1 hunks)src/backend/base/langflow/components/input_output/__init__.py
(1 hunks)src/backend/base/langflow/components/langchain_utilities/__init__.py
(2 hunks)src/backend/base/langflow/components/lmstudio/__init__.py
(1 hunks)src/backend/base/langflow/components/logic/__init__.py
(2 hunks)src/backend/base/langflow/components/maritalk/__init__.py
(1 hunks)src/backend/base/langflow/components/mistral/__init__.py
(1 hunks)src/backend/base/langflow/components/models/__init__.py
(1 hunks)src/backend/base/langflow/components/notdiamond/__init__.py
(1 hunks)src/backend/base/langflow/components/novita/__init__.py
(1 hunks)src/backend/base/langflow/components/nvidia/__init__.py
(2 hunks)src/backend/base/langflow/components/ollama/__init__.py
(1 hunks)src/backend/base/langflow/components/openai/__init__.py
(1 hunks)src/backend/base/langflow/components/openrouter/__init__.py
(1 hunks)src/backend/base/langflow/components/perplexity/__init__.py
(1 hunks)src/backend/base/langflow/components/processing/__init__.py
(2 hunks)src/backend/base/langflow/components/prototypes/__init__.py
(1 hunks)src/backend/base/langflow/components/sambanova/__init__.py
(1 hunks)src/backend/base/langflow/components/scrapegraph/__init__.py
(1 hunks)src/backend/base/langflow/components/searchapi/__init__.py
(1 hunks)src/backend/base/langflow/components/tools/__init__.py
(1 hunks)src/backend/base/langflow/components/twelvelabs/__init__.py
(2 hunks)src/backend/base/langflow/components/vectara/__init__.py
(1 hunks)src/backend/base/langflow/components/vectorstores/__init__.py
(2 hunks)src/backend/base/langflow/components/vertexai/__init__.py
(1 hunks)src/backend/base/langflow/components/xai/__init__.py
(1 hunks)src/backend/base/langflow/components/youtube/__init__.py
(2 hunks)src/backend/tests/integration/test_dynamic_import_integration.py
(1 hunks)src/backend/tests/unit/components/test_all_modules_importable.py
(1 hunks)src/backend/tests/unit/components/test_dynamic_imports.py
(1 hunks)src/backend/tests/unit/test_import_utils.py
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
`src/backend/base/langflow/components/**/*.py`: Add new backend components to th...
src/backend/base/langflow/components/**/*.py
: Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Implement async component methods using async def and await for asynchronous operations
Use asyncio.create_task for background work in async components and ensure proper cleanup on cancellation
Use asyncio.Queue for non-blocking queue operations in async components and handle timeouts appropriately
📄 Source: CodeRabbit Inference Engine (.cursor/rules/backend_development.mdc)
List of files the instruction was applied to:
src/backend/base/langflow/components/vectara/__init__.py
src/backend/base/langflow/components/docling/__init__.py
src/backend/base/langflow/components/sambanova/__init__.py
src/backend/base/langflow/components/langchain_utilities/__init__.py
src/backend/base/langflow/components/_importing.py
src/backend/base/langflow/components/input_output/__init__.py
src/backend/base/langflow/components/lmstudio/__init__.py
src/backend/base/langflow/components/assemblyai/__init__.py
src/backend/base/langflow/components/cloudflare/__init__.py
src/backend/base/langflow/components/aiml/__init__.py
src/backend/base/langflow/components/models/__init__.py
src/backend/base/langflow/components/helpers/__init__.py
src/backend/base/langflow/components/searchapi/__init__.py
src/backend/base/langflow/components/scrapegraph/__init__.py
src/backend/base/langflow/components/prototypes/__init__.py
src/backend/base/langflow/components/__init__.py
src/backend/base/langflow/components/crewai/__init__.py
src/backend/base/langflow/components/logic/__init__.py
src/backend/base/langflow/components/mistral/__init__.py
src/backend/base/langflow/components/anthropic/__init__.py
src/backend/base/langflow/components/twelvelabs/__init__.py
src/backend/base/langflow/components/firecrawl/__init__.py
src/backend/base/langflow/components/xai/__init__.py
src/backend/base/langflow/components/vertexai/__init__.py
src/backend/base/langflow/components/cleanlab/__init__.py
src/backend/base/langflow/components/amazon/__init__.py
src/backend/base/langflow/components/ibm/__init__.py
src/backend/base/langflow/components/maritalk/__init__.py
src/backend/base/langflow/components/notdiamond/__init__.py
src/backend/base/langflow/components/openrouter/__init__.py
src/backend/base/langflow/components/custom_component/__init__.py
src/backend/base/langflow/components/composio/__init__.py
src/backend/base/langflow/components/ollama/__init__.py
src/backend/base/langflow/components/huggingface/__init__.py
src/backend/base/langflow/components/embeddings/__init__.py
src/backend/base/langflow/components/processing/__init__.py
src/backend/base/langflow/components/azure/__init__.py
src/backend/base/langflow/components/tools/__init__.py
src/backend/base/langflow/components/baidu/__init__.py
src/backend/base/langflow/components/openai/__init__.py
src/backend/base/langflow/components/deepseek/__init__.py
src/backend/base/langflow/components/groq/__init__.py
src/backend/base/langflow/components/datastax/__init__.py
src/backend/base/langflow/components/youtube/__init__.py
src/backend/base/langflow/components/novita/__init__.py
src/backend/base/langflow/components/perplexity/__init__.py
src/backend/base/langflow/components/nvidia/__init__.py
src/backend/base/langflow/components/vectorstores/__init__.py
src/backend/base/langflow/components/cohere/__init__.py
`src/backend/base/langflow/components/**/__init__.py`: Update __init__.py with alphabetical imports when adding new components
src/backend/base/langflow/components/**/__init__.py
: Update init.py with alphabetical imports when adding new components
📄 Source: CodeRabbit Inference Engine (.cursor/rules/backend_development.mdc)
List of files the instruction was applied to:
src/backend/base/langflow/components/vectara/__init__.py
src/backend/base/langflow/components/docling/__init__.py
src/backend/base/langflow/components/sambanova/__init__.py
src/backend/base/langflow/components/langchain_utilities/__init__.py
src/backend/base/langflow/components/input_output/__init__.py
src/backend/base/langflow/components/lmstudio/__init__.py
src/backend/base/langflow/components/assemblyai/__init__.py
src/backend/base/langflow/components/cloudflare/__init__.py
src/backend/base/langflow/components/aiml/__init__.py
src/backend/base/langflow/components/models/__init__.py
src/backend/base/langflow/components/helpers/__init__.py
src/backend/base/langflow/components/searchapi/__init__.py
src/backend/base/langflow/components/scrapegraph/__init__.py
src/backend/base/langflow/components/prototypes/__init__.py
src/backend/base/langflow/components/__init__.py
src/backend/base/langflow/components/crewai/__init__.py
src/backend/base/langflow/components/logic/__init__.py
src/backend/base/langflow/components/mistral/__init__.py
src/backend/base/langflow/components/anthropic/__init__.py
src/backend/base/langflow/components/twelvelabs/__init__.py
src/backend/base/langflow/components/firecrawl/__init__.py
src/backend/base/langflow/components/xai/__init__.py
src/backend/base/langflow/components/vertexai/__init__.py
src/backend/base/langflow/components/cleanlab/__init__.py
src/backend/base/langflow/components/amazon/__init__.py
src/backend/base/langflow/components/ibm/__init__.py
src/backend/base/langflow/components/maritalk/__init__.py
src/backend/base/langflow/components/notdiamond/__init__.py
src/backend/base/langflow/components/openrouter/__init__.py
src/backend/base/langflow/components/custom_component/__init__.py
src/backend/base/langflow/components/composio/__init__.py
src/backend/base/langflow/components/ollama/__init__.py
src/backend/base/langflow/components/huggingface/__init__.py
src/backend/base/langflow/components/embeddings/__init__.py
src/backend/base/langflow/components/processing/__init__.py
src/backend/base/langflow/components/azure/__init__.py
src/backend/base/langflow/components/tools/__init__.py
src/backend/base/langflow/components/baidu/__init__.py
src/backend/base/langflow/components/openai/__init__.py
src/backend/base/langflow/components/deepseek/__init__.py
src/backend/base/langflow/components/groq/__init__.py
src/backend/base/langflow/components/datastax/__init__.py
src/backend/base/langflow/components/youtube/__init__.py
src/backend/base/langflow/components/novita/__init__.py
src/backend/base/langflow/components/perplexity/__init__.py
src/backend/base/langflow/components/nvidia/__init__.py
src/backend/base/langflow/components/vectorstores/__init__.py
src/backend/base/langflow/components/cohere/__init__.py
`src/backend/**/*.py`: Run make format_backend to format Python code early and often Run make lint to check for linting issues in backend Python code
src/backend/**/*.py
: Run make format_backend to format Python code early and often
Run make lint to check for linting issues in backend Python code
📄 Source: CodeRabbit Inference Engine (.cursor/rules/backend_development.mdc)
List of files the instruction was applied to:
src/backend/base/langflow/components/vectara/__init__.py
src/backend/base/langflow/components/docling/__init__.py
src/backend/base/langflow/components/sambanova/__init__.py
src/backend/base/langflow/components/langchain_utilities/__init__.py
src/backend/base/langflow/components/_importing.py
src/backend/base/langflow/components/input_output/__init__.py
src/backend/base/langflow/components/lmstudio/__init__.py
src/backend/base/langflow/components/assemblyai/__init__.py
src/backend/base/langflow/components/cloudflare/__init__.py
src/backend/base/langflow/components/aiml/__init__.py
src/backend/base/langflow/components/models/__init__.py
src/backend/base/langflow/components/helpers/__init__.py
src/backend/base/langflow/components/searchapi/__init__.py
src/backend/base/langflow/components/scrapegraph/__init__.py
src/backend/base/langflow/components/prototypes/__init__.py
src/backend/base/langflow/components/__init__.py
src/backend/base/langflow/components/crewai/__init__.py
src/backend/base/langflow/components/logic/__init__.py
src/backend/base/langflow/components/mistral/__init__.py
src/backend/base/langflow/components/anthropic/__init__.py
src/backend/base/langflow/components/twelvelabs/__init__.py
src/backend/base/langflow/components/firecrawl/__init__.py
src/backend/base/langflow/components/xai/__init__.py
src/backend/base/langflow/components/vertexai/__init__.py
src/backend/base/langflow/components/cleanlab/__init__.py
src/backend/base/langflow/components/amazon/__init__.py
src/backend/tests/unit/test_import_utils.py
src/backend/base/langflow/components/ibm/__init__.py
src/backend/base/langflow/components/maritalk/__init__.py
src/backend/base/langflow/components/notdiamond/__init__.py
src/backend/base/langflow/components/openrouter/__init__.py
src/backend/base/langflow/components/custom_component/__init__.py
src/backend/base/langflow/components/composio/__init__.py
src/backend/base/langflow/components/ollama/__init__.py
src/backend/base/langflow/components/huggingface/__init__.py
src/backend/base/langflow/components/embeddings/__init__.py
src/backend/base/langflow/components/processing/__init__.py
src/backend/base/langflow/components/azure/__init__.py
src/backend/base/langflow/components/tools/__init__.py
src/backend/base/langflow/components/baidu/__init__.py
src/backend/tests/integration/test_dynamic_import_integration.py
src/backend/base/langflow/components/openai/__init__.py
src/backend/base/langflow/components/deepseek/__init__.py
src/backend/base/langflow/components/groq/__init__.py
src/backend/base/langflow/components/datastax/__init__.py
src/backend/base/langflow/components/youtube/__init__.py
src/backend/base/langflow/components/novita/__init__.py
src/backend/base/langflow/components/perplexity/__init__.py
src/backend/base/langflow/components/nvidia/__init__.py
src/backend/base/langflow/components/vectorstores/__init__.py
src/backend/base/langflow/components/cohere/__init__.py
src/backend/tests/unit/components/test_all_modules_importable.py
src/backend/tests/unit/components/test_dynamic_imports.py
`src/backend/**/components/**/*.py`: In your Python component class, set the `icon` attribute to a string matching the frontend icon mapping exactly (case-sensitive).
src/backend/**/components/**/*.py
: In your Python component class, set theicon
attribute to a string matching the frontend icon mapping exactly (case-sensitive).
📄 Source: CodeRabbit Inference Engine (.cursor/rules/icons.mdc)
List of files the instruction was applied to:
src/backend/base/langflow/components/vectara/__init__.py
src/backend/base/langflow/components/docling/__init__.py
src/backend/base/langflow/components/sambanova/__init__.py
src/backend/base/langflow/components/langchain_utilities/__init__.py
src/backend/base/langflow/components/_importing.py
src/backend/base/langflow/components/input_output/__init__.py
src/backend/base/langflow/components/lmstudio/__init__.py
src/backend/base/langflow/components/assemblyai/__init__.py
src/backend/base/langflow/components/cloudflare/__init__.py
src/backend/base/langflow/components/aiml/__init__.py
src/backend/base/langflow/components/models/__init__.py
src/backend/base/langflow/components/helpers/__init__.py
src/backend/base/langflow/components/searchapi/__init__.py
src/backend/base/langflow/components/scrapegraph/__init__.py
src/backend/base/langflow/components/prototypes/__init__.py
src/backend/base/langflow/components/__init__.py
src/backend/base/langflow/components/crewai/__init__.py
src/backend/base/langflow/components/logic/__init__.py
src/backend/base/langflow/components/mistral/__init__.py
src/backend/base/langflow/components/anthropic/__init__.py
src/backend/base/langflow/components/twelvelabs/__init__.py
src/backend/base/langflow/components/firecrawl/__init__.py
src/backend/base/langflow/components/xai/__init__.py
src/backend/base/langflow/components/vertexai/__init__.py
src/backend/base/langflow/components/cleanlab/__init__.py
src/backend/base/langflow/components/amazon/__init__.py
src/backend/base/langflow/components/ibm/__init__.py
src/backend/base/langflow/components/maritalk/__init__.py
src/backend/base/langflow/components/notdiamond/__init__.py
src/backend/base/langflow/components/openrouter/__init__.py
src/backend/base/langflow/components/custom_component/__init__.py
src/backend/base/langflow/components/composio/__init__.py
src/backend/base/langflow/components/ollama/__init__.py
src/backend/base/langflow/components/huggingface/__init__.py
src/backend/base/langflow/components/embeddings/__init__.py
src/backend/base/langflow/components/processing/__init__.py
src/backend/base/langflow/components/azure/__init__.py
src/backend/base/langflow/components/tools/__init__.py
src/backend/base/langflow/components/baidu/__init__.py
src/backend/base/langflow/components/openai/__init__.py
src/backend/base/langflow/components/deepseek/__init__.py
src/backend/base/langflow/components/groq/__init__.py
src/backend/base/langflow/components/datastax/__init__.py
src/backend/base/langflow/components/youtube/__init__.py
src/backend/base/langflow/components/novita/__init__.py
src/backend/base/langflow/components/perplexity/__init__.py
src/backend/base/langflow/components/nvidia/__init__.py
src/backend/base/langflow/components/vectorstores/__init__.py
src/backend/base/langflow/components/cohere/__init__.py
src/backend/tests/unit/components/test_all_modules_importable.py
src/backend/tests/unit/components/test_dynamic_imports.py
`src/backend/tests/unit/**/*.py`: Use in-memory SQLite for database tests Test c...
src/backend/tests/unit/**/*.py
: Use in-memory SQLite for database tests
Test component integration within flows using create_flow, build_flow, and get_build_events utilities
Use pytest.mark.api_key_required and pytest.mark.no_blockbuster for tests involving external APIs
📄 Source: CodeRabbit Inference Engine (.cursor/rules/backend_development.mdc)
List of files the instruction was applied to:
src/backend/tests/unit/test_import_utils.py
src/backend/tests/unit/components/test_all_modules_importable.py
src/backend/tests/unit/components/test_dynamic_imports.py
`src/backend/tests/**/*.py`: Unit tests for backend code should be located in 's...
src/backend/tests/**/*.py
: Unit tests for backend code should be located in 'src/backend/tests/' and organized by component subdirectory for component tests.
Test files should use the same filename as the component with an appropriate test prefix or suffix (e.g., 'my_component.py' → 'test_my_component.py').
Use the 'client' fixture (an async httpx.AsyncClient) for API tests, as defined in 'src/backend/tests/conftest.py'.
Skip client creation in tests by marking them with '@pytest.mark.noclient' when the 'client' fixture is not needed.
Inherit from the appropriate ComponentTestBase class ('ComponentTestBase', 'ComponentTestBaseWithClient', or 'ComponentTestBaseWithoutClient') and provide the required fixtures: 'component_class', 'default_kwargs', and 'file_names_mapping' when adding a new component test.
📄 Source: CodeRabbit Inference Engine (.cursor/rules/testing.mdc)
List of files the instruction was applied to:
src/backend/tests/unit/test_import_utils.py
src/backend/tests/integration/test_dynamic_import_integration.py
src/backend/tests/unit/components/test_all_modules_importable.py
src/backend/tests/unit/components/test_dynamic_imports.py
`{src/backend/tests/**/*.py,src/frontend/**/*.test.{ts,tsx,js,jsx},src/frontend/...
{src/backend/tests/**/*.py,src/frontend/**/*.test.{ts,tsx,js,jsx},src/frontend/**/*.spec.{ts,tsx,js,jsx},tests/**/*.py}
: Each test should have a clear docstring explaining its purpose.
Complex test setups should be commented, and mock usage should be documented within the test code.
Expected behaviors should be explicitly stated in test docstrings or comments.
Create comprehensive unit tests for all new components.
Test both sync and async code paths in components.
Mock external dependencies appropriately in tests.
Test error handling and edge cases in components.
Validate input/output behavior in tests.
Test component initialization and configuration.
📄 Source: CodeRabbit Inference Engine (.cursor/rules/testing.mdc)
List of files the instruction was applied to:
src/backend/tests/unit/test_import_utils.py
src/backend/tests/integration/test_dynamic_import_integration.py
src/backend/tests/unit/components/test_all_modules_importable.py
src/backend/tests/unit/components/test_dynamic_imports.py
`{src/backend/tests/**/*.py,tests/**/*.py}`: Use '@pytest.mark.asyncio' for asyn...
{src/backend/tests/**/*.py,tests/**/*.py}
: Use '@pytest.mark.asyncio' for async test functions.
Test queue operations in async tests using 'asyncio.Queue' and non-blocking put/get methods.
Use the 'no_blockbuster' pytest marker to skip the blockbuster plugin in tests.
Be aware of ContextVar propagation in async tests and test both direct event loop execution and 'asyncio.to_thread' scenarios.
Each test should ensure proper resource cleanup, especially in async fixtures using 'try/finally' and cleanup methods.
Test that operations respect timeout constraints and assert elapsed time is within tolerance.
Test Langflow's 'Message' objects and chat functionality by asserting correct properties and structure.
Use predefined JSON flows and utility functions for flow testing (e.g., 'create_flow', 'build_flow', 'get_build_events', 'consume_and_assert_stream').
Test components that need external APIs with proper pytest markers such as '@pytest.mark.api_key_required' and '@pytest.mark.no_blockbuster'.
Use 'MockLanguageModel' for testing language model components without external API calls.
Use 'anyio' and 'aiofiles' for async file operations in tests.
Test Langflow's REST API endpoints using the async 'client' fixture and assert correct status codes and response structure.
Test component configuration updates by asserting changes in build config dictionaries.
Test real-time event streaming endpoints by consuming NDJSON event streams and validating event structure.
Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
Test webhook endpoints by posting payloads and asserting correct processing and status codes.
Test error handling by monkeypatching internal functions to raise exceptions and asserting correct error responses.
📄 Source: CodeRabbit Inference Engine (.cursor/rules/testing.mdc)
List of files the instruction was applied to:
src/backend/tests/unit/test_import_utils.py
src/backend/tests/integration/test_dynamic_import_integration.py
src/backend/tests/unit/components/test_all_modules_importable.py
src/backend/tests/unit/components/test_dynamic_imports.py
`src/backend/tests/unit/components/**/*.py`: Mirror the component directory stru...
src/backend/tests/unit/components/**/*.py
: Mirror the component directory structure in unit tests under src/backend/tests/unit/components/
Use ComponentTestBaseWithClient or ComponentTestBaseWithoutClient as base classes for component unit tests
Provide file_names_mapping in tests for backward compatibility version testing
Create comprehensive unit tests for all new components
Use the client fixture from conftest.py for FastAPI API endpoint tests
Test authenticated FastAPI endpoints using logged_in_headers in tests
📄 Source: CodeRabbit Inference Engine (.cursor/rules/backend_development.mdc)
List of files the instruction was applied to:
src/backend/tests/unit/components/test_all_modules_importable.py
src/backend/tests/unit/components/test_dynamic_imports.py
🧠 Learnings (54)
📓 Common learnings
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: ogabrielluiz
PR: langflow-ai/langflow#0
File: :0-0
Timestamp: 2025-06-26T19:43:18.260Z
Learning: In langflow custom components, the `module_name` parameter is now propagated through template building functions to add module metadata and code hashes to frontend nodes for better component tracking and debugging.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
src/backend/base/langflow/components/vectara/__init__.py (5)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/docs_development.mdc:0-0
Timestamp: 2025-06-23T12:46:29.953Z
Learning: All terminology such as 'Langflow', 'Component', 'Flow', 'API', and 'JSON' must be capitalized or uppercased as specified in the terminology section.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/icons.mdc:0-0
Timestamp: 2025-06-23T12:46:52.420Z
Learning: When implementing a new component icon in Langflow, ensure the icon name is clear, recognizable, and used consistently across both backend (Python 'icon' attribute) and frontend (React/TypeScript mapping).
src/backend/base/langflow/components/docling/__init__.py (6)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
Learnt from: ogabrielluiz
PR: langflow-ai/langflow#0
File: :0-0
Timestamp: 2025-06-26T19:43:18.260Z
Learning: In langflow custom components, the `module_name` parameter is now propagated through template building functions to add module metadata and code hashes to frontend nodes for better component tracking and debugging.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Use asyncio.Queue for non-blocking queue operations in async components and handle timeouts appropriately
src/backend/base/langflow/components/sambanova/__init__.py (4)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: ogabrielluiz
PR: langflow-ai/langflow#0
File: :0-0
Timestamp: 2025-06-26T19:43:18.260Z
Learning: In langflow custom components, the `module_name` parameter is now propagated through template building functions to add module metadata and code hashes to frontend nodes for better component tracking and debugging.
src/backend/base/langflow/components/langchain_utilities/__init__.py (5)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
Learnt from: ogabrielluiz
PR: langflow-ai/langflow#0
File: :0-0
Timestamp: 2025-06-26T19:43:18.260Z
Learning: In langflow custom components, the `module_name` parameter is now propagated through template building functions to add module metadata and code hashes to frontend nodes for better component tracking and debugging.
src/backend/base/langflow/components/_importing.py (2)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: ogabrielluiz
PR: langflow-ai/langflow#0
File: :0-0
Timestamp: 2025-06-26T19:43:18.260Z
Learning: In langflow custom components, the `module_name` parameter is now propagated through template building functions to add module metadata and code hashes to frontend nodes for better component tracking and debugging.
src/backend/base/langflow/components/input_output/__init__.py (3)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
src/backend/base/langflow/components/lmstudio/__init__.py (4)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: ogabrielluiz
PR: langflow-ai/langflow#0
File: :0-0
Timestamp: 2025-06-26T19:43:18.260Z
Learning: In langflow custom components, the `module_name` parameter is now propagated through template building functions to add module metadata and code hashes to frontend nodes for better component tracking and debugging.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
src/backend/base/langflow/components/assemblyai/__init__.py (3)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
src/backend/base/langflow/components/cloudflare/__init__.py (3)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
src/backend/base/langflow/components/aiml/__init__.py (3)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
src/backend/base/langflow/components/models/__init__.py (7)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/services/database/models/**/*.py : Place database models in src/backend/base/langflow/services/database/models/ and its subdirectories
Learnt from: ogabrielluiz
PR: langflow-ai/langflow#0
File: :0-0
Timestamp: 2025-06-26T19:43:18.260Z
Learning: In langflow custom components, the `module_name` parameter is now propagated through template building functions to add module metadata and code hashes to frontend nodes for better component tracking and debugging.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Use 'MockLanguageModel' for testing language model components without external API calls.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
src/backend/base/langflow/components/helpers/__init__.py (5)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
Learnt from: ogabrielluiz
PR: langflow-ai/langflow#0
File: :0-0
Timestamp: 2025-06-26T19:43:18.260Z
Learning: In langflow custom components, the `module_name` parameter is now propagated through template building functions to add module metadata and code hashes to frontend nodes for better component tracking and debugging.
src/backend/base/langflow/components/searchapi/__init__.py (3)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
src/backend/base/langflow/components/scrapegraph/__init__.py (1)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
src/backend/base/langflow/components/prototypes/__init__.py (3)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
src/backend/base/langflow/components/__init__.py (10)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: ogabrielluiz
PR: langflow-ai/langflow#0
File: :0-0
Timestamp: 2025-06-26T19:43:18.260Z
Learning: In langflow custom components, the `module_name` parameter is now propagated through template building functions to add module metadata and code hashes to frontend nodes for better component tracking and debugging.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/services/database/models/**/*.py : Place database models in src/backend/base/langflow/services/database/models/ and its subdirectories
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Use asyncio.Queue for non-blocking queue operations in async components and handle timeouts appropriately
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/tests/unit/components/**/*.py : Create comprehensive unit tests for all new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/tests/unit/components/**/*.py : Mirror the component directory structure in unit tests under src/backend/tests/unit/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/icons.mdc:0-0
Timestamp: 2025-06-23T12:46:52.420Z
Learning: When implementing a new component icon in Langflow, ensure the icon name is clear, recognizable, and used consistently across both backend (Python 'icon' attribute) and frontend (React/TypeScript mapping).
src/backend/base/langflow/components/crewai/__init__.py (6)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Use asyncio.create_task for background work in async components and ensure proper cleanup on cancellation
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Use asyncio.Queue for non-blocking queue operations in async components and handle timeouts appropriately
src/backend/base/langflow/components/logic/__init__.py (4)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
src/backend/base/langflow/components/mistral/__init__.py (3)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
src/backend/base/langflow/components/anthropic/__init__.py (3)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
src/backend/base/langflow/components/twelvelabs/__init__.py (4)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
src/backend/base/langflow/components/firecrawl/__init__.py (3)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
src/backend/base/langflow/components/xai/__init__.py (3)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
src/backend/base/langflow/components/vertexai/__init__.py (3)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
src/backend/base/langflow/components/cleanlab/__init__.py (1)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
src/backend/base/langflow/components/amazon/__init__.py (4)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
src/backend/tests/unit/test_import_utils.py (14)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/tests/unit/components/**/*.py : Create comprehensive unit tests for all new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,src/frontend/**/*.test.{ts,tsx,js,jsx},src/frontend/**/*.spec.{ts,tsx,js,jsx},tests/**/*.py} : Create comprehensive unit tests for all new components.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test error handling by monkeypatching internal functions to raise exceptions and asserting correct error responses.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,src/frontend/**/*.test.{ts,tsx,js,jsx},src/frontend/**/*.spec.{ts,tsx,js,jsx},tests/**/*.py} : Mock external dependencies appropriately in tests.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,src/frontend/**/*.test.{ts,tsx,js,jsx},src/frontend/**/*.spec.{ts,tsx,js,jsx},tests/**/*.py} : Complex test setups should be commented, and mock usage should be documented within the test code.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/tests/unit/components/**/*.py : Mirror the component directory structure in unit tests under src/backend/tests/unit/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to src/backend/tests/**/*.py : Unit tests for backend code should be located in 'src/backend/tests/' and organized by component subdirectory for component tests.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,src/frontend/**/*.test.{ts,tsx,js,jsx},src/frontend/**/*.spec.{ts,tsx,js,jsx},tests/**/*.py} : Validate input/output behavior in tests.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to src/backend/tests/**/*.py : Inherit from the appropriate ComponentTestBase class ('ComponentTestBase', 'ComponentTestBaseWithClient', or 'ComponentTestBaseWithoutClient') and provide the required fixtures: 'component_class', 'default_kwargs', and 'file_names_mapping' when adding a new component test.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/tests/unit/**/*.py : Use pytest.mark.api_key_required and pytest.mark.no_blockbuster for tests involving external APIs
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/tests/unit/**/*.py : Test component integration within flows using create_flow, build_flow, and get_build_events utilities
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test components that need external APIs with proper pytest markers such as '@pytest.mark.api_key_required' and '@pytest.mark.no_blockbuster'.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,src/frontend/**/*.test.{ts,tsx,js,jsx},src/frontend/**/*.spec.{ts,tsx,js,jsx},tests/**/*.py} : Test error handling and edge cases in components.
src/backend/base/langflow/components/ibm/__init__.py (3)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
src/backend/base/langflow/components/maritalk/__init__.py (5)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Use 'MockLanguageModel' for testing language model components without external API calls.
src/backend/base/langflow/components/notdiamond/__init__.py (3)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: ogabrielluiz
PR: langflow-ai/langflow#0
File: :0-0
Timestamp: 2025-06-26T19:43:18.260Z
Learning: In langflow custom components, the `module_name` parameter is now propagated through template building functions to add module metadata and code hashes to frontend nodes for better component tracking and debugging.
src/backend/base/langflow/components/openrouter/__init__.py (1)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
src/backend/base/langflow/components/custom_component/__init__.py (4)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: ogabrielluiz
PR: langflow-ai/langflow#0
File: :0-0
Timestamp: 2025-06-26T19:43:18.260Z
Learning: In langflow custom components, the `module_name` parameter is now propagated through template building functions to add module metadata and code hashes to frontend nodes for better component tracking and debugging.
src/backend/base/langflow/components/composio/__init__.py (4)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
src/backend/base/langflow/components/ollama/__init__.py (3)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: ogabrielluiz
PR: langflow-ai/langflow#0
File: :0-0
Timestamp: 2025-06-26T19:43:18.260Z
Learning: In langflow custom components, the `module_name` parameter is now propagated through template building functions to add module metadata and code hashes to frontend nodes for better component tracking and debugging.
src/backend/base/langflow/components/huggingface/__init__.py (4)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
src/backend/base/langflow/components/embeddings/__init__.py (5)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: ogabrielluiz
PR: langflow-ai/langflow#0
File: :0-0
Timestamp: 2025-06-26T19:43:18.260Z
Learning: In langflow custom components, the `module_name` parameter is now propagated through template building functions to add module metadata and code hashes to frontend nodes for better component tracking and debugging.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
src/backend/base/langflow/components/processing/__init__.py (7)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Use asyncio.Queue for non-blocking queue operations in async components and handle timeouts appropriately
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Use asyncio.create_task for background work in async components and ensure proper cleanup on cancellation
Learnt from: ogabrielluiz
PR: langflow-ai/langflow#0
File: :0-0
Timestamp: 2025-06-26T19:43:18.260Z
Learning: In langflow custom components, the `module_name` parameter is now propagated through template building functions to add module metadata and code hashes to frontend nodes for better component tracking and debugging.
src/backend/base/langflow/components/azure/__init__.py (3)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
src/backend/base/langflow/components/tools/__init__.py (4)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
src/backend/base/langflow/components/baidu/__init__.py (4)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Use asyncio.Queue for non-blocking queue operations in async components and handle timeouts appropriately
src/backend/tests/integration/test_dynamic_import_integration.py (13)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/tests/unit/components/**/*.py : Create comprehensive unit tests for all new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/tests/unit/**/*.py : Test component integration within flows using create_flow, build_flow, and get_build_events utilities
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,src/frontend/**/*.test.{ts,tsx,js,jsx},src/frontend/**/*.spec.{ts,tsx,js,jsx},tests/**/*.py} : Create comprehensive unit tests for all new components.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/tests/unit/components/**/*.py : Mirror the component directory structure in unit tests under src/backend/tests/unit/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to src/backend/tests/**/*.py : Inherit from the appropriate ComponentTestBase class ('ComponentTestBase', 'ComponentTestBaseWithClient', or 'ComponentTestBaseWithoutClient') and provide the required fixtures: 'component_class', 'default_kwargs', and 'file_names_mapping' when adding a new component test.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,src/frontend/**/*.test.{ts,tsx,js,jsx},src/frontend/**/*.spec.{ts,tsx,js,jsx},tests/**/*.py} : Test both sync and async code paths in components.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,src/frontend/**/*.test.{ts,tsx,js,jsx},src/frontend/**/*.spec.{ts,tsx,js,jsx},tests/**/*.py} : Mock external dependencies appropriately in tests.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to src/backend/tests/**/*.py : Unit tests for backend code should be located in 'src/backend/tests/' and organized by component subdirectory for component tests.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,src/frontend/**/*.test.{ts,tsx,js,jsx},src/frontend/**/*.spec.{ts,tsx,js,jsx},tests/**/*.py} : Test component initialization and configuration.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test component configuration updates by asserting changes in build config dictionaries.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/tests/unit/components/**/*.py : Use ComponentTestBaseWithClient or ComponentTestBaseWithoutClient as base classes for component unit tests
src/backend/base/langflow/components/openai/__init__.py (3)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
src/backend/base/langflow/components/deepseek/__init__.py (3)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
src/backend/base/langflow/components/groq/__init__.py (1)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
src/backend/base/langflow/components/datastax/__init__.py (3)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
src/backend/base/langflow/components/youtube/__init__.py (3)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
src/backend/base/langflow/components/novita/__init__.py (5)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: ogabrielluiz
PR: langflow-ai/langflow#0
File: :0-0
Timestamp: 2025-06-26T19:43:18.260Z
Learning: In langflow custom components, the `module_name` parameter is now propagated through template building functions to add module metadata and code hashes to frontend nodes for better component tracking and debugging.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
src/backend/base/langflow/components/perplexity/__init__.py (4)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
src/backend/base/langflow/components/nvidia/__init__.py (6)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Use asyncio.Queue for non-blocking queue operations in async components and handle timeouts appropriately
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Use asyncio.create_task for background work in async components and ensure proper cleanup on cancellation
src/backend/base/langflow/components/vectorstores/__init__.py (4)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
src/backend/base/langflow/components/cohere/__init__.py (6)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Implement async component methods using async def and await for asynchronous operations
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
Learnt from: ogabrielluiz
PR: langflow-ai/langflow#0
File: :0-0
Timestamp: 2025-06-26T19:43:18.260Z
Learning: In langflow custom components, the `module_name` parameter is now propagated through template building functions to add module metadata and code hashes to frontend nodes for better component tracking and debugging.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Use asyncio.Queue for non-blocking queue operations in async components and handle timeouts appropriately
src/backend/tests/unit/components/test_all_modules_importable.py (12)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/tests/unit/components/**/*.py : Create comprehensive unit tests for all new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,src/frontend/**/*.test.{ts,tsx,js,jsx},src/frontend/**/*.spec.{ts,tsx,js,jsx},tests/**/*.py} : Create comprehensive unit tests for all new components.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/tests/unit/components/**/*.py : Mirror the component directory structure in unit tests under src/backend/tests/unit/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to src/backend/tests/**/*.py : Inherit from the appropriate ComponentTestBase class ('ComponentTestBase', 'ComponentTestBaseWithClient', or 'ComponentTestBaseWithoutClient') and provide the required fixtures: 'component_class', 'default_kwargs', and 'file_names_mapping' when adding a new component test.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/tests/unit/**/*.py : Test component integration within flows using create_flow, build_flow, and get_build_events utilities
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to src/backend/tests/**/*.py : Test files should use the same filename as the component with an appropriate test prefix or suffix (e.g., 'my_component.py' → 'test_my_component.py').
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,src/frontend/**/*.test.{ts,tsx,js,jsx},src/frontend/**/*.spec.{ts,tsx,js,jsx},tests/**/*.py} : Test both sync and async code paths in components.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,src/frontend/**/*.test.{ts,tsx,js,jsx},src/frontend/**/*.spec.{ts,tsx,js,jsx},tests/**/*.py} : Test component initialization and configuration.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,src/frontend/**/*.test.{ts,tsx,js,jsx},src/frontend/**/*.spec.{ts,tsx,js,jsx},tests/**/*.py} : Test error handling and edge cases in components.
src/backend/tests/unit/components/test_dynamic_imports.py (14)
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/__init__.py : Update __init__.py with alphabetical imports when adding new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/tests/unit/components/**/*.py : Create comprehensive unit tests for all new components
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,tests/**/*.py} : Test backward compatibility across Langflow versions by mapping component files to supported versions using 'VersionComponentMapping'.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/tests/unit/components/**/*.py : Mirror the component directory structure in unit tests under src/backend/tests/unit/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,src/frontend/**/*.test.{ts,tsx,js,jsx},src/frontend/**/*.spec.{ts,tsx,js,jsx},tests/**/*.py} : Create comprehensive unit tests for all new components.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/base/langflow/components/**/*.py : Add new backend components to the appropriate subdirectory under src/backend/base/langflow/components/
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-06-30T14:39:17.464Z
Learning: Applies to src/backend/tests/unit/**/*.py : Test component integration within flows using create_flow, build_flow, and get_build_events utilities
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,src/frontend/**/*.test.{ts,tsx,js,jsx},src/frontend/**/*.spec.{ts,tsx,js,jsx},tests/**/*.py} : Mock external dependencies appropriately in tests.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to src/backend/tests/**/*.py : Inherit from the appropriate ComponentTestBase class ('ComponentTestBase', 'ComponentTestBaseWithClient', or 'ComponentTestBaseWithoutClient') and provide the required fixtures: 'component_class', 'default_kwargs', and 'file_names_mapping' when adding a new component test.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to src/backend/tests/**/*.py : Unit tests for backend code should be located in 'src/backend/tests/' and organized by component subdirectory for component tests.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,src/frontend/**/*.test.{ts,tsx,js,jsx},src/frontend/**/*.spec.{ts,tsx,js,jsx},tests/**/*.py} : Test both sync and async code paths in components.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,src/frontend/**/*.test.{ts,tsx,js,jsx},src/frontend/**/*.spec.{ts,tsx,js,jsx},tests/**/*.py} : Test component initialization and configuration.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to {src/backend/tests/**/*.py,src/frontend/**/*.test.{ts,tsx,js,jsx},src/frontend/**/*.spec.{ts,tsx,js,jsx},tests/**/*.py} : Test error handling and edge cases in components.
Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-06-30T14:41:58.849Z
Learning: Applies to src/backend/tests/**/*.py : Test files should use the same filename as the component with an appropriate test prefix or suffix (e.g., 'my_component.py' → 'test_my_component.py').
🧬 Code Graph Analysis (23)
src/backend/base/langflow/components/docling/__init__.py (1)
src/backend/base/langflow/components/_importing.py (1)
import_mod
(8-37)
src/backend/base/langflow/components/sambanova/__init__.py (2)
src/backend/base/langflow/components/_importing.py (1)
import_mod
(8-37)src/backend/base/langflow/components/sambanova/sambanova.py (1)
SambaNovaComponent
(11-84)
src/backend/base/langflow/components/input_output/__init__.py (1)
src/backend/base/langflow/components/_importing.py (1)
import_mod
(8-37)
src/backend/base/langflow/components/lmstudio/__init__.py (3)
src/backend/base/langflow/components/_importing.py (1)
import_mod
(8-37)src/backend/base/langflow/components/lmstudio/lmstudioembeddings.py (1)
LMStudioEmbeddingsComponent
(12-89)src/backend/base/langflow/components/lmstudio/lmstudiomodel.py (1)
LMStudioModelComponent
(14-129)
src/backend/base/langflow/components/assemblyai/__init__.py (1)
src/backend/base/langflow/components/_importing.py (1)
import_mod
(8-37)
src/backend/base/langflow/components/searchapi/__init__.py (2)
src/backend/base/langflow/components/_importing.py (1)
import_mod
(8-37)src/backend/base/langflow/components/searchapi/search.py (1)
SearchComponent
(12-79)
src/backend/base/langflow/components/scrapegraph/__init__.py (4)
src/backend/base/langflow/components/_importing.py (1)
import_mod
(8-37)src/backend/base/langflow/components/scrapegraph/scrapegraph_markdownify_api.py (1)
ScrapeGraphMarkdownifyApi
(10-66)src/backend/base/langflow/components/scrapegraph/scrapegraph_search_api.py (1)
ScrapeGraphSearchApi
(10-66)src/backend/base/langflow/components/scrapegraph/scrapegraph_smart_scraper_api.py (1)
ScrapeGraphSmartScraperApi
(10-73)
src/backend/base/langflow/components/prototypes/__init__.py (1)
src/backend/base/langflow/components/_importing.py (1)
import_mod
(8-37)
src/backend/base/langflow/components/logic/__init__.py (1)
src/backend/base/langflow/components/_importing.py (1)
import_mod
(8-37)
src/backend/base/langflow/components/anthropic/__init__.py (1)
src/backend/base/langflow/components/_importing.py (1)
import_mod
(8-37)
src/backend/base/langflow/components/xai/__init__.py (2)
src/backend/base/langflow/components/_importing.py (1)
import_mod
(8-37)src/backend/base/langflow/components/xai/xai.py (1)
XAIModelComponent
(22-167)
src/backend/base/langflow/components/amazon/__init__.py (4)
src/backend/base/langflow/components/_importing.py (1)
import_mod
(8-37)src/backend/base/langflow/components/amazon/amazon_bedrock_embedding.py (1)
AmazonBedrockEmbeddingsComponent
(8-109)src/backend/base/langflow/components/amazon/amazon_bedrock_model.py (1)
AmazonBedrockComponent
(8-124)src/backend/base/langflow/components/amazon/s3_bucket_uploader.py (1)
S3BucketUploaderComponent
(15-211)
src/backend/base/langflow/components/maritalk/__init__.py (2)
src/backend/base/langflow/components/_importing.py (1)
import_mod
(8-37)src/backend/base/langflow/components/maritalk/maritalk.py (1)
MaritalkModelComponent
(9-52)
src/backend/base/langflow/components/notdiamond/__init__.py (2)
src/backend/base/langflow/components/_importing.py (1)
import_mod
(8-37)src/backend/base/langflow/components/notdiamond/notdiamond.py (1)
NotDiamondComponent
(45-228)
src/backend/base/langflow/components/custom_component/__init__.py (1)
src/backend/base/langflow/components/_importing.py (1)
import_mod
(8-37)
src/backend/base/langflow/components/ollama/__init__.py (3)
src/backend/base/langflow/components/_importing.py (1)
import_mod
(8-37)src/backend/base/langflow/components/ollama/ollama.py (1)
ChatOllamaComponent
(18-327)src/backend/base/langflow/components/ollama/ollama_embeddings.py (1)
OllamaEmbeddingsComponent
(15-106)
src/backend/base/langflow/components/embeddings/__init__.py (3)
src/backend/base/langflow/components/_importing.py (1)
import_mod
(8-37)src/backend/base/langflow/components/embeddings/similarity.py (1)
EmbeddingSimilarityComponent
(10-76)src/backend/base/langflow/components/embeddings/text_embedder.py (1)
TextEmbedderComponent
(13-64)
src/backend/base/langflow/components/azure/__init__.py (3)
src/backend/base/langflow/components/_importing.py (1)
import_mod
(8-37)src/backend/base/langflow/components/azure/azure_openai.py (1)
AzureChatOpenAIComponent
(10-95)src/backend/base/langflow/components/azure/azure_openai_embeddings.py (1)
AzureOpenAIEmbeddingsComponent
(9-83)
src/backend/base/langflow/components/baidu/__init__.py (1)
src/backend/base/langflow/components/_importing.py (1)
import_mod
(8-37)
src/backend/base/langflow/components/groq/__init__.py (2)
src/backend/base/langflow/components/_importing.py (1)
import_mod
(8-37)src/backend/base/langflow/components/groq/groq.py (1)
GroqModel
(16-139)
src/backend/base/langflow/components/novita/__init__.py (2)
src/backend/base/langflow/components/_importing.py (1)
import_mod
(8-37)src/backend/base/langflow/components/novita/novita.py (1)
NovitaModelComponent
(21-130)
src/backend/base/langflow/components/perplexity/__init__.py (2)
src/backend/base/langflow/components/_importing.py (1)
import_mod
(8-37)src/backend/base/langflow/components/perplexity/perplexity.py (1)
PerplexityComponent
(10-85)
src/backend/base/langflow/components/cohere/__init__.py (4)
src/backend/base/langflow/components/_importing.py (1)
import_mod
(8-37)src/backend/base/langflow/components/cohere/cohere_embeddings.py (1)
CohereEmbeddingsComponent
(13-81)src/backend/base/langflow/components/cohere/cohere_models.py (1)
CohereComponent
(10-46)src/backend/base/langflow/components/cohere/cohere_rerank.py (1)
CohereRerankComponent
(8-51)
🔇 Additional comments (93)
src/backend/base/langflow/components/vectara/__init__.py (1)
1-4
: LGTM! Proper placeholder structure for future components.The empty
__all__
list and module docstring correctly establish this as a placeholder for future Vectara components, consistent with the overall component architecture.src/backend/base/langflow/components/docling/__init__.py (3)
13-18
: LGTM! Proper dynamic imports mapping.The
_dynamic_imports
dictionary correctly maps component names to their respective submodules, enabling lazy loading.
28-40
: LGTM! Robust lazy loading implementation.The
__getattr__
function implements proper lazy loading with:
- Attribute validation against
_dynamic_imports
- Comprehensive error handling with exception chaining
- Component caching in globals() to avoid repeated imports
- Clear error messages for debugging
The implementation follows the established pattern across the codebase.
42-43
: LGTM! Proper introspection support.The
__dir__
function correctly returns the public API as defined by__all__
, enabling proper IDE autocomplete and introspection.src/backend/base/langflow/components/sambanova/__init__.py (3)
10-12
: LGTM! Correct dynamic imports mapping.The
_dynamic_imports
dictionary properly mapsSambaNovaComponent
to itssambanova
submodule.
17-29
: LGTM! Consistent lazy loading implementation.The
__getattr__
function follows the established pattern with proper error handling, caching, and clear error messages. The implementation is consistent with other component modules.
31-32
: LGTM! Proper introspection support.The
__dir__
function correctly returns the public API for IDE support and introspection.src/backend/base/langflow/components/ollama/__init__.py (3)
11-14
: LGTM! Correct dynamic imports mapping.The
_dynamic_imports
dictionary properly maps both Ollama components to their respective submodules.
22-34
: LGTM! Consistent lazy loading implementation.The
__getattr__
function follows the established pattern with proper error handling, component caching, and informative error messages. The implementation is consistent across the codebase.
36-37
: LGTM! Proper introspection support.The
__dir__
function correctly returns the public API for IDE autocomplete and introspection.src/backend/base/langflow/components/cloudflare/__init__.py (3)
10-12
: LGTM! Correct dynamic imports mapping.The
_dynamic_imports
dictionary properly mapsCloudflareWorkersAIEmbeddingsComponent
to itscloudflare
submodule.
17-29
: LGTM! Consistent lazy loading implementation.The
__getattr__
function follows the established pattern with proper error handling, component caching, and clear error messages. The implementation is consistent with other component modules.
31-32
: LGTM! Proper introspection support.The
__dir__
function correctly returns the public API for IDE autocomplete and introspection.src/backend/base/langflow/components/ibm/__init__.py (3)
1-16
: LGTM! Well-structured lazy import setup.The imports, type checking, and dynamic imports dictionary are correctly structured. The
__all__
list maintains alphabetical ordering as per coding guidelines.
19-31
: Excellent lazy import implementation with robust error handling.The
__getattr__
function correctly implements lazy loading with proper error handling and caching. The exception chaining preserves the original error context while providing helpful error messages.
33-34
: Good IDE introspection support.The
__dir__
implementation properly exposes the available components for IDE autocomplete and introspection.src/backend/base/langflow/components/_importing.py (2)
1-7
: LGTM! Clean module structure and imports.The module docstring, future annotations, and imports are well-structured.
8-37
: Excellent centralized import utility with comprehensive error handling.The
import_mod
function is well-designed with:
- Clear documentation and type hints
- Proper handling of both module and attribute imports
- Robust error handling with descriptive messages
- Modern Python typing conventions
The logic correctly handles the two import scenarios and provides meaningful error messages while suppressing chained exceptions appropriately.
src/backend/base/langflow/components/anthropic/__init__.py (3)
1-16
: LGTM! Consistent lazy import setup.The structure matches the established pattern across other component modules, with proper imports, type checking, and dynamic imports mapping.
19-31
: Consistent and correct lazy import implementation.The
__getattr__
function follows the same robust pattern as other modules with proper error handling and caching.
33-34
: Good introspection support.The
__dir__
implementation is consistent with the established pattern.src/backend/base/langflow/components/models/__init__.py (3)
1-16
: LGTM! Consistent structure with proper mappings.The lazy import setup correctly maps both model components to their respective modules, maintaining alphabetical ordering in
__all__
.
19-31
: Consistent lazy import implementation.The
__getattr__
function follows the established pattern with proper error handling for both model components.
33-34
: Good introspection support.The
__dir__
implementation maintains consistency with other modules.src/backend/base/langflow/components/crewai/__init__.py (3)
1-31
: LGTM! Comprehensive lazy import setup for CrewAI components.The structure correctly handles all 6 CrewAI components with proper mappings and maintains alphabetical ordering in
__all__
. The type checking imports use appropriate relative imports.
34-46
: Consistent lazy import implementation for multiple components.The
__getattr__
function correctly handles all 6 CrewAI components using the same robust pattern with proper error handling and caching.
48-49
: Good introspection support.The
__dir__
implementation maintains consistency with other modules.src/backend/base/langflow/components/lmstudio/__init__.py (1)
1-35
: LGTM! Excellent implementation of lazy imports.This refactoring successfully implements the lazy import pattern for LangFlow components, providing several benefits:
- Performance: Components are only imported when actually accessed
- Consistency: Follows the standardized pattern across the codebase
- Error handling: Proper exception handling with descriptive messages
- Caching: Imported components are cached in globals() to avoid repeated imports
- IDE support: dir override maintains autocomplete functionality
The implementation correctly uses the
import_mod
helper function and maintains backward compatibility.src/backend/base/langflow/components/baidu/__init__.py (1)
1-33
: LGTM! Clean lazy import implementation.The implementation correctly follows the established lazy import pattern with:
- Proper mapping between component name and module in
_dynamic_imports
- Consistent error handling and caching in
__getattr__
- TYPE_CHECKING imports that match the dynamic import mapping
- Correct
__dir__
implementation for IDE supportThe single-component module demonstrates the pattern works well for both simple and complex component packages.
src/backend/base/langflow/components/langchain_utilities/__init__.py (1)
1-110
: LGTM! Excellent implementation of lazy imports for complex module.The lazy import implementation is well-executed for this large component module:
- Comprehensive coverage: All 22 components properly mapped in
_dynamic_imports
- Consistent pattern: Follows the established lazy import pattern perfectly
- Error handling: Proper exception handling with descriptive messages
- Performance: Significant benefit for modules with many components
- Maintainability: Clean separation of concerns with TYPE_CHECKING imports
The implementation correctly handles the complexity of multiple components while maintaining the established pattern.
src/backend/base/langflow/components/input_output/__init__.py (1)
1-39
: LGTM! Well-implemented lazy imports for input/output components.The implementation successfully applies the lazy import pattern to the input/output components:
- Correct mapping: All components properly mapped between
_dynamic_imports
and TYPE_CHECKING imports- Alphabetical ordering:
__all__
list maintains proper alphabetical order- Error handling: Comprehensive exception handling with clear error messages
- Performance: Efficient lazy loading for frequently used input/output components
- IDE compatibility:
__dir__
override maintains autocomplete functionalityThe pattern is particularly beneficial for input/output components which are commonly used throughout the system.
src/backend/base/langflow/components/azure/__init__.py (1)
1-38
: LGTM! Solid implementation of lazy imports for Azure components.The implementation correctly applies the lazy import pattern with:
- Proper component mapping: Azure components correctly mapped in
_dynamic_imports
- Alphabetical ordering:
__all__
list maintains proper alphabetical order- Error handling: Comprehensive exception handling with descriptive messages
- Type safety: TYPE_CHECKING imports provide static analysis support
- Caching: Imported components cached in globals() for efficiency
The lazy loading pattern is particularly beneficial for Azure components which may have external dependencies that should only be loaded when needed.
src/backend/base/langflow/components/aiml/__init__.py (1)
1-38
: Excellent lazy import implementation!The refactor successfully implements a consistent lazy loading pattern with proper error handling, caching, and introspection support. The alphabetical ordering in
__all__
follows the coding guidelines, and the_dynamic_imports
mapping is correctly aligned with the exported components.src/backend/base/langflow/components/xai/__init__.py (1)
1-33
: Consistent lazy import implementation!The implementation correctly follows the established lazy loading pattern with proper error handling and caching. The single-component structure is handled appropriately while maintaining consistency with the broader refactor.
src/backend/base/langflow/components/assemblyai/__init__.py (1)
1-47
: Well-implemented lazy loading for multiple components!The implementation correctly handles multiple AssemblyAI components using the established lazy loading pattern. The alphabetical ordering in
__all__
is maintained, and all components are properly mapped in_dynamic_imports
.src/backend/base/langflow/components/mistral/__init__.py (1)
1-38
: Proper lazy import implementation for Mistral components!The implementation correctly follows the established lazy loading pattern with both model and embeddings components. The alphabetical ordering in
__all__
is maintained, and the_dynamic_imports
mapping is accurate.src/backend/base/langflow/components/firecrawl/__init__.py (1)
1-44
: Excellent lazy import implementation for Firecrawl components!The implementation correctly handles all four Firecrawl API components using the established lazy loading pattern. The alphabetical ordering in
__all__
is maintained, and the_dynamic_imports
mapping accurately reflects all available components.src/backend/base/langflow/components/vertexai/__init__.py (1)
1-37
: LGTM: Excellent implementation of lazy import patternThe lazy import mechanism is well-implemented with proper:
- Error handling with descriptive messages
- Component caching in globals() to avoid repeated imports
- Type checking imports under
TYPE_CHECKING
guard- Alphabetical ordering in
__all__
list (per coding guidelines)- IDE-friendly introspection via
__dir__
The
_dynamic_imports
mapping correctly links component names to their module names, and the pattern is consistent with the broader refactor across the components package.src/backend/base/langflow/components/notdiamond/__init__.py (1)
1-37
: LGTM: Consistent lazy import implementationThe implementation follows the established pattern perfectly:
- Module docstring provides clear context
- Single component mapping is correctly configured
- Error handling and caching mechanism matches the standard
- Type checking imports are properly guarded
The pattern consistency across the components package makes the codebase more maintainable and predictable.
src/backend/base/langflow/components/searchapi/__init__.py (1)
1-37
: LGTM: Well-implemented lazy import patternThe implementation is excellent and maintains consistency with the broader refactor:
- Module docstring provides clear context
- Single component mapping is correctly configured
- Error handling follows the established pattern
- Type checking imports are properly implemented
The lazy loading mechanism will improve import performance while maintaining full compatibility.
src/backend/base/langflow/components/helpers/__init__.py (1)
1-53
: LGTM: Comprehensive lazy import implementationExcellent implementation of the lazy import pattern for multiple helper components:
- All 7 components properly mapped in
_dynamic_imports
__all__
list maintains alphabetical ordering (per coding guidelines)- Type checking imports are comprehensive and properly guarded
- Error handling and caching mechanism is consistent with the pattern
The multi-component setup demonstrates the scalability and maintainability of this lazy import approach.
src/backend/base/langflow/components/cleanlab/__init__.py (2)
18-22
: Verify alphabetical ordering of components in all.The coding guidelines specify to update
__init__.py
with alphabetical imports when adding new components. Please ensure the components in__all__
are in alphabetical order.Current order: CleanlabEvaluator, CleanlabRAGEvaluator, CleanlabRemediator
This appears to be correctly alphabetized.
25-36
: Excellent lazy import implementation.The
__getattr__
function correctly implements the lazy import pattern with proper error handling and caching. The implementation:
- Validates attribute existence in
_dynamic_imports
- Uses the centralized
import_mod
utility- Handles import errors with descriptive messages
- Caches imported components in
globals()
to avoid repeated imports- Maintains proper error chaining with
from e
src/backend/base/langflow/components/composio/__init__.py (2)
24-31
: Verify alphabetical ordering of components in all.The coding guidelines specify alphabetical imports. Let me check the current order:
- ComposioAPIComponent
- ComposioGitHubAPIComponent
- ComposioGmailAPIComponent
- ComposioGoogleCalendarAPIComponent
- ComposioOutlookAPIComponent
- ComposioSlackAPIComponent
This appears to be correctly alphabetized.
34-45
: Consistent lazy import implementation.The
__getattr__
function follows the same well-structured pattern as other component modules with proper error handling and caching mechanism.src/backend/base/langflow/components/prototypes/__init__.py (1)
19-30
: Consistent lazy import implementation for single component.The
__getattr__
function properly implements the lazy import pattern even for a single component, maintaining consistency with the broader refactor across the components package.src/backend/base/langflow/components/scrapegraph/__init__.py (2)
18-22
: Verify alphabetical ordering of components in all.Let me check the current order:
- ScrapeGraphMarkdownifyApi
- ScrapeGraphSearchApi
- ScrapeGraphSmartScraperApi
This appears to be correctly alphabetized.
25-36
: Consistent lazy import implementation.The
__getattr__
function follows the established pattern with proper error handling and component caching.src/backend/base/langflow/components/logic/__init__.py (2)
26-34
: Verify alphabetical ordering of components in all.Let me check the current order:
- ConditionalRouterComponent
- DataConditionalRouterComponent
- FlowToolComponent
- LoopComponent
- PassMessageComponent
- RunFlowComponent
- SubFlowComponent
This appears to be correctly alphabetized.
37-48
: Consistent lazy import implementation with proper error handling.The
__getattr__
function maintains the established pattern across all component modules with comprehensive error handling and caching.src/backend/base/langflow/components/novita/__init__.py (1)
10-28
: Lazy loading implementation is well-structured.The dynamic import mechanism is correctly implemented with proper error handling, caching, and IDE support through
__dir__
. The pattern is consistent with the broader refactor across component modules.src/backend/base/langflow/components/perplexity/__init__.py (1)
19-34
: Excellent implementation of lazy loading pattern.The dynamic import mechanism is correctly implemented with proper error handling, caching through
globals()[attr_name] = result
, and IDE support via__dir__
. The relative import path in the TYPE_CHECKING block is also the preferred approach for consistency.src/backend/base/langflow/components/openrouter/__init__.py (1)
17-32
: Lazy loading implementation is correct and well-structured.The dynamic import mechanism follows the established pattern with proper error handling, caching, and IDE support. The use of
import_mod
ensures consistent behavior across all component modules.src/backend/base/langflow/components/custom_component/__init__.py (1)
19-34
: Excellent implementation of the lazy loading pattern.The dynamic import mechanism is correctly implemented with proper error handling, caching, and IDE support. The relative import path in the TYPE_CHECKING block is also the preferred approach for consistency across the codebase.
src/backend/base/langflow/components/twelvelabs/__init__.py (4)
7-14
: Excellent adherence to alphabetical ordering guidelines.The TYPE_CHECKING imports are properly ordered alphabetically, which aligns with the coding guidelines for component modules. The relative import paths are also the preferred approach for consistency.
16-24
: Well-structured dynamic imports mapping.The
_dynamic_imports
dictionary is correctly structured with alphabetical ordering and proper mapping of component names to their respective module names.
26-34
: Proper alphabetical ordering in all list.The
__all__
list maintains alphabetical ordering as specified in the coding guidelines, which improves maintainability and consistency across component modules.
37-52
: Robust lazy loading implementation for multiple components.The dynamic import mechanism correctly handles multiple components with proper error handling, caching, and IDE support through
__dir__
. The implementation is consistent with the broader refactor across component modules.src/backend/base/langflow/components/maritalk/__init__.py (1)
1-33
: LGTM! Clean lazy loading implementation following established pattern.The lazy import mechanism is well-implemented with proper error handling, caching, and TYPE_CHECKING support. This refactoring will improve startup performance by deferring imports until components are actually accessed.
src/backend/base/langflow/components/embeddings/__init__.py (1)
22-37
: LGTM! Consistent lazy loading implementation.The
__getattr__
and__dir__
functions are properly implemented following the established pattern. The error handling is comprehensive and the caching mechanism will prevent repeated imports.src/backend/base/langflow/components/deepseek/__init__.py (1)
1-35
: LGTM! Consistent lazy loading implementation.The implementation follows the established pattern perfectly with proper error handling, caching, and TYPE_CHECKING support. The mapping from
DeepSeekModelComponent
to thedeepseek
submodule is correct.src/backend/base/langflow/components/youtube/__init__.py (2)
16-24
: LGTM! Correct mapping of multiple YouTube components.The
_dynamic_imports
dictionary correctly maps all seven YouTube components to their respective submodules. The alphabetical ordering is maintained consistent with the__all__
list.
37-52
: LGTM! Proper lazy loading implementation for multiple components.The
__getattr__
function correctly handles the lazy loading of multiple components with appropriate error handling and caching. The__dir__
implementation supports IDE introspection.src/backend/base/langflow/components/huggingface/__init__.py (1)
1-38
: LGTM! Excellent completion of the lazy loading refactor.The implementation is clean and follows the established pattern perfectly. The mapping of HuggingFace components to their respective submodules is correct, and the alphabetical ordering is maintained. This completes a well-designed refactoring that will improve startup performance across all LangFlow components.
src/backend/base/langflow/components/amazon/__init__.py (2)
18-18
: The__all__
list is properly alphabetically sorted.This follows the coding guideline for maintaining alphabetical order in component imports.
21-33
: Well-implemented lazy import mechanism.The
__getattr__
function correctly implements lazy loading with proper error handling and caching. The descriptive error messages will help with debugging import issues.src/backend/base/langflow/components/__init__.py (2)
164-239
: The__all__
list follows the alphabetical ordering guideline.All components are listed in alphabetical order, making the module easy to navigate and maintain.
272-276
: Excellent consistency check for early error detection.This validation ensures that all components listed in
__all__
have corresponding import mappings, preventing runtime errors and making the module more maintainable.src/backend/base/langflow/components/vectorstores/__init__.py (1)
60-85
: The__all__
list is correctly alphabetically sorted.All vectorstore components are listed in proper alphabetical order as required by the coding guidelines.
src/backend/base/langflow/components/openai/__init__.py (1)
16-19
: Proper alphabetical ordering in__all__
list.The components are listed in alphabetical order following the coding guidelines.
src/backend/base/langflow/components/cohere/__init__.py (1)
18-22
: Components are properly listed in alphabetical order.The
__all__
list maintains alphabetical ordering as required by the coding guidelines.src/backend/base/langflow/components/tools/__init__.py (2)
58-70
: LGTM!The lazy import implementation is correct and follows the established pattern across the codebase.
72-74
: LGTM!The
__dir__
implementation correctly exposes available components for introspection.src/backend/base/langflow/components/datastax/__init__.py (1)
1-71
: LGTM!The lazy import implementation is well-structured and follows the coding guidelines, including alphabetical ordering of imports and components.
src/backend/tests/unit/test_import_utils.py (1)
12-170
: Excellent test coverage!The test suite comprehensively covers the
import_mod
function with both normal and edge cases, proper error handling tests, and good use of mocking.src/backend/base/langflow/components/nvidia/__init__.py (1)
1-58
: Well-implemented platform-specific component handling!The lazy import system correctly handles the Windows-specific component with consistent checks across type hints, dynamic imports, and exports.
src/backend/base/langflow/components/processing/__init__.py (1)
1-118
: LGTM!The lazy import implementation is well-structured with proper documentation and follows all coding guidelines, including alphabetical ordering of components.
src/backend/tests/integration/test_dynamic_import_integration.py (11)
19-31
: LGTM!The test correctly validates that component discovery mechanisms continue to work after the dynamic import refactor.
32-46
: LGTM!The test comprehensively validates that all existing import patterns continue to work correctly after the refactor.
48-58
: LGTM!The test appropriately validates that components can be accessed and are callable, with a helpful comment noting initialization requirements.
66-82
: LGTM!Excellent test validating that different import styles yield the exact same class object, ensuring proper caching behavior.
118-140
: LGTM!The test effectively validates memory efficiency by confirming that components are loaded incrementally on-demand.
141-152
: LGTM!The test properly validates error handling for both non-existent categories and components with appropriate AttributeError exceptions.
153-167
: LGTM!The test thoroughly validates IDE autocomplete support by checking
__dir__
output at both main module and category levels.
168-203
: LGTM!The test effectively validates thread-safe concurrent access to components, ensuring no race conditions in the dynamic import system.
204-220
: LGTM!The test effectively validates that no circular import issues are introduced by testing various import orders.
221-245
: LGTM!The test effectively validates large-scale component access with proper existence checks and uniqueness validation.
246-255
: LGTM!The test properly validates that essential component metadata is preserved after dynamic loading.
src/backend/tests/unit/components/test_dynamic_imports.py (4)
18-45
: LGTM!The
TestImportUtils
class comprehensively tests theimport_mod
utility function with proper coverage of success cases and error handling.
47-201
: LGTM!The
TestComponentDynamicImports
class provides comprehensive coverage of the dynamic import behavior including caching, error handling, backward compatibility, and TYPE_CHECKING support.
203-249
: LGTM!The
TestPerformanceCharacteristics
class effectively validates lazy loading, caching behavior, and memory efficiency of the dynamic import system.
251-290
: LGTM!The
TestSpecialCases
class provides good coverage of edge cases including empty init files, platform-specific components, and import structure integrity.src/backend/tests/unit/components/test_all_modules_importable.py (1)
13-246
: LGTM!The
TestAllModulesImportable
class provides exceptional comprehensive coverage of the dynamic import system, testing importability, consistency, backward compatibility, caching, error handling, and metadata preservation across all component modules. The error collection and reporting approach is particularly well-designed.
src/backend/tests/integration/test_dynamic_import_integration.py
Outdated
Show resolved
Hide resolved
src/backend/tests/integration/test_dynamic_import_integration.py
Outdated
Show resolved
Hide resolved
- Moved the warning suppression for LangChainDeprecationWarning into the dynamic import context to ensure it only applies during the import process. - This change enhances clarity and maintains the original functionality while improving the robustness of the import mechanism.
- Removed unnecessary import of AgentComponent and added assertions to verify essential attributes of OpenAIModelComponent, including display_name, description, icon, and inputs. - Ensured that each input field has the required attributes for better validation of component integrity during dynamic imports.
…ties - Changed the import of the Message class from langflow.field_typing to langflow.schema.message across multiple utility files, ensuring consistency and alignment with the updated module structure. - This refactor enhances code clarity and maintains compatibility with the latest schema definitions.
- Deleted the Vectara components module from the codebase, streamlining the component structure. - This change helps to reduce complexity and maintain focus on core functionalities.
- Eliminated Vectara from both the import statements and dynamic imports mapping, streamlining the component structure. - This change contributes to reducing complexity and maintaining focus on core functionalities within the LangFlow framework.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8932 +/- ##
==========================================
+ Coverage 32.61% 32.65% +0.03%
==========================================
Files 1193 1194 +1
Lines 56001 56017 +16
Branches 5278 5278
==========================================
+ Hits 18267 18294 +27
+ Misses 37684 37673 -11
Partials 50 50
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
@ogabrielluiz @coderabbitai How can we optimise it ? in order to reduce the repeatable codes? |
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chainI'll analyze the repetitive code patterns in this PR to suggest optimization strategies. @edwinjosechittilappilly Great question! Looking at this PR, there's significant code duplication across 40+ component modules. Here are several optimization strategies to reduce the repetitive code: 1. Create a Lazy Import Decorator/FactoryCreate a utility function that generates the lazy import functionality: # src/backend/base/langflow/components/_lazy_loader.py
from __future__ import annotations
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from collections.abc import Mapping
def create_lazy_module(
dynamic_imports: Mapping[str, str],
package: str,
all_exports: list[str] | None = None
) -> tuple[callable, callable]:
"""Factory function to create __getattr__ and __dir__ for lazy loading."""
all_exports = all_exports or list(dynamic_imports.keys())
def __getattr__(attr_name: str) -> Any:
if attr_name in dynamic_imports:
try:
from ._importing import import_mod
module = import_mod(attr_name, dynamic_imports[attr_name], package)
globals()[attr_name] = module
return module
except (ImportError, ModuleNotFoundError, AttributeError) as e:
msg = f"Failed to import {attr_name} from {package}: {e}"
raise AttributeError(msg) from e
raise AttributeError(f"module '{package}' has no attribute '{attr_name}'")
def __dir__() -> list[str]:
return all_exports
return __getattr__, __dir__ Then each module becomes much simpler: # src/backend/base/langflow/components/openai/__init__.py
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from .embeddings import OpenAIEmbeddingsComponent
from .model import OpenAIModelComponent
__all__ = ["OpenAIEmbeddingsComponent", "OpenAIModelComponent"]
_dynamic_imports = {
"OpenAIEmbeddingsComponent": "embeddings",
"OpenAIModelComponent": "model",
}
from ._lazy_loader import create_lazy_module
__getattr__, __dir__ = create_lazy_module(_dynamic_imports, __name__, __all__) 2. Use a Module-Level Configuration ApproachCreate a base class or configuration system: # src/backend/base/langflow/components/_base_module.py
from __future__ import annotations
import sys
from types import ModuleType
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from collections.abc import Mapping
class LazyModule(ModuleType):
"""A module that lazily imports its attributes."""
def __init__(
self,
name: str,
dynamic_imports: Mapping[str, str],
all_exports: list[str] | None = None,
) -> None:
super().__init__(name)
self._dynamic_imports = dynamic_imports
self._all_exports = all_exports or list(dynamic_imports.keys())
self.__all__ = self._all_exports
def __getattr__(self, attr_name: str) -> Any:
if attr_name in self._dynamic_imports:
try:
from ._importing import import_mod
module = import_mod(attr_name, self._dynamic_imports[attr_name], self.__name__)
setattr(self, attr_name, module)
return module
except (ImportError, ModuleNotFoundError, AttributeError) as e:
msg = f"Failed to import {attr_name} from {self.__name__}: {e}"
raise AttributeError(msg) from e
raise AttributeError(f"module '{self.__name__}' has no attribute '{attr_name}'")
def __dir__(self) -> list[str]:
return self._all_exports
def setup_lazy_module(
module_name: str,
dynamic_imports: Mapping[str, str],
all_exports: list[str] | None = None,
) -> None:
"""Replace the current module with a lazy-loading version."""
lazy_module = LazyModule(module_name, dynamic_imports, all_exports)
sys.modules[module_name] = lazy_module 3. Create a Shared Pattern GeneratorUse a more functional approach with a pattern generator: # src/backend/base/langflow/components/_patterns.py
from __future__ import annotations
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from collections.abc import Mapping
def lazy_import_pattern(
dynamic_imports: Mapping[str, str],
package_name: str,
) -> dict[str, Any]:
"""Generate the lazy import pattern for a module."""
def __getattr__(attr_name: str) -> Any:
if attr_name in dynamic_imports:
try:
from ._importing import import_mod
import sys
current_module = sys.modules[package_name]
component = import_mod(attr_name, dynamic_imports[attr_name], package_name)
setattr(current_module, attr_name, component)
return component
except (ImportError, ModuleNotFoundError, AttributeError) as e:
msg = f"Failed to import {attr_name} from {package_name}: {e}"
raise AttributeError(msg) from e
raise AttributeError(f"module '{package_name}' has no attribute '{attr_name}'")
def __dir__() -> list[str]:
return list(dynamic_imports.keys())
return {
"__getattr__": __getattr__,
"__dir__": __dir__,
} 4. Centralized ConfigurationCreate a single configuration file for all component mappings: # src/backend/base/langflow/components/_component_registry.py
COMPONENT_MAPPINGS = {
"openai": {
"OpenAIEmbeddingsComponent": "embeddings",
"OpenAIModelComponent": "model",
},
"anthropic": {
"AnthropicModelComponent": "anthropic",
},
# ... all other mappings
}
def get_component_mapping(category: str) -> dict[str, str]:
"""Get the component mapping for a category."""
return COMPONENT_MAPPINGS.get(category, {}) Recommended ApproachI'd recommend Option 1 (Factory Function) as it:
The factory approach would reduce each component module from ~30-40 lines to just ~15 lines, eliminating the repetitive Would you like me to create a complete implementation of any of these optimization strategies? 🏁 Script executed:
Length of output: 4368 🏁 Script executed:
Length of output: 2079 🏁 Script executed:
Length of output: 2358 Perfect! Now I can see the exact patterns and provide more targeted optimization recommendations. The analysis shows 47 modules with identical lazy loading patterns, confirming significant code duplication. Current Pattern AnalysisLooking at the code, every module follows this exact pattern: # 1. Standard imports (4-5 lines)
from __future__ import annotations
from typing import TYPE_CHECKING, Any
from langflow.components._importing import import_mod
# 2. TYPE_CHECKING imports (variable lines)
if TYPE_CHECKING:
from .module import Component
# 3. Configuration (variable lines)
_dynamic_imports = {"Component": "module"}
__all__ = ["Component"]
# 4. Identical __getattr__ function (12 lines)
def __getattr__(attr_name: str) -> Any:
"""Lazily import components on attribute access."""
if attr_name not in _dynamic_imports:
msg = f"module '{__name__}' has no attribute '{attr_name}'"
raise AttributeError(msg)
try:
result = import_mod(attr_name, _dynamic_imports[attr_name], __spec__.parent)
except (ModuleNotFoundError, ImportError, AttributeError) as e:
msg = f"Could not import '{attr_name}' from '{__name__}': {e}"
raise AttributeError(msg) from e
globals()[attr_name] = result
return result
# 5. Identical __dir__ function (2 lines)
def __dir__() -> list[str]:
return list(__all__) Total repetitive code: ~18 lines × 47 modules = 846 lines of duplicated code Optimized SolutionHere's my recommended optimization that reduces each module to just 6-8 lines: Now each component module becomes incredibly simple. Here's what the OpenAI module would look like: # src/backend/base/langflow/components/openai/__init__.py
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from .openai import OpenAIEmbeddingsComponent
from .openai_chat_model import OpenAIModelComponent
__all__ = ["OpenAIEmbeddingsComponent", "OpenAIModelComponent"]
from .._lazy_loader import create_lazy_loader
__getattr__, __dir__ = create_lazy_loader(
{"OpenAIEmbeddingsComponent": "openai", "OpenAIModelComponent": "openai_chat_model"},
__all__
) Even More Optimized: Configuration-Driven ApproachFor maximum optimization, we could use a single configuration: With this approach, each module becomes just 4-5 lines: # src/backend/base/langflow/components/openai/__init__.py
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from .openai import OpenAIEmbeddingsComponent
from .openai_chat_model import OpenAIModelComponent
from .._lazy_loader import create_lazy_loader
__getattr__, __dir__ = create_lazy_loader(
{"OpenAIEmbeddingsComponent": "openai", "OpenAIModelComponent": "openai_chat_model"},
["OpenAIEmbeddingsComponent", "OpenAIModelComponent"]
)
__all__ = ["OpenAIEmbeddingsComponent", "OpenAIModelComponent"] Benefits of This Optimization
Implementation Strategy
This optimization would eliminate ~846 lines of repetitive code while maintaining identical functionality! Would you like me to create a complete implementation with a migration script to convert all the modules automatically? 🏁 Script executed:
Length of output: 90 🏁 Script executed:
Length of output: 86 Perfect! Let me now create a complete implementation with a migration script to demonstrate how this optimization would work in practice. Now let me show you concrete examples of the transformation: SummaryThis optimization would provide massive benefits: 📊 Quantified Impact
🎯 Key Benefits
🚀 Implementation Plan
The optimization maintains 100% backward compatibility while dramatically reducing code duplication. Each component module becomes a simple configuration file rather than repeating the same implementation logic. Would you like me to create the complete implementation files and migration script that you could use to apply this optimization to the codebase? 🏁 Script executed:
Length of output: 118 🏁 Script executed:
Length of output: 104 🏁 Script executed:
Length of output: 1480 🏁 Script executed:
Length of output: 2246 🏁 Script executed:
Length of output: 1416 Perfect! Now let me create a complete implementation package that you can use to apply this optimization. Perfect! I've created a complete optimization package that addresses your question about reducing repetitive code. Here's what you get: 🎯 Complete Solution Package1. Core Utility (
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Tested.
This will likely improve the experience of using components in Python and help with dependency management and bundles.
Summary by CodeRabbit
New Features
Refactor
Tests