The `process_base_classes` method in the `FrontendNode` class is no longer used and can be safely removed to improve code readability and maintainability.
Merge remote-tracking branch 'origin/form_io' into python_custom_node_component
- Updated the README files to correct the spelling of "Langflow" in various places.
- Added a new `.env.example` file for reference and configuration.
- Updated the CONTRIBUTING.md file to use "Langflow" instead of "LangFlow".
- Updated the GCP_DEPLOYMENT.md file to use the correct GitHub repository URL.
- Updated the README file to use "Langflow" instead of "LangFlow" and corrected the formatting of the table of contents.
- Updated the CLI usage instructions in the README file to use "Langflow" and provided more detailed explanations of each option.
- Added a section on Deployment in the README file with instructions for deploying Langflow on Google Cloud Platform.
- Updated the "Creating Flows" section in the README file to use "Langflow" instead of "LangFlow" and corrected the link to the LangChain components.
- Updated the "Contributing" section in the README file to use "Langflow" instead of "LangFlow" and corrected the link to the contributing guidelines.
- Updated the "License" section in the README file to use "Langflow" instead of "LangFlow".
- Updated the version of the "anyio" package in the poetry.lock file to 3.7.1.
Merge remote-tracking branch 'origin/form_io' into python_custom_node_component
- Updated the README files to correct the spelling of "Langflow" in various places.
- Added a new `.env.example` file for reference and configuration.
- Updated the CONTRIBUTING.md file to use "Langflow" instead of "Langflow".
- Updated the GCP_DEPLOYMENT.md file to use the correct GitHub repository URL.
- Updated the README file to use "Langflow" instead of "Langflow" and corrected the formatting of the table of contents.
- Updated the CLI usage instructions in the README file to use "Langflow" and provided more detailed explanations of each option.
- Added a section on Deployment in the README file with instructions for deploying Langflow on Google Cloud Platform.
- Updated the "Creating Flows" section in the README file to use "Langflow" instead of "Langflow" and corrected the link to the LangChain components.
- Updated the "Contributing" section in the README file to use "Langflow" instead of "Langflow" and corrected the link to the contributing guidelines.
- Updated the "License" section in the README file to use "Langflow" instead of "Langflow".
- Updated the version of the "anyio" package in the poetry.lock file to 3.7.1.
Merge remote-tracking branch 'origin/form_io' into python_custom_node_component
- Updated the README files to correct the spelling of "Langflow" in various places.
- Added a new `.env.example` file for reference and configuration.
- Updated the CONTRIBUTING.md file to use "Langflow" instead of "Langflow".
- Updated the GCP_DEPLOYMENT.md file to use the correct GitHub repository URL.
- Updated the README file to use "Langflow" instead of "Langflow" and corrected the formatting of the table of contents.
- Updated the CLI usage instructions in the README file to use "Langflow" and provided more detailed explanations of each option.
- Added a section on Deployment in the README file with instructions for deploying Langflow on Google Cloud Platform.
- Updated the "Creating Flows" section in the README file to use "Langflow" instead of "Langflow" and corrected the link to the LangChain components.
- Updated the "Contributing" section in the README file to use "
✨ feat(memories.py): add MongoDBChatMessageHistoryFrontendNode class to support MongoDB as a memory store
The CUSTOM_NODES dictionary in customs.py has been updated to include the "MongoDBChatMessageHistory" memory. This allows the application to use MongoDB as a memory store for chat message history. The MongoDBChatMessageHistoryFrontendNode class has been added to memories.py, providing the necessary functionality and configuration options for interacting with MongoDB as a memory store.
The order of sections in the config.yaml file has been adjusted for better readability and organization. The "prompts" section has been moved to the top, followed by the "memories" section, and then the "textsplitters" section. This change improves the structure and consistency of the config file.
🐛 fix(utils.py): add input validation for 'chat_inputs.message' to prevent errors when no message is provided
🐛 fix(loading.py): add type hint for 'format_kwargs' variable in instantiate_prompt function
🐛 fix(base.py): add type hint for 'inputs' parameter in get_result_and_steps function
The changes in `base.py` and `utils.py` are bug fixes that address potential issues in the code. The type hint for the 'template' attribute in the `FrontendNodeRequest` class is added to improve code clarity and maintainability. The input validation for 'chat_inputs.message' in the `process_graph` function ensures that an error is raised when no message is provided, preventing potential issues down the line. In `loading.py`, the type hint for the 'format_kwargs' variable in the `instantiate_prompt` function improves type safety. Lastly, in `base.py`, the type hint for the 'inputs' parameter in the `get_result_and_steps` function ensures proper type checking.
The 'type_name' attribute for the 'Tools' field in the 'ZeroShotAgent' class has been changed to 'field_type' to improve consistency with the naming conventions used in the codebase.
The condition to remove empty input_key and output_key parameters has been fixed to correctly handle cases where the parameters are empty strings. This ensures that the parameters are only removed if they are either empty strings or not present in the params dictionary.
🔧 fix(types.py): process field_type to convert "Prompt" to "prompt"
The `utils.py` file was missing an import statement for the `CustomComponent` class from the `langflow.interface.custom.custom` module. This import statement has been added to the top of the file. Additionally, a new function `import_custom_component` has been added to import a custom component based on its name.
In the `types.py` file, a new function `process_type` has been added to convert the field_type "Prompt" to "prompt". This is done to ensure consistency in the field types used throughout the codebase.
The code now uses ast.literal_eval to evaluate each item in the split_item list. This is done to handle cases where the items are not strings and cannot be directly converted to their respective types. This ensures that the output_list contains correctly evaluated items.
🐛 fix(loading.py): fix instantiation of custom components and handle single document input in instantiate_textsplitter function
The code in loading.py has been reorganized to improve readability and remove duplicate import_by_type function. The instantiation of custom components has been fixed to correctly build the class object. Additionally, the instantiate_textsplitter function now handles single document input by converting it to a list before processing.
The contextlib.suppress block was suppressing import errors, but it is no longer needed as the import errors are handled elsewhere in the code. Removing this block improves code readability and removes unnecessary complexity.
🔀 refactor(constants.py): refactor build method in YourComponent class to use PromptTemplate and limit response text length
The YourComponent class in constants.py has been refactored to improve readability and remove unused imports. The build method now uses PromptTemplate to handle the template parameter and limits the length of the response text to 300 characters to avoid potential issues.
🔧 fix(constants.py): remove unused import statements
🔧 fix(types.py): refactor add_new_custom_field function to update field_config values
The import statement for `get_custom_nodes` in `base.py` is removed as it is not being used in the code. Similarly, the import statements for `requests` and `LLMChain` in `constants.py` are removed as they are not being used either.
In `types.py`, the `add_new_custom_field` function is refactored to update the values of `field_config` if any of the keys are present in it. This allows for more flexibility in customizing the field configuration for a custom component.
🐛 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.
🔀 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.
The condition `name in settings.<type>` is removed from the `get_signature` method in the `base.py` files of the `agents`, `chains`, `memories`, and `prompts` modules. This condition was unnecessary as it was already checked in the `get_custom_nodes` function. Removing this condition simplifies the code and improves readability.
The code now checks if the name is present in the settings before accessing the corresponding keys in the get_custom_nodes function. This prevents accessing non-existent keys and avoids potential errors.
The type annotation of the name parameter in the format_field method has been changed to Optional[str] to indicate that it can be either a string or None. This change improves the clarity of the code and makes it easier to understand the expected input for the method.
The documentation links for PromptTemplate and CharacterTextSplitter have been updated to the correct URLs. This ensures that users can access the relevant documentation for these components.
The FieldFormatter class now inherits from pydantic.BaseModel in addition to ABC (Abstract Base Class). This change allows FieldFormatter instances to benefit from the data validation and serialization capabilities provided by pydantic, improving the reliability and maintainability of the code.
The "base_classes" list in the ToolNode class has been updated to include "BaseTool" in addition to "Tool". This ensures that the ToolNode class correctly inherits from the BaseTool class, which is the intended parent class for this node.
The "BaseTool" class is added to the base_classes list in the get_signature method. This change ensures that the "BaseTool" class is considered as one of the base classes when creating a tool's signature.
🔧 fix(agents/base.py): import missing AgentFrontendNode class from langflow.template.frontend_node.agents
🔧 fix(initialize/loading.py): pass node_type to instantiate_agent function to handle creation of frontend nodes for agents
🔧 fix(template/frontend_node/agents.py): add format_field method to AgentFrontendNode class to customize field behavior
The missing import statement for the AgentFrontendNode class from langflow.template.frontend_node.agents has been added to the base.py file. Support for creating frontend nodes for agents has been added to the AgentCreator class in the base.py file. The instantiate_agent function in the loading.py file now receives the node_type parameter to handle the creation of frontend nodes for agents. The AgentFrontendNode class in the agents.py file now includes a format_field method to customize the behavior of certain fields.
The _built_object_repr method in the PromptVertex class was missing a return statement, causing it to not return any value. This fix adds the missing return statement to ensure the method returns the correct value.
The format_dict function now properly handles different variations of list types by removing unnecessary characters from the type string. This improves the consistency and accuracy of the type formatting in the function.
🔀 refactor(callback.py): reorganize imports and add missing type hints to improve code readability and maintainability
The changes in this commit include reorganizing the imports to group them properly and adding missing type hints to improve code readability and maintainability.
The code now removes the "input_key" and "output_key" keys from the params dictionary if they are empty strings. This ensures that the dictionary does not contain unnecessary keys with empty values.
The _built_object_repr method in the Vertex class has been updated to include emojis and more descriptive messages. The message "Built successfully ✨" is now returned when the _built_object attribute is True, indicating that the object has been successfully built. On the other hand, the message "Failed to build 😵💫" is returned when the _built_object attribute is False, indicating that the object failed to build. This change improves the clarity and visual representation of the build status.