From cf3c480ad9114c8ef9ef56a7e9f6c844f9df8eea Mon Sep 17 00:00:00 2001 From: Rahul Johny <116638720+johnyrahul@users.noreply.github.com> Date: Tue, 16 Jul 2024 12:27:27 +0530 Subject: [PATCH 1/5] Handling the error msg from from validation error from djnago serializer (#487) --- frontend/src/hooks/useExceptionHandler.jsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frontend/src/hooks/useExceptionHandler.jsx b/frontend/src/hooks/useExceptionHandler.jsx index d1268823d..4f7835e54 100644 --- a/frontend/src/hooks/useExceptionHandler.jsx +++ b/frontend/src/hooks/useExceptionHandler.jsx @@ -26,6 +26,13 @@ const useExceptionHandler = () => { // Handle validation errors if (setBackendErrors) { setBackendErrors(err?.response?.data); + } else { + return { + title: title, + type: "error", + content: errors?.[0]?.detail ? errors[0].detail : errMessage, + duration: duration, + }; } break; case "subscription_error": From 142174cf8dfeba40219e96bc75bd791a8d1521f3 Mon Sep 17 00:00:00 2001 From: harini-venkataraman <115449948+harini-venkataraman@users.noreply.github.com> Date: Tue, 16 Jul 2024 14:52:31 +0530 Subject: [PATCH 2/5] Moving public prefix within try-catch block (#486) * Moving public prefix to block * Path prefix config addition * Abstracting Cloud share APIs * Addressing public attributes for OSS * Update backend/backend/public_urls.py Signed-off-by: Chandrasekharan M <117059509+chandrasekharan-zipstack@users.noreply.github.com> --------- Signed-off-by: Chandrasekharan M <117059509+chandrasekharan-zipstack@users.noreply.github.com> Co-authored-by: Chandrasekharan M <117059509+chandrasekharan-zipstack@users.noreply.github.com> Co-authored-by: Rahul Johny <116638720+johnyrahul@users.noreply.github.com> --- backend/backend/public_urls.py | 3 ++- .../helpers/custom-tools/CustomToolsHelper.js | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/backend/backend/public_urls.py b/backend/backend/public_urls.py index ffeb5f02e..5eb9ab823 100644 --- a/backend/backend/public_urls.py +++ b/backend/backend/public_urls.py @@ -22,7 +22,6 @@ path_prefix = settings.PATH_PREFIX api_path_prefix = settings.API_DEPLOYMENT_PATH_PREFIX -share_path_prefix = settings.PUBLIC_PATH_PREFIX urlpatterns = [ path(f"{path_prefix}/", include("account.urls")), @@ -51,6 +50,8 @@ import pluggable_apps.platform_admin.urls # noqa # pylint: disable=unused-import import pluggable_apps.public_shares_share_controller.urls # noqa # pylint: disable=unused-import + share_path_prefix = settings.PUBLIC_PATH_PREFIX + urlpatterns += [ path(f"{path_prefix}/", include("pluggable_apps.platform_admin.urls")), # Public Sharing diff --git a/frontend/src/components/helpers/custom-tools/CustomToolsHelper.js b/frontend/src/components/helpers/custom-tools/CustomToolsHelper.js index 7bd9017c8..529c0f48c 100644 --- a/frontend/src/components/helpers/custom-tools/CustomToolsHelper.js +++ b/frontend/src/components/helpers/custom-tools/CustomToolsHelper.js @@ -10,6 +10,13 @@ import { useSocketCustomToolStore } from "../../../store/socket-custom-tool"; import { SpinnerLoader } from "../../widgets/spinner-loader/SpinnerLoader"; import { useTokenUsageStore } from "../../../store/token-usage-store"; +let shareManagerToolSource; +try { + shareManagerToolSource = + require("../../../plugins/prompt-studio-public-share/helpers/PublicShareAPIs").shareManagerToolSource; +} catch (err) { + // Do nothing, Not-found Page will be triggered. +} function CustomToolsHelper() { const [isLoading, setIsLoading] = useState(true); const { id } = useParams(); @@ -82,11 +89,13 @@ function CustomToolsHelper() { .then((res) => { const data = res?.data; updatedCusTool["llmProfiles"] = data; - const reqOpsShare = { - method: "GET", - url: `/api/v1/unstract/${sessionDetails?.orgId}/share-manager/tool-source/?tool_id=${id}`, - }; - return handleApiRequest(reqOpsShare); + if (shareManagerToolSource) { + const reqOpsShare = { + method: "GET", + url: shareManagerToolSource(id, sessionDetails?.orgId), + }; + return handleApiRequest(reqOpsShare); + } }) .then((res) => { const data = res?.data; 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 3/5] 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({
-
- -
Date: Tue, 16 Jul 2024 16:20:22 +0530 Subject: [PATCH 4/5] fix: Update version to specific release tag (#488) * * Fix release tag for version update via run platform script * Rename version update command * Improve readability of script output * Update docstring * Fix tags fetch to be explicit * Update docker/scripts/merge_env.py Co-authored-by: ali <117142933+muhammad-ali-e@users.noreply.github.com> Signed-off-by: Rahul Johny <116638720+johnyrahul@users.noreply.github.com> --------- Signed-off-by: Rahul Johny <116638720+johnyrahul@users.noreply.github.com> Co-authored-by: Rahul Johny <116638720+johnyrahul@users.noreply.github.com> Co-authored-by: ali <117142933+muhammad-ali-e@users.noreply.github.com> --- docker/scripts/merge_env.py | 4 +-- run-platform.sh | 63 +++++++++++++++++++++++++------------ 2 files changed, 45 insertions(+), 22 deletions(-) diff --git a/docker/scripts/merge_env.py b/docker/scripts/merge_env.py index 3099da501..9a328b00c 100644 --- a/docker/scripts/merge_env.py +++ b/docker/scripts/merge_env.py @@ -54,8 +54,8 @@ def _merge_to_env_file(base_env_file_path: str, target_env: dict[str, str] = {}) target env. Args: - base_env_path (string): Base env file path. - target_env (dict, optional): Target env to use for merge. + base_env_file_path (string): Base env file path e.g. `sample.env` + target_env (dict, optional): Target env to use for merge e.g. `.env` Returns: string: File contents after merge. diff --git a/run-platform.sh b/run-platform.sh index e09184253..6483b7dd5 100755 --- a/run-platform.sh +++ b/run-platform.sh @@ -69,7 +69,7 @@ display_help() { echo -e " -e, --only-env Only do env files setup" echo -e " -p, --only-pull Only do docker images pull" echo -e " -b, --build-local Build docker images locally" - echo -e " -u, --upgrade Upgrade services" + echo -e " -u, --update Update services version" echo -e " -x, --trace Enables trace mode" echo -e " -V, --verbose Print verbose logs" echo -e " -v, --version Docker images version tag (default \"latest\")" @@ -93,8 +93,8 @@ parse_args() { -b | --build-local) opt_build_local=true ;; - -u | --upgrade) - opt_upgrade=true + -u | --update) + opt_update=true ;; -x | --trace) set -o xtrace # display every line before execution; enables PS4 @@ -126,21 +126,40 @@ parse_args() { debug "OPTION only_env: $opt_only_env" debug "OPTION only_pull: $opt_only_pull" debug "OPTION build_local: $opt_build_local" - debug "OPTION upgrade: $opt_upgrade" + debug "OPTION upgrade: $opt_update" debug "OPTION verbose: $opt_verbose" debug "OPTION version: $opt_version" } do_git_pull() { - if [ "$opt_upgrade" = false ]; then + if [ "$opt_update" = false ]; then return fi - echo -e "Performing git switch to ""$blue_text""main branch""$default_text". - git switch main + echo "Fetching release tags." + git fetch --quiet --tags - echo -e "Performing ""$blue_text""git pull""$default_text"" on main branch." - git pull + if [[ "$opt_version" == "latest" ]]; then + branch=`git describe --tags --abbrev=0` + elif [[ "$opt_version" == "main" ]]; then + branch="main" + opt_build_local=true + echo -e "Choosing ""$blue_text""local build""$default_text"" of Docker images from ""$blue_text""main""$default_text"" branch." + elif [ -z $(git tag -l "$opt_version") ]; then + echo -e "$red_text""Version not found.""$default_text" + if [[ ! $opt_version == v* ]]; then + echo -e "$red_text""Version must be provided with a 'v' prefix (e.g. v0.47.0).""$default_text" + fi + exit 1 + else + branch="$opt_version" + fi + + echo -e "Performing ""$blue_text""git checkout""$default_text"" to ""$blue_text""$branch""$default_text""." + git checkout --quiet $branch + + echo -e "Performing ""$blue_text""git pull""$default_text"" on ""$blue_text""$branch""$default_text""." + git pull --quiet $(git remote) $branch } setup_env() { @@ -180,7 +199,7 @@ setup_env() { fi fi echo -e "Created env for ""$blue_text""$service""$default_text" at ""$blue_text""$env_path""$default_text"." - elif [ "$opt_upgrade" = true ]; then + elif [ "$opt_update" = true ]; then python3 $script_dir/docker/scripts/merge_env.py $sample_env_path $env_path if [ $? -ne 0 ]; then exit 1 @@ -192,7 +211,7 @@ setup_env() { if [ ! -e "$script_dir/docker/essentials.env" ]; then cp "$script_dir/docker/sample.essentials.env" "$script_dir/docker/essentials.env" echo -e "Created env for ""$blue_text""essential services""$default_text"" at ""$blue_text""$script_dir/docker/essentials.env""$default_text""." - elif [ "$opt_upgrade" = true ]; then + elif [ "$opt_update" = true ]; then python3 $script_dir/docker/scripts/merge_env.py "$script_dir/docker/sample.essentials.env" "$script_dir/docker/essentials.env" if [ $? -ne 0 ]; then exit 1 @@ -202,9 +221,9 @@ setup_env() { # Not part of an upgrade. if [ ! -e "$script_dir/docker/proxy_overrides.yaml" ]; then - echo -e "NOTE: Proxy behaviour can be overridden via ""$blue_text""$script_dir/docker/proxy_overrides.yaml""$default_text""." + echo -e "NOTE: Reverse proxy config can be overridden via ""$blue_text""$script_dir/docker/proxy_overrides.yaml""$default_text""." else - echo -e "Found ""$blue_text""$script_dir/docker/proxy_overrides.yaml""$default_text"". Proxy behaviour will be overridden." + echo -e "Found ""$blue_text""$script_dir/docker/proxy_overrides.yaml""$default_text"". ""$yellow_text""Reverse proxy config will be overridden.""$default_text" fi if [ "$opt_only_env" = true ]; then @@ -221,7 +240,7 @@ build_services() { echo -e "$red_text""Failed to build docker images.""$default_text" exit 1 } - elif [ "$first_setup" = true ] || [ "$opt_upgrade" = true ]; then + elif [ "$first_setup" = true ] || [ "$opt_update" = true ]; then echo -e "$blue_text""Pulling""$default_text"" docker images tag ""$blue_text""$opt_version""$default_text""." # Try again on a slow network. VERSION=$opt_version $docker_compose_cmd -f $script_dir/docker/docker-compose.yaml pull || @@ -246,15 +265,19 @@ run_services() { echo -e "$blue_text""Starting docker containers in detached mode""$default_text" VERSION=$opt_version $docker_compose_cmd up -d - if [ "$opt_upgrade" = true ]; then + if [ "$opt_update" = true ]; then echo "" - echo -e "$green_text""Upgraded platform to $opt_version version.""$default_text" + if [[ "$opt_version" == "main" ]]; then + echo -e "$green_text""Updated platform to latest main (unstable).""$default_text" + else + echo -e "$green_text""Updated platform to $opt_version version.""$default_text" + fi fi echo -e "\nOnce the services are up, visit ""$blue_text""http://frontend.unstract.localhost""$default_text"" in your browser." - echo "See logs with:" + echo -e "\nSee logs with:" echo -e " ""$blue_text""$docker_compose_cmd -f docker/docker-compose.yaml logs -f""$default_text" - echo -e "Configure services by updating their ""$yellow_text"".env""$default_text"" files." - echo "Make sure to restart the services with:" + echo -e "Configure services by updating corresponding ""$yellow_text""/.env""$default_text"" files." + echo -e "Make sure to ""$yellow_text""restart""$default_text"" the services with:" echo -e " ""$blue_text""$docker_compose_cmd -f docker/docker-compose.yaml up -d""$default_text" popd 1>/dev/null @@ -268,7 +291,7 @@ check_dependencies opt_only_env=false opt_only_pull=false opt_build_local=false -opt_upgrade=false +opt_update=false opt_verbose=false opt_version="latest" From 8e42a2352c71290ad3c5c92543e3737d903d049e Mon Sep 17 00:00:00 2001 From: harini-venkataraman <115449948+harini-venkataraman@users.noreply.github.com> Date: Tue, 16 Jul 2024 16:26:24 +0530 Subject: [PATCH 5/5] [FIX] Support of tif and PDF extension in workflow. (#490) * Supporting tif and PDF extentions * Supporting tif and PDF extentions --------- Co-authored-by: Rahul Johny <116638720+johnyrahul@users.noreply.github.com> --- backend/workflow_manager/endpoint/constants.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/workflow_manager/endpoint/constants.py b/backend/workflow_manager/endpoint/constants.py index d9553245d..ca84b5d15 100644 --- a/backend/workflow_manager/endpoint/constants.py +++ b/backend/workflow_manager/endpoint/constants.py @@ -70,9 +70,9 @@ class FileType: class FilePattern: - PDF_DOCUMENTS = ["*.pdf"] + PDF_DOCUMENTS = ["*.pdf", "*.PDF"] TEXT_DOCUMENTS = ["*.txt"] - IMAGES = ["*.jpg", "*.jpeg", "*.png", "*.gif", "*.bmp"] + IMAGES = ["*.jpg", "*.jpeg", "*.png", "*.gif", "*.bmp", "*.tif", "*.tiff"] class SourceConstant: