LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows
Python ai-agentsdata-engineeringdocument-aigenerative-aiidpjson-extractionllmmcp-serverocrpdf-extractionprompt-engineeringstructured-output
FEAT: Simple Prompt Studio CRUD functionality (#481)
Tahier Hussainc4d14191f579
diff --git a/backend/backend/public_urls.py b/backend/backend/public_urls.pyindex 0afee2ead..971ccfcec 100644--- a/backend/backend/public_urls.py+++ b/backend/backend/public_urls.py@@ -54,6 +54,34 @@ try:except ImportError:pass+try:+ import pluggable_apps.simple_prompt_studio.sps_document.urls # noqa # pylint: disable=unused-import+ import pluggable_apps.simple_prompt_studio.sps_project.urls # noqa # pylint: disable=unused-import+ import pluggable_apps.simple_prompt_studio.sps_prompt.urls # noqa # pylint: disable=unused-import+ import pluggable_apps.simple_prompt_studio.sps_prompt_output.urls # noqa # pylint: disable=unused-import++ simple_prompt_studio_path_prefix = settings.SIMPLE_PROMPT_STUDIO_PATH_PREFIX+ urlpatterns += [+ path(+ f"{path_prefix}/{simple_prompt_studio_path_prefix}/",+ include("pluggable_apps.simple_prompt_studio.sps_project.urls"),+ ),+ path(+ f"{path_prefix}/{simple_prompt_studio_path_prefix}/",+ include("pluggable_apps.simple_prompt_studio.sps_document.urls"),+ ),+ path(+ f"{path_prefix}/{simple_prompt_studio_path_prefix}/",+ include("pluggable_apps.simple_prompt_studio.sps_prompt.urls"),+ ),+ path(+ f"{path_prefix}/{simple_prompt_studio_path_prefix}/",+ include("pluggable_apps.simple_prompt_studio.sps_prompt_output.urls"),+ ),+ ]+except ImportError:+ pass+try:import pluggable_apps.public_shares.share_controller.urls # noqa # pylint: disable=unused-importdiff --git a/backend/prompt_studio/prompt_studio/controller.py b/backend/prompt_studio/prompt_studio/controller.pyindex 4a0280200..e3de0dd30 100644--- a/backend/prompt_studio/prompt_studio/controller.py+++ b/backend/prompt_studio/prompt_studio/controller.py@@ -1,5 +1,6 @@import logging+from django.db import modelsfrom prompt_studio.prompt_studio.constants import ToolStudioPromptKeysfrom prompt_studio.prompt_studio.helper import PromptStudioHelperfrom prompt_studio.prompt_studio.models import ToolStudioPrompt@@ -12,7 +13,7 @@ logger = logging.getLogger(__name__)class PromptStudioController:- def reorder_prompts(self, request: Request) -> Response:+ def reorder_prompts(self, request: Request, prompt_model: models.Model) -> Response:"""Reorder the sequence of prompts based on the start and end sequencenumbers.@@ -46,6 +47,7 @@ class PromptStudioController:prompt_id=prompt_id,start_sequence_number=start_sequence_number,end_sequence_number=end_sequence_number,+ prompt_model=prompt_model,)logger.info("Re-ordering completed successfully.")diff --git a/backend/prompt_studio/prompt_studio/helper.py b/backend/prompt_studio/prompt_studio/helper.pyindex f362104c2..8d70802f2 100644--- a/backend/prompt_studio/prompt_studio/helper.py+++ b/backend/prompt_studio/prompt_studio/helper.py@@ -1,6 +1,6 @@import logging-from prompt_studio.prompt_studio.models import ToolStudioPrompt+from django.db import modelslogger = logging.getLogger(__name__)@@ -8,7 +8,10 @@ logger = logging.getLogger(__name__)class PromptStudioHelper:@staticmethoddef reorder_prompts_helper(- prompt_id: str, start_sequence_number: int, end_sequence_number: int+ prompt_id: str,+ start_sequence_number: int,+ end_sequence_number: int,+ prompt_model: models.Model,) -> list[dict[str, int]]:"""Helper method to reorder prompts based on sequence numbers.@@ -16,17 +19,18 @@ class PromptStudioHelper:prompt_id (str): The ID of the prompt to be reordered.start_sequence_number (int): The initial sequence number of the prompt.end_sequence_number (int): The new sequence number of the prompt.+ is_sps (bool): Flag to determine the prompt model to use.Returns:list[dict[str, int]]: A list of updated prompt data with their IDsand new sequence numbers."""- prompt_instance: ToolStudioPrompt = ToolStudioPrompt.objects.get(pk=prompt_id)- filtered_prompts_data = []++ prompt_instance = prompt_model.objects.get(pk=prompt_id)tool_id = prompt_instance.tool_id- # Determine the direction of sequence adjustment based on start- # and end sequence numbers+ # Determine the direction of sequence adjustment based on start and+ # end sequence numbersif start_sequence_number < end_sequence_number:logger.info("Start sequence number is less than end sequence number. "@@ -38,7 +42,6 @@ class PromptStudioHelper:"tool_id": tool_id,}increment = False-elif start_sequence_number > end_sequence_number:logger.info("Start sequence number is greater than end sequence number. "@@ -51,9 +54,9 @@ class PromptStudioHelper:}increment = True- # Call helper method to update sequence numbers and get filtered prompt data+ # Update sequence numbers and get filtered prompt datafiltered_prompts_data = PromptStudioHelper.update_sequence_numbers(- filters, increment+ filters, increment, prompt_model)# Update the sequence number of the moved prompt@@ -71,7 +74,9 @@ class PromptStudioHelper:return filtered_prompts_data@staticmethod- def update_sequence_numbers(filters: dict, increment: bool) -> list[dict[str, int]]:+ def update_sequence_numbers(+ filters: dict, increment: bool, prompt_model: models.Model+ ) -> list[dict[str, int]]:"""Update the sequence numbers for prompts based on the providedfilters and increment flag.@@ -79,23 +84,21 @@ class PromptStudioHelper:filters (dict): The filter criteria for selecting prompts.increment (bool): Whether to increment (True) or decrement (False)the sequence numbers.+ prompt_model: The model class for the prompts+ (either ToolStudioPrompt or SPSPrompt).Returns:list[dict[str, int]]: A list of updated prompt data with their IDsand new sequence numbers."""- # Filter prompts based on the provided filters- filtered_prompts = ToolStudioPrompt.objects.filter(**filters)+ filtered_prompts = prompt_model.objects.filter(**filters)# List to hold updated prompt datafiltered_prompts_data = []# Prepare updates and collect datafor prompt in filtered_prompts:- if increment:- prompt.sequence_number += 1- else:- prompt.sequence_number -= 1+ prompt.sequence_number += 1 if increment else -1# Append prompt data to the listfiltered_prompts_data.append(@@ -106,6 +109,6 @@ class PromptStudioHelper:)# Bulk update the sequence numbers- ToolStudioPrompt.objects.bulk_update(filtered_prompts, ["sequence_number"])+ prompt_model.objects.bulk_update(filtered_prompts, ["sequence_number"])return filtered_prompts_datadiff --git a/backend/prompt_studio/prompt_studio/urls.py b/backend/prompt_studio/prompt_studio/urls.pyindex 3d8c3d74c..23e5f0243 100644--- a/backend/prompt_studio/prompt_studio/urls.py+++ b/backend/prompt_studio/prompt_studio/urls.py@@ -22,7 +22,7 @@ urlpatterns = format_suffix_patterns(name="tool-studio-prompt-detail",),path(- "prompt/reorder",+ "prompt/reorder/",reorder_prompts,name="reorder_prompts",),diff --git a/backend/prompt_studio/prompt_studio/views.py b/backend/prompt_studio/prompt_studio/views.pyindex ef68a13a5..a7d734f94 100644--- a/backend/prompt_studio/prompt_studio/views.py+++ b/backend/prompt_studio/prompt_studio/views.py@@ -53,4 +53,4 @@ class ToolStudioPromptView(viewsets.ModelViewSet):Response: The HTTP response indicating the status of the reorder operation."""prompt_studio_controller = PromptStudioController()- return prompt_studio_controller.reorder_prompts(request)+ return prompt_studio_controller.reorder_prompts(request, ToolStudioPrompt)diff --git a/docker/dockerfiles/backend.Dockerfile b/docker/dockerfiles/backend.Dockerfileindex 340c02a10..2522113c8 100644--- a/docker/dockerfiles/backend.Dockerfile+++ b/docker/dockerfiles/backend.Dockerfile@@ -37,7 +37,7 @@ COPY ${BUILD_PACKAGES_PATH}/ /unstractRUN set -e; \\- rm -rf .venv .pdm* .python* requirements.txt 2>/dev/null; \+ rm -rf .venv .pdm* .python* 2>/dev/null; \\pdm venv create -w virtualenv --with-pip; \# source command may not be availble in shdiff --git a/frontend/package-lock.json b/frontend/package-lock.jsonindex d7661da1f..d2c4d022f 100644--- a/frontend/package-lock.json+++ b/frontend/package-lock.json@@ -43,6 +43,7 @@"react-dnd": "^16.0.1","react-dnd-html5-backend": "^16.0.1","react-dom": "^18.2.0",+ "react-google-recaptcha": "^3.1.0","react-gtm-module": "^2.0.11","react-js-cron": "^5.0.1","react-product-fruits": "^2.2.6",@@ -17031,6 +17032,18 @@"node": ">=14"}},+ "node_modules/react-async-script": {+ "version": "1.2.0",+ "resolved": "https://registry.npmjs.org/react-async-script/-/react-async-script-1.2.0.tgz",+ "integrity": "sha512-bCpkbm9JiAuMGhkqoAiC0lLkb40DJ0HOEJIku+9JDjxX3Rcs+ztEOG13wbrOskt3n2DTrjshhaQ/iay+SnGg5Q==",+ "dependencies": {+ "hoist-non-react-statics": "^3.3.0",+ "prop-types": "^15.5.0"+ },+ "peerDependencies": {+ "react": ">=16.4.1"+ }+ },"node_modules/react-dev-utils": {"version": "12.0.1","resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-12.0.1.tgz",@@ -17127,6 +17140,18 @@"resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.11.tgz","integrity": "sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg=="},+ "node_modules/react-google-recaptcha": {+ "version": "3.1.0",+ "resolved": "https://registry.npmjs.org/react-google-recaptcha/-/react-google-recaptcha-3.1.0.tgz",+ "integrity": "sha512-cYW2/DWas8nEKZGD7SCu9BSuVz8iOcOLHChHyi7upUuVhkpkhYG/6N3KDiTQ3XAiZ2UAZkfvYKMfAHOzBOcGEg==",+ "dependencies": {+ "prop-types": "^15.5.0",+ "react-async-script": "^1.2.0"+ },+ "peerDependencies": {+ "react": ">=16.4.1"+ }+ },"node_modules/react-gtm-module": {"version": "2.0.11","resolved": "https://registry.npmjs.org/react-gtm-module/-/react-gtm-module-2.0.11.tgz",@@ -32660,6 +32685,15 @@"whatwg-fetch": "^3.6.2"}},+ "react-async-script": {+ "version": "1.2.0",+ "resolved": "https://registry.npmjs.org/react-async-script/-/react-async-script-1.2.0.tgz",+ "integrity": "sha512-bCpkbm9JiAuMGhkqoAiC0lLkb40DJ0HOEJIku+9JDjxX3Rcs+ztEOG13wbrOskt3n2DTrjshhaQ/iay+SnGg5Q==",+ "requires": {+ "hoist-non-react-statics": "^3.3.0",+ "prop-types": "^15.5.0"+ }+ },"react-dev-utils": {"version": "12.0.1","resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-12.0.1.tgz",@@ -32732,6 +32766,15 @@"resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.11.tgz","integrity": "sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg=="},+ "react-google-recaptcha": {+ "version": "3.1.0",+ "resolved": "https://registry.npmjs.org/react-google-recaptcha/-/react-google-recaptcha-3.1.0.tgz",+ "integrity": "sha512-cYW2/DWas8nEKZGD7SCu9BSuVz8iOcOLHChHyi7upUuVhkpkhYG/6N3KDiTQ3XAiZ2UAZkfvYKMfAHOzBOcGEg==",+ "requires": {+ "prop-types": "^15.5.0",+ "react-async-script": "^1.2.0"+ }+ },"react-gtm-module": {"version": "2.0.11","resolved": "https://registry.npmjs.org/react-gtm-module/-/react-gtm-module-2.0.11.tgz",diff --git a/frontend/package.json b/frontend/package.jsonindex 80516d443..9b2e384cd 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -38,6 +38,7 @@"react-dnd": "^16.0.1","react-dnd-html5-backend": "^16.0.1","react-dom": "^18.2.0",+ "react-google-recaptcha": "^3.1.0","react-gtm-module": "^2.0.11","react-js-cron": "^5.0.1","react-product-fruits": "^2.2.6",diff --git a/frontend/src/components/custom-tools/document-manager/DocumentManager.jsx b/frontend/src/components/custom-tools/document-manager/DocumentManager.jsxindex 0b2a27fa3..a7e8c9ad2 100644--- a/frontend/src/components/custom-tools/document-manager/DocumentManager.jsx+++ b/frontend/src/components/custom-tools/document-manager/DocumentManager.jsx@@ -21,9 +21,8 @@ import { ManageDocsModal } from "../manage-docs-modal/ManageDocsModal";import { PdfViewer } from "../pdf-viewer/PdfViewer";import { TextViewerPre } from "../text-viewer-pre/TextViewerPre";import usePostHogEvents from "../../../hooks/usePostHogEvents";-import { useParams } from "react-router-dom";-const items = [+let items = [{key: "1",label: "PDF View",@@ -97,26 +96,27 @@ function DocumentManager({ generateIndex, handleUpdateTool, handleDocChange }) {const { sessionDetails } = useSessionStore();const axiosPrivate = useAxiosPrivate();const { setPostHogCustomEvent } = usePostHogEvents();- const { id } = useParams();useEffect(() => {if (isSimplePromptStudio) {- items[0] = {- key: "1",- label: (- <Tooltip title="PDF View">- <FilePdfOutlined />- </Tooltip>- ),- };- items[1] = {- key: "2",- label: (- <Tooltip title="Raw View">- <FileTextOutlined />- </Tooltip>- ),- };+ items = [+ {+ key: "1",+ label: (+ <Tooltip title="PDF View">+ <FilePdfOutlined />+ </Tooltip>+ ),+ },+ {+ key: "2",+ label: (+ <Tooltip title="Raw View">+ <FileTextOutlined />+ </Tooltip>+ ),+ },+ ];}}, []);@@ -181,7 +181,7 @@ function DocumentManager({ generateIndex, handleUpdateTool, handleDocChange }) {};const handleGetDocumentsReq = (getDocsFunc, viewType) => {- getDocsFunc(viewType)+ getDocsFunc(details?.tool_id, selectedDoc?.document_id, viewType).then((res) => {const data = res?.data?.data || "";processGetDocsResponse(data, viewType);@@ -194,11 +194,12 @@ function DocumentManager({ generateIndex, handleUpdateTool, handleDocChange }) {});};- const getDocuments = async (viewType) => {- let url = `/api/v1/unstract/${sessionDetails?.orgId}/prompt-studio/file/${details?.tool_id}?document_id=${selectedDoc?.document_id}&view_type=${viewType}`;+ const getDocuments = async (toolId, docId, viewType) => {+ let url = `/api/v1/unstract/${sessionDetails?.orgId}/prompt-studio/file/${toolId}?document_id=${docId}&view_type=${viewType}`;if (isPublicSource) {- url = publicDocumentApi(id, selectedDoc?.document_id, viewType);+ url = publicDocumentApi(toolId, docId, viewType);}+const requestOptions = {url,method: "GET",diff --git a/frontend/src/components/custom-tools/document-parser/DocumentParser.jsx b/frontend/src/components/custom-tools/document-parser/DocumentParser.jsxindex 69951a46e..e84e3342c 100644--- a/frontend/src/components/custom-tools/document-parser/DocumentParser.jsx+++ b/frontend/src/components/custom-tools/document-parser/DocumentParser.jsx@@ -17,9 +17,15 @@ import { useExceptionHandler } from "../../../hooks/useExceptionHandler";import { PromptDnd } from "../prompt-card/PrompDnd";let promptPatchApiSps;+let promptReorderApiSps;+let SpsPromptsEmptyState;try {promptPatchApiSps =require("../../../plugins/simple-prompt-studio/helper").promptPatchApiSps;+ promptReorderApiSps =+ require("../../../plugins/simple-prompt-studio/helper").promptReorderApiSps;+ SpsPromptsEmptyState =+ require("../../../plugins/simple-prompt-studio/SpsPromptsEmptyState").SpsPromptsEmptyState;} catch {// The component will remain null of it is not available}@@ -193,9 +199,13 @@ function DocumentParser({};const handleDelete = (promptId) => {+ let url = promptUrl(promptId + "/");+ if (isSimplePromptStudio) {+ url = promptPatchApiSps(promptId);+ }const requestOptions = {method: "DELETE",- url: promptUrl(promptId + "/"),+ url,headers: {"X-CSRFToken": sessionDetails?.csrfToken,},@@ -242,9 +252,14 @@ function DocumentParser({prompt_id: details.prompts[startIndex]?.prompt_id,};+ let url = promptUrl("reorder/");+ if (isSimplePromptStudio) {+ url = promptReorderApiSps;+ }+const requestOptions = {method: "POST",- url: promptUrl("reorder"),+ url,headers: {"X-CSRFToken": sessionDetails?.csrfToken,"Content-Type": "application/json",@@ -288,6 +303,10 @@ function DocumentParser({};if (!details?.prompts?.length) {+ if (isSimplePromptStudio && SpsPromptsEmptyState) {+ return <SpsPromptsEmptyState />;+ }+return (<EmptyStatetext="Add prompt or a note and choose the LLM profile"diff --git a/frontend/src/components/custom-tools/prompt-card/Header.jsx b/frontend/src/components/custom-tools/prompt-card/Header.jsxindex 6af40b3fd..498b23ec1 100644--- a/frontend/src/components/custom-tools/prompt-card/Header.jsx+++ b/frontend/src/components/custom-tools/prompt-card/Header.jsx@@ -7,7 +7,7 @@ import {PlayCircleOutlined,SyncOutlined,} from "@ant-design/icons";-import { useState } from "react";+import { useEffect, useState } from "react";import { Button, Checkbox, Col, Dropdown, Row, Tag, Tooltip } from "antd";import PropTypes from "prop-types";@@ -17,6 +17,14 @@ import { EditableText } from "../editable-text/EditableText";import { useCustomToolStore } from "../../../store/custom-tool-store";import { ExpandCardBtn } from "./ExpandCardBtn";+let PromptRunBtnSps;+try {+ PromptRunBtnSps =+ require("../../../plugins/simple-prompt-studio/PromptRunBtnSps").PromptRunBtnSps;+} catch {+ // The component will remain 'undefined' it is not available+}+function Header({promptDetails,promptKey,@@ -33,6 +41,9 @@ function Header({expandCard,setExpandCard,enabledProfiles,+ spsLoading,+ handleSpsLoading,+ handleGetOutput,}) {const {selectedDoc,@@ -41,7 +52,9 @@ function Header({isSinglePassExtractLoading,indexDocs,isPublicSource,+ isSimplePromptStudio,} = useCustomToolStore();+ const [items, setItems] = useState([]);const [isDisablePrompt, setIsDisablePrompt] = useState(promptDetails?.active);@@ -60,32 +73,39 @@ function Header({);};- const items = [- {- label: (- <Checkbox checked={isDisablePrompt} onChange={handleDisablePrompt}>- {isDisablePrompt ? "Enabled" : "Disabled"}- </Checkbox>- ),- key: "enable",- },- {- label: (- <ConfirmModal- handleConfirm={() => handleDelete(promptDetails?.prompt_id)}- content="The prompt will be permanently deleted."- >- <DeleteOutlined /> Delete- </ConfirmModal>- ),- key: "delete",- disabled:- disableLlmOrDocChange?.includes(promptDetails?.prompt_id) ||- isSinglePassExtractLoading ||- indexDocs?.includes(selectedDoc?.document_id) ||- isPublicSource,- },- ];+ useEffect(() => {+ const dropdownItems = [+ {+ label: (+ <Checkbox checked={isDisablePrompt} onChange={handleDisablePrompt}>+ {isDisablePrompt ? "Enabled" : "Disabled"}+ </Checkbox>+ ),+ key: "enable",+ },+ {+ label: (+ <ConfirmModal+ handleConfirm={() => handleDelete(promptDetails?.prompt_id)}+ content="The prompt will be permanently deleted."+ >+ <DeleteOutlined /> Delete+ </ConfirmModal>+ ),+ key: "delete",+ disabled:+ disableLlmOrDocChange?.includes(promptDetails?.prompt_id) ||+ isSinglePassExtractLoading ||+ indexDocs?.includes(selectedDoc?.document_id) ||+ isPublicSource,+ },+ ];+ if (isSimplePromptStudio) {+ dropdownItems.splice(0, 1);+ }++ setItems(dropdownItems);+ }, []);return (<Row>@@ -147,7 +167,7 @@ function Header({)}</>)}- {!singlePassExtractMode && (+ {!singlePassExtractMode && !isSimplePromptStudio && (<><Tooltip title="Run"><Button@@ -163,7 +183,8 @@ function Header({promptStudioUpdateStatus?.isUpdating) ||disableLlmOrDocChange?.includes(promptDetails?.prompt_id) ||indexDocs?.includes(selectedDoc?.document_id) ||- isPublicSource+ isPublicSource ||+ spsLoading[selectedDoc?.document_id]}><PlayCircleOutlined className="prompt-card-actions-head" />@@ -174,7 +195,7 @@ function Header({size="small"type="text"className="prompt-card-action-button"- onClick={() => handleRunBtnClick()}+ onClick={handleRunBtnClick}disabled={(updateStatus?.promptId === promptDetails?.prompt_id &&updateStatus?.status ===@@ -189,6 +210,14 @@ function Header({</Tooltip></>)}+ {isSimplePromptStudio && PromptRunBtnSps && (+ <PromptRunBtnSps+ spsLoading={spsLoading}+ handleSpsLoading={handleSpsLoading}+ handleGetOutput={handleGetOutput}+ promptDetails={promptDetails}+ />+ )}<Dropdown menu={{ items }} trigger={["click"]} placement="bottomLeft"><Buttonsize="small"@@ -221,6 +250,9 @@ Header.propTypes = {expandCard: PropTypes.bool.isRequired,setExpandCard: PropTypes.func.isRequired,enabledProfiles: PropTypes.array.isRequired,+ spsLoading: PropTypes.object,+ handleSpsLoading: PropTypes.func.isRequired,+ handleGetOutput: PropTypes.func.isRequired,};export { Header };diff --git a/frontend/src/components/custom-tools/prompt-card/PromptCard.jsx b/frontend/src/components/custom-tools/prompt-card/PromptCard.jsxindex ef0ed947e..136b923e1 100644--- a/frontend/src/components/custom-tools/prompt-card/PromptCard.jsx+++ b/frontend/src/components/custom-tools/prompt-card/PromptCard.jsx@@ -63,6 +63,7 @@ function PromptCard({const [progressMsg, setProgressMsg] = useState({});const [docOutputs, setDocOutputs] = useState([]);const [timers, setTimers] = useState({});+ const [spsLoading, setSpsLoading] = useState({});const {getDropdownItems,llmProfiles,@@ -129,9 +130,6 @@ function PromptCard({resetInfoMsgs();handleGetOutput();handleGetCoverage();- if (isSinglePassExtractLoading) {- return;- }}, [selectedLlmProfileId,selectedDoc,@@ -228,6 +226,13 @@ function PromptCard({});};+ const handleSpsLoading = (docId, isLoadingStatus) => {+ setSpsLoading((prev) => ({+ ...prev,+ [docId]: isLoadingStatus,+ }));+ };+// Generate the result for the currently selected documentconst handleRun = (profileManagerId,@@ -618,7 +623,11 @@ function PromptCard({return;}- if (!singlePassExtractMode && !selectedLlmProfileId) {+ if (+ !singlePassExtractMode &&+ !isSimplePromptStudio &&+ !selectedLlmProfileId+ ) {setResult([]);return;}@@ -807,6 +816,9 @@ function PromptCard({selectedLlmProfileId={selectedLlmProfileId}handleSelectDefaultLLM={handleSelectDefaultLLM}timers={timers}+ spsLoading={spsLoading}+ handleSpsLoading={handleSpsLoading}+ handleGetOutput={handleGetOutput}/>{EvalModal && !singlePassExtractMode && (<EvalModaldiff --git a/frontend/src/components/custom-tools/prompt-card/PromptCardItems.jsx b/frontend/src/components/custom-tools/prompt-card/PromptCardItems.jsxindex 5fb2deb22..4f64f8484 100644--- a/frontend/src/components/custom-tools/prompt-card/PromptCardItems.jsx+++ b/frontend/src/components/custom-tools/prompt-card/PromptCardItems.jsx@@ -67,6 +67,9 @@ function PromptCardItems({selectedLlmProfileId,handleSelectDefaultLLM,timers,+ spsLoading,+ handleSpsLoading,+ handleGetOutput,}) {const {llmProfiles,@@ -121,6 +124,11 @@ function PromptCardItems({};const getAdapterInfo = async (adapterData) => {+ // If simple prompt studio, return early+ if (isSimplePromptStudio) {+ return;+ }+// Update llmProfiles with additional fieldsconst updatedProfiles = llmProfiles?.map((profile) => {return { ...getModelOrAdapterId(profile, adapterData), ...profile };@@ -174,19 +182,22 @@ function PromptCardItems({const renderSinglePassResult = () => {const [firstResult] = result || [];if (- promptDetails.active &&- (firstResult?.output || firstResult?.output === 0)+ (promptDetails.active || isSimplePromptStudio) &&+ (firstResult?.output ||+ firstResult?.output === 0 ||+ spsLoading[selectedDoc?.document_id])) {return (<><Divider className="prompt-card-divider" /><divclassName={`prompt-card-result prompt-card-div ${- expandedProfiles.includes(firstResult.profileManager) &&+ expandedProfiles.includes(firstResult?.profileManager) &&"prompt-profile-run-expanded"}`}>- {isSinglePassExtractLoading ? (+ {isSinglePassExtractLoading ||+ spsLoading[selectedDoc?.document_id] ? (<Spin indicator={<SpinnerLoader size="small" />} />) : (<Typography.Paragraph className="prompt-card-res font-size-12">@@ -246,6 +257,7 @@ function PromptCardItems({useEffect(() => {getAdapterInfo(adapters);}, [llmProfiles, selectedLlmProfileId, enabledProfiles]);+return (<Card className="prompt-card"><div className="prompt-card-div prompt-card-bg-col1 prompt-card-rad">@@ -266,6 +278,9 @@ function PromptCardItems({expandCard={expandCard}setExpandCard={setExpandCard}enabledProfiles={enabledProfiles}+ spsLoading={spsLoading}+ handleSpsLoading={handleSpsLoading}+ handleGetOutput={handleGetOutput}/></Space></div>@@ -355,6 +370,7 @@ function PromptCardItems({<Row><AnimatePresence>{!singlePassExtractMode &&+ !isSimplePromptStudio &&llmProfileDetails.map((profile, index) => {const profileId = profile?.profile_id;const isChecked = enabledProfiles.includes(profileId);@@ -578,7 +594,8 @@ function PromptCardItems({);})}</AnimatePresence>- {singlePassExtractMode && renderSinglePassResult()}+ {(singlePassExtractMode || isSimplePromptStudio) &&+ renderSinglePassResult()}</Row></Collapse.Panel></Collapse>@@ -614,6 +631,9 @@ PromptCardItems.propTypes = {setOpenOutputForDoc: PropTypes.func.isRequired,selectedLlmProfileId: PropTypes.string,timers: PropTypes.object.isRequired,+ spsLoading: PropTypes.object,+ handleSpsLoading: PropTypes.func.isRequired,+ handleGetOutput: PropTypes.func.isRequired,};export { PromptCardItems };diff --git a/frontend/src/index.css b/frontend/src/index.cssindex 21420c95c..27697caa6 100644--- a/frontend/src/index.css+++ b/frontend/src/index.css@@ -123,6 +123,14 @@ body {height: 100%;}+.pad-right-6 {+ padding-right: 6px;+}++.pad-left-6 {+ padding-left: 6px;+}+.cur-pointer {cursor: pointer;}diff --git a/frontend/src/setupProxy.js b/frontend/src/setupProxy.jsindex 6ec9ebbda..6b592e3ae 100644--- a/frontend/src/setupProxy.js+++ b/frontend/src/setupProxy.js@@ -8,11 +8,4 @@ module.exports = (app) => {changeOrigin: true,}));- app.use(- "/public",- createProxyMiddleware({- target: process.env.REACT_APP_BACKEND_URL,- changeOrigin: true,- })- );};diff --git a/prompt-service/src/unstract/prompt_service/constants.py b/prompt-service/src/unstract/prompt_service/constants.pyindex 2b8dacd58..cad39731e 100644--- a/prompt-service/src/unstract/prompt_service/constants.py+++ b/prompt-service/src/unstract/prompt_service/constants.py@@ -52,6 +52,7 @@ class PromptServiceContants:EXTRACTION = "extraction"SUMMARIZE = "summarize"SINGLE_PASS_EXTRACTION = "single-pass-extraction"+ SIMPLE_PROMPT_STUDIO = "simple-prompt-studio"LLM_USAGE_REASON = "llm_usage_reason"METADATA = "metadata"OUTPUT = "output"diff --git a/prompt-service/src/unstract/prompt_service/main.py b/prompt-service/src/unstract/prompt_service/main.pyindex f9a05506a..c58543266 100644--- a/prompt-service/src/unstract/prompt_service/main.py+++ b/prompt-service/src/unstract/prompt_service/main.py@@ -803,6 +803,7 @@ def enable_plugins() -> None:PSKeys.SINGLE_PASS_EXTRACTION, {})summarize_plugin: dict[str, Any] = plugins.get(PSKeys.SUMMARIZE, {})+ simple_prompt_studio: dict[str, Any] = plugins.get(PSKeys.SIMPLE_PROMPT_STUDIO, {})if single_pass_extration_plugin:single_pass_extration_plugin["entrypoint_cls"](app=app, challenge_plugin=plugins.get(PSKeys.CHALLENGE, {})@@ -811,6 +812,10 @@ def enable_plugins() -> None:summarize_plugin["entrypoint_cls"](app=app,)+ if simple_prompt_studio:+ simple_prompt_studio["entrypoint_cls"](+ app=app,+ )enable_plugins()