Commit graph

1,953 commits

Author SHA1 Message Date
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
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
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
Cristhian Zanforlin Lousa
4f33f02d4f 🐛 fix(parameterComponent): fix syntax error in refHtml.current assignment
🐛 fix(parameterComponent): fix classNames usage in span element
🐛 fix(parameterComponent): remove unnecessary line break element
🐛 fix(parameterComponent): fix className usage in span element
🐛 fix(ShadTooltipComponent): add className prop to TooltipContent component
🐛 fix(utils): fix syntax error in groupByFamily function
 feat(parameterComponent): add support for grouping and displaying multiple types in parameterComponent
 feat(utils): add support for grouping and filtering data in groupByFamily function
2023-07-04 19:08:19 -03:00
gustavoschaedler
13bb0280f5 [extract_info_from_class.py] Remove unnecessary code
This commit removes the file `extract_info_from_class.py` which contained unnecessary code.

[v1/endpoints.py] Fix error handling in custom_component endpoint

This commit fixes the error handling in the `custom_component` endpoint in `endpoints.py`. If the class template extracted from the code is not valid, an error message is printed.

[importing/utils.py] Comment out unused code

This commit comments out unused code in `get_function_custom` function in `utils.py` file.

[initialize/loading.py] Comment out unused code

This commit comments out unused code in the `instantiate_tool` function in `loading.py` file.

[interface/tools/custom.py] Refactor code and add properties

This commit refactors the code in `CustomComponent` class in `custom.py` file. It adds properties for `data`, `is_valid`, and `args_and_return_type`.

[interface/types.py] Add base classes to custom component template

This commit adds base classes to the custom component template in the `build_langchain_template_custom_component` function in `types.py` file.

[utils/constants.py] Remove unnecessary import

This commit removes an unnecessary import in `DEFAULT_CUSTOM_COMPONENT_CODE` constant in `constants.py` file.
2023-07-04 21:00:02 +01:00
anovazzi1
0d6293de17 fix(codeAreaModal): move postCustomComponent call outside of the else block to ensure it is always executed 2023-07-04 15:51:32 -03:00
anovazzi1
da4be03451 using post 2023-07-04 15:46:38 -03:00
anovazzi1
cbcb8bf36d feat(utils.ts): add custom icon for Edit functionality in nodeIconsLucide to improve user experience 2023-07-04 15:32:18 -03:00
anovazzi1
57a12d2084 fix(codeAreaModal): comment out unused code block to improve code readability
fix(codeAreaModal): fix condition in TabsTrigger component to correctly disable the error tab when error detail is undefined
2023-07-04 15:22:38 -03:00
anovazzi1
18a2459131 fix(codeAreaModal): initialize error state with null to avoid undefined error
fix(codeAreaModal): disable second tab trigger if error detail is null to prevent user from switching to it
2023-07-04 15:13:57 -03:00
anovazzi1
562efe2867 new attribute dynamic added 2023-07-04 14:55:17 -03:00
Gabriel Luiz Freitas Almeida
8a4f1406de 🐛 fix(validate.py): fix input_types in add_new_variables_to_template function to use correct input types
The input_types in the add_new_variables_to_template function were incorrect. They were set to ["BaseLoader", "BaseOutputParser"] instead of ["Document", "BaseOutputParser"]. This fix ensures that the correct input types are used for the template field.
2023-07-04 09:49:00 -03:00
Gabriel Luiz Freitas Almeida
9e1bb15003 🐛 fix(main.py): fix formatting of multiline string in my_user_python_function value
🔀 chore(main.py): add trailing commas to dictionary entries for improved readability
The multiline string in the value of the `my_user_python_function` key was not properly formatted. The double quotes were changed to triple quotes to match the Python docstring convention. Trailing commas were added to the dictionary entries for improved readability and maintainability.
2023-07-03 23:27:59 -03:00
Gabriel Luiz Freitas Almeida
3c7ecd15f7 🐛 fix(validate.py): check if variable is already in the list before appending and remove variable from custom_fields and template when not in input_variables
The code now checks if the variable is already in the list before appending it to the custom_fields. Additionally, when removing old variables from the template, the code now also removes the variable from the custom_fields associated with the given name. This ensures that the custom_fields and template stay in sync with the input_variables.
2023-07-03 23:27:49 -03:00
Gabriel Luiz Freitas Almeida
ac4b322c88 🔨 refactor(parameterComponent): improve code formatting and indentation for better readability
The unused import of the lodash library has been removed to clean up the code and reduce unnecessary dependencies. The code formatting and indentation have also been improved to enhance readability and maintain consistency throughout the file.
🔥 refactor(parameterComponent): remove unused import of lodash library
2023-07-03 23:27:27 -03:00
Gabriel Luiz Freitas Almeida
77a1a9c065 added field_name attribute 2023-07-03 23:12:56 -03:00
Gabriel Luiz Freitas Almeida
00f4726f38 🔧 chore(EditNodeModal): reorder CSS classes in DialogContent and TableCell components for consistency
🔧 chore(EditNodeModal): add field_name prop to PromptAreaComponent for better clarity and maintainability

