fix: Remove duplicate options in Save File Component (#8559)
* fix: Take only unique values for the file format * Update save_file.py * Update News Aggregator.json * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * Update News Aggregator.json * Update src/backend/base/langflow/components/processing/save_file.py Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update News Aggregator.json * Small tweaks to the save file * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * Update News Aggregator.json * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * Update save_file.py * Update News Aggregator.json * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes (attempt 3/3) * Reorder list * Update save_file.py * [autofix.ci] apply automated fixes * Change default for message --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
parent
9c252453dc
commit
f04e336f1d
2 changed files with 11 additions and 11 deletions
|
|
@ -45,7 +45,7 @@ class SaveToFileComponent(Component):
|
||||||
DropdownInput(
|
DropdownInput(
|
||||||
name="file_format",
|
name="file_format",
|
||||||
display_name="File Format",
|
display_name="File Format",
|
||||||
options=DATA_FORMAT_CHOICES + MESSAGE_FORMAT_CHOICES,
|
options=list(dict.fromkeys(DATA_FORMAT_CHOICES + MESSAGE_FORMAT_CHOICES)),
|
||||||
info="Select the file format to save the input. If not provided, the default format will be used.",
|
info="Select the file format to save the input. If not provided, the default format will be used.",
|
||||||
value="",
|
value="",
|
||||||
advanced=True,
|
advanced=True,
|
||||||
|
|
@ -100,13 +100,15 @@ class SaveToFileComponent(Component):
|
||||||
|
|
||||||
def _get_input_type(self) -> str:
|
def _get_input_type(self) -> str:
|
||||||
"""Determine the input type based on the provided input."""
|
"""Determine the input type based on the provided input."""
|
||||||
if isinstance(self.input, DataFrame):
|
# Use exact type checking (type() is) instead of isinstance() to avoid inheritance issues.
|
||||||
|
# Since Message inherits from Data, isinstance(message, Data) would return True for Message objects,
|
||||||
|
# causing Message inputs to be incorrectly identified as Data type.
|
||||||
|
if type(self.input) is DataFrame:
|
||||||
return "DataFrame"
|
return "DataFrame"
|
||||||
if isinstance(self.input, Data):
|
if type(self.input) is Message:
|
||||||
return "Data"
|
|
||||||
if isinstance(self.input, Message):
|
|
||||||
return "Message"
|
return "Message"
|
||||||
|
if type(self.input) is Data:
|
||||||
|
return "Data"
|
||||||
msg = f"Unsupported input type: {type(self.input)}"
|
msg = f"Unsupported input type: {type(self.input)}"
|
||||||
raise ValueError(msg)
|
raise ValueError(msg)
|
||||||
|
|
||||||
|
|
@ -117,7 +119,7 @@ class SaveToFileComponent(Component):
|
||||||
if self._get_input_type() == "Data":
|
if self._get_input_type() == "Data":
|
||||||
return "json"
|
return "json"
|
||||||
if self._get_input_type() == "Message":
|
if self._get_input_type() == "Message":
|
||||||
return "markdown"
|
return "json"
|
||||||
return "json" # Fallback
|
return "json" # Fallback
|
||||||
|
|
||||||
def _adjust_file_path_with_format(self, path: Path, fmt: str) -> Path:
|
def _adjust_file_path_with_format(self, path: Path, fmt: str) -> Path:
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue