From 51b952dad9c7cd9f253b15b130ba8cf7eafb156f Mon Sep 17 00:00:00 2001 From: Rahul Johny <116638720+johnyrahul@users.noreply.github.com> Date: Tue, 16 Jul 2024 16:15:33 +0530 Subject: [PATCH] Fix/workflow tool addition changes (#489) * Fix to add validation while adding multiple tools to workflow * Fix to remove prompt dialog box to generate and add tools to workflow * Annoted the method with deprecation warning and TODO --- backend/tool_instance/serializers.py | 5 +++++ backend/workflow_manager/workflow/generator.py | 1 + backend/workflow_manager/workflow/views.py | 12 ++++-------- .../WorkflowExecutionMain.jsx | 4 ---- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/backend/tool_instance/serializers.py b/backend/tool_instance/serializers.py index 4ce323b49..f36b66f87 100644 --- a/backend/tool_instance/serializers.py +++ b/backend/tool_instance/serializers.py @@ -68,6 +68,11 @@ def create(self, validated_data: dict[str, Any]) -> Any: raise ValidationError(f"Workflow with ID {workflow_id} does not exist.") validated_data[TIKey.WORKFLOW] = workflow + if workflow.workflow_tool.count() > 0: + raise ValidationError( + f"Workflow with ID {workflow_id} can't have more than one tool." + ) + tool_uid = validated_data.get(TIKey.TOOL_ID) if not tool_uid: raise ToolDoesNotExist() diff --git a/backend/workflow_manager/workflow/generator.py b/backend/workflow_manager/workflow/generator.py index 7c901b4bf..31aabafb6 100644 --- a/backend/workflow_manager/workflow/generator.py +++ b/backend/workflow_manager/workflow/generator.py @@ -17,6 +17,7 @@ logger = logging.getLogger(__name__) +# TODO: Can be removed as not getting used with UX chnages. class WorkflowGenerator: """Helps with generating a workflow using the LLM.""" diff --git a/backend/workflow_manager/workflow/views.py b/backend/workflow_manager/workflow/views.py index c02569355..0a3c451cf 100644 --- a/backend/workflow_manager/workflow/views.py +++ b/backend/workflow_manager/workflow/views.py @@ -4,6 +4,7 @@ from connector.connector_instance_helper import ConnectorInstanceHelper from django.conf import settings from django.db.models.query import QuerySet +from numpy import deprecate_with_doc from permissions.permission import IsOwner from pipeline.models import Pipeline from pipeline.pipeline_processor import PipelineProcessor @@ -78,6 +79,7 @@ def get_serializer_class(self) -> serializers.Serializer: else: return WorkflowSerializer + @deprecate_with_doc("Not using with the latest UX chnages") def _generate_workflow(self, workflow_id: str) -> WorkflowGenerator: registry_tools: list[Tool] = ToolProcessor.get_registry_tools() generator = WorkflowGenerator(workflow_id=workflow_id) @@ -86,18 +88,12 @@ def _generate_workflow(self, workflow_id: str) -> WorkflowGenerator: return generator def perform_update(self, serializer: WorkflowSerializer) -> Workflow: - """To edit a workflow. Regenerates the tool instances for a new prompt. + """To edit a workflow. Raises: WorkflowGenerationError """ kwargs = {} - if serializer.validated_data.get(WorkflowKey.PROMPT_TEXT): - workflow: Workflow = self.get_object() - generator = self._generate_workflow(workflow_id=workflow.id) - kwargs = { - WorkflowKey.LLM_RESPONSE: generator.llm_response, - WorkflowKey.WF_IS_ACTIVE: True, - } + try: workflow = serializer.save(**kwargs) return workflow diff --git a/frontend/src/components/agency/workflow-execution-layout/WorkflowExecutionMain.jsx b/frontend/src/components/agency/workflow-execution-layout/WorkflowExecutionMain.jsx index fb5acdaec..2d11f0eeb 100644 --- a/frontend/src/components/agency/workflow-execution-layout/WorkflowExecutionMain.jsx +++ b/frontend/src/components/agency/workflow-execution-layout/WorkflowExecutionMain.jsx @@ -1,7 +1,6 @@ import { Col, Row } from "antd"; import PropTypes from "prop-types"; -import { Prompt } from "../prompt/Prompt"; import { Steps } from "../steps/Steps"; import "./WorkflowExecutionMain.css"; import { InputOutput } from "../input-output/InputOutput"; @@ -19,9 +18,6 @@ function WorkflowExecutionMain({
-
- -