fix: add a check in ComponentToolkit to avoid building a tool that builds tools (#4678)
* Enhance tool filtering logic by adding TOOL_TYPES set for output type checking * Rename TOOL_TYPES to TOOL_TYPES_SET for clarity
This commit is contained in:
parent
699ec18205
commit
50defedfe6
2 changed files with 4 additions and 2 deletions
|
|
@ -27,6 +27,9 @@ if TYPE_CHECKING:
|
||||||
from langflow.schema.content_block import ContentBlock
|
from langflow.schema.content_block import ContentBlock
|
||||||
|
|
||||||
|
|
||||||
|
TOOL_TYPES_SET = {"Tool", "BaseTool", "StructuredTool"}
|
||||||
|
|
||||||
|
|
||||||
def _get_input_type(_input: InputTypes):
|
def _get_input_type(_input: InputTypes):
|
||||||
if _input.input_types:
|
if _input.input_types:
|
||||||
if len(_input.input_types) == 1:
|
if len(_input.input_types) == 1:
|
||||||
|
|
@ -165,7 +168,7 @@ class ComponentToolkit:
|
||||||
) -> list[BaseTool]:
|
) -> list[BaseTool]:
|
||||||
tools = []
|
tools = []
|
||||||
for output in self.component.outputs:
|
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
|
continue
|
||||||
|
|
||||||
if not output.method:
|
if not output.method:
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ class CalculatorToolComponent(LCToolComponent):
|
||||||
name="expression",
|
name="expression",
|
||||||
display_name="Expression",
|
display_name="Expression",
|
||||||
info="The arithmetic expression to evaluate (e.g., '4*4*(33/22)+12-20').",
|
info="The arithmetic expression to evaluate (e.g., '4*4*(33/22)+12-20').",
|
||||||
tool_mode=True,
|
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue