Skip to content

Commit

Permalink
fix: add a check in ComponentToolkit to avoid building a tool that bu…
Browse files Browse the repository at this point in the history
…ilds tools (#4678)

* Enhance tool filtering logic by adding TOOL_TYPES set for output type checking

* Rename TOOL_TYPES to TOOL_TYPES_SET for clarity
  • Loading branch information
ogabrielluiz authored Nov 19, 2024
1 parent 699ec18 commit 50defed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/backend/base/langflow/base/tools/component_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
from langflow.schema.content_block import ContentBlock


TOOL_TYPES_SET = {"Tool", "BaseTool", "StructuredTool"}


def _get_input_type(_input: InputTypes):
if _input.input_types:
if len(_input.input_types) == 1:
Expand Down Expand Up @@ -165,7 +168,7 @@ def get_tools(
) -> list[BaseTool]:
tools = []
for output in self.component.outputs:
if output.name == TOOL_OUTPUT_NAME:
if output.name == TOOL_OUTPUT_NAME or any(tool_type in output.types for tool_type in TOOL_TYPES_SET):
continue

if not output.method:
Expand Down
1 change: 0 additions & 1 deletion src/backend/base/langflow/components/tools/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class CalculatorToolComponent(LCToolComponent):
name="expression",
display_name="Expression",
info="The arithmetic expression to evaluate (e.g., '4*4*(33/22)+12-20').",
tool_mode=True,
),
]

Expand Down

0 comments on commit 50defed

Please sign in to comment.