feat: Add toolset component utilities and refactor tool mode handling (#4946)
This commit is contained in:
parent
9cee720365
commit
ce12ac096c
13 changed files with 55 additions and 13 deletions
|
|
@ -615,6 +615,9 @@ async def custom_component_update(
|
|||
component,
|
||||
user_id=user.id,
|
||||
)
|
||||
|
||||
component_node["tool_mode"] = code_request.tool_mode
|
||||
|
||||
if hasattr(cc_instance, "set_attributes"):
|
||||
template = code_request.get_template()
|
||||
params = {}
|
||||
|
|
|
|||
|
|
@ -204,6 +204,7 @@ class UpdateCustomComponentRequest(CustomComponentRequest):
|
|||
field: str
|
||||
field_value: str | int | float | bool | dict | list | None = None
|
||||
template: dict
|
||||
tool_mode: bool = False
|
||||
|
||||
def get_template(self):
|
||||
return dotdict(self.template)
|
||||
|
|
|
|||
|
|
@ -396,10 +396,10 @@ class Component(CustomComponent):
|
|||
|
||||
def run_and_validate_update_outputs(self, frontend_node: dict, field_name: str, field_value: Any):
|
||||
frontend_node = self.update_outputs(frontend_node, field_name, field_value)
|
||||
if field_name == "tool_mode":
|
||||
# Replace all outputs with the tool_output value if tool_mode is True
|
||||
# else replace it with the original outputs
|
||||
frontend_node["outputs"] = [self._build_tool_output()] if field_value else frontend_node["outputs"]
|
||||
if field_name == "tool_mode" or frontend_node.get("tool_mode"):
|
||||
is_tool_mode = field_value or frontend_node.get("tool_mode")
|
||||
frontend_node["outputs"] = [self._build_tool_output()] if is_tool_mode else frontend_node["outputs"]
|
||||
|
||||
return self._validate_frontend_node(frontend_node)
|
||||
|
||||
def _validate_frontend_node(self, frontend_node: dict):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue