Commit graph

51 commits

Author SHA1 Message Date
Gabriel Luiz Freitas Almeida
bc6e918f49
fix: add tests to cycles in Graph and improve error handling (#3628)
* Add cycle detection and handling in graph edge building process

- Introduced `cycles` property to detect cycles in the graph.
- Modified `_build_edges` and `build_edge` methods to differentiate between `CycleEdge` and `Edge`.
- Updated imports and type hints to support new functionality.

* Add cycle detection and handling in graph processing

- Introduced `is_cyclic` property to check for cycles in the graph.
- Added `_snapshot` method for capturing the current state of the graph.
- Modified `layered_topological_sort` to handle cyclic graphs by starting from a specified start component.
- Updated imports and type hints for better code clarity and functionality.

* Refactor tests and components for improved caching and data handling

- Updated `test_vector_store_rag.py` to use `set_on_output` with `cache=True` and simplified assertions.
- Enhanced `test_memory_chatbot.py` with additional assertions for graph structure and caching.
- Simplified `to_data` method in `base.py` to directly return `_data` without JSON serialization.

* Add unit tests for detecting cycles in graph

- Introduce `test_cycle_in_graph` to verify cyclic behavior in the graph.
- Add `test_cycle_in_graph_max_iterations` to ensure max iterations limit is respected.
- Implement `Concatenate` component for testing purposes.

* Disable output cache in graph tests to allow loops to work

* Refactor: Update VertexStates enum values to uppercase and optimize imports in base.py

* Refactor type hints and improve error handling in `Vertex` class

- Replace `ValueError` with `NoComponentInstance` exception for missing component instances.
- Add `target_handle_name` parameter to `_get_result` method for better result retrieval.
- Refactor type hints to use `collections.abc` for `AsyncIterator`, `Generator`, and `Iterator`.
- Update type hints for `extract_messages_from_artifacts` and `successors_ids` methods to use generic `dict` and `list`.
2024-09-02 11:45:37 +00:00
Nicolò Boschi
1c87a804bf
chore: improve db session access (#3138)
* chore: improve db session access

* chore: improve db session access

* fix

* [autofix.ci] apply automated fixes

* Refactor session management in test_sqlite_pragmas to use with_session method

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
2024-08-30 14:03:29 -07:00
Gabriel Luiz Freitas Almeida
e7a48d58e6
style: Fix type comparison issues in codebase (#3606)
style: fix E721
2024-08-29 11:48:15 +00:00
Gabriel Luiz Freitas Almeida
48fb846a4d
refactor: change typing annotations in tests folder (#3594)
* refactor(log_router.py): change variable type annotation from List to list for better consistency
refactor(utils.py): change variable type annotation from Dict to dict for better consistency
refactor(base.py): change variable type annotation from Optional to Union for better clarity
refactor(callback.py): change variable type annotation from Dict to dict for better consistency
refactor(chat.py): change variable type annotation from Optional to Union for better clarity
refactor(endpoints.py): change variable type annotation from Optional to Union for better clarity
refactor(flows.py): change variable type annotation from List to list for better consistency

refactor(api): update response_model annotations to use lowercase list for consistency and improve readability

refactor(store.py): update type annotations for query parameters in get_components endpoint to improve code readability and maintainability
feat(store.py): add support for type hinting Union and list types in query parameters for better data validation and documentation

* run make format

* refactor(input_mixin.py): update typing annotations for variables to use union types for better clarity and compatibility with Python 3.10
refactor(inputs.py): update typing annotations for variables to use union types and import necessary modules for compatibility with Python 3.10

* refactor(base.py): remove unnecessary imports and update typing for fields in Input and Output classes
feat(base.py): add support for specifying field types more explicitly in Input and Output classes
feat(frontend_node/base.py): enhance typing and field definitions in FrontendNode class
feat(frontend_node/custom_components.py): improve typing and field definitions in CustomComponentFrontendNode and ComponentFrontendNode classes
feat(template/base.py): update typing for fields in Template class and remove unnecessary imports

* refactor(inputs): remove unnecessary Optional import from typing in input_mixin.py and inputs.py files to improve code readability and maintainability

* refactor(schema.py): change 'Type' to 'type' for consistency in type annotations
refactor(schema.py): change 'list' to 'List' and 'Literal' to 'literal' for correct type hinting in create_input_schema function

* refactor(utils.py): change typing annotations from List and Union to list and type to follow PEP 585 standards
refactor(test_schema.py): change typing annotations from List and List to list and list to follow PEP 585 standards
refactor(test_graph.py): change typing annotations from Type and Union to type and Vertex | None to follow PEP 585 standards
refactor(test_io_schema.py): change typing annotations from List and List to list and list to follow PEP 585 standards
refactor(test_custom_component.py): update file reading method to remove unnecessary "r" mode
refactor(test_helper_components.py): update file reading method to remove unnecessary "r" mode
refactor(test_kubernetes_secrets.py): update b64encode method argument to bytes type
refactor(test_template.py): change typing annotations from Optional, List, and Dict to list, dict, and None to follow PEP 585 standards

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-08-28 19:45:19 +00:00
Gabriel Luiz Freitas Almeida
1883710dd1
chore: update type annotations in template, io and inputs modules (#3593)
* refactor(input_mixin.py): update typing annotations for variables to use union types for better clarity and compatibility with Python 3.10
refactor(inputs.py): update typing annotations for variables to use union types and import necessary modules for compatibility with Python 3.10

* refactor(base.py): remove unnecessary imports and update typing for fields in Input and Output classes
feat(base.py): add support for specifying field types more explicitly in Input and Output classes
feat(frontend_node/base.py): enhance typing and field definitions in FrontendNode class
feat(frontend_node/custom_components.py): improve typing and field definitions in CustomComponentFrontendNode and ComponentFrontendNode classes
feat(template/base.py): update typing for fields in Template class and remove unnecessary imports

* refactor(inputs): remove unnecessary Optional import from typing in input_mixin.py and inputs.py files to improve code readability and maintainability

* refactor(schema.py): change 'Type' to 'type' for consistency in type annotations
refactor(schema.py): change 'list' to 'List' and 'Literal' to 'literal' for correct type hinting in create_input_schema function

* test: fix tests

---------

Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>
2024-08-28 19:35:01 +00:00
Gabriel Luiz Freitas Almeida
3e19a3fd36
feat: allow passing a Component to the set method (#3597)
* refactor: Add _find_matching_output_method to Component class

* feat: allow components to be passed in set method

* fix: Add test for graph set method with valid component

* set value variable to the output callable

* refactor: Update test_component.py to use set_component method

This commit refactors the test_component.py file in the custom_component directory. The test_set_invalid_input() function has been renamed to test_set_component() to better reflect its purpose. Additionally, the test_set_component() function now sets the agent parameter using the set_component() method instead of raising a ValueError. This change improves the readability and maintainability of the code.

* refactor: Fix formatting issue in _build_error_string_from_matching_pairs

The _build_error_string_from_matching_pairs method in the Component class had a formatting issue when input types were empty. This commit fixes the issue by adding a check for empty input types and providing an empty list as a fallback. This improves the accuracy and readability of the error string generated by the method.

* fix(component.py): add validation to ensure output method is a string to prevent potential runtime errors
2024-08-28 12:31:14 -07:00
Gabriel Luiz Freitas Almeida
9c8dd8e1f0
chore: upgrade type annotations in graph and custom modules (#3591)
* 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>
2024-08-28 18:48:24 +00:00
Edwin Jose
46a9789028
fix(ollama): resolve model list loading issue and add Pytest for component testing (#3575)
* Commit to solve Model not loading issue

The issue was that the url of the models: api/tags was not parsed correctly.
It was having a // hence used urlencode to parse it properly.

Th e correct apporach works only if the base_url is correct,i.e a valid ollama URL:
for DS LF this must be a public ollama Server URL.

* updated the component Ollama Component

changed the get model to take in base url and the function will make the expected url for the model names. This makes the function better, than providing the model url as paramter.

Added Pytest, 7 tests, 1 test excluded for future implememtstion: test_build_model_failure

Make lint and Make format had touched multiple files

* removed unwanted print statements

removed unwanted print statements.

make format, formatted a lot of .tsx files also

* removed skipped tests

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-08-27 19:21:06 -04:00
anovazzi1
9bf72ab444
fix: improve file name generation in upload_file function to prevent files with the same name (#3550)
* fix: improve file name generation in upload_file function to prevent files with the same name

* [autofix.ci] apply automated fixes

* fix: improve file name generation in upload_file function

* [autofix.ci] apply automated fixes

* fix: improve file name generation in upload_file function

* fix: improve file path generation in test_upload_file function

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-08-26 18:35:19 +00:00
Jordan Frazier
75520729de
build: fix astra integration tests (#3518) 2024-08-26 16:44:27 +00:00
Gabriel Luiz Freitas Almeida
6d048b2d2c
refactor: add fixtures for client in test files to speed them up (#3490)
refactor: Add fixtures for client in test files to speed them up
2024-08-22 12:08:47 -07:00
Gabriel Luiz Freitas Almeida
bf650ecec5
refactor: improve attribute compatibility and error messages (#3367)
* feat: Refactor how configuration attributes are handled in Component class.

* refactor: Update method name to handle singular and plural inputs.

* refactor: Add value validation for input and attribute assignment.

* test: Add test for setting invalid input in task component.

* fix: add param without underscore to inputs

* test(astra): Refactor AstraDB imports in test_astra_component (#3413)

* test(astra): Refactor AstraDB imports in test_astra_component

* fix: Add AstraVectorizeComponent to AstraDB tests.

* fix: Refactor custom component error message for setting parameter or attribute.

* test(astra): Refactor AstraDB imports in test_astra_component (#3413)

* test(astra): Refactor AstraDB imports in test_astra_component

* fix: Add AstraVectorizeComponent to AstraDB tests.

* chore: Refactor joining methods list in _set_parameter_or_attribute function.

* refactor: Refactor error message string formatting in Component class.
2024-08-21 12:34:15 +00:00
Gabriel Luiz Freitas Almeida
188708281a
test(astra): Refactor AstraDB imports in test_astra_component (#3413)
* test(astra): Refactor AstraDB imports in test_astra_component

* fix: Add AstraVectorizeComponent to AstraDB tests.
2024-08-20 12:49:12 -07:00
Gabriel Luiz Freitas Almeida
037c0902d5
fix: update type extraction to extract inner types correctly (#3446)
* refactor: Improve post-processing of return type in type extraction.

* feat: Add support for Union[int, Sequence[str]] in post_process_type.

* refactor(langflow): Simplify return type extraction in CustomComponent.

* Refactor: Remove 'Sequence' and 'list' type options in starter projects.

* test: fix assertion

---------

Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>
2024-08-20 12:48:18 +00:00
Gabriel Luiz Freitas Almeida
0e1155bb43
test: Add client fixture override for runnable vertices manager unit test. (#3430) 2024-08-20 04:00:38 -07:00
Gabriel Luiz Freitas Almeida
b588ac071a
feat: add endpoint to get starter projects (#3370)
* feat(api): Add endpoint to get list of starter projects with error handling.

* feat: Add test for getting starter projects with valid API key.

* [autofix.ci] apply automated fixes

* refactor(langflow): Update function name from get_all_graphs_dump to get_starter_projects_dump.

* bug: fixes route collision

* bug: fixes serialization

* chore: move endpoint to new file

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>
2024-08-19 15:32:17 -07:00
Gabriel Luiz Freitas Almeida
75dbb68dfc
feat: add ComponentTool to support converting Component to Tool (#3412)
* feat: Add ComponentTool to convert a Component to a Tool

* test(component): add unit test for ComponentTool with ChatInput input.

* feat: Add method to convert Component to ComponentTool.

* feat: Add unit test for ChatInput to Tool conversion.

* chore: add comment

* test: fix assertion

---------

Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>
2024-08-19 10:05:59 -07:00
Gabriel Luiz Freitas Almeida
149c96d26c
feat: add function to create input schema from component inputs (#3411)
* feat: Add function to create input schema from list of input types.

* feat: Add unit tests for creating input schemas.

* refactor(io): Improve input schema creation logic.

* refactor(schema): Simplify eval call in create_input_schema function.

* fix: Change ValueError to TypeError in create_input_schema to reflect correct exception.

* refactor: refactor create_input_schema to accept a list of input instances.
2024-08-19 09:36:05 -07:00
Gabriel Luiz Freitas Almeida
d313137f8c
feat: add starter project graphs (#3369)
* feat: Add basic prompting graph function.

* feat: Add blog writer starter project function.

* feat(langflow): Add document QA starter project.

* feat: Add memory chatbot graph function to create chatbot with memory component.

* feat: Add hierarchical tasks agent graph to handle sequential tasks.

* feat: Add a function to create a sequential tasks agent with specific tasks.

* feat: Add vector_store_rag module with ingestion and RAG graphs.

* Refactor: Update the hierarchical task agent to use builder methods for agents and models.

* feat: Refactor sequential tasks agent to utilize build_model and build_output methods.

* refactor: Rename functions in blog_writer, document_qa, and vector_store_rag to end with "_graph".

* feat: Add new graphs to starter projects __init__.py.

* feat: Add complex agent graph setup with prompts, tools, and agents.

* refactor: Add complex agent graph to starter projects.

* feat: Add starter project graphs and dump retrieval functions.

* test: Refactor test_directory_without_mocks method with temporary directory for testing purposes.
2024-08-16 12:47:19 -07:00
Gabriel Luiz Freitas Almeida
e4e1a747f8
test: Fix assertion in test_get_vertices function. (#3387)
* test: Fix assertion in test_get_vertices function.

* test: fix set

---------

Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>
2024-08-16 10:49:02 -07:00
Gabriel Luiz Freitas Almeida
c4d2dc56c7
fix(edge): Handle invalid input types when creating TargetHandle (#3368)
* fix(edge): Handle invalid input types when creating TargetHandle

* test(edge): add test for raising error on invalid target handle

* fix: mypy error union-attr

---------

Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>
2024-08-16 07:52:43 -07:00
Gabriel Luiz Freitas Almeida
2baee5fef1
feat: get result from output if possible (#3338)
* refactor: Extract method to set params from normal edge in Vertex class.

* feat: Add method to retrieve value from template dict in Vertex class.

* feat: Add handling for cycle and contract edge targets in ComponentVertex build method.

* refactor: Update result retrieval logic in ComponentVertex class.

* refactor: Add condition to check flow_id before creating log transactions.

* refactor: Add missing `Edge` import and cast `cast` in types.py for better typing.
2024-08-15 16:44:06 +00:00
Gabriel Luiz Freitas Almeida
bb923cf9e1
feat: update output attribute handling (#3329)
* refactor: improve function structure in _build_results

* fix: remove function call that overrides Component.outputs

* refactor: Add handling for outputs in __getattr__ method.
2024-08-15 13:00:09 +00:00
Gabriel Luiz Freitas Almeida
77b071155c
feat: add functions to detect cycles in Graph (#3327)
* feat: Add functions to detect cycles in directed graphs.

* test: Add new test cases for cycle detection in graph utils.

* test: temporarily disable test

---------

Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>
2024-08-14 16:14:56 +00:00
Ítalo Johnny
4f5dca89f3
test: adds new tests for new variable service (#3306)
* test: adds new tests for new method

* test: remove unused variable
2024-08-13 18:01:10 +00:00
Ítalo Johnny
952ba5eef1
feat: centralize global variable management (#3284)
* test: add tests for global variable endpoints

* test: add unit tests variable service

* fix: anticipate checks to prevent the code from breaking

* feat: add a new method to interface

* feat: add method to update fields in variable service

* feat: replace variable api code

* fix: mypy error

* fix: mypy error

* feat(variable): Allow deleting variables by name or ID in DatabaseVariableService.

* refactor(api): Simplify delete method in variable router.

---------

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
2024-08-13 13:32:57 +00:00
Gabriel Luiz Freitas Almeida
c5d9cbae49
feat: add dynamic state model creation and update (#3271)
* feat: add initial implementation of dynamic state model creation and output getter in graph state module

* feat: implement _reset_all_output_values method to initialize component outputs in custom_component class

* feat: add state model management with lazy initialization and dynamic instance getter in custom_component class

* feat: Refactor Component class to use public method get_output_by_method

Refactor the Component class in the custom_component module to change the visibility of the method `_get_output_by_method` to public by renaming it to `get_output_by_method`. This change improves the accessibility and clarity of the method for external use.

* feat: add output setter utility to manage output values in state model properties

* feat: implement validation for methods' classes in output getter/setter utilities in state model to ensure proper structure

* feat: add state model creation from graph in state_model.py

* feat: enhance Graph class with lazy loading for state model creation from graph

* feat: add unit tests for state model creation and validation in test_state_model.py

* feat: add unit tests for state model creation and validation in test_state_model.py

* feat: add functional test for graph state update and validation in test_graph_state_model.py

* fix: update _instance_getter function to accept a parameter in component.py for state model instance retrieval

* refactor: rename test to clarify purpose in test_state_model.py for functional state update validation

* chore: import Finish constant in test_graph_state_model.py for improved clarity and usage in state model tests

* refactor: add optional validation in output getter/setter methods for improved method integrity in state model handling

* refactor: enhance state model creation with optional validation and error handling for output methods in model.py

* refactor: serialize and deserialize GraphStateModel in test_graph_state_model.py

* refactor: improve error message and add verbose mode for graph start in test_state_model.py

* refactor: remove verbose flag from graph.start in TestCreateStateModel for consistency in test_state_model.py

* refactor: disable validation when creating GraphStateModel in state_model.py for improved flexibility

* refactor: add validation documentation for method attributes in model.py to enhance code clarity and usability

* refactor: expand docstring for build_output_getter in model.py to clarify usage and validation details

* refactor: add detailed docstring for build_output_setter in model.py to improve clarity on functionality and usage scenarios

* refactor: add comprehensive docstring for create_state_model in model.py to clarify functionality and usage examples

* refactor: enhance docstring for create_state_model_from_graph in state_model.py to clarify functionality and provide examples

* test: add JSON schema validation in graph state model tests for improved structure and correctness verification

* refactor: Improve graph_state_model.json_schema unit test readability and structure.
2024-08-12 17:53:57 -07:00
Gabriel Luiz Freitas Almeida
9da2c34551
fix: update type to silence warning and memory chatbot json (#3265)
* fix: update value type in DefaultPromptField from str to Any for increased flexibility in input handling

* fix: replace _instantiate_input with instantiate_input for consistency in input instantiation across the codebase

* chore: update test durations

* update memory chatbot
2024-08-09 16:01:25 +00:00
Gabriel Luiz Freitas Almeida
645c723d21
feat: start using dev mode flag and add exception filter in logger (#3260)
* refactor: reorganize logger module and add setup.py for logging configuration

* refactor: update logger import path to align with recent module restructuring

* refactor: add logging configuration parameter to Graph initialization for improved logging setup flexibility

* feat: create logging init module for improved logger configuration and management

* refactor: update Settings class to include development mode flag and associated validator for enhanced configuration management

* refactor: enhance logger.py with DEV mode handling and TypedDict for log configuration settings

* feat: add settings module with DEV mode flag and helper functions for setting development state

* refactor: update flow assertions in tests to check for Data object type instead of Flow object type

* feat: add deepcopy method to Graph class to copy start and end components, ensuring proper graph cloning functionality

* feat: implement deepcopy method in Component class for proper cloning of inputs and configuration attributes

* feat: enhance attribute access in Component class to support backwards-compatible private attributes retrieval

* feat: improve test assertion for list_flows in custom component to display types of returned objects for better debugging

* feat: refactor imports in constants.py and remove redundant Data class definition for cleaner code structure

* feat: refactor imports in logger.py to include NotRequired from typing_extensions for better type hinting support
2024-08-09 13:59:49 +00:00
Gabriel Luiz Freitas Almeida
e42b6bdb94
fix: change ValueError into Warning to allow disconnected flows to run and other small fixes (#3249)
* fix: add task to end all traces on asyncio.CancelledError in build_flow function for better cleanup handling

* fix: replace ValueError with warnings in Graph class when vertices exist without edges for better logging and handling

* chore: add type annotations to test_vector_store_rag_add function

* feat: Fix assertion in test_create_flows to check for substring in name field

The assertion in the test_create_flows function was modified to check if the name field contains the substring "Flow 1" instead of an exact match. This change allows for more flexibility in the test and ensures that the test passes even if there are additional characters in the name field.
2024-08-08 20:21:21 +00:00
Gabriel Luiz Freitas Almeida
22305fe6e3
feat: Implement graph combination method (#3224)
* feat(utils.py): add escape_json_dump function to escape JSON strings for Edge dictionaries

* refactor(Output): streamline add_types method to prevent duplicate entries in types list for improved type management

* feat(data.py): add classmethod decorator to validate_data for enhanced validation logic when checking data types

* feat(setup.py): implement retry logic for loading starter projects to enhance robustness against JSON decode errors

* fix(input_mixin.py): improve model_config formatting and update field_type alias for clarity and consistency in field definitions

* feat(types.py): refactor vertex constructors to use NodeData and add input/output methods for better component interaction

* feat(schema.py): add NodeData and Position TypedDicts for improved type safety and structure in vertex data handling

* feat(base.py): update Vertex to use NodeData type and add to_data method for better data management and access

* refactor(schema.py): update TargetHandle and SourceHandle models to include model_config attribute

* Add TypedDict classes for graph schema serialization in `schema.py`

* Refactor `Edge` class to improve handle validation and data handling

- Consolidated imports and removed redundant `BaseModel` definitions for `SourceHandle` and `TargetHandle`.
- Added `valid_handles`, `target_param`, and `_target_handle` attributes to `Edge` class.
- Enhanced handle validation logic to distinguish between dictionary and string types.
- Introduced `to_data` method to return edge data.
- Updated attribute names to follow consistent naming conventions (`base_classes`, `input_types`, `field_name`).

* Refactor `Edge` class to improve handle validation and data handling

* Refactor: Standardize attribute naming and add `to_data` method in Edge class

- Renamed attributes to use snake_case consistently (`baseClasses` to `base_classes`, `inputTypes` to `input_types`, `fieldName` to `field_name`).
- Added `to_data` method to return `_data` attribute.
- Updated validation methods to use new attribute names.

* Refactor: Update Edge class to consistently use snake_case for attributes and improve validation logic for handles

* Refactor: Change node argument type in add_node and _create_vertex methods to NodeData for better type safety and clarity

* Refactor: Implement JSON serialization for graph data with `dumps` and `dump` methods, enhancing data export capabilities

* Refactor: Add pytest fixtures for ingestion and RAG graphs, enhance test structure for better clarity and organization

* Refactor: Add pytest fixtures for memory_chatbot_graph tests and improve test structure

* Refactor: Remove unused methods in ComponentVertex class to streamline code and improve readability

* Refactor: Remove unnecessary line in ComponentVertex class to enhance code clarity and maintainability

* refactor: Add utility functions for getting handle IDs in CustomNodes

- Added `getRightHandleId` function to generate the right handle ID for source handles.
- Added `getLeftHandleId` function to generate the left handle ID for target handles.
- These functions improve code readability and maintainability by encapsulating the logic for generating handle IDs.

* refactor: Add type for escaped handle IDs in edges to improve type safety in reactflowUtils

* feat: Add function to escape handle IDs in edges, enhancing edge management in reactflowUtils

* feat: Add function to check edges without escaped handle IDs, improving edge validation in reactflowUtils

* feat: Enhance edge processing in reactflowUtils to handle edges without escaped handle IDs more effectively

* feat: Add layoutUtils module for handling node layout using elkjs

* feat: update processDataFromFlow to add layout to nodes if needed

* feat: Update flowsManagerStore to parse flow data from file before processing

- Replace usages of `fileData` with `parsedFlowData` for improved clarity
- Ensure compatibility with newProject and isComponent parameters
- Improve error handling for uploading components as flows or vice versa
- Refactor code for better readability and maintainability

* Refactor import paths to use 'initialize' module in 'base.py'

* feat: Add method to set class source code and integrate it with frontend node input field

* refactor: Update sourceHandle dataType to use custom component class name

* fix: Raise error for unknown vertex types instead of returning default Vertex class

* refactor: Remove redundant call to _import_vertex_types() in VertexTypesDict initialization

* refactor: Simplify add_code_field by removing unnecessary field_config parameter from function signature

* feat: Add elkjs dependency to package.json and package-lock.json for enhanced functionality in the frontend

* refactor: Update fields type in Template class to use InputTypes for improved type safety

* refactor: Update import path for DefaultPromptField to improve code organization and maintain compatibility

* refactor: Reorganize imports in __init__.py for better structure and consistency across the inputs module

* refactor: Clean up imports in types.py for better organization and consistency in the graph vertex module

* refactor: Change vertex type annotations to strings for better compatibility and consistency in the graph module methods

* refactor: Update component instantiation to include _code parameter and fix input type annotations for improved type handling

* refactor: Remove unused CustomComponent import from __init__.py for cleaner module structure and improved organization

* refactor: Modify custom_component instantiation to include _code argument for enhanced functionality and clarity in CodeParser class

* refactor: Update CustomComponent import in __init__.py for improved module structure and organization

* refactor: Update launch.json to include correct path for backend source files

* refactor: Update dependencies in poetry.lock to latest versions and resolve merge conflicts in backend files

* [autofix.ci] apply automated fixes

* refactor: Remove unnecessary line in test_memory_chatbot.py

* refactor: Update dataType assignment in Component class to use component name if available, or fallback to class name

* refactor: Correct flow_id reference in MemoryComponent to improve clarity and consistency in memory handling

* refactor: Update import path for DefaultPromptField to improve code organization and maintainability in api_utils.py

* refactor: Add loading module to __init__.py for improved organization of interface package

* refactor: Clean up imports in base.py and enforce edge validation in Graph class for improved maintainability and error handling

* refactor: Remove edge component additions in test_base.py to streamline graph tests and emphasize error handling for unprepared graphs

* refactor: Mark @clack/prompts is-unicode-supported as extraneous in package-lock.json for better dependency management

* refactor: Update dataType assignment in Component class to use component name if available, or fallback to class name

* refactor: Fix edge existence check in Graph class to use correct variable, ensuring accurate validation of graph structure

* refactor: Add test for graph with edge and improve graph preparation logic

* refactor: Set default node type to "genericNode" in getLayoutedNodes for consistent layout structure

* create consts for node widht and height

* refactor: Catch and log errors when processing flow data in flowsManagerStore and reactflowUtils

* [autofix.ci] apply automated fixes

* fix: Validate custom components for source and target vertices in Graph edges

* test: Add fixture for client and raise TypeError for invalid class parsing in CodeParser tests

* test: Add unit test for listing flows as Flow objects in custom component with client

* test: Update assertions for memory chatbot component types in unit tests

* test: Refactor assertions to use updated component names in vector store RAG unit tests

* fix: Change error handling to return default Vertex for unknown node types in graph class

* [autofix.ci] apply automated fixes

* test: Add pytest fixture for CustomComponent in unit tests to enhance test structure and readability

* chore: Update component names in vector store RAG unit tests

* test: Refactor imports and make flow name generation unique in database unit tests

* chore: Add new attributes to Edge class for improved state management and validation in edge processing logic

* chore: Implement addition methods for Graph class to combine vertices and edges from other graph instances safely

* chore: Extend serialization in Graph class to include additional internal attributes for improved state handling

* chore: Call initialize method in prepare for proper setup before validating component IDs in Graph class

* chore: Add test to validate graph combination in vector store RAG, ensuring correct vertices and edges in merged graph structure

* refactor: Add utility functions for getting handle IDs in CustomNodes

- Added `getRightHandleId` function to generate the right handle ID for source handles.
- Added `getLeftHandleId` function to generate the left handle ID for target handles.
- These functions improve code readability and maintainability by encapsulating the logic for generating handle IDs.

* refactor: Add type for escaped handle IDs in edges to improve type safety in reactflowUtils

* feat: Add function to escape handle IDs in edges, enhancing edge management in reactflowUtils

* feat: Add function to check edges without escaped handle IDs, improving edge validation in reactflowUtils

* feat: Enhance edge processing in reactflowUtils to handle edges without escaped handle IDs more effectively

* feat: Add layoutUtils module for handling node layout using elkjs

* feat: update processDataFromFlow to add layout to nodes if needed

* Refactor import paths to use 'initialize' module in 'base.py'

* feat: Add method to set class source code and integrate it with frontend node input field

* refactor: Update sourceHandle dataType to use custom component class name

* fix: Raise error for unknown vertex types instead of returning default Vertex class

* refactor: Remove redundant call to _import_vertex_types() in VertexTypesDict initialization

* refactor: Simplify add_code_field by removing unnecessary field_config parameter from function signature

* feat: Add elkjs dependency to package.json and package-lock.json for enhanced functionality in the frontend

* refactor: Update fields type in Template class to use InputTypes for improved type safety

* refactor: Reorganize imports in __init__.py for better structure and consistency across the inputs module

* refactor: Clean up imports in types.py for better organization and consistency in the graph vertex module

* refactor: Change vertex type annotations to strings for better compatibility and consistency in the graph module methods

* refactor: Update component instantiation to include _code parameter and fix input type annotations for improved type handling

* refactor: Remove unused CustomComponent import from __init__.py for cleaner module structure and improved organization

* refactor: Modify custom_component instantiation to include _code argument for enhanced functionality and clarity in CodeParser class

* refactor: Update CustomComponent import in __init__.py for improved module structure and organization

* refactor: Update launch.json to include correct path for backend source files

* refactor: Update dependencies in poetry.lock to latest versions and resolve merge conflicts in backend files

* refactor: Update dataType assignment in Component class to use component name if available, or fallback to class name

* refactor: Correct flow_id reference in MemoryComponent to improve clarity and consistency in memory handling

* refactor: Update import path for DefaultPromptField to improve code organization and maintainability in api_utils.py

* refactor: Add loading module to __init__.py for improved organization of interface package

* refactor: Clean up imports in base.py and enforce edge validation in Graph class for improved maintainability and error handling

* refactor: Remove edge component additions in test_base.py to streamline graph tests and emphasize error handling for unprepared graphs

* refactor: Mark @clack/prompts is-unicode-supported as extraneous in package-lock.json for better dependency management

* refactor: Update dataType assignment in Component class to use component name if available, or fallback to class name

* refactor: Fix edge existence check in Graph class to use correct variable, ensuring accurate validation of graph structure

* refactor: Add test for graph with edge and improve graph preparation logic

* refactor: Set default node type to "genericNode" in getLayoutedNodes for consistent layout structure

* create consts for node widht and height

* refactor: Catch and log errors when processing flow data in flowsManagerStore and reactflowUtils

* [autofix.ci] apply automated fixes

* fix: Validate custom components for source and target vertices in Graph edges

* test: Add fixture for client and raise TypeError for invalid class parsing in CodeParser tests

* test: Add unit test for listing flows as Flow objects in custom component with client

* test: Update assertions for memory chatbot component types in unit tests

* test: Refactor assertions to use updated component names in vector store RAG unit tests

* fix: Change error handling to return default Vertex for unknown node types in graph class

* [autofix.ci] apply automated fixes

* test: Add pytest fixture for CustomComponent in unit tests to enhance test structure and readability

* chore: Update component names in vector store RAG unit tests

* test: Refactor imports and make flow name generation unique in database unit tests

* chore: Remove unused upload and flow management functions from flowsManagerStore for cleaner codebase

* chore: Await processDataFromFlow in useAddFlow hook

* chore: Correct NODE_HEIGHT calculation to use NODE_WIDTH constant for consistency in constants file

* chore: Remove extraneous flag for is-unicode-supported in package-lock.json for cleaner dependency management

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: anovazzi1 <otavio2204@gmail.com>
2024-08-07 09:21:07 -07:00
anovazzi1
48ffdbf760
feat: Add suggestion message to API exception response (#3149)
* feat: suggest updating outdated components in API exception handling

Suggest updating the outdated components in the API exception handling. This commit adds a suggestion message to the API exception response when there are outdated components in the flow. The suggestion message provides the number of outdated components and recommends updating them. The suggestion is generated based on the list of outdated components obtained from the flow data.

* feat: refactor code

* [autofix.ci] apply automated fixes

* Update src/backend/base/langflow/exceptions/api.py

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* Update src/backend/base/langflow/api/utils.py

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* Update src/backend/base/langflow/exceptions/api.py

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* update function name

* [autofix.ci] apply automated fixes

* refactor: fix import casing in langflow.api.utils and langflow.exceptions.api

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* refactor: remove unused code and update exception handling in langflow.api.utils and langflow.exceptions.api

* [autofix.ci] apply automated fixes

* refactor: update exception handling and class  in langflow.api.utils and langflow.exceptions.api

* [autofix.ci] apply automated fixes

* update function name and refactor none flow logic

* [autofix.ci] apply automated fixes

* refactor: fix typo in get_suggestion_message function name

* refactor: improve get_suggestion_message function in langflow.api.utils

* refactor: add unit tests for get_suggestion_message and get_outdated_components functions

* refactor: add unit tests for APIException in langflow.exceptions.api

* refactor: improve test coverage for APIException and related functions

* [autofix.ci] apply automated fixes

* update file name

* refactor: update build_exception_body method in APIException to handle Exception type

* refactor: handle None flow data in get_components_versions

* [autofix.ci] apply automated fixes

* refactor: update useDeleteBuilds function signature in _builds API query

* fix: Fix test changing screen before request ended

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
2024-08-07 15:26:24 +00:00
Gabriel Luiz Freitas Almeida
919073a0db
feat: import Graph without position information (#3203)
* refactor: Add utility functions for getting handle IDs in CustomNodes

- Added `getRightHandleId` function to generate the right handle ID for source handles.
- Added `getLeftHandleId` function to generate the left handle ID for target handles.
- These functions improve code readability and maintainability by encapsulating the logic for generating handle IDs.

* refactor: Add type for escaped handle IDs in edges to improve type safety in reactflowUtils

* feat: Add function to escape handle IDs in edges, enhancing edge management in reactflowUtils

* feat: Add function to check edges without escaped handle IDs, improving edge validation in reactflowUtils

* feat: Enhance edge processing in reactflowUtils to handle edges without escaped handle IDs more effectively

* feat: Add layoutUtils module for handling node layout using elkjs

* feat: update processDataFromFlow to add layout to nodes if needed

* Refactor import paths to use 'initialize' module in 'base.py'

* feat: Add method to set class source code and integrate it with frontend node input field

* refactor: Update sourceHandle dataType to use custom component class name

* fix: Raise error for unknown vertex types instead of returning default Vertex class

* refactor: Remove redundant call to _import_vertex_types() in VertexTypesDict initialization

* refactor: Simplify add_code_field by removing unnecessary field_config parameter from function signature

* feat: Add elkjs dependency to package.json and package-lock.json for enhanced functionality in the frontend

* refactor: Update fields type in Template class to use InputTypes for improved type safety

* refactor: Reorganize imports in __init__.py for better structure and consistency across the inputs module

* refactor: Clean up imports in types.py for better organization and consistency in the graph vertex module

* refactor: Change vertex type annotations to strings for better compatibility and consistency in the graph module methods

* refactor: Update component instantiation to include _code parameter and fix input type annotations for improved type handling

* refactor: Remove unused CustomComponent import from __init__.py for cleaner module structure and improved organization

* refactor: Modify custom_component instantiation to include _code argument for enhanced functionality and clarity in CodeParser class

* refactor: Update CustomComponent import in __init__.py for improved module structure and organization

* refactor: Update launch.json to include correct path for backend source files

* refactor: Update dependencies in poetry.lock to latest versions and resolve merge conflicts in backend files

* refactor: Update dataType assignment in Component class to use component name if available, or fallback to class name

* refactor: Correct flow_id reference in MemoryComponent to improve clarity and consistency in memory handling

* refactor: Update import path for DefaultPromptField to improve code organization and maintainability in api_utils.py

* refactor: Add loading module to __init__.py for improved organization of interface package

* refactor: Clean up imports in base.py and enforce edge validation in Graph class for improved maintainability and error handling

* refactor: Remove edge component additions in test_base.py to streamline graph tests and emphasize error handling for unprepared graphs

* refactor: Mark @clack/prompts is-unicode-supported as extraneous in package-lock.json for better dependency management

* refactor: Update dataType assignment in Component class to use component name if available, or fallback to class name

* refactor: Fix edge existence check in Graph class to use correct variable, ensuring accurate validation of graph structure

* refactor: Add test for graph with edge and improve graph preparation logic

* refactor: Set default node type to "genericNode" in getLayoutedNodes for consistent layout structure

* create consts for node widht and height

* refactor: Catch and log errors when processing flow data in flowsManagerStore and reactflowUtils

* [autofix.ci] apply automated fixes

* fix: Validate custom components for source and target vertices in Graph edges

* test: Add fixture for client and raise TypeError for invalid class parsing in CodeParser tests

* test: Add unit test for listing flows as Flow objects in custom component with client

* test: Update assertions for memory chatbot component types in unit tests

* test: Refactor assertions to use updated component names in vector store RAG unit tests

* fix: Change error handling to return default Vertex for unknown node types in graph class

* [autofix.ci] apply automated fixes

* test: Add pytest fixture for CustomComponent in unit tests to enhance test structure and readability

* chore: Update component names in vector store RAG unit tests

* test: Refactor imports and make flow name generation unique in database unit tests

* chore: Remove unused upload and flow management functions from flowsManagerStore for cleaner codebase

* chore: Await processDataFromFlow in useAddFlow hook

* chore: Correct NODE_HEIGHT calculation to use NODE_WIDTH constant for consistency in constants file

* chore: Remove extraneous flag for is-unicode-supported in package-lock.json for cleaner dependency management

---------

Co-authored-by: anovazzi1 <otavio2204@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-08-07 07:04:48 -07:00
Gabriel Luiz Freitas Almeida
bb1bc5c2df
feat: add dump and dumps methods to Graph (#3202)
* feat(utils.py): add escape_json_dump function to escape JSON strings for Edge dictionaries

* refactor(Output): streamline add_types method to prevent duplicate entries in types list for improved type management

* feat(data.py): add classmethod decorator to validate_data for enhanced validation logic when checking data types

* feat(setup.py): implement retry logic for loading starter projects to enhance robustness against JSON decode errors

* fix(input_mixin.py): improve model_config formatting and update field_type alias for clarity and consistency in field definitions

* feat(types.py): refactor vertex constructors to use NodeData and add input/output methods for better component interaction

* feat(schema.py): add NodeData and Position TypedDicts for improved type safety and structure in vertex data handling

* feat(base.py): update Vertex to use NodeData type and add to_data method for better data management and access

* refactor(schema.py): update TargetHandle and SourceHandle models to include model_config attribute

* Add TypedDict classes for graph schema serialization in `schema.py`

* Refactor `Edge` class to improve handle validation and data handling

- Consolidated imports and removed redundant `BaseModel` definitions for `SourceHandle` and `TargetHandle`.
- Added `valid_handles`, `target_param`, and `_target_handle` attributes to `Edge` class.
- Enhanced handle validation logic to distinguish between dictionary and string types.
- Introduced `to_data` method to return edge data.
- Updated attribute names to follow consistent naming conventions (`base_classes`, `input_types`, `field_name`).

* Refactor `Edge` class to improve handle validation and data handling

* Refactor: Standardize attribute naming and add `to_data` method in Edge class

- Renamed attributes to use snake_case consistently (`baseClasses` to `base_classes`, `inputTypes` to `input_types`, `fieldName` to `field_name`).
- Added `to_data` method to return `_data` attribute.
- Updated validation methods to use new attribute names.

* Refactor: Update Edge class to consistently use snake_case for attributes and improve validation logic for handles

* Refactor: Change node argument type in add_node and _create_vertex methods to NodeData for better type safety and clarity

* Refactor: Implement JSON serialization for graph data with `dumps` and `dump` methods, enhancing data export capabilities

* Refactor: Add pytest fixtures for ingestion and RAG graphs, enhance test structure for better clarity and organization

* Refactor: Add pytest fixtures for memory_chatbot_graph tests and improve test structure

* Refactor: Remove unused methods in ComponentVertex class to streamline code and improve readability

* Refactor: Remove unnecessary line in ComponentVertex class to enhance code clarity and maintainability

* Refactor: Update import path for DefaultPromptField to improve code organization and maintainability in api_utils.py

* Refactor: Update import path for DefaultPromptField to enhance code organization and maintainability in prompt.py

* fix: Remove  fixture in test_memory_chatbot.py that blocked db setup

* Refactor: Add durations path for unit tests to improve test reporting

* Refactor: Add splitting algorithm option for unit tests

* Add async option to Makefile for unit tests and update GitHub Actions workflow

- Introduced `async` variable in Makefile to conditionally run unit tests with or without parallel execution.
- Updated `unit_tests` target in Makefile to handle `async` flag.
- Modified GitHub Actions workflow to set `async=false` for unit tests.
2024-08-05 21:00:46 +00:00
Gabriel Luiz Freitas Almeida
f706b05438
refactor: enhance CustomComponent class and updates tests (#3201)
* fix: update CustomComponent to use properties for user_id and flow_id

Refactored user_id and flow_id in CustomComponent to use properties for better encapsulation and code clarity

* refactor: update CustomComponent initialization and remove unused imports

Refactored the CustomComponent class to streamline initialization and removed unnecessary import for BaseCallbackHandler

* refactor: update build_custom_component_template to use cc_instance for field order to improve consistency and clarity

* refactor: update user_id parameter in FlowToolComponent to use self.user_id for consistency

* refactor: remove unused _tree attribute and clean up imports in CustomComponent for better code clarity

* refactor: rename CustomComponent to Component for consistency in directory_reader.py import and usage

* refactor: enhance timestamp handling in _timestamp_to_str for better validation and error reporting in message.py

* refactor: preserve async get_file_content_dicts method for backwards compatibility in message.py

* refactor: update function_entrypoint_name to _function_entrypoint_name for consistency in test_custom_component.py

* feat: add client fixture for improved test structure in test_data_components.py

* feat: add unit tests for PromptComponent including template processing and custom fields in test_prompt_component.py

* feat: add dev dependencies for improved testing and development tools in pyproject.toml
2024-08-05 19:55:29 +00:00
Gabriel Luiz Freitas Almeida
86ca23397e
feat: add possibility to initialize the Graph with components (#3134)
* refactor: update code references to use _code instead of code

* refactor: add backwards compatible attributes to Component class

* refactor: update Component constructor to pass config params with underscore

Refactored the `Component` class in `component.py` to handle inputs and outputs. Added a new method `map_outputs` to map a list of outputs to the component. Also updated the `__init__` method to properly initialize the inputs, outputs, and other attributes. This change improves the flexibility and extensibility of the `Component` class.

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* refactor: change attribute to use underscore

* refactor: update CustomComponent initialization parameters

Refactored the `instantiate_class` function in `loading.py` to update the initialization parameters for the `CustomComponent` class. Changed the parameter names from `user_id`, `parameters`, `vertex`, and `tracing_service` to `_user_id`, `_parameters`, `_vertex`, and `_tracing_service` respectively. This change ensures consistency and improves code readability.

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* refactor: update BaseComponent to accept UUID for _user_id

Updated the `BaseComponent` class in `base_component.py` to accept a `UUID` type for the `_user_id` attribute. This change improves the type safety and ensures consistency with the usage of `_user_id` throughout the codebase.

* refactor: import nanoid with type annotation

The `nanoid` import in `component.py` has been updated to include a type annotation `# type: ignore`. This change ensures that the type checker ignores any errors related to the `nanoid` import.

* fix(custom_component.py): convert _user_id to string before passing to functions to ensure compatibility with function signatures

* feat(component.py): add method to set output types based on method return type to improve type checking and validation in custom components

* refactor: extract method to get method return type in CustomComponent

* refactor(utils.py): refactor code to use _user_id instead of user_id for consistency and clarity

perf(utils.py): optimize code by reusing cc_instance instead of calling get_component_instance multiple times

* refactor(utils.py, base.py): change parameter name 'add_name' to 'keep_name' for clarity and consistency in codebase

* [autofix.ci] apply automated fixes

* refactor: update schema.py to include Edge related typres

The `schema.py` file in the `src/backend/base/langflow/graph/edge` directory has been updated to include the `TargetHandle` and `SourceHandle` models. These models define the structure and attributes of the target and source handles used in the edge data. This change improves the clarity and consistency of the codebase.

* refactor: update BaseInputMixin to handle invalid field types gracefully

The `BaseInputMixin` class in `input_mixin.py` has been updated to handle invalid field types gracefully. Instead of raising an exception, it now returns `FieldTypes.OTHER` for any invalid field type. This change improves the robustness and reliability of the codebase.

* refactor: update file_types field alias in FileMixin

The `file_types` field in the `FileMixin` class of `input_mixin.py` has been updated to use the `alias` parameter instead of `serialization_alias`. This change ensures consistency and improves the clarity of the codebase.

* refactor(inputs): update field_type declarations in various input classes to use SerializableFieldTypes enum for better type safety and clarity

* refactor(inputs): convert dict to Message object in _validate_value method

* refactor(inputs): convert dict to Message object in _validate_value method

* refactor(inputs): update model_config in BaseInputMixin to enable populating by name

The `model_config` attribute in the `BaseInputMixin` class of `input_mixin.py` has been updated to include the `populate_by_name=True` parameter. This change allows the model configuration to be populated by name, improving the flexibility and usability of the codebase.

* refactor: update _extract_return_type method in CustomComponent to accept Any type

The _extract_return_type method in CustomComponent has been updated to accept the Any type as the return_type parameter. This change improves the flexibility and compatibility of the method, allowing it to handle a wider range of return types.

* refactor(component): add get_input and get_output methods for easier access to input and output values

The `Component` class in `component.py` has been updated to include the `get_input` and `get_output` methods. These methods allow for easier retrieval of input and output values by name, improving the usability and readability of the codebase.

* refactor(vertex): add get_input and get_output methods for easier access to input and output values

* refactor(component): add set_output_value method for easier modification of output values

The `Component` class in `component.py` has been updated to include the `set_output_value` method. This method allows for easier modification of output values by name, improving the usability and flexibility of the codebase.

* feat: add run_until_complete and run_in_thread functions for handling asyncio tasks

The `async_helpers.py` file in the `src/backend/base/langflow/utils` directory has been added. This file includes the `run_until_complete` and `run_in_thread` functions, which provide a way to handle asyncio tasks in different scenarios. The `run_until_complete` function checks if an event loop is already running and either runs the coroutine in a separate event loop in a new thread or creates a new event loop and runs the coroutine. The `run_in_thread` function runs the coroutine in a separate thread and returns the result or raises an exception if one occurs. These functions improve the flexibility and usability of the codebase.

* refactor(component): add _edges attribute to Component class for managing edges

The `Component` class in `component.py` has been updated to include the `_edges` attribute. This attribute is a list of `EdgeData` objects and is used for managing edges in the component. This change improves the functionality and organization of the codebase.

* fix(component.py): fix conditional statement to check if self._vertex is not None before accessing its attributes

* refactor(component): add _get_fallback_input method for handling fallback input

The `Component` class in `component.py` has been updated to include the `_get_fallback_input` method. This method returns an `Input` object with the provided keyword arguments, which is used as a fallback input when needed. This change improves the flexibility and readability of the codebase.

* refactor(component): add TYPE_CHECKING import for Vertex in component.py

* refactor(component): add _map_parameters_on_frontend_node and _map_parameters_on_template and other methods

The `Component` class in `component.py` has been refactored to include the `_map_parameters_on_frontend_node` and `_map_parameters_on_template` methods. These methods are responsible for mapping the parameters of the component onto the frontend node and template, respectively. This change improves the organization and maintainability of the codebase.

* refactor(component): Add map_inputs and map_outputs methods for mapping inputs and outputs

The `Component` class in `component.py` has been updated to include the `map_inputs` and `map_outputs` methods. These methods allow for mapping the given inputs and outputs to the component, improving the functionality and organization of the codebase.

* refactor(component): Add Input, Output, and ComponentFrontendNode imports and run_until_complete function

This commit refactors the `component.py` file in the `src/backend/base/langflow/custom/custom_component` directory. It adds the `Input`, `Output`, and `ComponentFrontendNode` imports, as well as the `run_until_complete` function from the `async_helpers.py` file. These changes improve the functionality and organization of the codebase.

* refactor(component): Add map_inputs and map_outputs methods for mapping inputs and outputs

* refactor(component): Add _process_connection_or_parameter method for handling connections and parameters

The `Component` class in `component.py` has been updated to include the `_process_connection_or_parameter` method. This method is responsible for handling connections and parameters based on the provided key and value. It checks if the value is callable and connects it to the component, otherwise it sets the parameter or attribute. This change improves the functionality and organization of the codebase.

* refactor(frontend_node): Add set_field_value_in_template method for updating field values

The `FrontendNode` class in `base.py` has been updated to include the `set_field_value_in_template` method. This method allows for updating the value of a specific field in the template of the frontend node. It iterates through the fields and sets the value of the field with the provided name. This change improves the flexibility and functionality of the codebase.

* refactor(inputs): Add DefaultPromptField class for default prompt inputs

The `inputs.py` file in the `src/backend/base/langflow/inputs` directory has been refactored to include the `DefaultPromptField` class. This class represents a default prompt input with customizable properties such as name, display name, field type, advanced flag, multiline flag, input types, and value. This change improves the flexibility and functionality of the codebase.

* feat: Add Template.from_dict method for creating Template objects from dictionaries

This commit adds the `from_dict` class method to the `Template` class in `base.py`. This method allows for creating `Template` objects from dictionaries by converting the dictionary keys and values into the appropriate `Template` attributes. This change improves the flexibility and functionality of the codebase.

* refactor(frontend_node): Add from_dict method for creating FrontendNode objects from dictionaries

* refactor: update BaseComponent to use get_template_config method

Refactored the `BaseComponent` class in `base_component.py` to use the `get_template_config` method instead of duplicating the code. This change improves code readability and reduces redundancy.

* refactor(graph): Add EdgeData import and update add_nodes_and_edges method signature

The `Graph` class in `base.py` has been updated to include the `EdgeData` import and modify the signature of the `add_nodes_and_edges` method. The `add_nodes_and_edges` method now accepts a list of dictionaries representing `EdgeData` objects instead of a list of dictionaries with string keys and values. This change improves the type safety and clarity of the codebase.

* refactor(graph): Add first_layer property to Graph class

The `Graph` class in `base.py` has been updated to include the `first_layer` property. This property returns the first layer of the graph and throws a `ValueError` if the graph is not prepared. This change improves the functionality and organization of the codebase.

* refactor(graph): Update Graph class instantiation in base.py

The `Graph` class in `base.py` has been updated to use keyword arguments when instantiating the class. This change improves the readability and maintainability of the codebase.

* refactor(graph): Add prepare method to Graph class

The `Graph` class in `base.py` has been updated to include the `prepare` method. This method prepares the graph for execution by validating the stream, building edges, and sorting vertices. It also adds the first layer of vertices to the run manager and sets the run queue. This change improves the functionality and organization of the codebase.

* refactor(graph): Improve graph preparation in retrieve_vertices_order function

The `retrieve_vertices_order` function in `chat.py` has been updated to improve the graph preparation process. Instead of manually sorting vertices and adding them to the run manager, the function now calls the `prepare` method of the `Graph` class. This method validates the stream, builds edges, and sets the first layer of vertices. This change improves the functionality and organization of the codebase.

* refactor: Add GetCache and SetCache protocols for caching functionality

* refactor(graph): Add VertexBuildResult class for representing vertex build results

* refactor(chat.py, base.py): update build_vertex method in chat.py and base.py

* refactor(graph): Update Edge and ContractEdge constructors to use EdgeData type

The constructors of the `Edge` and `ContractEdge` classes in `base.py` have been updated to use the `EdgeData` type for the `edge` and `raw_edge` parameters, respectively. This change improves the type safety and clarity of the codebase.

* feat: add BaseModel class with model_config attribute

A new `BaseModel` class has been added to the `base_model.py` file. This class extends the `PydanticBaseModel` and includes a `model_config` attribute of type `ConfigDict`. This change improves the codebase by providing a base model with a configuration dictionary for models.

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* refactor: update langflow.graph.edge.schema.py

Refactor the `langflow.graph.edge.schema.py` file to include the `TargetHandle` and `SourceHandle` models. This change improves the clarity and consistency of the codebase.

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* refactor(base): Update target_param assignment in Edge class

The `target_param` assignment in the `Edge` class of `base.py` has been updated to use the `cast` function for type hinting. This change improves the type safety and clarity of the codebase.

* refactor(base): Add check for existing type in add_types method

* refactor: update build_custom_component_template to use add_name instead of keep_name

Refactor the `build_custom_component_template` function in `utils.py` to use the `add_name` parameter instead of the deprecated `keep_name` parameter. This change ensures consistency with the updated method signature and improves code clarity.

* feat(component.py): add method to set output types based on method return type to improve type checking and validation in custom components (#3115)

* feat(component.py): add method to set output types based on method return type to improve type checking and validation in custom components

* refactor: extract method to get method return type in CustomComponent

* refactor: update _extract_return_type method in CustomComponent to accept Any type

The _extract_return_type method in CustomComponent has been updated to accept the Any type as the return_type parameter. This change improves the flexibility and compatibility of the method, allowing it to handle a wider range of return types.

* refactor: add _template_config property to BaseComponent

Add a new `_template_config` property to the `BaseComponent` class in `base_component.py`. This property is used to store the template configuration for the custom component. If the `_template_config` property is empty, it is populated by calling the `build_template_config` method. This change improves the efficiency of accessing the template configuration and ensures that it is only built when needed.

* refactor: add type checking for Output types in add_types method

Improve type checking in the `add_types` method of the `Output` class in `base.py`. Check if the `type_` already exists in the `types` list before adding it. This change ensures that duplicate types are not added to the list.

* update starter projects

* refactor: optimize imports in base.py

Optimize imports in the `base.py` file by removing unused imports and organizing the remaining imports. This change improves code readability and reduces unnecessary clutter.

* fix(base.py): fix condition to check if self.types is not None before checking if type_ is in self.types

* refactor: update build_custom_component_template to use add_name instead of keep_name

* refactor(prompts): Update PromptComponent to support custom fields and template updates

The `PromptComponent` class in `Prompt.py` has been updated to support custom fields and template updates. The `_update_template` method has been added to update the prompt template with custom fields. The `post_code_processing` method has been modified to update the template and improve backwards compatibility. The `_get_fallback_input` method has been added to provide a default prompt field. These changes improve the functionality and flexibility of the codebase.

* refactor(base): Add DefaultPromptField to langflow.io

The `DefaultPromptField` class has been added to the `langflow.io` module. This class provides a default prompt field for the `TableInput` class. This change improves the functionality and flexibility of the codebase.

* refactor(prompts): Update PromptComponent to support custom fields and template updates

* refactor(base): Update langflow.template.field.prompt.py for backwards compatibility

* refactor(base): Update langflow.components.__init__.py to import the prompts module

This change adds the prompts module to the list of imports in the __init__.py file of the langflow.components package. This ensures that the prompts module is available for use in the codebase.

* refactor(base): Update langflow.template.field.prompt.py for backwards compatibility

* refactor(graph): Update VertexTypesDict to import vertex types lazily

The VertexTypesDict class in constants.py has been updated to import vertex types lazily. This change improves the performance of the codebase by deferring the import until it is actually needed.

* refactor(graph): Add missing attributes and lock to Graph class

The Graph class in base.py has been updated to add missing attributes and a lock. This change ensures that the necessary attributes are initialized and provides thread safety with the addition of a lock. It improves the functionality and reliability of the codebase.

* refactor(graph): Add method to set inputs in Graph class

The `_set_inputs` method has been added to the Graph class in base.py. This method allows for setting inputs for specific vertices based on input components, inputs, and input type. It improves the functionality and flexibility of the codebase.

* refactor(graph): Set inputs for specific vertices in Graph class

The `_set_inputs` method has been added to the Graph class in base.py. This method allows for setting inputs for specific vertices based on input components, inputs, and input type. It improves the functionality and flexibility of the codebase.

* refactor(graph): Update Graph class to set cache using flow_id

The `Graph` class in `base.py` has been updated to set the cache using the `flow_id` attribute. This change ensures that the cache is properly set when `cache` is enabled and `flow_id` is not None. It improves the functionality and reliability of the codebase.

* refactor(graph): Refactor Graph class to improve edge building

The `Graph` class in `base.py` has been refactored to improve the process of building edges. The `build_edge` method has been added to encapsulate the logic of creating a `ContractEdge` object from the given `EdgeData`. This change enhances the readability and maintainability of the codebase.

* refactor(graph): Update _create_vertex method parameter name for clarity

The `_create_vertex` method in the `Graph` class of `base.py` has been updated to change the parameter name from `vertex` to `frontend_data` for improved clarity. This change enhances the readability and maintainability of the codebase.

* refactor(graph): Update Graph class to return first layer in sort_interface_components_first

The `sort_interface_components_first` method in the `Graph` class of `base.py` has been updated to return just the first layer of vertices. This change improves the functionality of the codebase by providing a more focused and efficient sorting mechanism.

* refactor(graph): Update Graph class to use get_vertex method for building vertices

The _build_vertices method in the Graph class of base.py has been updated to use the get_vertex method instead of creating a new vertex instance. This change improves the efficiency and maintainability of the codebase.

* refactor(graph): Update Graph class to use astep method for asynchronous execution

The `Graph` class in `base.py` has been updated to use the `astep` method for asynchronous execution of vertices. This change improves the efficiency and maintainability of the codebase by leveraging asyncio and allowing for concurrent execution of vertices.

* feat(base.py): implement methods to add components and component edges in the Graph class

* refactor(graph): Import nest_asyncio for asynchronous execution in Graph class

* refactor(base.py): Update Vertex class to handle parameter dictionaries in build_params

The `build_params` method in the `Vertex` class of `base.py` has been updated to handle parameter dictionaries correctly. If the `param_dict` is empty or has more than one key, the method now sets the parameter value to the vertex that is the source of the edge. Otherwise, it sets the parameter value to a dictionary with keys corresponding to the keys in the `param_dict` and values as the vertex that is the source of the edge. This change improves the functionality and maintainability of the codebase.

* refactor(base.py): Add methods to set input values and add component instances in Vertex class

The `Vertex` class in `base.py` has been refactored to include two new methods: `set_input_value` and `add_component_instance`. The `set_input_value` method allows setting input values for a vertex by name, while the `add_component_instance` method adds a component instance to the vertex. These changes enhance the functionality and maintainability of the codebase.

* refactor(message.py): Update _timestamp_to_str to handle datetime or str input

The `_timestamp_to_str` function in `message.py` has been updated to handle both `datetime` and `str` input. If the input is a `datetime` object, it will be formatted as a string using the "%Y-%m-%d %H:%M:%S" format. If the input is already a string, it will be returned as is. This change improves the flexibility and usability of the function.

* refactor(test_base.py): Add unit tests for Graph class

Unit tests have been added to the `test_base.py` file to test the functionality of the `Graph` class. These tests ensure that the graph is prepared correctly, components are added and connected properly, and the graph executes as expected. This change improves the reliability and maintainability of the codebase.

* refactor(initialize/loading.py): Refactor get_instance_results function

The `get_instance_results` function in `initialize/loading.py` has been refactored to simplify the logic for building custom components and components. The previous implementation had separate checks for `CustomComponent` and `Component` types, but the refactored version combines these checks into a single condition based on the `base_type` parameter. This change improves the readability and maintainability of the codebase.

* refactor(component.py): Add set_input_value method to Component class

The `set_input_value` method has been added to the `Component` class in `component.py`. This method allows setting the value of an input by name, and also updates the `load_from_db` attribute if applicable. This change enhances the functionality and maintainability of the codebase.

* refactor(component.py): Set input value in _set_parameter_or_attribute method

The `_set_parameter_or_attribute` method in the `Component` class now sets the input value using the `set_input_value` method. This change improves the clarity and consistency of the codebase.

* refactor(inputs.py): Improve error message for invalid value type

The `SecretStrInput` class in `inputs.py` has been updated to improve the error message when an invalid value type is encountered. Instead of a generic error message, the new message includes the specific value type and the name of the input. This change enhances the clarity and usability of the codebase.

* feat: Add unit test for memory chatbot functionality

* refactor(base.py): Update __repr__ method in ContractEdge class

The `__repr__` method in the `ContractEdge` class of `base.py` has been updated to include the source handle and target handle information when available. This change improves the readability and clarity of the representation of the edge in the codebase.

* refactor(component.py): Update set method to return self

The `set` method in the `Component` class of `component.py` has been updated to return `self` after processing the connection or parameter. This change improves the chaining capability of the method and enhances the readability and consistency of the codebase.

* refactor(starter_projects): Add unit test for vector store RAG

A unit test has been added to the `test_vector_store_rag.py` file in the `starter_projects` directory. This test ensures that the vector store RAG graph is set up correctly and produces the expected results. This change improves the reliability and maintainability of the codebase.

* refactor: remove unused prepare method in Graph class

* refactor: update Output class to use list[str] for types field

* refactor: add name validation to BaseInputMixin

* refactor: update ContractEdge __repr__ method for improved readability and consistency

* refactor: update BaseInputMixin to ensure name field is required with appropriate description

* refactor: remove name validation from BaseInputMixin

* refactor: update input tests to include 'name' field in all input types for better validation and clarity

* refactor: enhance Component class with methods to validate callable outputs and inheritance checks for better robustness

* refactor: disable load_from_db for inputs in Component class to improve input handling logic and prevent unwanted database loading

* refactor: add test for setting invalid output in test_component.py

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-08-05 14:26:13 +00:00
Cristhian Zanforlin Lousa
5dc3ff2b1f
bugfix: parse password on db connection string when it has @ on It (#3173)
*  (test_connection_string.py): add unit test for the transform_connection_string function to ensure correct transformation of connection strings

* 📝 (pgvector.py): add support for parsing and transforming connection string in PGVectorStoreComponent to improve security and maintainability
📝 (connection_string_parser.py): create utility function to transform connection string by encoding password to improve security
📝 (test_connection_string_parser.py): add unit tests for transform_connection_string function to ensure correct transformation of connection string

* test: fix import

---------

Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>
2024-08-05 09:15:33 -03:00
Nicolò Boschi
f311a6db54
feat: ui build in one single http request (#3020)
* feat: ui build in one single http request

* fix use session_id

* fix frozen

* [autofix.ci] apply automated fixes

* prettier

* add tests

* add tests

* fix mypy

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-08-02 06:53:34 -07:00
Gabriel Luiz Freitas Almeida
b5180c4d70
refactor: input field handling and serialization (#3118)
* refactor: update code references to use _code instead of code

* refactor: add backwards compatible attributes to Component class

* refactor: update Component constructor to pass config params with underscore

Refactored the `Component` class in `component.py` to handle inputs and outputs. Added a new method `map_outputs` to map a list of outputs to the component. Also updated the `__init__` method to properly initialize the inputs, outputs, and other attributes. This change improves the flexibility and extensibility of the `Component` class.

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* refactor: change attribute to use underscore

* refactor: update CustomComponent initialization parameters

Refactored the `instantiate_class` function in `loading.py` to update the initialization parameters for the `CustomComponent` class. Changed the parameter names from `user_id`, `parameters`, `vertex`, and `tracing_service` to `_user_id`, `_parameters`, `_vertex`, and `_tracing_service` respectively. This change ensures consistency and improves code readability.

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* refactor: update BaseComponent to accept UUID for _user_id

Updated the `BaseComponent` class in `base_component.py` to accept a `UUID` type for the `_user_id` attribute. This change improves the type safety and ensures consistency with the usage of `_user_id` throughout the codebase.

* refactor: import nanoid with type annotation

The `nanoid` import in `component.py` has been updated to include a type annotation `# type: ignore`. This change ensures that the type checker ignores any errors related to the `nanoid` import.

* fix(custom_component.py): convert _user_id to string before passing to functions to ensure compatibility with function signatures

* feat(component.py): add method to set output types based on method return type to improve type checking and validation in custom components

* refactor: extract method to get method return type in CustomComponent

* refactor(utils.py): refactor code to use _user_id instead of user_id for consistency and clarity

perf(utils.py): optimize code by reusing cc_instance instead of calling get_component_instance multiple times

* refactor(utils.py, base.py): change parameter name 'add_name' to 'keep_name' for clarity and consistency in codebase

* [autofix.ci] apply automated fixes

* refactor: update schema.py to include Edge related typres

The `schema.py` file in the `src/backend/base/langflow/graph/edge` directory has been updated to include the `TargetHandle` and `SourceHandle` models. These models define the structure and attributes of the target and source handles used in the edge data. This change improves the clarity and consistency of the codebase.

* refactor: update BaseInputMixin to handle invalid field types gracefully

The `BaseInputMixin` class in `input_mixin.py` has been updated to handle invalid field types gracefully. Instead of raising an exception, it now returns `FieldTypes.OTHER` for any invalid field type. This change improves the robustness and reliability of the codebase.

* refactor: update file_types field alias in FileMixin

The `file_types` field in the `FileMixin` class of `input_mixin.py` has been updated to use the `alias` parameter instead of `serialization_alias`. This change ensures consistency and improves the clarity of the codebase.

* refactor(inputs): update field_type declarations in various input classes to use SerializableFieldTypes enum for better type safety and clarity

* refactor(inputs): convert dict to Message object in _validate_value method

* refactor(inputs): convert dict to Message object in _validate_value method

* refactor(inputs): update model_config in BaseInputMixin to enable populating by name

The `model_config` attribute in the `BaseInputMixin` class of `input_mixin.py` has been updated to include the `populate_by_name=True` parameter. This change allows the model configuration to be populated by name, improving the flexibility and usability of the codebase.

* refactor: update _extract_return_type method in CustomComponent to accept Any type

The _extract_return_type method in CustomComponent has been updated to accept the Any type as the return_type parameter. This change improves the flexibility and compatibility of the method, allowing it to handle a wider range of return types.

* refactor: update BaseComponent to use get_template_config method

Refactored the `BaseComponent` class in `base_component.py` to use the `get_template_config` method instead of duplicating the code. This change improves code readability and reduces redundancy.

* feat: add BaseModel class with model_config attribute

A new `BaseModel` class has been added to the `base_model.py` file. This class extends the `PydanticBaseModel` and includes a `model_config` attribute of type `ConfigDict`. This change improves the codebase by providing a base model with a configuration dictionary for models.

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* refactor: update langflow.graph.edge.schema.py

Refactor the `langflow.graph.edge.schema.py` file to include the `TargetHandle` and `SourceHandle` models. This change improves the clarity and consistency of the codebase.

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* refactor: update build_custom_component_template to use add_name instead of keep_name

Refactor the `build_custom_component_template` function in `utils.py` to use the `add_name` parameter instead of the deprecated `keep_name` parameter. This change ensures consistency with the updated method signature and improves code clarity.

* feat(component.py): add method to set output types based on method return type to improve type checking and validation in custom components (#3115)

* feat(component.py): add method to set output types based on method return type to improve type checking and validation in custom components

* refactor: extract method to get method return type in CustomComponent

* refactor: update _extract_return_type method in CustomComponent to accept Any type

The _extract_return_type method in CustomComponent has been updated to accept the Any type as the return_type parameter. This change improves the flexibility and compatibility of the method, allowing it to handle a wider range of return types.

* refactor: add _template_config property to BaseComponent

Add a new `_template_config` property to the `BaseComponent` class in `base_component.py`. This property is used to store the template configuration for the custom component. If the `_template_config` property is empty, it is populated by calling the `build_template_config` method. This change improves the efficiency of accessing the template configuration and ensures that it is only built when needed.

* refactor: add type checking for Output types in add_types method

Improve type checking in the `add_types` method of the `Output` class in `base.py`. Check if the `type_` already exists in the `types` list before adding it. This change ensures that duplicate types are not added to the list.

* update starter projects

* refactor: optimize imports in base.py

Optimize imports in the `base.py` file by removing unused imports and organizing the remaining imports. This change improves code readability and reduces unnecessary clutter.

* fix(base.py): fix condition to check if self.types is not None before checking if type_ is in self.types

* refactor: update build_custom_component_template to use add_name instead of keep_name

* feat: update logger warning message for invalid value type in StrInput

* refactor: update logger warning message for invalid value type in StrInput

* refactor: add unit tests for inputs in test_inputs.py

* refactor: update validation for IntInput value type

Improve the validation for the value type in the IntInput class. The updated code ensures that the value is of a valid type (int or float) and converts float values to integers. This change enhances the accuracy and reliability of the input validation process.

* refactor: improve validation for FloatInput value type

Improve the validation for the value type in the FloatInput class. The updated code ensures that the value is of a valid type (int or float) and converts integer values to floats. This change enhances the accuracy and reliability of the input validation process.

* fix(data.py): add validation to check if data is a dictionary before processing to prevent potential errors

* refactor: update test_inputs.py to include comprehensive unit tests for input classes

Add comprehensive unit tests for the input classes in the test_inputs.py file. This change ensures that the input classes are thoroughly tested and functioning correctly. The unit tests cover various scenarios and edge cases to validate the behavior of the input classes. This improvement enhances the reliability and stability of the codebase.

* refactor: remove invalid input tests for DataInput and FileInput in test_inputs.py

Cleaned up unnecessary test cases for invalid input types

* refactor: improve validation for IntInput and FloatInput value types

* refactor: add async version of get_file_content_dicts method in Message class

* refactor: update get_file_content_dicts method in Message class

The `get_file_content_dicts` method in the `Message` class has been updated to use an async version for improved performance. This change enhances the efficiency of retrieving file content dictionaries.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-08-01 11:29:22 -07:00
ming
1dd840c526
feat: set sqlite pragma by env variable (#3136)
* set sqlite pragma by env variable

* configurable

* [autofix.ci] apply automated fixes

* fix circular dep

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Nicolò Boschi <boschi1997@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-08-01 12:48:00 +00:00
Gabriel Luiz Freitas Almeida
e0afe90410
refactor: update code references to use _code instead of code (#3113) 2024-07-31 18:23:34 +00:00
Nicolò Boschi
aa46f320ab
fix: starter projects refresh don't add new fields (#3110)
export stremaing module
2024-07-31 13:43:00 +00:00
Nicolò Boschi
4b650152f7
fix: ensure starter projects refreshed at startup (#3078)
* fix: ensure starter projects refreshed at startup

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-07-31 09:20:05 +02:00
Gabriel Luiz Freitas Almeida
4382e42d77
fix: update message reload and update langchain-core (#3054)
* refactor: update langchain-core to version 0.2.24

* refactor: convert inner messages to BaseMessage in load_lc_prompt method

* refactor: update ChatPromptTemplate instantiation in message.py

* refactor: update langflow-base dependency to use local path for development

* [autofix.ci] apply automated fixes

* refactor: update ChatPromptTemplate instantiation in message.py

* refactor: add async_from_template_and_variables and sync from_template_and_variables

* feat(tests): add unit test for Message schema serialization and prompt loading

* refactor: update langchain-core dependency to version 0.2.24

* chore: new lock

* mypy

* chore: format pyproject

* refactor: rename async_from_template_and_variables to from_template_and_variables in Message class

* refactor: Rename async_from_template_and_variables to from_template_and_variables in Message class

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Nicolò Boschi <boschi1997@gmail.com>
2024-07-30 13:54:51 +00:00
Cristhian Zanforlin Lousa
c2b5b98b64
bugfix: add steps to delete flows caused by new constraints (#3045)
* 📝 (flows.py): refactor delete_multiple_flows function to improve readability and efficiency
 (use-delete-flows.ts): add useDeleteFlows hook to handle deletion of multiple flows in frontend
♻️ (index.tsx): refactor handleDeleteMultiple function to use useDeleteFlows hook for deleting multiple flows
🔧 (actionsMainPage-shard-1.spec.ts): add test for selecting and deleting a flow in end-to-end tests

* 📝 (flows.py): Remove unused imports and variables to clean up the code and improve readability
♻️ (flows.py): Refactor code to remove unnecessary import and variable declarations, making the code more concise and maintainable

* add unit tests to delete multiple flows with transactions and build

* format

* add assert on tests
2024-07-30 13:41:54 +00:00
Nicolò Boschi
c7575b18df
feat: migrate vertex_builds to sql database (#2978)
* feat: migrate vertex_builds to sql database

* [autofix.ci] apply automated fixes

* name

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-07-29 14:58:19 +00:00
Nicolò Boschi
9ac861da2f
feat: migrate transactions to sql database (#2915)
* feat: migrate transactions to sql database

* feat: migrate transactions to sql database

* feat: migrate transactions to sql database

* feat: migrate transactions to sql database

* feat: migrate transactions to sql database

* feat: migrate transactions to sql database

* [autofix.ci] apply automated fixes

* remove useless

* remove useless

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-07-26 14:57:38 +00:00
Nicolò Boschi
53084bcf92
feat: expose main_version on /version endpoint (#2944) 2024-07-26 13:56:18 +02:00
Cristhian Zanforlin Lousa
61265cc327
feat: change download flows to download as .zip file (#2870)
* 📝 (flows.py): Add endpoint to download multiple flows as a zip file
📝 (constants.ts): Add FLOWS constant for API endpoint
📝 (index.ts): Add use-post-download-multiple-flows query function
📝 (use-post-download-multiple-flows.ts): Implement function to download multiple flows as a zip file
📝 (index.tsx): Import usePostDownloadMultipleFlows in componentsComponent
📝 (index.tsx): Implement handleExport function to download multiple flows as a zip file
📝 (index.tsx): Update handleExport function to handle downloading and saving the zip file
📝 (headerComponent.tsx): Add shouldSelectAll state and setShouldSelectAll function to manage select all functionality

* formatting file

* 📝 (flows.py): Remove download_file endpoint and refactor download_multiple_file to support downloading multiple flows as a zip file
📝 (index.tsx): Refactor export functionality to handle exporting multiple flows as a zip file or a single flow as a JSON file
🔧 (use-post-download-multiple-flows.ts): Update API endpoint for downloading flows
🔧 (index.tsx): Remove unused imports and functions related to exporting flows
🔧 (reactflowUtils.ts): Remove unused downloadFlows function and related imports

* [autofix.ci] apply automated fixes

* 📝 (flows.py): remove unnecessary whitespace and improve code readability by aligning function parameters in download_multiple_file function

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-07-23 14:41:55 +00:00
Gabriel Luiz Freitas Almeida
77cc789e62
refactor: separate initialization of nodes and edges in test_graph.py (#2828)
* 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.
2024-07-22 16:48:29 -03:00