Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dataframe): add support for DataFrame outputs across multiple co…
…mponents (langflow-ai#5589) * add dataframe outputs to vector stores, directory, url, split text * add dataframe import * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * add parse dataframe * [autofix.ci] apply automated fixes * Refactor: Update DataFrame handling in components - Added import of DataFrame in directory and url components. - Renamed variable 'df' to 'dataframe' in ParseDataFrameComponent for clarity. - Updated method _clean_args and parse_data to use 'dataframe' instead of 'df' for consistency. These changes enhance code readability and maintainability by standardizing the terminology used for DataFrame objects. * [autofix.ci] apply automated fixes * remove parse dataframe * Add tests for URL component functionality and data handling * Enhance DirectoryComponent tests with new functionality and parameters - Added tests for loading files with specific types and handling hidden files. - Implemented tests for directory loading with depth and multithreading support. - Introduced a new test for converting directory contents to a DataFrame. - Updated existing tests to include additional parameters like 'silent_errors' and 'types'. These changes improve test coverage and ensure the DirectoryComponent behaves as expected under various conditions. * update retrieve_file_paths for backwards compatibility * Refactor DirectoryComponent to handle file types more robustly - Removed the default assignment of TEXT_FILE_TYPES to 'types' and added logic to use all supported types if none are specified. - Implemented validation to ensure only valid file types are processed, improving error handling. - Updated the file retrieval process to utilize the filtered list of valid types. These changes enhance the flexibility and reliability of the DirectoryComponent's file loading functionality. * Refactor and simplify tests in test_data_components.py - Removed multiple tests related to HTTP requests, including successful and failed GET requests, timeouts, and multiple URL handling, to streamline the test suite. - Cleaned up imports and unnecessary mock setups to enhance readability and maintainability. - Focused on retaining essential tests for DirectoryComponent and URLComponent functionality, ensuring core features are still validated. These changes improve the clarity and efficiency of the test suite while maintaining coverage for critical components. * Add unit tests for DirectoryComponent functionality - Introduced a new test file for DirectoryComponent, enhancing test coverage. - Implemented various tests to validate loading files with specific types, handling hidden files, and supporting multithreading. - Added tests for directory loading with depth and converting directory contents to a DataFrame. - Ensured tests cover different scenarios, including recursive loading and file type filtering. These changes improve the robustness and reliability of the DirectoryComponent's functionality through comprehensive testing. * Add unit tests for URLComponent functionality - Introduced a new test file for URLComponent, enhancing test coverage for its methods. - Implemented tests for fetching content from valid URLs, handling multiple URLs, and validating error handling for invalid URLs. - Added tests for converting fetched content to a DataFrame and ensuring correct message formatting. - Mocked web requests to simulate various scenarios, ensuring robust testing of URLComponent's functionality. These changes improve the reliability and correctness of the URLComponent through comprehensive testing. * Add unit tests for SplitTextComponent functionality - Introduced a new test file for SplitTextComponent, enhancing test coverage for its methods. - Implemented tests for basic text splitting, handling overlaps, custom separators, and preserving metadata. - Added tests for converting split text results to a DataFrame and handling empty input. - Ensured functionality for single and multiple input texts is validated. These changes improve the reliability and correctness of the SplitTextComponent through comprehensive testing. * Add comment to ignore FBT001 in retrieve_file_paths function * Validate specified file types in DirectoryComponent and raise ValueError for invalid types * Fix type hint in DataFrame constructor to support list of dicts or Data objects. This change enhances type safety and clarity in the DataFrame initialization process. * Enhance DirectoryComponent tests to validate error handling for invalid file types - Removed the test case for 'exe' file type from valid scenarios. - Added a new test to ensure DirectoryComponent raises a ValueError for invalid file types, specifically when 'exe' is specified. - Improved test coverage for DirectoryComponent by validating error messages for unsupported file types. These changes strengthen the reliability of the DirectoryComponent by ensuring proper error handling for invalid inputs. * [autofix.ci] apply automated fixes * Update error handling in Component class to return None for missing flow_id or session_id - Modified the send_error_message method to include a type hint that allows for returning None in addition to Message. - Added a conditional check to return None if flow_id or session_id is not present, improving robustness in error handling. These changes enhance the reliability of the Component class by ensuring it gracefully handles cases with missing identifiers. * Refactor error handling in Component class to return None for missing session_id - Updated the send_error_message method to remove the flow_id check, simplifying the logic. - Enhanced robustness by ensuring that the method returns None if session_id is not present. These changes improve the reliability of the Component class in handling error messages. * Update required_inputs for DataFrame method in JSON configurations - Modified the 'required_inputs' field for the 'DataFrame' method in both 'Graph Vector Store RAG.json' and 'Vector Store RAG.json' files to include necessary parameters: 'api_endpoint', 'collection_name', and 'token'. - In 'Vector Store RAG.json', added 'collection_name_new' to the 'required_inputs' list. These changes ensure that the DataFrame method has the appropriate inputs defined for proper functionality. * [autofix.ci] apply automated fixes * Enhance BaseComponent to use deep copy for attribute values in template configuration - Updated the BaseComponent class to utilize `copy.deepcopy` when assigning values to `template_config`. This change ensures that modifications to the original component's attributes do not affect the template configuration, enhancing data integrity and preventing unintended side effects. These changes improve the reliability of the BaseComponent by ensuring that the template configuration remains consistent and isolated from the original component's state. * Added output for 'dataframe' in both ingestion and rag graphs - Updated the ingestion vector store ID for better identification. - Added output for 'dataframe' in both ingestion and rag graphs to enhance data handling. - Simplified the output assignment for search results in rag graph by using a data list. These changes improve the test structure and ensure that the vector store components are correctly configured for better testing outcomes. * Refactor vector store RAG tests for improved validation and consistency - Updated test assertions in `test_vector_store_rag_dump_components_and_edges` to verify the expected number of nodes and their types using a mapping for easier lookup. - Changed the ingestion vector store ID from `vector-store-123` to `ingestion-vector-store-123` for better identification. - Adjusted expected edges in the tests to reflect the new vector store ID, ensuring accurate edge validation. These changes enhance the test structure and ensure that the vector store components are correctly configured for better testing outcomes. --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]>
- Loading branch information