Skip to content

Commit

Permalink
[autofix.ci] apply automated fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] authored Sep 18, 2024
1 parent 92e066b commit fc337da
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
9 changes: 5 additions & 4 deletions src/backend/base/langflow/components/helpers/CSVtoData.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import csv
import io


class CSVToDataComponent(Component):
display_name = "CSV to Data List"
description = "Load a CSV file, CSV from a file path, or a valid CSV string and convert it to a list of Data"
Expand Down Expand Up @@ -45,16 +46,16 @@ def load_csv_to_data(self) -> list[Data]:
if self.csv_file:
resolved_path = self.resolve_path(self.csv_file)
file_path = Path(resolved_path)
if file_path.suffix.lower() != '.csv':
if file_path.suffix.lower() != ".csv":
raise ValueError("The provided file must be a CSV file.")
with open(file_path, 'r', newline='', encoding='utf-8') as csvfile:
with open(file_path, "r", newline="", encoding="utf-8") as csvfile:
csv_data = csvfile.read()

elif self.csv_path:
file_path = Path(self.csv_path)
if file_path.suffix.lower() != '.csv':
if file_path.suffix.lower() != ".csv":
raise ValueError("The provided file must be a CSV file.")
with open(file_path, 'r', newline='', encoding='utf-8') as csvfile:
with open(file_path, "r", newline="", encoding="utf-8") as csvfile:
csv_data = csvfile.read()

elif self.csv_string:
Expand Down
13 changes: 8 additions & 5 deletions src/backend/base/langflow/components/helpers/JSONtoData.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
from langflow.io import FileInput, MessageTextInput, MultilineInput, Output
from langflow.schema import Data


class JSONToDataComponent(Component):
display_name = "JSON to Data"
description = "Convert a JSON file, JSON from a file path, or a JSON string to a Data object or a list of Data objects"
description = (
"Convert a JSON file, JSON from a file path, or a JSON string to a Data object or a list of Data objects"
)
icon = "braces"
beta = True
name = "JSONtoData"
Expand Down Expand Up @@ -47,16 +50,16 @@ def convert_json_to_data(self) -> Union[Data, List[Data]]:
if self.json_file:
resolved_path = self.resolve_path(self.json_file)
file_path = Path(resolved_path)
if file_path.suffix.lower() != '.json':
if file_path.suffix.lower() != ".json":
raise ValueError("The provided file must be a JSON file.")
with open(file_path, 'r', encoding='utf-8') as jsonfile:
with open(file_path, "r", encoding="utf-8") as jsonfile:
json_data = jsonfile.read()

elif self.json_path:
file_path = Path(self.json_path)
if file_path.suffix.lower() != '.json':
if file_path.suffix.lower() != ".json":
raise ValueError("The provided file must be a JSON file.")
with open(file_path, 'r', encoding='utf-8') as jsonfile:
with open(file_path, "r", encoding="utf-8") as jsonfile:
json_data = jsonfile.read()

elif self.json_string:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
from langflow.schema import Data
from langflow.schema.message import Message


class MessageToDataComponent(Component):
display_name = "Message to Data"
description = "Convert a Message object to a Data object"
icon = "message-square-share"
beta = True
name = "MessagetoData"


inputs = [
MessageInput(
name="message",
Expand Down

0 comments on commit fc337da

Please sign in to comment.