refactor: Tool Output Management: Add Component-Specific Variable for Conditional Tool Output (#4259)
Implement conditional tool output handling - Updated `component.py` to check for `FEATURE_FLAGS.add_toolkit_output` and call `_append_tool_output` if the component has the `add_tool_output` attribute set to True. - Ensured that the tool output behavior is correctly managed based on feature flags and component attributes in `custom_component.py`.
This commit is contained in:
parent
4075212c34
commit
5811857ca2
3 changed files with 21 additions and 4 deletions
|
|
@ -14,6 +14,16 @@ def code_component_with_multiple_outputs():
|
|||
return Component(_code=code)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def code_component_with_multiple_outputs_with_add_tool_output():
|
||||
code = Path("src/backend/tests/data/component_multiple_outputs.py").read_text(encoding="utf-8")
|
||||
code = code.replace(
|
||||
"class MultipleOutputsComponent(Component):",
|
||||
"class MultipleOutputsComponent(Component):\n add_tool_output = True",
|
||||
)
|
||||
return Component(_code=code)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def component(
|
||||
client, # noqa: ARG001
|
||||
|
|
@ -43,9 +53,14 @@ def test_list_flows_return_type(component):
|
|||
assert isinstance(flows, list)
|
||||
|
||||
|
||||
def test_feature_flags_add_toolkit_output(active_user, code_component_with_multiple_outputs):
|
||||
def test_feature_flags_add_toolkit_output(
|
||||
active_user, code_component_with_multiple_outputs, code_component_with_multiple_outputs_with_add_tool_output
|
||||
):
|
||||
frontnd_node_dict, _ = build_custom_component_template(code_component_with_multiple_outputs, active_user.id)
|
||||
len_outputs = len(frontnd_node_dict["outputs"])
|
||||
FEATURE_FLAGS.add_toolkit_output = True
|
||||
frontnd_node_dict, _ = build_custom_component_template(code_component_with_multiple_outputs, active_user.id)
|
||||
code_component_with_multiple_outputs_with_add_tool_output.add_tool_output = True
|
||||
frontnd_node_dict, _ = build_custom_component_template(
|
||||
code_component_with_multiple_outputs_with_add_tool_output, active_user.id
|
||||
)
|
||||
assert len(frontnd_node_dict["outputs"]) == len_outputs + 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue