feat: Improve data handling and text formatting (loop fix) (#6771)

* 📝 (loop.py): Improve code readability and semantics by updating the return condition in the LoopComponent class
📝 (data.py): Enhance the data_to_text_list function to handle various data structures and ensure consistent text formatting
📝 (LoopTemplate.json): Update the LoopComponent class description and method implementations for better clarity and maintainability
📝 (test_data_to_text_list.py): Add unit tests to cover different scenarios and edge cases for the data_to_text_list function

* [autofix.ci] apply automated fixes

* 📝 (langflow): Add noqa comments to ignore linting rule A005 for specific files in the project. Fix type annotations and improve error handling in data.py module. Add noqa comments to ignore linting rule A005 for specific files in the project.

* ✅ (test_data_to_text_list.py): update parameter names in pytest.mark.parametrize to improve readability and maintainability

* 🐛 (data.py): refactor error message handling in data_to_text_list function to improve readability and maintainability

* [autofix.ci] apply automated fixes

* Update src/backend/base/langflow/helpers/data.py

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>

* ♻️ (data.py): refactor data_to_text_list function to simplify the logic and improve readability by removing unnecessary if conditions and updating the format_dict directly from data_obj.data.

* ✅ (test_data.py): refactor test_data_to_text_list function to handle defaultdict behavior and improve test coverage

* ✅ (loop-component.spec.ts): update test expectation to match the correct number of occurrences of "modified_value" in the output

* ✅ (Memory Chatbot.spec.ts): add assertion to check if the concatenated text length is greater than 20 to ensure the chatbot response is meaningful

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
This commit is contained in:
Cristhian Zanforlin Lousa 2025-02-24 17:27:34 -03:00 • committed by GitHub
commit 7b85505117
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 217 additions and 32 deletions

View file

@ -1,4 +1,4 @@
import { test } from "@playwright/test";
import { expect, test } from "@playwright/test";
import * as dotenv from "dotenv";
import path from "path";
import { awaitBootstrapTest } from "../../utils/await-bootstrap-test";
@ -63,8 +63,16 @@ withEventDeliveryModes(
await page.getByTestId("button-send").last().click();
await page.waitForSelector("text=roar", { timeout: 30000 });
await page.getByText("roar").last().isVisible();
await page.waitForSelector(".markdown", { timeout: 3000 });
const textContents = await page
.locator(".markdown")
.last()
.allTextContents();
const concatAllText = textContents.join(" ");
expect(concatAllText.length).toBeGreaterThan(20);
await page.getByText("Default Session").last().click();
await page.getByText("timestamp", { exact: true }).last().isVisible();

View file

@ -237,6 +237,6 @@ test(
// Count occurrences of modified_value in output
const matches = output?.match(/modified_value/g) || [];
expect(matches).toHaveLength(1);
expect(matches).toHaveLength(2);
},
);