Commit graph

1,062 commits

Author SHA1 Message Date
Gabriel Luiz Freitas Almeida
74e263811b 🔨 refactor(types.py): import CustomComponentFrontendNode from custom_components module to improve code organization and readability
🔨 refactor(types.py): change usage of CustomComponentNode to CustomComponentFrontendNode to align with updated module structure

🔨 refactor(frontend_node/base.py): add beta flag to FrontendNode class to indicate if a node is in beta stage

🔨 refactor(custom_components.py): add beta flag to CustomComponentFrontendNode class to indicate it is in beta stage

🔨 refactor(tools.py): remove unused import of DEFAULT_CUSTOM_COMPONENT_CODE

🔨 refactor(tools.py): remove CustomComponentNode class as it is no longer used
2023-07-25 17:22:02 -03:00
Gabriel Luiz Freitas Almeida
b76141b3df 🔄 refactor(custom_component.py): rename list_flow_names method to list_flows for better clarity and consistency
🐛 fix(custom_component.py): fix return value of list_flows method to return the actual flow objects instead of just their names
🔥 chore(custom_component.py): remove unused build method as it is not implemented
2023-07-25 17:12:48 -03:00
Gabriel Luiz Freitas Almeida
46c6afd85f 🔥 refactor(main.py): remove commented out code for getting log level in create_app() function
🔒 chore(main.py): configure logger in create_app() function to ensure proper logging setup
2023-07-25 15:13:43 -03:00
Gabriel Luiz Freitas Almeida
a928005b7b 🐛 fix(endpoints.py): change import statement for typing module to import Annotated from typing module to fix type hinting error
 feat(endpoints.py): add support for clear_cache parameter in process_flow endpoint to allow clearing the cache before processing the flow
🐛 fix(process.py): add logic to clear cache if clear_cache parameter is True in process_graph_cached function to fix caching issue
2023-07-25 15:04:41 -03:00
Gabriel Luiz Freitas Almeida
c83060ed58 🐛 fix(base.py): import CLASSES_TO_REMOVE constant from constants module to fix NameError
🔀 chore(constants.py): add CLASSES_TO_REMOVE constant to store classes to be removed from base.py module
2023-07-25 14:21:43 -03:00
Gabriel Luiz Freitas Almeida
12933ccf52 🔧 chore(__main__.py): add debug logs to update_settings function for better troubleshooting
 feat(__main__.py): add support for loading settings from a specified config file
 feat(__main__.py): add support for setting remove_api_keys flag
 feat(__main__.py): add support for setting cache flag
 feat(__main__.py): add support for adding component path
2023-07-25 13:53:39 -03:00
Gabriel Luiz Freitas Almeida
0095fc4753 🔧 chore(settings.py): add BASE_COMPONENTS_PATH constant to improve code readability and maintainability
🔧 chore(settings.py): add support for LANGFLOW_COMPONENT_PATH environment variable to allow custom component paths to be added
2023-07-25 12:16:06 -03:00
Gabriel Luiz Freitas Almeida
aebdfad63c 🔀 chore(config.yaml): rename 'custom' section to 'custom_components' for better clarity and consistency 2023-07-25 12:03:28 -03:00
Gabriel Luiz Freitas Almeida
aa387f89b3 🐛 fix(types.py): add error handling when building custom components to prevent crashes and log the error message 2023-07-25 11:47:21 -03:00
Gabriel Luiz Freitas Almeida
eb94b957b5 🐛 fix(endpoints.py): fix merging of custom component dictionaries from multiple paths
 feat(endpoints.py): add support for merging custom component dictionaries from multiple paths to build the final dictionary of all components
2023-07-25 11:46:57 -03:00
Gabriel Luiz Freitas Almeida
ac0aa71c10 🐛 fix(__main__.py): add support for component_path parameter to update_settings function
 feat(__main__.py): add component_path option to serve command to specify the directory containing custom components
