Commit graph

2,922 commits

Author SHA1 Message Date
Gabriel Luiz Freitas Almeida
bed962e513 🔀 refactor(endpoints.py): fix import statement for CustomComponent
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.
2023-07-06 23:52:59 -03:00
Gabriel Luiz Freitas Almeida
a29b83e4fa 🔧 chore(settings.py): add support for custom components in the settings
 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.
2023-07-06 23:52:43 -03:00
Gabriel Luiz Freitas Almeida
a06b47c9a8 🐛 fix(GenericNode/index.tsx): remove unnecessary console.log statement
🔧 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.
2023-07-06 23:51:07 -03:00
anovazzi1
0733b56b8f refactor(codeAreaModal/v2.tsx): improve code readability and error display in CodeAreaModal component
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.
2023-07-06 19:30:37 -03:00
Gabriel Luiz Freitas Almeida
2459e4ecb9 🔀 chore(config.yaml): remove unused CustomComponent entry and add custom configuration for CustomComponent
🔀 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.
2023-07-06 17:42:20 -03:00
gustavoschaedler
38da799224 Add langchain imports and format error detail message
- Import new modules for langchain functionality
- Format error detail message for better readability and organization
2023-07-06 01:05:56 +01:00
gustavoschaedler
11cece92b8 Refactor code for CustomComponent class
- 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.
2023-07-06 01:02:34 +01:00
gustavoschaedler
f92fefba46 Refactor code for CustomComponent class and build_langchain_template_custom_component function
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.
2023-07-06 00:21:35 +01:00
anovazzi1
c9a2ba5821 fix(codeAreaComponent): add key prop to CodeAreaModal component to fix React warning
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
2023-07-05 19:59:08 -03:00
anovazzi1
6391cfd671 Merge branch 'python_custom_node_component' of personal:logspace-ai/langflow into python_custom_node_component 2023-07-05 18:01:27 -03:00
anovazzi1
f6f471cc53 fix(codeAreaComponent): update import path for CodeAreaModal to use v2 version
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
2023-07-05 18:01:16 -03:00
anovazzi1
27776f473f subcomponents with type assertion 2023-07-05 17:49:44 -03:00
anovazzi1
e832711a1f first modal with subcomponents 2023-07-05 17:04:32 -03:00
Gabriel Luiz Freitas Almeida
d9891b9c86 🔧 chore(base.py): refactor code to improve readability and handle optional parameters
📝 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.
2023-07-05 17:00:50 -03:00
anovazzi1
b7124de011 Merge branch 'python_custom_node_component' of personal:logspace-ai/langflow into python_custom_node_component 2023-07-05 16:04:47 -03:00
anovazzi1
754cfceab6 feat(twoColumnsModal): add TwoColumnsModal component to display a modal with two columns
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.
2023-07-05 16:04:42 -03:00
gustavoschaedler
f12efa104d Refactor API v1 endpoints and remove unnecessary imports and code duplication
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.
2023-07-05 19:59:38 +01:00
gustavoschaedler
ecbb0feeab Refactor tools and constants modules
- 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.
2023-07-05 19:57:28 +01:00
gustavoschaedler
e3b6037fe9 Merge from form_io to python_custom_node_component 2023-07-05 19:56:41 +01:00
anovazzi1
b5c7646b37 fix(codeAreaModal): update error state type to match API response structure for better error handling
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
2023-07-05 14:01:09 -03:00
gustavoschaedler
68c6ac8ea2 Refactor base class removal logic and add dict representation
- 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.
2023-07-05 17:23:53 +01:00
gustavoschaedler
ae5bc1e203 Refactor custom.py for better error handling
- 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()`
2023-07-05 16:23:32 +01:00
gustavoschaedler
a21582589c import custom.py: Add HTTPExceptionWithTraceback class
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.
2023-07-05 16:22:22 +01:00
gustavoschaedler
53656dcc1f feat: Add dynamic field support
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.
2023-07-05 15:04:22 +01:00
anovazzi1
ffb8e17eb6 Merge branch 'python_custom_node_component' of personal:logspace-ai/langflow into python_custom_node_component 2023-07-05 10:52:19 -03:00
anovazzi1
900aacb5fb debug dynamic on console 2023-07-05 10:52:10 -03:00
gustavoschaedler
bc809c6a9e Add dynamic option for custom component code in FrontendNode. 2023-07-05 14:51:57 +01:00
gustavoschaedler
617552d212 Merge branch 'python_custom_node_component' of github.com:logspace-ai/langflow into python_custom_node_component 2023-07-05 14:44:18 +01:00
gustavoschaedler
fd16b385ab feat: Add dynamic field to code field in types module
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.
2023-07-05 14:44:11 +01:00
anovazzi1
8b0a39f6ee fix(codeAreaModal): move postCustomComponent call inside else block to prevent unnecessary API calls when condition is false
fix(codeAreaModal): remove commented out code for axios.get call
2023-07-05 10:44:00 -03:00
Gabriel Luiz Freitas Almeida
8d77e51037 🔧 chore(pre-commit): change file mode from 100644 to 100755 for better execution permissions
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.
2023-07-05 09:49:18 -03:00
Gabriel Luiz Freitas Almeida
a69225bb07 🔧 chore(loading.py): remove unused import statement
🐛 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.
2023-07-05 09:46:27 -03:00
Gabriel Luiz Freitas Almeida
5879ad99f2 🔥 refactor(main.py): remove unused /dynamic_node endpoint and template_node variable
💡 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.
2023-07-05 09:41:40 -03:00
Gabriel Luiz Freitas Almeida
3059e8c670 🐛 fix(base.py): fix add_edge method to prevent adding duplicate edges
🐛 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.
2023-07-05 09:37:25 -03:00
Cristhian Zanforlin Lousa
864fb2f8ef Merge branch 'form_io' of https://github.com/logspace-ai/langflow into form_io 2023-07-05 06:52:07 -03:00
Cristhian Zanforlin Lousa
b8e76b0be4 🐛 fix(parameterComponent): remove unnecessary line break to improve code readability
🐛 fix(utils.ts): set 'type' property to an empty string instead of undefined to avoid potential issues
2023-07-05 06:52:01 -03:00
Gabriel Luiz Freitas Almeida
6d9bcd5e65 🔧 chore(Makefile): make pre-commit hook executable
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.
2023-07-05 00:03:32 -03:00
Gabriel Luiz Freitas Almeida
10bbb8e901 style: improve readability 2023-07-05 00:01:06 -03:00
Gabriel Luiz Freitas Almeida
834429cd37 fix: add verification for formKeysData 2023-07-04 23:58:54 -03:00
gustavoschaedler
48345dd8dd Refactor MyPythonClass build method to accept openai_api_key parameter.
- The `build` method of `MyPythonClass` is modified to accept an `openai_api_key` parameter instead of using a hardcoded value.
- This change allows for dynamic usage of different API keys when constructing an instance of `ConversationChain`.
- The `my_conversation` method now takes `openai_api_key` as an argument and uses it to initialize the `llm` instance of `OpenAI`.
- The `build` method simply delegates the `openai_api_key` argument to the `my_conversation` method and returns the resulting `ConversationChain` instance.
2023-07-05 03:37:18 +01:00
gustavoschaedler
839e9737cc Refactor code to extract class name from custom code
- Updatethe `get_function_custom` function to use the `validate.extract_class_name` function to extract class name from the `code` parameter.
- Modify `instantiate_tool` function to update the `class_object` with the return value of `get_function_custom` and call the `build` method on the instantiated object with the remaining params.
- Add a new function `extract_class_name` in the `validate` module to extract class name from the `code` parameter.
2023-07-05 03:34:16 +01:00
Gabriel Luiz Freitas Almeida
5445adbbce 🐛 fix(validate.py): set new field value with the old value if variable already exists in the template
The code now checks if the variable already exists in the template and if so, sets the new field value with the old value. This ensures that the existing value is preserved when adding new variables to the template.
2023-07-04 23:32:25 -03:00
Gabriel Luiz Freitas Almeida
244aeae916 🔧 chore(validate.py): add multiline option to input_variables field in add_new_variables_to_template function
The multiline option is added to the input_variables field in the add_new_variables_to_template function. This allows the field to accept multiline input, which can be useful in certain scenarios where multiple lines of text need to be entered.
2023-07-04 23:30:24 -03:00
Gabriel Luiz Freitas Almeida
44011f3dd5 🐛 fix(GenericNode/index.tsx): fix class order in div element to ensure correct styling
 feat(GenericNode/index.tsx): improve readability and maintainability by extracting repeated class names into variables
The class order in the div element has been fixed to ensure the correct styling is applied. Repeated class names have been extracted into variables to improve readability and maintainability of the code.
2023-07-04 23:30:23 -03:00
gustavoschaedler
ac569f3405 Refactor code, improve type validation, and update build function name 2023-07-05 02:03:22 +01:00
gustavoschaedler
64e5a3a98d Add a dynamic flag to CustomComponentNode
- Added a dynamic flag to CustomComponentNode class in tools.py for enabling dynamic behavior.
- This flag allows for flexibility in executing the Python class.
- The flag defaults to True.
2023-07-05 01:30:40 +01:00
gustavoschaedler
4028554ef6 Refactor build method argument name for clarity
Previously, the `build` method in the `MyPythonClass` class had an argument named `name`, which could be confusing. This commit changes the argument name to `my_custom_input` to improve readability and clarity.
2023-07-05 00:57:16 +01:00
gustavoschaedler
92b747b6da Update Vertex params with code type and add a my_conversation method to the MyPythonClass. Modify the instantiate_tool function to properly handle the CustomComponent node type. Add a dynamic field to the FrontendNode class. 2023-07-05 00:46:51 +01:00
Cristhian Zanforlin Lousa
3f0cc57cd5 🐛 fix(parameterComponent): fix styling issue in tooltip and icon rendering in ParameterComponent 2023-07-04 19:24:37 -03:00
Cristhian Zanforlin Lousa
80efed1d91 adjust edge tooltips 2023-07-04 19:11:15 -03:00