🐛 fix(custom_components.py): update import statement for DEFAULT_CUSTOM_COMPONENT_CODE constant
🐛 fix(tools.py): update import statement for DEFAULT_CUSTOM_COMPONENT_CODE constant
The `CustomComponent` class now supports parsing annotated assignments, allowing attributes with annotated values to be added to the `attributes` dictionary. This improves the flexibility and extensibility of the class.
The import statement for the `DEFAULT_CUSTOM_COMPONENT_CODE` constant in `custom_components.py` and `tools.py` has been updated to reflect the correct location of the constant in the `langflow.interface.custom.constants` module. This ensures that the correct value is imported and used in the code.
🔥 chore(constants.py): remove unused DEFAULT_CUSTOM_COMPONENT_CODE constant
The FieldFormatter class now inherits from pydantic.BaseModel, which allows for improved type checking and validation of the format method arguments. The unused DEFAULT_CUSTOM_COMPONENT_CODE constant has been removed to clean up the codebase.
The CustomComponentFrontendNode class is added to the custom_components.py file. This class represents a custom component in the frontend of the application. It has properties such as name, display_name, template, description, and base_classes. The template property defines the structure of the custom component, including a code field with default value. The to_dict() method is also implemented to convert the class instance to a dictionary. This allows the custom component to be serialized and used in other parts of the application.
The custom_components module is now included in the list of exported modules in the frontend_node package. This change allows other modules or packages to import and use the custom components provided by the frontend_node package.
🚀 feat(custom.py): refactor CustomComponent class to remove unused code and improve code organization
The changes in this commit remove unused imports and commented out code from the `custom.py` file. The `CustomComponent` class has been refactored to remove the `CustomComponent_old` class and unused methods. The code has been reorganized to improve readability and maintainability.
The import statement for CustomComponent is no longer needed as it is not used in the CUSTOM_TOOLS dictionary. Removing the unused import and the unused CustomComponent entry from the dictionary improves code cleanliness and reduces potential confusion.
🐛 fix(custom.py): fix typo in function_entrypoint_name variable assignment
The CustomComponent class is added to handle custom code components. It includes methods to handle imports, classes, and functions in the provided code. The class also has methods to extract class information, get entrypoint function arguments and return type, build a template configuration, validate the class template, and get the entrypoint function. A typo in the assignment of the function_entrypoint_name variable is fixed.
🔧 chore(custom): create a custom component creator class to handle custom component creation and loading
The commit adds two new files: `__init__.py` and `base.py` under the `src/backend/langflow/interface/custom` directory. The `__init__.py` file imports the `CustomComponentCreator` and `CustomComponent` classes from the `base.py` file. The `base.py` file defines the `CustomComponentCreator` class, which is responsible for creating and loading custom components. It also includes necessary imports and a `CustomComponentFrontendNode` class.
The addition of these files is necessary to support custom components in the application. The `CustomComponentCreator` class provides a way to create and load custom components, and the `CustomComponent` class represents a custom component. This allows for the dynamic creation and usage of custom components in the application.
This commit adds a new file `constants.py` to the `src/backend/langflow/interface/custom` directory. The file defines a dictionary `LANGCHAIN_BASE_TYPES` which maps string names to corresponding langflow interface custom types. This file will be used to store and access the custom types used in the langflow interface.
🔧 fix(types.py): fix import for CustomComponent class
🔧 fix(types.py): remove unused imports
🔧 fix(types.py): fix function signature for add_new_custom_field
🔧 fix(types.py): fix function signature for build_langchain_template_custom_component
🔧 fix(types.py): fix return type validation and error handling in build_langchain_template_custom_component
🔧 fix(types.py): fix appending base classes to frontend_node in build_langchain_template_custom_component
🔧 fix(types.py): fix return statement in build_langchain_template_custom_component
The changes in this commit fix import statements, function signatures, and error handling in the types.py file. The correct module is now imported for the custom component creator. The import for the CustomComponent class is fixed. Unused imports are removed. The function signature for add_new_custom_field is fixed to include the field_config parameter. The function signature for build_langchain_template_custom_component is fixed to include the field_config parameter. The return type validation and error handling in build_langchain_template_custom_component are fixed to handle invalid return types. The base classes are correctly appended to the frontend_node in build_langchain_template_custom_component. The return statement in build_langchain_template_custom_component is fixed to return the frontend_node.
The type dictionary now includes a new key "custom_components" which contains a list of custom components created using the custom_component_creator. This allows for better organization and management of custom components within the application.
The "CustomComponent" node was removed from the CUSTOM_NODES dictionary as it was no longer being used. This improves code cleanliness and removes unnecessary clutter.
The import statement for CustomComponent has been updated to reflect the correct module path. This ensures that the correct CustomComponent class is imported and used in the code.
✨ feat(settings.py): allow updating custom components in the settings
The `custom_components` attribute has been added to the `Settings` class to support custom components in the application. This allows users to define and use their own components in addition to the built-in ones. The `update_settings` method has been updated to include the `custom_components` attribute when updating the settings. This change improves the flexibility and extensibility of the application.
🔧 chore(GenericNode/index.tsx): optimize rendering of GenericNode component by removing unused useEffect dependency
The console.log statement was removed as it was no longer needed. The useEffect dependency was optimized by removing the unused data.node.template dependency, which improves the performance of the component rendering.
🔧 chore(utils.ts): add support for custom components in nodeColors and nodeNames
The nodeColors and nodeNames objects were updated to include support for custom components. The custom_components key was added to both objects with the corresponding color and display name. This allows for consistent styling and labeling of custom components throughout the application.
🔧 chore(utils.ts): add Sparkles icon for custom_components in nodeIconsLucide
The nodeIconsLucide object was updated to include the Sparkles icon for the custom_components key. This ensures that the custom components are visually represented with an appropriate icon in the application.
🔧 chore(utils.ts): optimize groupByFamily function in utils.ts
The groupByFamily function in utils.ts was optimized to improve performance and readability. The code was refactored to eliminate unnecessary code duplication and improve variable naming. The function now correctly groups the data based on the specified criteria and returns the desired result.
The changes in this commit include:
- Added `overflow-y-scroll` and `overflow-x-clip` classes to the error message container to enable vertical scrolling and prevent horizontal scrolling.
- Added `break-all` class to the error message and traceback to ensure long lines of text are broken and wrapped within the container.
- Added `whitespace-pre-wrap` class to the error message to preserve whitespace and line breaks.
These changes were made to improve the readability of the code and enhance the display of error messages in the CodeAreaModal component.
🔀 fix(config.yaml): fix indentation issue in the custom configuration section
The unused CustomComponent entry has been removed from the tools section to clean up the configuration file. Additionally, a custom configuration section has been added for the CustomComponent, allowing for specific configuration options for this component. The indentation issue in the custom configuration section has also been fixed for consistency.
- Refactored code to replace the deprecated is_valid property with the is_check_valid method.
- Added validation for the entrypoint function name and return type.
- Modified the error messages to provide more specific details.
This commit implements the necessary changes to refactor the CustomComponent class in the endpoints.py file. The is_valid property has been replaced with the is_check_valid method to check the validity of the custom component. Additionally, validation has been added to ensure the presence of a valid entrypoint function and a valid return type. If any of the validation checks fail, appropriate error messages are raised to provide detailed traceback information.
The code in the CustomComponent class has been refactored to improve readability and maintainability. The `_handle_function` method now handles function arguments correctly. Additionally, the `is_valid_class_template` method has been renamed to `_class_template_validation`, and it now raises an HTTPException with a detailed error message when the main class or the build function contains invalid information.
In the `build_langchain_template_custom_component` function, base classes are now retrieved from the `return_type` and added to the `template.base_classes` list. A try-except block is used to handle possible KeyError or AttributeError exceptions, and an HTTPException is raised with the corresponding error message and traceback if an error occurs.
These changes ensure more accurate validation and handle potential errors more gracefully.
feat(baseModal): create a reusable BaseModal component to be used in different modals
fix(codeAreaModal): add missing imports and fix indentation in CodeAreaModal component
refactor(codeAreaModal): refactor handleClick function to handle dynamic and non-dynamic code validation and execution
refactor(codeAreaModal): refactor useEffect to update value prop when code state changes
fix(codeAreaModal/v2): set open prop to true in TwoColumnsModal component
fix(twoColumnsModal): add missing import statement for PopUpContext
refactor(twoColumnsModal): remove unused code and add logic to close modal and reset state when modal is closed
📝 chore(base.py): update comments and remove unused imports
The code in the `Vertex` class has been refactored to improve readability and handle optional parameters more effectively. The code now checks if a parameter is of type "code", "str", or "prompt" and if it is not already set in the `params` dictionary, it sets it to the corresponding value from the `value` dictionary. Additionally, if a parameter is not required and not set in the `params` dictionary, it checks if a default value is provided and sets it to the default value if available, otherwise it removes the parameter from the `params` dictionary. This change improves the handling of optional parameters and makes the code more maintainable.
The TwoColumnsModal component is added to display a modal with two columns. It takes the following props:
- title: the title of the modal
- description: the description of the modal
- open: a boolean indicating whether the modal is open or not
- setOpen: a function to set the open state of the modal
The component renders a Dialog component from the ui/dialog module. It consists of a DialogTrigger, DialogContent, DialogHeader, DialogTitle, and DialogDescription. The DialogContent has a minimum width of 80vw.
Inside the DialogContent, there is a flex container with a height of 80vh and width of 100%. It contains two divs: one with a width of 2/5 and the other with a width of the remaining space.
The TwoColumnsModal component also exports two additional components: first and second. These components can be used as children of the TwoColumnsModal component to render content in the first and second columns, respectively.
The `endpoints` module in the API v1 folder has been modified to remove an unnecessary import and some code duplication. These changes improve the code organization and maintainability.
This commit also removes a commented-out test endpoint that was intended for testing purposes but was never used. The endpoint has been removed from the codebase to avoid confusion and clutter.
The changes include removing an unused import statement from the module and removing an unused endpoint. The unused endpoint was a commented-out code block that contained example error responses. Since these examples were not needed for testing or documentation purposes, the endpoint has been safely removed.
- Refactored the tools module to improve code readability and maintainability.
- Fixed import statements in the constants module to correctly import modules.
- Updated documentation and added comments for better understanding of the code.
feat(codeAreaModal): add support for displaying error details and traceback in the error tab for better debugging
refactor(codeAreaModal): improve code readability and formatting for better maintainability
- Extracted the logic for removing unwanted base classes to a separate method called `process_base_classes`.
- Created a list `CLASSES_TO_REMOVE` which contains the names of the base classes to be removed.
- Updated `to_dict` method to call `process_base_classes` before generating the dict representation of the frontend node.
- Added a new method `process_base_classes` which removes the unwanted base classes from the list of base classes.
- The method `process_base_classes` updates the `base_classes` list, removing any base classes present in `CLASSES_TO_REMOVE`.
This commit enhances the code by separating the concerns of base class removal logic and dict representation generation.
- Modifies the `CustomComponent` class to handle errors using `HTTPException` from FastAPI
- Removes the unused `HTTPExceptionWithTraceback` class
- Updates the error response format with `err.msg` and `traceback.format_exc()`
This commit adds a new class `HTTPExceptionWithTraceback` that extends `HTTPException` from the `fastapi` module. This new class includes a `traceback` attribute. Additionally, in the `extract_class_info` method of the `CustomComponent` class, a try-except block is added to catch any syntax errors raised by parsing the provided code. If a syntax error is encountered, an HTTPException is raised with the error message and traceback.
This commit adds support for dynamic fields in the template field creator class. The "dynamic" attribute has been added to the class definition and its default value is set to False.
This commit adds a dynamic field to the code field in the types module. The dynamic field is set to True, indicating that the field allows updates.
refactor: Remove dynamic field from FrontendNode class
In the FrontendNode class of the base module, the dynamic field has been removed. This change aligns with the removal of the dynamic field in the types module.
refactor: Remove dynamic field from CustomComponentNode class
The dynamic field has been removed from the CustomComponentNode class in the tools module. This aligns with the removal of the dynamic field in the FrontendNode class.
The file mode of the pre-commit hook has been changed from 100644 to 100755. This change ensures that the pre-commit hook has the necessary execution permissions, allowing it to be executed properly before each commit.
🐛 fix(loading.py): remove unnecessary None default value for file_filter parameter
The unused import statement from langchain.prompts.base has been removed to improve code cleanliness. The None default value for the file_filter parameter in the instantiate_documentloader function has been removed as it is unnecessary and can be safely assumed that the parameter will always be provided.
💡 chore(main.py): clean up code by removing an unused endpoint and a template_node variable that is no longer needed
The /dynamic_node endpoint and the template_node variable are no longer used in the application and can be safely removed. This improves code cleanliness and reduces unnecessary complexity.
🐛 fix(base.py): fix __eq__ method in Edge class to correctly compare objects
The add_edge method in the Vertex class has been modified to prevent adding duplicate edges. Now, before adding an edge, it checks if the edge already exists in the edges list to avoid duplicates.
The __eq__ method in the Edge class has been fixed to correctly compare objects. It now compares the string representation of the objects to determine equality, ensuring that the comparison is accurate.
The pre-commit hook in the .githooks directory was not executable, causing it to not be triggered. This commit makes the pre-commit hook executable by adding the `chmod +x` command to set the executable permission on the pre-commit hook file.