🐛 fix(settings.py): modify update_settings function to handle list attributes correctly
2023-07-25 10:58:08 -03:00
Gabriel Luiz Freitas Almeida
17e84e4b2e 🔨 refactor(endpoints.py): rename directory_loader module to directory_reader for better naming consistency
🔨 refactor(endpoints.py): rename directory_loader import to directory_reader for better naming consistency
🔨 refactor(directory_reader.py): rename directory_loader module to directory_reader for better naming consistency
🔨 refactor(types.py): rename directory_loader import to directory_reader for better naming consistency
2023-07-25 10:58:07 -03:00
Gabriel Luiz Freitas Almeida
eece41a69a 🔨 refactor(endpoints.py): rename 'load_custom_component_from_path' module to 'directory_loader' for better clarity and consistency
🔨 refactor(types.py): rename 'load_custom_component_from_path' module to 'directory_loader' for better clarity and consistency
2023-07-25 10:06:26 -03:00
Lucas Oliveira
b6ee0ff800 Merge branch 'modalRefactor' into python_custom_node_component 2023-07-23 19:50:51 -03:00
Gabriel Luiz Freitas Almeida
564b113c3a 🔧 chore(main.py): configure logger in create_app function to improve logging configuration
🔧 chore(logger.py): change default log level to DEBUG in configure function for more detailed logging
2023-07-21 23:58:28 -03:00
Gabriel Luiz Freitas Almeida
80db6b910e 🔧 fix(__main__.py): import get_number_of_workers function from langflow.utils.util module to fix NameError
🔧 fix(__main__.py): change default value of workers option to -1 to indicate automatic calculation of number of workers
🔧 fix(__main__.py): remove unused import of cpu_count from multiprocess module
🔧 fix(__main__.py): remove unused import of time module
🔧 fix(__main__.py): remove unused import of httpx module
🔧 fix(__main__.py): remove unused import of sys module
🔧 fix(__main__.py): remove unused import of os module
🔧 fix(__main__.py): remove unused import of Path class from pathlib module
🔧 fix(__main__.py): remove unused import of load_dotenv function from dotenv module
🔧 fix(__main__.py): remove unused import of typer module
🔧 fix(__main__.py): remove unused import of app object from typer module
🔧 fix(__main__.py): remove unused import of Optional type from typing module
🔧 fix(__main__.py): remove unused import of Process class from multiprocess module
🔧 fix(__main__.py): remove unused import of platform module
🔧 fix(__main__.py): remove unused import of update_settings function
🔧 fix(__main__.py): remove unused import of run_langflow function
🔧 fix(util.py): import logger from langflow.utils.logger module to fix NameError
🔧 fix(util.py): import cpu_count from multiprocess module to fix NameError
🔧 fix(util.py): add default value of None to workers parameter in get_number_of_workers function to fix TypeError
2023-07-21 23:57:52 -03:00
Gabriel Luiz Freitas Almeida
cf688adf53 🚀 feat(custom_component.py): add method list_flow_names() to retrieve a list of flow names from the database
🐛 fix(custom_component.py): remove unused build() method to improve code cleanliness and avoid confusion
2023-07-21 23:15:53 -03:00
Gabriel Luiz Freitas Almeida
67e12c425f 🔀 chore(constants.py): add "str" as a base type in LANGCHAIN_BASE_TYPES to support string values in custom interfaces 2023-07-21 23:15:26 -03:00
Gabriel Luiz Freitas Almeida
6f300ddf94 🐛 fix(custom_component.py): add missing build_config method to CustomComponent class
🐛 fix(types.py): update build_langchain_template_custom_component function to use build_config method of CustomComponent class
2023-07-21 19:09:20 -03:00
gustavoschaedler
e84aca717b 🔀 chore(endpoints.py): move merge_nested_dicts function to correct local scope
🐛 fix(endpoints.py): fix get_all endpoint to correctly merge native_components and custom_components_from_file dictionaries
2023-07-21 22:32:54 +01:00
gustavoschaedler
548383b09e 🐛 fix(endpoints.py): add missing import statement for 'settings' module
 feat(endpoints.py): add support for loading custom components from a specified path
