Skip to content

refactor: update Output definitions to remove incorrectly passed parameters #7334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/backend/base/langflow/components/apify/apify_actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ class ApifyActorsComponent(Component):
]

outputs = [
Output(display_name="Output", name="output", type_=list[Data], method="run_model"),
Output(display_name="Tool", name="tool", type_=Tool, method="build_tool"),
Output(display_name="Output", name="output", method="run_model"),
Output(display_name="Tool", name="tool", method="build_tool"),
]

def __init__(self, *args, **kwargs) -> None:
Expand Down
9 changes: 2 additions & 7 deletions src/backend/base/langflow/components/helpers/batch_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class BatchRunComponent(Component):
display_name="Batch Results",
name="batch_results",
method="run_batch",
info="A DataFrame with columns: 'text_input', 'model_response', 'batch_index', and 'metadata'.",
),
]

Expand Down Expand Up @@ -158,12 +157,8 @@ async def run_batch(self) -> DataFrame:
)

# Process batches and track progress
responses_with_idx = [
(idx, response)
for idx, response in zip(
range(len(conversations)), await model.abatch(list(conversations)), strict=True
)
]
responses = await model.abatch(list(conversations))
responses_with_idx = list(enumerate(responses))

# Sort by index to maintain order
responses_with_idx.sort(key=operator.itemgetter(0))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class OutputParserComponent(Component):
Output(
display_name="Format Instructions",
name="format_instructions",
info="Pass to a prompt template to include formatting instructions for LLM responses.",
method="format_instructions",
),
Output(display_name="Output Parser", name="output_parser", method="build_parser"),
Expand Down
2 changes: 1 addition & 1 deletion src/backend/base/langflow/components/needle/needle.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class NeedleComponent(Component):
),
]

outputs = [Output(display_name="Result", name="result", type_="Message", method="run")]
outputs = [Output(display_name="Result", name="result", method="run")]

def run(self) -> Message:
# Extract query and top_k
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,11 @@ class AlterMetadataComponent(Component):
Output(
name="data",
display_name="Data",
info="List of Input objects each with added Metadata",
method="process_output",
),
Output(
display_name="DataFrame",
name="dataframe",
info="Data objects as a DataFrame, with metadata as columns",
method="as_dataframe",
),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class DataToDataFrameComponent(Component):
display_name="DataFrame",
name="dataframe",
method="build_dataframe",
info="A DataFrame built from each Data object's fields plus a 'text' column.",
),
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ class DataFrameOperationsComponent(Component):
display_name="DataFrame",
name="output",
method="perform_operation",
info="The resulting DataFrame after the operation.",
)
]

Expand Down
2 changes: 0 additions & 2 deletions src/backend/base/langflow/components/processing/parse_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,11 @@ class ParseDataComponent(Component):
Output(
display_name="Message",
name="text",
info="Data as a single Message, with each input Data separated by Separator",
method="parse_data",
),
Output(
display_name="Data List",
name="data_list",
info="Data as a list of new Data, each having `text` formatted by Template",
method="parse_data_as_list",
),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class ParseDataFrameComponent(Component):
Output(
display_name="Text",
name="text",
info="All rows combined into a single text, each row formatted by the template and separated by `sep`.",
method="parse_data",
),
]
Expand Down
1 change: 0 additions & 1 deletion src/backend/base/langflow/components/processing/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class ParserComponent(Component):
Output(
display_name="Parsed Text",
name="parsed_text",
info="Formatted text output.",
method="parse_combined_text",
),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class SaveToFileComponent(Component):
name="confirmation",
display_name="Confirmation",
method="save_to_file",
info="Confirmation message after saving the file.",
),
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class CalculatorComponent(Component):
]

outputs = [
Output(display_name="Data", name="result", type_=Data, method="evaluate_expression"),
Output(display_name="Data", name="result", method="evaluate_expression"),
]

