feat: Add text key option to CSVToDataComponent (#5935)

Enhance CSV to Data component by introducing a configurable text key parameter, allowing users to specify the column used for text extraction when converting CSV data to Data objects.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2025-01-28 09:35:05 -03:00 committed by GitHub
commit fb0696c526
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -31,6 +31,12 @@ class CSVToDataComponent(Component):
display_name="CSV String",
info="Paste a CSV string directly to convert to a list of Data objects",
),
MessageTextInput(
name="text_key",
display_name="Text Key",
info="The key to use for the text column. Defaults to 'text'.",
value="text",
),
]
outputs = [
@ -66,7 +72,7 @@ class CSVToDataComponent(Component):
if csv_data:
csv_reader = csv.DictReader(io.StringIO(csv_data))
result = [Data(data=row) for row in csv_reader]
result = [Data(data=row, text_key=self.text_key) for row in csv_reader]
if not result:
self.status = "The CSV data is empty."