🐛 fix(endpoints.py): fix typo in variable name 'custom_components_from_file'
🐛 fix(endpoints.py): fix typo in variable name 'filtered'
🐛 fix(base.py): fix indentation of raise statement to improve code readability
🐛 fix(component.py): fix indentation of if statements to improve code readability
🐛 fix(load_custom_component_from_path.py): fix indentation of base_path comment to improve code readability
🐛 fix(load_custom_component_from_path.py): fix indentation of base_path assignment to improve code readability
🐛 fix(load_custom_component_from_path.py): fix indentation of validate_code method to improve code readability
🐛 fix(load_custom_component_from_path.py): fix indentation of build_component_menu_list method to improve code readability
🐛 fix(types.py): fix indentation of extract_type_from_optional function to improve code readability
 feat(types.py): add support for building custom component templates
 feat(types.py): add support for building custom component templates with extra fields
 feat(types.py): add support for building custom component templates with function arguments
 feat(types.py): add support for building custom component templates with base classes
 feat(types.py): add support for building custom component templates with return type
 feat(types.py): add support for building custom component templates with exception handling
 feat(types.py): add support for building custom component templates from a specified path
🐛 fix(settings.py): fix indentation of set_env_variables method to improve code readability
 feat(settings.py): add support for specifying component path in settings

🐛 fix(test_custom_component.py): change variable names and attributes in YourComponent class for better readability and consistency
🐛 fix(test_custom_component.py): reformat code to adhere to PEP8 style guide
🐛 fix(test_custom_component.py): fix syntax error in test_component_get_code_tree_syntax_error()
🐛 fix(test_custom_component.py): fix syntax error in test_custom_component_class_template_validation_no_code()
🐛 fix(test_custom_component.py): fix syntax error in test_custom_component_get_main_class_name_no_main_class()
 feat(test_custom_component.py): add test_component_get_function_valid() to test the get_function method of the Component class with valid code and function_entrypoint_name
 feat(test_custom_component.py): add test_code_parser_parse_assign() to test the parse_assign method of the CodeParser class
 feat(test_custom_component.py): add test_custom_component_class_template_validation_no_code() to test the _class_template_validation method of the CustomComponent class when the code is None
 feat(test_custom_component.py): add test_custom_component_get_main_class_name_no_main_class() to test the get_main_class_name method of the CustomComponent class when there is no main class
 feat(test_custom_component.py): add test_custom_component_get_function_entrypoint_args_no_args() to test the get_function_entrypoint_args method of the CustomComponent class when there are no arguments
 feat(test_custom_component.py): add test_custom_component_get_function_entrypoint_return_type_none() to test the get_function_entrypoint_return_type method of the CustomComponent class when the return type is None
2023-07-21 19:13:52 +01:00
Gabriel Luiz Freitas Almeida
33f8b63431 🐛 fix(loading.py): refactor instantiate_custom_component function to improve readability and maintainability 2023-07-21 09:27:30 -03:00
Gabriel Luiz Freitas Almeida
e835d4a0e9 🐛 fix(types.py): change base_type from "tools" to "custom_components" for CustomComponentVertex to improve categorization
🔧 refactor(types.py): modify _built_object_repr method in CustomComponentVertex to handle custom representation if available in artifacts
2023-07-21 09:27:04 -03:00
Gabriel Luiz Freitas Almeida
4307c24c6d 🐛 fix(custom_component.py): fix session handling in load_flow method to ensure proper context management and avoid potential resource leaks
 feat(custom_component.py): add custom_repr method to CustomComponent class to provide a custom representation value for the component
2023-07-21 09:25:55 -03:00
Gabriel Luiz Freitas Almeida
b64d43fe22 🔀 chore(constants.py): update import statement for custom component creator in vertex type map
🔀 chore(constants.py): update vertex type map to include custom component vertices using custom_component_creator
2023-07-21 09:25:33 -03:00
Gabriel Luiz Freitas Almeida
a722fe063b 🔧 chore(base.py): import contextlib's contextmanager to improve code readability and maintainability
 feat(base.py): add session_getter context manager to handle session creation, rollback, and closure in a more robust way
