Skip to content

Commit

Permalink
Fix/workflow tool addition changes (#489)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
johnyrahul authored Jul 16, 2024
1 parent 142174c commit 51b952d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
5 changes: 5 additions & 0 deletions backend/tool_instance/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions backend/workflow_manager/workflow/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down
12 changes: 4 additions & 8 deletions backend/workflow_manager/workflow/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -19,9 +18,6 @@ function WorkflowExecutionMain({
<Row className="wf-exec-main-layout">
<Col span={8} className="wf-exec-main-layout">
<div className="wf-exec-main-col-1">
<div className="wf-exec-main-prompt">
<Prompt />
</div>
<div className="wf-exec-main-steps">
<Steps
setSteps={setSteps}
Expand Down

0 comments on commit 51b952d

Please sign in to comment.