* fix: ensure unique flow names when assigning to superuser
* refactor: Creates a new function with logic to rename flows
* refactor: simplify function
* Extract STARTER_FOLDER constants to a separate module
* Filter orphaned flows by excluding those in the starter folder
---------
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
* fix: update assistants client import (#4150)
* remove unnecessary patch
* remove unnecessary patch
* compatible release operator
* chore: add opensearch-py dependency (#4134)
Add opensearch-py dependency to pyproject.toml
* patch version
* lock
* lock some packages to speed up pip install
* langflow-base version
* fix: fix retrieverTool component (#4201)
♻️ (RetrieverTool.py): refactor build method signature to accept additional keyword arguments for future extensibility
* Fixed save modal not exiting
* fix: object has no attribute 'set_event_manager' (#4200)
* 🐛 (base.py): fix AttributeError by checking if custom_component has set_event_manager method before calling it
* 📝 (base.py): Import Component from langflow.custom to improve code readability and maintainability
♻️ (base.py): Refactor code to use isinstance() method for checking if custom_component is an instance of Component
* Refactor: Eliminate Global Variables for Improved Code Maintainability_fix_release (#4208)
Refactor: Eliminate Global Variables for Improved Code Maintainability
- Replaced global variables with local variables or class attributes.
- Enhanced code readability and reduced potential side effects.
* fix: Update example (#4204)
update example
* fix: avoids error NameError: name 'MAX_NUMBER_OF_FIELDS' is not defin… (#4203)
fix: avoids error NameError: name 'MAX_NUMBER_OF_FIELDS' is not defined and fixes build method
Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
* fix: unexpected keyword argument 'code' -> SQLExecutor and SQLDatabase (#4230)
🔧 (SQLDatabase.py): update build method signature to accept additional keyword arguments for future extensibility
🔧 (SQLExecutor.py): update method signature to accept additional keyword arguments for future extensibility
* lock httptools to 0.6.4
* Move ChatInput import to within flow_component fixture in conftest.py
* Simplify error message formatting in test cases for data components
* Add readme to dockerfile
* build: dockerfile with entrypoint (#4062)
Adds a dockerfile with an entrypoint for use with Datastax Langflow
* fixes the leading v for checking out commits correctly
* fixes on more version checkout for docker build
* ✨ (authContext.tsx): Add functionality to fetch global variables on authentication
🔧 (api.tsx): Replace universal-cookie import with react-cookie for consistency
🔧 (authStore.ts): Replace universal-cookie import with react-cookie for consistency
🔧 (use-get-global-variables.ts): Add check to only fetch global variables if user is authenticated
✨ (use-get-mutation-global-variables.ts): Add mutation function to fetch and update global variables
🔧 (authStore.ts): Replace universal-cookie import with react-cookie for consistency
* [autofix.ci] apply automated fixes
* revert changes to workflows
* upgrade lockfile
* update pyproject versions
* update lockfile again
* ⬆️ (pyproject.toml): upgrade langflow-base dependency to version 0.0.99
* ⬆️ (pyproject.toml): downgrade version from 0.0.99 to 0.0.97 to align with project requirements and dependencies.
* ⬆️ (pyproject.toml): downgrade langflow-base dependency version from 0.0.99 to 0.0.97 to resolve compatibility issues
* ⬆️ (uv.lock): downgrade langchain-core package version from 0.3.15 to 0.3.12 to resolve compatibility issues with dependencies
* ⬆️ (pyproject.toml): upgrade langflow-base dependency to version 0.0.99 to utilize the latest features and improvements
---------
Co-authored-by: Sebastián Estévez <estevezsebastian@gmail.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: Lucas Oliveira <lucas.edu.oli@hotmail.com>
Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
Co-authored-by: anovazzi1 <otavio2204@gmail.com>
Co-authored-by: João <38133825+joaoguilhermeS@users.noreply.github.com>
Co-authored-by: Jordan Frazier <jordan.frazier@datastax.com>
Co-authored-by: Jordan Frazier <122494242+jordanrfrazier@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* Refactor Alembic environment script to simplify database connection logic and remove unused imports
* Refactor test client fixture to use TemporaryDirectory and UUID for database path
* Add `reload_engine` method to reinitialize the database engine
* Add cleanup steps to test fixtures to ensure proper resource management
- Added cleanup steps to various pytest fixtures to ensure temporary directories, database entries, and other resources are properly cleaned up after tests.
- Modified fixtures to use `yield` for better resource management.
- Ensured database connections are closed and tables are dropped after tests.
- Improved temporary directory handling with context managers.
* Add unit test to verify return type of list_flows method in custom component
* Refactor tests in `test_custom_component.py` to remove unused imports and fixtures, and update existing fixtures for consistency.
* Add debug checks for user existence in `test_user_waiting_for_approval` test
* Fix import order and add flow_id validation in transaction handling
- Corrected the import order in `utils.py`.
- Added validation for `flow_id` in the transaction handling logic to ensure it is set correctly.
* Add function to delete transactions by flow ID in CRUD module
* Add cleanup for transactions and vertex builds in test teardown
- Introduced `_delete_transactions_and_vertex_builds` function to remove transactions and vertex builds associated with a user.
- Updated `user` fixture to call the new cleanup function before deleting the user.
* Refactor flow_id assignment logic in `utils.py` to improve readability and correctness
* [autofix.ci] apply automated fixes
* Refactor test to use pytest's tmp_path fixture for temporary directory creation
* Convert `test_user_waiting_for_approval` to an async test function
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* Set `_has_cycle_edges` to `True` for source and target vertices in cycle edges
* feat: Add `has_cycle_edges` method to Vertex class
The `has_cycle_edges` method is added to the `Vertex` class to check if the vertex has any cycle edges. Additionally, the `instantiate_component` method is updated to use the `initialize.loading.instantiate_class` function for custom component instantiation.
* Add `apply_on_outputs` method to Vertex for applying functions to outputs
* Add utility to find vertices in cycles within a directed graph
- Implement `find_cycle_vertices` function to identify all vertices that are part of cycles in a directed graph.
- Utilize depth-first search (DFS) to detect cycles and collect vertices involved in those cycles.
* Add unit tests for `find_cycle_vertices` utility function in graph module
* Add method to set cache for vertices in cycle
- Introduced `_set_cache_to_vertices_in_cycle` method to enable caching for vertices involved in cycles.
- Added `find_cycle_vertices` import to support the new method.
- Refactored vertex instantiation into `_instantiate_components_in_vertices` method for better code organization.
* refactor: Update caching logic for vertices in cycles
Refactor the `_set_cache_to_vertices_in_cycle` method to improve caching logic for vertices involved in cycles. Instead of setting the `cache` attribute to `True`, it is now set to `False` for better clarity and consistency. This change ensures that the cache is properly handled for vertices in cycles.
* Refactor `find_cycle_vertices` to use NetworkX for cycle detection
* Refactor `find_cycle_vertices` tests to remove entry point parameter and add new test case
- Removed the `entry_point` parameter from all test cases for `find_cycle_vertices`.
- Added a new parameterized test case `test_handle_two_inputs_in_cycle` to verify handling of cycles with two inputs.
* Disable cache in cycle: Update `apply_on_outputs` to handle empty outputs in `base.py`
* Add unit test to ensure output cache is disabled in graph cycles
* Add unit test for graph cyclicity with prompt components and OpenAI integration
- Introduce `test_updated_graph_with_prompts` to validate graph cyclicity and execution.
- Integrate `PromptComponent`, `OpenAIModelComponent`, and `ConditionalRouterComponent` in the test.
- Ensure graph execution with a maximum of 20 iterations and cache disabled.
- Validate the presence of expected output vertices in the results.
* Convert `_instantiate_components_in_vertices` to async and disable cache in cycle vertices
* Add default value handling for cycle edges in vertex component
- Introduced `default_value` to handle cases where edges are cycles and target parameters are present.
- Ensured that `default_value` is returned if defined, preventing errors when the component is not built.
* Switch from os.environ to os.getenv for API key retrieval in test_cycles.py
* Add __repr__ method to Edge class to indicate cycle edges with a symbol
* Refactor test_cycles.py to streamline component initialization and update assertions
- Simplified component initialization using method chaining.
- Corrected router input and message parameters to use openai_component_1.
- Updated assertions to check for correct output IDs.
* Refactor test_cycles.py to streamline component initialization and update assertions
* Refactor test to use custom serialization method instead of pickle
* Add cycle_vertices property to optimize cycle detection in graph
- Introduced `_cycle_vertices` attribute to store vertices involved in cycles.
- Added `cycle_vertices` property to compute and cache cycle vertices.
- Updated edge creation logic to use `cycle_vertices` for cycle detection.
* Enhance error message in `types.py` to include component ID for better debugging
* Refactor test_cycles.py to update graph configuration and assertions
- Changed router operator from "equals" to "contains".
- Consolidated chat output to a single component.
- Updated graph construction to use a single chat output.
- Replaced `_snapshot` with `get_snapshot` for graph state capture.
- Adjusted assertions to reflect the updated graph structure and outputs.
* Add api_key_required marker to test_updated_graph_with_prompts test
* Add validation to require max_iterations for cyclic graphs
* run ruff
- Refactored error message handling in `base.py` for cyclic graphs.
- Optimized cycle vertex extraction in `utils.py` by using set comprehension.
* Comment out tests for loading flow from JSON in test_loading.py
* Refactor test fixture for webhook flow creation in conftest.py
* Update unit tests to reflect new webhook flow structure in vertices endpoints
* Temporarily disable tests for loading Langchain objects with and without cached sessions
* Disable caching in vector store and OpenAI model components
* Add async support and dependencies to pyproject.toml files
- Added `asgi-lifespan>=2.1.0` to dependencies.
- Configured `asyncio_mode` and `asyncio_default_fixture_loop_scope` for pytest.
- Updated `tool.uv` section with `asgi-lifespan` in dev-dependencies.
* Convert test fixtures to async and use AsyncClient for HTTP requests
* Handle 'ImportFrom' nodes in AST validation to support module attribute imports
* Convert test cases to use async HTTP client
- Updated test cases in `test_database.py`, `test_endpoints.py`, `test_user.py`, `test_variable.py`, `test_files.py`, `test_chat_endpoint.py`, `test_misc.py`, `test_messages_endpoints.py`, `test_api_key.py`, `test_webhook.py`, and `test_login.py` to use `httpx.AsyncClient` instead of `fastapi.TestClient`.
- Modified test functions to be asynchronous and use `await` for HTTP requests.
- Adjusted fixtures and helper functions to support asynchronous operations.
- Ensured consistency in endpoint paths and request methods across all test cases.
* Refactor string concatenation to f-string in test_chat_endpoint.py
* [autofix.ci] apply automated fixes
* Refactor import validation to use pattern matching for AST nodes
* Set `startup_timeout` and `shutdown_timeout` to `None` in `LifespanManager` for test files.
* Convert test functions to async in `test_messages_endpoints.py`
* Add `api_key_required` marker to assistant component tests
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* Add `required_inputs` field to `Output` model in `base.py`
* Refactor ComponentTool to ComponentToolkit and enhance tool creation logic
- Replaced `ComponentTool` with `ComponentToolkit` to better encapsulate component-related tools.
- Introduced `build_description` and `_build_output_function` helper functions for dynamic tool creation.
- Updated tool initialization to handle multiple outputs and required inputs using `StructuredTool`.
- Improved schema creation for tool arguments based on component inputs.
* Refactor `to_tool` method to `to_toolkit` to use `ComponentToolkit` instead of `ComponentTool`
* Refactor `ComponentTool` to `ComponentToolkit` in unit tests
- Updated import statements to reflect the new `ComponentToolkit` class.
- Modified test logic to use `ComponentToolkit` for retrieving tools.
- Adjusted assertions to match the new structure and output format.
- Ensured compatibility with `Message` schema for output validation.
* Refactor `test_component_to_tool` to validate `ComponentToolkit` and tool properties
* Refactor `build_description` to include input types in the output format
* Add method to set required inputs for outputs based on method analysis
- Introduced `_set_output_required_inputs` method to determine and set required inputs for each output by analyzing the method's source code.
- Added necessary imports (`ast` and `dedent`) to support the new functionality.
* Update test to assert full tool description in test_component_to_tool.py
* Add unit tests for verifying required inputs of various components
- Added tests to ensure that required inputs for outputs are present in the inputs of `ChatInput`, `ChatOutput`, `SequentialTaskComponent`, `ToolCallingAgentComponent`, and `OpenAIModelComponent`.
- Included helper functions to check if required inputs are in inputs and to assert that all outputs have different required inputs.
* Add RequiredInputsVisitor to identify required inputs in AST nodes
- Introduced RequiredInputsVisitor class to traverse AST nodes and collect required inputs.
- The visitor checks for 'self' attributes matching the provided inputs and adds them to the required_inputs set.
* Refactor required inputs extraction using `RequiredInputsVisitor`
* Add feature flags configuration for toolkit output in settings
* Add toolkit output handling based on feature flag in custom component utils
* Add method to append 'component_as_tool' output in custom component
* Add unit test for toolkit output feature flag in custom component
* Add utility functions for lazy loading and instantiating input types in langflow
- Introduced `get_InputTypesMap` for lazy loading of `InputTypesMap`.
- Added `instantiate_input` function to create instances of input types dynamically.
- Included type checking and error handling for invalid input types.
* Refactor input instantiation logic and update imports
- Removed `instantiate_input` function from `inputs.py` and moved it to `utils.py`.
- Updated imports in `base.py` to reflect the new location of `instantiate_input`.
- Added missing import for `Callable` in `base.py`.
* Refactor import statement to use `instantiate_input` from `langflow.inputs.utils` in test_inputs.py
* Add TOOL_OUTPUT_NAME constant to tools module
* Add type checking and TOOL_OUTPUT_NAME filter in ComponentToolkit
- Introduced `TYPE_CHECKING` for type hints to avoid circular imports.
- Added `TOOL_OUTPUT_NAME` constant to filter specific outputs in `ComponentToolkit`.
- Updated type annotations to use forward references.
* Refactor component toolkit import to avoid circular dependency and use constant for tool output name
* Refactor `ComponentToolkit` class to remove inheritance from `BaseToolkit` and add an initializer for `component`
* Add unit test for ComponentToolkit in test_component_to_tool
- Added `test_component_to_tool_has_no_component_as_tool` to verify that `ComponentToolkit` correctly initializes with a `ChatInput` component and returns the expected tools.
* Refactor toolkit output handling to `custom_component` module
* fix: mypy errors union-attr and arg-type
* Add 'OTHER' field type to schema in langflow/io/schema.py
* Add tool name formatting to ComponentToolkit to ensure valid characters
* Refactor toolkit output handling and add type hint for `to_toolkit` method
* Add `is_interface_component` attribute to vertex types and update import order
* Add tests for ToolCallingAgentComponent and ChatOutput with API key handling
- Updated `test_component_tool` to reflect new description format.
- Added `test_component_tool_with_api_key` to test `ToolCallingAgentComponent` with `ChatOutput` and OpenAI API key.
- Enabled `add_toolkit_output` feature flag for testing.
* Refactor `_find_matching_output_method` to accept `input_name` parameter for more precise input-output matching
* Replace ValueError with warning in build_description function
* use chat_output component directly in set
* [autofix.ci] apply automated fixes
* [autofix.ci] apply automated fixes
* [autofix.ci] apply automated fixes (attempt 3/3)
* Refactor: Reorder method calls in `__init__` for logical consistency
Moved `set_class_code` method call to ensure output types and required inputs are set before class code initialization.
* Update _format_tool_name to allow '.' in tool names
* Refactor `_format_tool_name` to remove non-alphanumeric characters
* Update test assertions for component tool name and output mapping
* Handle case where 'required_inputs' is empty in 'component_tool.py'
* Refactor import statements for better readability in `base.py`
* [autofix.ci] apply automated fixes
* Add noqa comment to suppress import warning and re-add Any import in base.py
---------
Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* Add fixture for creating flow component in tests
* Add test for reading flows with components only in test_database.py
* Add `components_only` parameter to filter flows by components in API endpoint
* Refactor test fixtures and imports for optimization
- Reordered and optimized imports in `conftest.py`.
- Changed return statements to yield in `basic_graph` and `create_webhook` fixtures for better resource management.
- Added cleanup step to `create_webhook` fixture to delete created webhook after test completion.
* Refactor imports and add placeholder client fixture in test_ChatOllama_component.py
* Add pytest fixture 'client' to test_graph.py
* Add pytest fixture 'client' to test_callback_graph.py for test optimization
* Add 'unit_tests_looponfail' target to Makefile for running unit tests with loop-on-fail option
* Optimize test durations and update test cases in various modules
* refactor(tests): update import statements in conftest.py to use collections.abc module for better compatibility and maintainability
* run pyupgrade on graph module
* [autofix.ci] apply automated fixes
* refactor(attributes.py): change import statement from 'typing.Callable' to 'collections.abc.Callable' for better compatibility
refactor(code_parser.py): update type annotations to use '|' for Union types for better readability
refactor(base_component.py): update type annotations to use '|' for Union types for better readability
refactor(component.py): change import statement from 'typing.Callable' to 'collections.abc.Callable' for better compatibility
refactor(component.py): update type annotations to use '|' for Union types for better readability
refactor(component.py): update type annotations to use 'list' instead of 'List' for consistency
refactor(custom_component.py): update typing imports and annotations for better readability and consistency
refactor(utils.py): change type hint 'List' to 'list' for consistency and compatibility with Python 3.9
* run make format
* [autofix.ci] apply automated fixes
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* refactor: move test_graph.py
* refactor: allow Graph to be initialized with no nodes and edges
The Graph class in `base.py` was refactored to separate the initialization of nodes and edges into a separate method called `add_nodes_and_edges()`. This improves code readability and maintainability by organizing the code logic more effectively.
* refactor: separate initialization of nodes and edges in get_graph()
The `get_graph()` function in `conftest.py` was refactored to separate the initialization of nodes and edges. This improves code readability and maintainability by organizing the code logic more effectively.
* refactor: separate initialization of nodes and edges in test_graph.py
* refactor: separate initialization of nodes and edges in base.py
The `add_node()` and `add_edge()` methods were added to the `Graph` class in `base.py` to separate the initialization of nodes and edges. This improves code readability and maintainability by organizing the code logic more effectively.
* refactor: move tests folder to src/backend
* chore(Makefile): update pytest commands to run tests from the correct directory paths for unit and integration tests
* refactor: update file path in test_custom_component.py
The file path in the test_custom_component.py file has been updated to use the correct relative path to the component_multiple_outputs.py file. This change ensures that the test code can access the correct file and improves the reliability of the test.