feat: Better multi-file consistency for File Component (#8625)

* feat: First pass at output changes for file component

* SQLite support and json parsing

* [autofix.ci] apply automated fixes

* Update base_file.py

* [autofix.ci] apply automated fixes

* Update file.py

* [autofix.ci] apply automated fixes

* Split text supporting messages

* [autofix.ci] apply automated fixes

* Support structured json data

* Routine for inclusion of sample data

* Couple more template updates

* [autofix.ci] apply automated fixes

* Update Text Sentiment Analysis.json

* Update Portfolio Website Code Generator.json

* Test coverage

* [autofix.ci] apply automated fixes

* Update constants.py

* Update base_file.py

* Update service.py

* Update src/backend/base/langflow/components/processing/split_text.py

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

* [autofix.ci] apply automated fixes

* Update service.py

* Add get file size that is unimplemented

* Update service.py

* Fix return

* Remove type annotation

* Update graph for new templates

* Update test_vector_store_rag.py

* Update stop-building.spec.ts

* [autofix.ci] apply automated fixes

* Update fileUploadComponent.spec.ts

* Update fileUploadComponent.spec.ts

* Update fileUploadComponent.spec.ts

* Update fileUploadComponent.spec.ts

* Update fileUploadComponent.spec.ts

* Update fileUploadComponent.spec.ts

* [autofix.ci] apply automated fixes

* Update fileUploadComponent.spec.ts

* test update

* Update fileUploadComponent.spec.ts

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: Mike Fortman <michael.fortman@datastax.com>
This commit is contained in:
Eric Hare 2025-06-26 14:12:34 -07:00 • committed by GitHub
commit e1624b8c6e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 3680 additions and 3965 deletions

View file

@ -0,0 +1,60 @@
from langflow.components.data import FileComponent
from langflow.io import Output
class TestFileComponentDynamicOutputs:
def test_update_outputs_single_csv_file(self):
"""Test single CSV file shows structured + raw outputs."""
component = FileComponent()
frontend_node = {"outputs": [], "template": {"path": {"file_path": ["test.csv"]}}}
result = component.update_outputs(frontend_node, "path", ["test.csv"])
assert len(result["outputs"]) == 3
output_names = [output.name for output in result["outputs"]]
assert "dataframe" in output_names # Structured content
assert "message" in output_names # Raw content
assert "path" in output_names # File path
def test_update_outputs_single_json_file(self):
"""Test single JSON file shows JSON + raw outputs."""
component = FileComponent()
frontend_node = {"outputs": [], "template": {"path": {"file_path": ["data.json"]}}}
result = component.update_outputs(frontend_node, "path", ["data.json"])
assert len(result["outputs"]) == 3
output_names = [output.name for output in result["outputs"]]
assert "json" in output_names # JSON content
assert "message" in output_names # Raw content
assert "path" in output_names # File path
def test_update_outputs_multiple_files(self):
"""Test multiple files show only Files output."""
component = FileComponent()
frontend_node = {"outputs": [], "template": {"path": {"file_path": ["file1.txt", "file2.txt"]}}}
result = component.update_outputs(frontend_node, "path", ["file1.txt", "file2.txt"])
assert len(result["outputs"]) == 1
assert result["outputs"][0].name == "dataframe"
assert result["outputs"][0].display_name == "Files"
def test_update_outputs_empty_path(self):
"""Test empty path results in no outputs."""
component = FileComponent()
frontend_node = {"outputs": [], "template": {"path": {"file_path": []}}}
result = component.update_outputs(frontend_node, "path", [])
assert len(result["outputs"]) == 0
def test_update_outputs_non_path_field(self):
"""Test non-path fields don't affect outputs."""
component = FileComponent()
original_outputs = [Output(display_name="Test", name="test", method="test_method")]
frontend_node = {"outputs": original_outputs, "template": {"path": {"file_path": ["value"]}}}
result = component.update_outputs(frontend_node, "other_field", "value")
assert result["outputs"] == original_outputs

View file

@ -15,6 +15,7 @@ from langflow.graph.graph.base import Graph
from langflow.graph.graph.constants import Finish
from langflow.schema import Data
from langflow.schema.dataframe import DataFrame
from langflow.schema.message import Message
@pytest.fixture
@ -22,9 +23,9 @@ def ingestion_graph():
# Ingestion Graph
file_component = FileComponent(_id="file-123")
file_component.set(path="test.txt")
file_component.set_on_output(name="dataframe", value=Data(text="This is a test file."), cache=True)
file_component.set_on_output(name="message", value=Message(text="This is a test file."), cache=True)
text_splitter = SplitTextComponent(_id="text-splitter-123")
text_splitter.set(data_inputs=file_component.load_files)
text_splitter.set(data_inputs=file_component.load_files_message)
openai_embeddings = OpenAIEmbeddingsComponent(_id="openai-embeddings-123")
openai_embeddings.set(
openai_api_key="sk-123", openai_api_base="https://api.openai.com/v1", openai_api_type="openai"