The CSS classes in the DialogContent and TableCell components have been reordered to follow a consistent pattern of ordering. This improves readability and maintainability of the code.

Additionally, a new prop `field_name` has been added to the PromptAreaComponent to provide better clarity and maintainability when working with the component.
2023-07-03 23:12:30 -03:00
Gabriel Luiz Freitas Almeida
67ffdcd0c7 🔧 chore(API/index.ts): add name parameter to postValidatePrompt function for improved code readability
The postValidatePrompt function now accepts a name parameter, which represents the name of the field to check. This change improves the code readability by explicitly specifying the name of the field being validated.
2023-07-03 23:12:18 -03:00
Gabriel Luiz Freitas Almeida
2344c575cf 🔧 fix(promptComponent): fix linting issues and add missing field_name prop
🚀 feat(promptComponent): improve prompt functionality by adding missing field_name prop
Fixed some linting issues in the PromptAreaComponent and added the missing field_name prop to improve code quality and maintainability. The field_name prop was missing, which caused an error in the postValidatePrompt function. This commit also improves the prompt functionality by ensuring that the reactFlowInstance is updated and the nodes are re-rendered when the value changes.
2023-07-03 23:11:37 -03:00
Gabriel Luiz Freitas Almeida
6431b50fa6 🐛 fix(base.py): change custom_fields default value from an empty list to a defaultdict to prevent potential errors
The custom_fields attribute in the FrontendNode class now has a default value of defaultdict(list) instead of an empty list. This change ensures that custom_fields is always a defaultdict, which prevents potential errors when accessing or modifying the custom_fields attribute.
2023-07-03 23:11:08 -03:00
Gabriel Luiz Freitas Almeida
88dbff7bf5 🚀 feat(base.py): add 'name' field to ValidatePromptRequest model for improved data validation
The 'name' field is added to the ValidatePromptRequest model to enhance data validation. This field will allow for more specific identification and validation of prompt names in the API.
2023-07-03 23:10:56 -03:00
Gabriel Luiz Freitas Almeida
d5c7fb9dc5 🐛 fix(validate.py): rename parameter 'prompt' to 'prompt_request' in post_validate_prompt function for clarity
 feat(validate.py): refactor post_validate_prompt function to improve code readability and maintainability
The parameter 'prompt' in the 'post_validate_prompt' function has been renamed to 'prompt_request' to improve clarity and avoid confusion with the 'prompt' variable used within the function. The function has also been refactored to improve code readability and maintainability by extracting logic into separate helper functions. The helper functions 'get_old_custom_fields', 'add_new_variables_to_template', 'remove_old_variables_from_template', and 'update_input_variables_field' have been added to handle specific tasks within the 'post_validate_prompt' function. This refactoring improves the overall structure and organization of the code.
2023-07-03 23:10:41 -03:00
Lucas Oliveira
369a32d53a 🎨 style(extraSidebarComponent): add bottom padding to the overflow container to improve UI spacing 2023-07-03 22:25:02 -03:00