🔧 chore(base.py): update get_session function to use session_getter context manager for session creation
2023-07-21 09:24:59 -03:00
Gabriel Luiz Freitas Almeida
9811b97908 🐛 fix(base.py): fix validation logic in _validate_nodes method to handle case when there is only one node in the graph 2023-07-21 08:56:34 -03:00
Gabriel Luiz Freitas Almeida
a0748e1093 🐛 fix(base.py): fix validation logic in _validate_nodes method to handle case when there is only one node in the graph 2023-07-21 08:55:31 -03:00
gustavoschaedler
7b22e0780f 🐛 fix(endpoints.py): handle CustomComponentPathValueError and raise HTTPException with error details
🐛 fix(chat/manager.py): rename exception variable from e to exc for clarity
🐛 fix(load_custom_component_from_path.py): handle case when file_path does not exist and return None
🐛 fix(load_custom_component_from_path.py): raise CustomComponentPathValueError if directory path is invalid
🐛 fix(load_custom_component_from_path.py): handle case when file_content is None and return error message
2023-07-20 23:35:02 +01:00
gustavoschaedler
5f8439ae7e 🔧 chore(.gitignore): add /tmp/* to the gitignore file to exclude temporary files from version control
 feat(endpoints.py): add new endpoint to load custom components from a specified path
📦 feat(load_custom_component_from_path.py): add new module to load custom components from a directory path
🔧 chore(types.py): add function to build and validate custom components from a directory path
2023-07-20 21:39:07 +01:00
Gabriel Luiz Freitas Almeida
30968e089f 🐛 fix(callback.py): improve error logging by including the specific error message
🐛 fix(chat.py): improve error logging by including the specific error message
🐛 fix(manager.py): improve error logging by including the specific error message
🐛 fix(base.py): improve error logging by including the specific error message
🐛 fix(processing/base.py): improve error logging by including the specific error message
2023-07-20 16:34:25 -03:00
Gabriel Luiz Freitas Almeida
7193bb4488 🐛 fix(custom_component.py): fix session context and add error handling for flow not found 2023-07-20 15:38:22 -03:00
Gabriel Luiz Freitas Almeida
c5bf15a2c4 🔧 fix(custom_component.py): fix import statements and refactor load_flow method to use UUID and improve code readability
🔀 merge(custom_component.py): merge changes from langflow.processing.process module to load_flow method to improve performance and data retrieval
2023-07-20 15:09:51 -03:00
gustavoschaedler
eb7158ad26 🔨 refactor(custom_component.py): remove unused imports and unused load_flow method parameters for better code cleanliness
🔨 refactor(custom_component.py): update load_flow method to use the process_flow function from the api endpoints module for improved modularity and separation of concerns
2023-07-20 18:56:46 +01:00
gustavoschaedler
2513cbcdd9 🔧 chore(custom_component.py): reformat code for better readability and maintainability
🚀 feat(custom_component.py): add `load_flow` method to load a flow from the database using session and flow_id
2023-07-20 18:35:53 +01:00
Gabriel Luiz Freitas Almeida
583eca137a feat(logger.py): configure default logger with optional log level and log file parameters for better customization
🔧 chore(logger.py): remove unnecessary blank lines and comments for cleaner code
2023-07-20 09:09:17 -03:00
Gabriel Luiz Freitas Almeida
1ab0dd6257 🐛 fix(main.py): add error handling for non-existent static files directory 2023-07-20 07:11:46 -03:00
Gabriel Luiz Freitas Almeida
55f468be3d 🐛 fix(chat.py): add exception logging to track errors in stream_build function 2023-07-20 06:59:04 -03:00
Gabriel Luiz Freitas Almeida
e648ac4f41 🐛 fix(types.py): convert avg_length to an integer to improve readability in DocumentLoaderVertex and TextSplitterVertex 2023-07-20 06:58:39 -03:00
Gabriel Luiz Freitas Almeida
0cf37f4f1f 🐛 fix(base.py): add check to initialize empty list for params[key] if it doesn't exist before extending it with built values
Fixes textsplitter error #661
2023-07-20 06:58:21 -03:00
Gabriel Luiz Freitas Almeida
0b283f8703 🐛 fix(types.py): convert avg_length to an integer to improve readability in DocumentLoaderVertex and TextSplitterVertex 2023-07-19 17:59:04 -03:00
gustavoschaedler
9adff855fb 🔧 chore(constants.py): update class attribute names to follow Langflow naming convention for better consistency and clarity
 feat(load_custom_component_from_file.py): add functionality to compress and decompress code, validate code syntax, validate build function presence, read file content, get list of .py files in a directory, find menu by name in response, process file by validating content and returning result and content/error message, and build component menu list from .py files in a directory
2023-07-19 21:16:36 +01:00
Gabriel Luiz Freitas Almeida
58d7491d83 🔨 refactor(endpoints.py): rename langchain_types_dict import to build_langchain_types_dict for clarity and consistency
🔨 refactor(types.py): remove unused langchain_types_dict variable to improve code cleanliness
2023-07-19 10:00:47 -03:00
Gabriel Luiz Freitas Almeida
4827c99368 🐛 fix(code_parser.py): handle case when code parameter is a class by getting its source code using inspect module
 feat(code_parser.py): add support for parsing class source code in addition to string source code to improve flexibility and usability
2023-07-19 07:03:54 -03:00
gustavoschaedler
598a833b75 🐛 fix(util.py): fix import order to follow PEP8 guidelines for better readability and maintainability
 feat(util.py): add sync_to_async decorator to convert sync functions to async functions for better performance and compatibility
🐛 fix(util.py): fix formatting of dictionary by removing certain keys and modifying the values of other keys to improve consistency and clarity
🐛 fix(util.py): fix update_verbose function to recursively update the value of the 'verbose' key in a dictionary
🐛 fix(util.py): fix update_verbose function to correctly handle nested dictionaries
🐛 fix(util.py): fix update_verbose function to correctly handle non-dictionary values
🐛 fix(util.py): fix format_dict function to correctly handle the 'type' value when it is a type object
🐛 fix(util.py): fix format_dict function to correctly handle the 'type' value when it is a list type
🐛 fix(util.py): fix format_dict function to correctly handle the 'type' value when it is a Mapping type
🐛 fix(util.py): fix format_dict function to correctly handle the 'type' value when it is a dict type
🐛 fix(util.py): fix format_dict function to correctly handle the 'type' value when it is a Tool type
🐛 fix(util.py): fix format_dict function to correctly handle the 'type' value when it is an int type
🐛 fix(util.py): fix format_dict function to correctly handle the 'show' value based on field requirements and naming conventions
🐛 fix(util.py): fix format_dict function to correctly handle the 'password' value based on field naming conventions
🐛 fix(util.py): fix format_dict function to correctly handle the 'multiline' value based on field naming conventions
🐛 fix(util.py): fix format_dict function to correctly handle the 'type' value when it is a dict type for the 'dict_' key
🐛 fix(util.py): fix format_dict function to correctly handle the 'value' field when it is a default value
🐛 fix(util.py): fix format_dict function to correctly handle the 'value' field for the 'headers' key
🐛 fix(util.py): fix format_dict function to correctly handle the 'options' field for specific class and key combinations
2023-07-18 18:47:04 +01:00
Gabriel Luiz Freitas Almeida
ab61890997 🔀 refactor(main.py): extract get_static_files_dir() function to improve code readability and reusability
🔀 refactor(main.py): simplify setup_app() function by using get_static_files_dir() function to get static files directory
2023-07-18 07:26:30 -03:00
gustavoschaedler
cee4740b0f 🔧 fix(custom_component.py): add line break to improve readability of TODO comment
🔧 fix(index.tsx): remove unused imports to clean up code

🔧 fix(utils.ts): add space before opening parenthesis to improve code style

🔧 fix(test_custom_component.py): add line breaks to improve readability of test cases
2023-07-18 02:05:37 +01:00
gustavoschaedler
0aab360629 🔨 refactor(langflow): improve code parsing and custom component handling
- Refactor code parsing in `code_parser.py` to handle imports, function definitions, and class attributes more robustly and cleanly.
- Add new methods in `component.py` to parse Assign and AnnAssign statements, and FunctionDef statements.
- Refactor `custom_component.py` to improve the handling of custom components, including better extraction of main class name and template configuration.
- Update `types.py` to better handle the building of custom component templates, including handling of field configurations and error handling.
- Minor formatting fix in `conftest.py` test fixture.

These changes improve the robustness and readability of the code, and provide better handling and validation of custom components.
2023-07-15 00:41:31 +01:00
Gabriel Luiz Freitas Almeida
82b973de43 🔧 fix(frontend_node/textsplitters.py): add is_list=True to the 'documents' parameter to indicate it is a list
🔧 fix(frontend_node/vectorstores.py): add is_list=True to the 'field' parameter to indicate it is a list
2023-07-14 18:37:30 -03:00
gustavoschaedler
f2687fa926 Merge branch 'python_custom_node_component' of github.com:logspace-ai/langflow into python_custom_node_component 2023-07-14 18:36:23 +01:00