def _eval_expr(self, node: ast.AST) -> float:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class GoogleSearchAPICore(Component):
Output(
display_name="Results",
name="results",
type_=DataFrame,
method="search_google",
),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class GoogleSerperAPICore(Component):
Output(
display_name="Results",
name="results",
type_=DataFrame,
method="search_serper",
),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class PythonREPLComponent(Component):
Output(
display_name="Results",
name="results",
type_=Data,
method="run_python_repl",
),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
"show": true,
"title_case": false,
"type": "code",
"value": "from langflow.custom import Component\nfrom langflow.helpers.data import data_to_text, data_to_text_list\nfrom langflow.io import DataInput, MultilineInput, Output, StrInput\nfrom langflow.schema import Data\nfrom langflow.schema.message import Message\n\n\nclass ParseDataComponent(Component):\n display_name = \"Data to Message\"\n description = \"Convert Data objects into Messages using any {field_name} from input data.\"\n icon = \"message-square\"\n name = \"ParseData\"\n metadata = {\n \"legacy_name\": \"Parse Data\",\n }\n\n inputs = [\n DataInput(\n name=\"data\",\n display_name=\"Data\",\n info=\"The data to convert to text.\",\n is_list=True,\n required=True,\n ),\n MultilineInput(\n name=\"template\",\n display_name=\"Template\",\n info=\"The template to use for formatting the data. \"\n \"It can contain the keys {text}, {data} or any other key in the Data.\",\n value=\"{text}\",\n required=True,\n ),\n StrInput(name=\"sep\", display_name=\"Separator\", advanced=True, value=\"\\n\"),\n ]\n\n outputs = [\n Output(\n display_name=\"Message\",\n name=\"text\",\n info=\"Data as a single Message, with each input Data separated by Separator\",\n method=\"parse_data\",\n ),\n Output(\n display_name=\"Data List\",\n name=\"data_list\",\n info=\"Data as a list of new Data, each having `text` formatted by Template\",\n method=\"parse_data_as_list\",\n ),\n ]\n\n def _clean_args(self) -> tuple[list[Data], str, str]:\n data = self.data if isinstance(self.data, list) else [self.data]\n template = self.template\n sep = self.sep\n return data, template, sep\n\n def parse_data(self) -> Message:\n data, template, sep = self._clean_args()\n result_string = data_to_text(template, data, sep)\n self.status = result_string\n return Message(text=result_string)\n\n def parse_data_as_list(self) -> list[Data]:\n data, template, _ = self._clean_args()\n text_list, data_list = data_to_text_list(template, data)\n for item, text in zip(data_list, text_list, strict=True):\n item.set_text(text)\n self.status = data_list\n return data_list\n"
"value": "from langflow.custom import Component\nfrom langflow.helpers.data import data_to_text, data_to_text_list\nfrom langflow.io import DataInput, MultilineInput, Output, StrInput\nfrom langflow.schema import Data\nfrom langflow.schema.message import Message\n\n\nclass ParseDataComponent(Component):\n display_name = \"Data to Message\"\n description = \"Convert Data objects into Messages using any {field_name} from input data.\"\n icon = \"message-square\"\n name = \"ParseData\"\n metadata = {\n \"legacy_name\": \"Parse Data\",\n }\n\n inputs = [\n DataInput(\n name=\"data\",\n display_name=\"Data\",\n info=\"The data to convert to text.\",\n is_list=True,\n required=True,\n ),\n MultilineInput(\n name=\"template\",\n display_name=\"Template\",\n info=\"The template to use for formatting the data. \"\n \"It can contain the keys {text}, {data} or any other key in the Data.\",\n value=\"{text}\",\n required=True,\n ),\n StrInput(name=\"sep\", display_name=\"Separator\", advanced=True, value=\"\\n\"),\n ]\n\n outputs = [\n Output(\n display_name=\"Message\",\n name=\"text\",\n method=\"parse_data\",\n ),\n Output(\n display_name=\"Data List\",\n name=\"data_list\",\n method=\"parse_data_as_list\",\n ),\n ]\n\n def _clean_args(self) -> tuple[list[Data], str, str]:\n data = self.data if isinstance(self.data, list) else [self.data]\n template = self.template\n sep = self.sep\n return data, template, sep\n\n def parse_data(self) -> Message:\n data, template, sep = self._clean_args()\n result_string = data_to_text(template, data, sep)\n self.status = result_string\n return Message(text=result_string)\n\n def parse_data_as_list(self) -> list[Data]:\n data, template, _ = self._clean_args()\n text_list, data_list = data_to_text_list(template, data)\n for item, text in zip(data_list, text_list, strict=True):\n item.set_text(text)\n self.status = data_list\n return data_list\n"
},
"data": {
"advanced": false,
Expand Down
Loading
Loading