Skip to content

Commit

Permalink
feat: Removed dead code from unstract-core (#646)
Browse files Browse the repository at this point in the history
* Removed dead code from unstract-core, removed old WF generation method

* Added missing import statement for WF views

* Removed dead code around WF's prompt based generation - schema migration present

* Reverting model and migration change in v1 workflow

---------

Signed-off-by: Chandrasekharan M <[email protected]>
Co-authored-by: Gayathri <[email protected]>
  • Loading branch information
1 parent d5d1d5f commit 8037dbe
Show file tree
Hide file tree
Showing 28 changed files with 29 additions and 950 deletions.
8 changes: 4 additions & 4 deletions backend/migrating/v2/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,16 +317,16 @@ def get_organization_migrations(
{
"name": f"migration_{schema}_003_workflow",
"src_query": f"""
SELECT id, prompt_name, description, workflow_name, prompt_text,
is_active, status, llm_response, workflow_owner_id,
SELECT id, description, workflow_name,
is_active, status, workflow_owner_id,
deployment_type, source_settings, destination_settings,
created_by_id, modified_by_id, modified_at, created_at
FROM "{schema}".workflow_workflow;
""",
"dest_query": f"""
INSERT INTO "{self.v2_schema}".workflow (
id, prompt_name, description, workflow_name, prompt_text,
is_active, status, llm_response, workflow_owner_id,
id, description, workflow_name,
is_active, status, workflow_owner_id,
deployment_type, source_settings, destination_settings,
created_by_id, modified_by_id, modified_at, created_at,
organization_id
Expand Down
10 changes: 0 additions & 10 deletions backend/sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,6 @@ LANDING_URL="http://frontend.unstract.localhost/landing"
ERROR_URL="http://frontend.unstract.localhost/error"
WEB_APP_ORIGIN_URL="http://frontend.unstract.localhost"

# Azure OpenAI
OPENAI_API_KEY=
OPENAI_API_BASE=
OPENAI_API_VERSION=
OPENAI_API_ENGINE=
OPENAI_API_MODEL=
OPENAI_API_MODEL_EMBEDDING=
OPENAI_API_DEPLOYMENT_EMBEDDING=
OPENAI_API_TYPE=

# API keys for trusted services
INTERNAL_SERVICE_API_KEY=

Expand Down
7 changes: 0 additions & 7 deletions backend/tool_instance/tool_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,3 @@ def get_tool_list(user: User) -> list[dict[str, Any]]:
tool_list: list[dict[str, Any]] = tool_registry.fetch_tools_descriptions()
tool_list = tool_list + prompt_studio_tools
return tool_list

@staticmethod
def get_registry_tools() -> list[Tool]:
"""Function to get a list of tools."""
tool_registry = ToolRegistry()
tool_list: list[Tool] = tool_registry.fetch_all_tools()
return tool_list
7 changes: 0 additions & 7 deletions backend/tool_instance_v2/tool_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,3 @@ def get_tool_list(user: User) -> list[dict[str, Any]]:
tool_list: list[dict[str, Any]] = tool_registry.fetch_tools_descriptions()
tool_list = tool_list + prompt_studio_tools
return tool_list

@staticmethod
def get_registry_tools() -> list[Tool]:
"""Function to get a list of tools."""
tool_registry = ToolRegistry()
tool_list: list[Tool] = tool_registry.fetch_all_tools()
return tool_list
1 change: 0 additions & 1 deletion backend/workflow_manager/workflow/constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
class WorkflowKey:
"""Dict keys related to workflows."""

PROMPT_TEXT = "prompt_text"
LLM_RESPONSE = "llm_response"
WF_STEPS = "steps"
WF_TOOL = "tool"
Expand Down
114 changes: 0 additions & 114 deletions backend/workflow_manager/workflow/generator.py

This file was deleted.

29 changes: 0 additions & 29 deletions backend/workflow_manager/workflow/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
from tool_instance.tool_instance_helper import ToolInstanceHelper
from workflow_manager.endpoint.models import WorkflowEndpoint
from workflow_manager.workflow.constants import WorkflowExecutionKey, WorkflowKey
from workflow_manager.workflow.exceptions import WorkflowGenerationError
from workflow_manager.workflow.generator import WorkflowGenerator
from workflow_manager.workflow.models.execution import WorkflowExecution
from workflow_manager.workflow.models.execution_log import ExecutionLog
from workflow_manager.workflow.models.workflow import Workflow
Expand Down Expand Up @@ -59,33 +57,6 @@ def create(self, validated_data: dict[str, Any]) -> Any:
).user
return super().create(validated_data)

def update(self, instance: Any, validated_data: dict[str, Any]) -> Any:
if validated_data.get(WorkflowKey.PROMPT_TEXT):
instance.workflow_tool.all().delete()
return super().update(instance, validated_data)

def save(self, **kwargs: Any) -> Workflow:
workflow: Workflow = super().save(**kwargs)
if self.validated_data.get(WorkflowKey.PROMPT_TEXT):
try:
tool_serializer = ToolInstanceSerializer(
data=WorkflowGenerator.get_tool_instance_data_from_llm(
workflow=workflow
),
many=True,
context=self.context,
)
tool_serializer.is_valid(raise_exception=True)
tool_serializer.save()
except Exception as exc:
logger.error(f"Error while generating tool instances: {exc}")
raise WorkflowGenerationError

request = self.context.get("request")
if not request:
return workflow
return workflow


class ExecuteWorkflowSerializer(Serializer):
workflow_id = UUIDField(required=False)
Expand Down
12 changes: 0 additions & 12 deletions backend/workflow_manager/workflow/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
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 All @@ -13,8 +12,6 @@
from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.versioning import URLPathVersioning
from tool_instance.tool_processor import ToolProcessor
from unstract.tool_registry.dto import Tool
from utils.filtering import FilterHelper
from workflow_manager.endpoint.destination import DestinationConnector
from workflow_manager.endpoint.dto import FileHash
Expand All @@ -29,7 +26,6 @@
WorkflowGenerationError,
WorkflowRegenerationError,
)
from workflow_manager.workflow.generator import WorkflowGenerator
from workflow_manager.workflow.models.execution import WorkflowExecution
from workflow_manager.workflow.models.workflow import Workflow
from workflow_manager.workflow.serializers import (
Expand Down Expand Up @@ -82,14 +78,6 @@ 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)
generator.set_request(self.request)
generator.generate_workflow(registry_tools)
return generator

def perform_update(self, serializer: WorkflowSerializer) -> Workflow:
"""To edit a workflow.
Expand Down
1 change: 0 additions & 1 deletion backend/workflow_manager/workflow_v2/constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
class WorkflowKey:
"""Dict keys related to workflows."""

PROMPT_TEXT = "prompt_text"
LLM_RESPONSE = "llm_response"
WF_STEPS = "steps"
WF_TOOL = "tool"
Expand Down
114 changes: 0 additions & 114 deletions backend/workflow_manager/workflow_v2/generator.py

This file was deleted.

Loading

0 comments on commit 8037dbe

Please sign in to comment.