LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows
Python ai-agentsdata-engineeringdocument-aigenerative-aiidpjson-extractionllmmcp-serverocrpdf-extractionprompt-engineeringstructured-output
Added support for single pass extraction (#104)
Deepak K81e12b6dc35e
diff --git a/backend/prompt_studio/prompt_studio_core/constants.py b/backend/prompt_studio/prompt_studio_core/constants.pyindex 2bc8e8889..a40ce2fac 100644--- a/backend/prompt_studio/prompt_studio_core/constants.py+++ b/backend/prompt_studio/prompt_studio_core/constants.py@@ -78,6 +78,8 @@ class ToolStudioPromptKeys:SUMMARIZE = "summarize"SUMMARIZED_RESULT = "summarized_result"DOCUMENT_ID = "document_id"+ EXTRACT = "extract"+ LLM_PROFILE_MANAGER = "llm_profile_manager"class LogLevels:diff --git a/backend/prompt_studio/prompt_studio_core/exceptions.py b/backend/prompt_studio/prompt_studio_core/exceptions.pyindex 1d3d1dda2..609dd567d 100644--- a/backend/prompt_studio/prompt_studio_core/exceptions.py+++ b/backend/prompt_studio/prompt_studio_core/exceptions.py@@ -19,7 +19,7 @@ class PromptNotValid(APIException):class IndexingError(APIException):- status_code = 500+ status_code = 400default_detail = "Error while indexing file"@@ -49,3 +49,8 @@ class OutputSaveError(APIException):class ToolDeleteError(APIException):status_code = 500default_detail = "Failed to delete the error"+++class NoPromptsFound(APIException):+ status_code = 404+ default_detail = "No prompts available to process"diff --git a/backend/prompt_studio/prompt_studio_core/prompt_studio_helper.py b/backend/prompt_studio/prompt_studio_core/prompt_studio_helper.pyindex 2fa311813..920d9fccd 100644--- a/backend/prompt_studio/prompt_studio_core/prompt_studio_helper.py+++ b/backend/prompt_studio/prompt_studio_core/prompt_studio_helper.py@@ -17,6 +17,7 @@ from prompt_studio.prompt_studio_core.exceptions import (AnswerFetchError,DefaultProfileError,IndexingError,+ NoPromptsFound,PromptNotValid,ToolNotValid,)@@ -171,18 +172,18 @@ class PromptStudioHelper:@staticmethoddef prompt_responder(- id: str,tool_id: str,file_name: str,org_id: str,user_id: str,document_id: str,+ id: Optional[str] = None,) -> Any:"""Execute chain/single run of the prompts. Makes a call to promptservice and returns the dict of response.Args:- id (str): ID of the prompt+ id (Optional[str]): ID of the prompttool_id (str): ID of tool created in prompt studiofile_name (str): Name of the file uploadedorg_id (str): Organization ID@@ -195,7 +196,6 @@ class PromptStudioHelper:Returns:Any: Dictionary containing the response from prompt-service"""- logger.info(f"Invoking prompt responser for prompt {id}")file_path = FileManagerHelper.handle_sub_directory_for_tenants(org_id=org_id,user_id=user_id,@@ -203,8 +203,9 @@ class PromptStudioHelper:is_create=False,)file_path = str(Path(file_path) / file_name)- if id and tool_id:- logger.info("Executing in single prompt mode")+ if id:+ message: str = f"Executing single prompt {id} of tool {tool_id}"+ logger.info(message)try:prompt_instance = PromptStudioHelper._fetch_prompt_from_id(id)prompts: list[ToolStudioPrompt] = []@@ -224,8 +225,7 @@ class PromptStudioHelper:stream_log.log(stage=LogLevels.RUN,level=LogLevels.INFO,- message=f"Executing single prompt \- {id} of tool {tool.tool_id}",+ message=message,),)if not prompt_instance:@@ -271,6 +271,66 @@ class PromptStudioHelper:)logger.info(f"Response fetched succesfully for prompt {id}")return response+ else:+ message = f"Executing in single pass prompt mode for tool {tool_id}"+ logger.info(message)+ try:+ prompts = PromptStudioHelper.fetch_prompt_from_tool(tool_id)++ if not prompts:+ raise NoPromptsFound()++ tool = prompts[0].tool_id+ response = PromptStudioHelper._fetch_single_pass_response(+ file_path=file_path,+ tool=tool,+ prompts=prompts,+ org_id=org_id,+ document_id=document_id,+ )++ stream_log.publish(+ tool_id,+ stream_log.log(+ stage=LogLevels.RUN,+ level=LogLevels.INFO,+ message="Executing single pass "+ f"prompt for tool {tool_id}",+ ),+ )+ except NoPromptsFound:+ logger.error("No prompts found for tool %s", tool_id)+ raise+ except Exception as e:+ logger.error("Error while fetching prompt %s", e)+ raise AnswerFetchError()+ stream_log.publish(+ tool_id,+ stream_log.log(+ stage=LogLevels.RUN,+ level=LogLevels.INFO,+ message=f"Prompt instances fetched for tool {tool_id}",+ ),+ )+ stream_log.publish(+ tool_id,+ stream_log.log(+ stage=LogLevels.RUN,+ level=LogLevels.INFO,+ message=f"Invoking prompt service for tool {tool_id}",+ ),+ )+ stream_log.publish(+ tool_id,+ stream_log.log(+ stage=LogLevels.RUN,+ level=LogLevels.INFO,+ message=f"Response fetched sucessfully \+ from platform for tool {tool_id}",+ ),+ )+ logger.info("Response fetched succesfully for tool %s", tool_id)+ return response@staticmethoddef _fetch_response(@@ -449,7 +509,8 @@ class PromptStudioHelper:extract_file_path = os.path.join(directory, "extract", os.path.splitext(filename)[0] + ".txt")-+ else:+ profile_manager.chunk_size = 0try:doc_id: str = tool_index.index_file(tool_id=tool_id,@@ -473,3 +534,90 @@ class PromptStudioHelper:return doc_idexcept SdkError as e:raise IndexingError(str(e))++ @staticmethod+ def _fetch_single_pass_response(+ tool: CustomTool,+ file_path: str,+ prompts: list[ToolStudioPrompt],+ org_id: str,+ document_id: str,+ ) -> Any:+ tool_id: str = str(tool.tool_id)+ outputs: list[dict[str, Any]] = []+ grammar: list[dict[str, Any]] = []+ prompt_grammar = tool.prompt_grammer+ default_profile: ProfileManager = ProfileManager.objects.get(+ prompt_studio_tool=tool, is_default=True+ )+ default_profile.chunk_size = 0 # To retrive full context++ if prompt_grammar:+ for word, synonyms in prompt_grammar.items():+ grammar.append({TSPKeys.WORD: word, TSPKeys.SYNONYMS: synonyms})++ if not default_profile:+ raise DefaultProfileError()++ PromptStudioHelper.dynamic_indexer(+ profile_manager=default_profile,+ file_path=file_path,+ tool_id=tool_id,+ org_id=org_id,+ is_summary=tool.summarize_as_source,+ document_id=document_id,+ )++ vector_db = str(default_profile.vector_store.id)+ embedding_model = str(default_profile.embedding_model.id)+ llm = str(default_profile.llm.id)+ x2text = str(default_profile.x2text.id)+ llm_profile_manager = {}+ llm_profile_manager[TSPKeys.PREAMBLE] = tool.preamble+ llm_profile_manager[TSPKeys.POSTAMBLE] = tool.postamble+ llm_profile_manager[TSPKeys.GRAMMAR] = grammar+ llm_profile_manager[TSPKeys.LLM] = llm+ llm_profile_manager[TSPKeys.X2TEXT_ADAPTER] = x2text+ llm_profile_manager[TSPKeys.VECTOR_DB] = vector_db+ llm_profile_manager[TSPKeys.EMBEDDING] = embedding_model+ llm_profile_manager[TSPKeys.CHUNK_SIZE] = default_profile.chunk_size+ llm_profile_manager[+ TSPKeys.CHUNK_OVERLAP+ ] = default_profile.chunk_overlap++ for prompt in prompts:+ output: dict[str, Any] = {}+ output[TSPKeys.PROMPT] = prompt.prompt+ output[TSPKeys.ACTIVE] = prompt.active+ output[TSPKeys.TYPE] = prompt.enforce_type+ output[TSPKeys.NAME] = prompt.prompt_key+ outputs.append(output)++ if tool.summarize_as_source:+ path = Path(file_path)+ file_path = str(+ path.parent / TSPKeys.SUMMARIZE / (path.stem + ".txt")+ )+ file_hash = ToolUtils.get_hash_from_file(file_path=file_path)++ payload = {+ TSPKeys.LLM_PROFILE_MANAGER: llm_profile_manager,+ TSPKeys.OUTPUTS: outputs,+ TSPKeys.TOOL_ID: tool_id,+ TSPKeys.FILE_HASH: file_hash,+ }++ util = PromptIdeBaseTool(log_level=LogLevel.INFO, org_id=org_id)++ responder = PromptTool(+ tool=util,+ prompt_host=settings.PROMPT_HOST,+ prompt_port=settings.PROMPT_PORT,+ )++ answer = responder.single_pass_extraction(payload)+ # TODO: Make use of dataclasses+ if answer["status"] == "ERROR":+ raise AnswerFetchError()+ output_response = json.loads(answer["structure_output"])+ return output_responsediff --git a/backend/prompt_studio/prompt_studio_core/urls.py b/backend/prompt_studio/prompt_studio_core/urls.pyindex b90476b63..089ac4ace 100644--- a/backend/prompt_studio/prompt_studio_core/urls.py+++ b/backend/prompt_studio/prompt_studio_core/urls.py@@ -30,6 +30,9 @@ prompt_studio_prompt_response = PromptStudioCoreView.as_view(prompt_studio_adapter_choices = PromptStudioCoreView.as_view({"get": "get_adapter_choices"})+prompt_studio_single_pass_extraction = PromptStudioCoreView.as_view(+ {"post": "single_pass_extraction"}+)urlpatterns = format_suffix_patterns([@@ -64,5 +67,10 @@ urlpatterns = format_suffix_patterns(prompt_studio_adapter_choices,name="prompt-studio-adapter-choices",),+ path(+ "prompt-studio/single-pass-extraction",+ prompt_studio_single_pass_extraction,+ name="prompt-studio-single-pass-extraction",+ ),])diff --git a/backend/prompt_studio/prompt_studio_core/views.py b/backend/prompt_studio/prompt_studio_core/views.pyindex 868e85faa..c5ee0d0d4 100644--- a/backend/prompt_studio/prompt_studio_core/views.py+++ b/backend/prompt_studio/prompt_studio_core/views.py@@ -264,3 +264,35 @@ class PromptStudioCoreView(viewsets.ModelViewSet):document_id=document_id,)return Response(response, status=status.HTTP_200_OK)++ @action(detail=True, methods=["post"])+ def single_pass_extraction(self, request: HttpRequest) -> Response:+ """API Entry point method to fetch response to prompt.++ Args:+ request (HttpRequest): _description_++ Raises:+ FilenameMissingError: _description_++ Returns:+ Response+ """+ # TODO: Handle fetch_response and single_pass_+ # extraction using common function+ tool_id: str = request.data.get(ToolStudioPromptKeys.TOOL_ID)+ document_id: str = request.data.get(ToolStudioPromptKeys.DOCUMENT_ID)+ document: DocumentManager = DocumentManager.objects.get(pk=document_id)+ file_name: str = document.document_name++ if not file_name or file_name == ToolStudioPromptKeys.UNDEFINED:+ logger.error("Mandatory field file_name is missing")+ raise FilenameMissingError()+ response: dict[str, Any] = PromptStudioHelper.prompt_responder(+ tool_id=tool_id,+ file_name=file_name,+ org_id=request.org_id,+ user_id=request.user.user_id,+ document_id=document_id,+ )+ return Response(response, status=status.HTTP_200_OK)diff --git a/frontend/src/components/custom-tools/combined-output/CombinedOutput.jsx b/frontend/src/components/custom-tools/combined-output/CombinedOutput.jsxindex ed011562a..1baa101e3 100644--- a/frontend/src/components/custom-tools/combined-output/CombinedOutput.jsx+++ b/frontend/src/components/custom-tools/combined-output/CombinedOutput.jsx@@ -1,5 +1,3 @@-import { Segmented } from "antd";-import jsYaml from "js-yaml";import Prism from "prismjs";import "prismjs/components/prism-json";import "prismjs/plugins/line-numbers/prism-line-numbers.css";@@ -17,19 +15,11 @@ import { SpinnerLoader } from "../../widgets/spinner-loader/SpinnerLoader";import "./CombinedOutput.css";import { useExceptionHandler } from "../../../hooks/useExceptionHandler";-const outputTypes = {- json: "JSON",- yaml: "YAML",-};--function CombinedOutput({ docId, setFilledFields }) {+function CombinedOutput({ docId, setFilledFields, triggerRunSinglePass }) {const [combinedOutput, setCombinedOutput] = useState({});- const [yamlData, setYamlData] = useState(null);- const [selectedOutputType, setSelectedOutputType] = useState(- outputTypes.json- );const [isOutputLoading, setIsOutputLoading] = useState(false);- const { details } = useCustomToolStore();+ const { details, isSinglePassExtract, updateCustomTool } =+ useCustomToolStore();const { sessionDetails } = useSessionStore();const { setAlertDetails } = useAlertStore();const axiosPrivate = useAxiosPrivate();@@ -40,6 +30,10 @@ function CombinedOutput({ docId, setFilledFields }) {return;}+ if (isSinglePassExtract) {+ return;+ }+let filledFields = 0;setIsOutputLoading(true);handleOutputApiRequest()@@ -81,9 +75,6 @@ function CombinedOutput({ docId, setFilledFields }) {if (setFilledFields) {setFilledFields(filledFields);}-- const yamlDump = jsYaml.dump(output);- setYamlData(yamlDump);}).catch((err) => {setAlertDetails(@@ -97,11 +88,11 @@ function CombinedOutput({ docId, setFilledFields }) {useEffect(() => {Prism.highlightAll();- }, [combinedOutput, selectedOutputType]);+ }, [combinedOutput]);- const handleOutputTypeChange = (value) => {- setSelectedOutputType(value);- };+ useEffect(() => {+ runSinglePassExtraction();+ }, [triggerRunSinglePass]);const handleOutputApiRequest = async () => {const requestOptions = {@@ -119,6 +110,37 @@ function CombinedOutput({ docId, setFilledFields }) {});};+ const runSinglePassExtraction = () => {+ const body = {+ document_id: docId,+ tool_id: details?.tool_id,+ };++ const requestOptions = {+ method: "POST",+ url: `/api/v1/unstract/${sessionDetails?.orgId}/prompt-studio/single-pass-extraction`,+ headers: {+ "X-CSRFToken": sessionDetails?.csrfToken,+ "Content-Type": "application/json",+ },+ data: body,+ };++ axiosPrivate(requestOptions)+ .then((res) => {+ const data = res?.data || {};+ setCombinedOutput(data);+ })+ .catch((err) => {+ setAlertDetails(+ handleException(err, "Failed to generate single pass extraction")+ );+ })+ .finally(() => {+ updateCustomTool({ isSinglePassExtract: false });+ });+ };+if (isOutputLoading) {return <SpinnerLoader />;}@@ -126,23 +148,14 @@ function CombinedOutput({ docId, setFilledFields }) {return (<div className="combined-op-layout"><div className="combined-op-header">- <div className="combined-op-segment">- <Segmented- size="small"- defaultValue={selectedOutputType}- options={["JSON", "YAML"]}- onChange={handleOutputTypeChange}- />- </div>+ <div className="combined-op-segment"></div></div><div className="combined-op-divider" /><div className="combined-op-body code-snippet">{combinedOutput && (<pre className="line-numbers width-100"><code className="language-javascript width-100">- {selectedOutputType === outputTypes.json- ? JSON.stringify(combinedOutput, null, 2)- : yamlData}+ {JSON.stringify(combinedOutput, null, 2)}</code></pre>)}@@ -155,6 +168,7 @@ function CombinedOutput({ docId, setFilledFields }) {CombinedOutput.propTypes = {docId: PropTypes.string,setFilledFields: PropTypes.func,+ triggerRunSinglePass: PropTypes.bool.isRequired,};export { CombinedOutput };diff --git a/frontend/src/components/custom-tools/document-manager/DocumentManager.css b/frontend/src/components/custom-tools/document-manager/DocumentManager.cssindex f28432a7f..47af475d1 100644--- a/frontend/src/components/custom-tools/document-manager/DocumentManager.css+++ b/frontend/src/components/custom-tools/document-manager/DocumentManager.css@@ -10,6 +10,7 @@.doc-manager-header {display: flex;justify-content: space-between;+ padding-right: 12px}.doc-manager-btn {diff --git a/frontend/src/components/custom-tools/document-manager/DocumentManager.jsx b/frontend/src/components/custom-tools/document-manager/DocumentManager.jsxindex f1e70f4ba..71d0319ab 100644--- a/frontend/src/components/custom-tools/document-manager/DocumentManager.jsx+++ b/frontend/src/components/custom-tools/document-manager/DocumentManager.jsx@@ -59,8 +59,14 @@ function DocumentManager({ generateIndex, handleUpdateTool, handleDocChange }) {const [currDocIndexStatus, setCurrDocIndexStatus] = useState(docIndexStatus.yet_to_start);- const { selectedDoc, listOfDocs, disableLlmOrDocChange, details, indexDocs } =- useCustomToolStore();+ const {+ selectedDoc,+ listOfDocs,+ disableLlmOrDocChange,+ details,+ indexDocs,+ isSinglePassExtract,+ } = useCustomToolStore();const { sessionDetails } = useSessionStore();const axiosPrivate = useAxiosPrivate();@@ -219,7 +225,10 @@ function DocumentManager({ generateIndex, handleUpdateTool, handleDocChange }) {type="text"size="small"disabled={- !selectedDoc || disableLlmOrDocChange?.length > 0 || page <= 1+ !selectedDoc ||+ disableLlmOrDocChange?.length > 0 ||+ page <= 1 ||+ isSinglePassExtract}onClick={handlePageLeft}>@@ -231,7 +240,8 @@ function DocumentManager({ generateIndex, handleUpdateTool, handleDocChange }) {disabled={!selectedDoc ||disableLlmOrDocChange?.length > 0 ||- page >= listOfDocs?.length+ page >= listOfDocs?.length ||+ isSinglePassExtract}onClick={handlePageRight}>diff --git a/frontend/src/components/custom-tools/manage-docs-modal/ManageDocsModal.jsx b/frontend/src/components/custom-tools/manage-docs-modal/ManageDocsModal.jsxindex 73d6839b9..ec823b981 100644--- a/frontend/src/components/custom-tools/manage-docs-modal/ManageDocsModal.jsx+++ b/frontend/src/components/custom-tools/manage-docs-modal/ManageDocsModal.jsx@@ -69,6 +69,7 @@ function ManageDocsModal({indexDocs,rawIndexStatus,summarizeIndexStatus,+ isSinglePassExtract,} = useCustomToolStore();const axiosPrivate = useAxiosPrivate();const handleException = useExceptionHandler();@@ -275,7 +276,8 @@ function ManageDocsModal({disableLlmOrDocChange?.length > 0 ||indexDocs.includes(item?.document_id) ||isUploading ||- !defaultLlmProfile+ !defaultLlmProfile ||+ isSinglePassExtract}/></Tooltip>@@ -293,7 +295,7 @@ function ManageDocsModal({disableLlmOrDocChange?.length > 0 ||indexDocs.includes(item?.document_id) ||isUploading ||- !defaultLlmProfile+ isSinglePassExtract}><DeleteOutlined className="manage-llm-pro-icon" />@@ -307,7 +309,8 @@ function ManageDocsModal({onClick={() => handleDocChange(item?.document_id)}disabled={disableLlmOrDocChange?.length > 0 ||- indexDocs.includes(item?.document_id)+ indexDocs.includes(item?.document_id) ||+ isSinglePassExtract}/>),@@ -321,6 +324,7 @@ function ManageDocsModal({rawIndexStatus,summarizeIndexStatus,indexDocs,+ isSinglePassExtract,]);const beforeUpload = (file) => {@@ -441,7 +445,9 @@ function ManageDocsModal({blockloading={isUploading}disabled={- !defaultLlmProfile || disableLlmOrDocChange?.length > 0+ !defaultLlmProfile ||+ disableLlmOrDocChange?.length > 0 ||+ isSinglePassExtract}>Upload New Filediff --git a/frontend/src/components/custom-tools/tools-main/ToolsMain.jsx b/frontend/src/components/custom-tools/tools-main/ToolsMain.jsxindex d097b4b85..424ad7026 100644--- a/frontend/src/components/custom-tools/tools-main/ToolsMain.jsx+++ b/frontend/src/components/custom-tools/tools-main/ToolsMain.jsx@@ -1,5 +1,6 @@-import { Tabs } from "antd";+import { Button, Tabs, Tooltip } from "antd";import { useEffect, useState } from "react";+import { PlayCircleOutlined } from "@ant-design/icons";import { promptType } from "../../../helpers/GetStaticData";import { useAxiosPrivate } from "../../../hooks/useAxiosPrivate";@@ -15,6 +16,7 @@ import { useExceptionHandler } from "../../../hooks/useExceptionHandler";function ToolsMain() {const [activeKey, setActiveKey] = useState("1");const [prompts, setPrompts] = useState([]);+ const [triggerRunSinglePass, setTriggerRunSinglePass] = useState(false);const [scrollToBottom, setScrollToBottom] = useState(false);const { sessionDetails } = useSessionStore();const {@@ -23,6 +25,7 @@ function ToolsMain() {selectedDoc,updateCustomTool,disableLlmOrDocChange,+ isSinglePassExtract,} = useCustomToolStore();const { setAlertDetails } = useAlertStore();const axiosPrivate = useAxiosPrivate();@@ -32,6 +35,7 @@ function ToolsMain() {{key: "1",label: "Document Parser",+ disabled: isSinglePassExtract,},{key: "2",@@ -87,6 +91,14 @@ function ToolsMain() {setPrompts(details?.prompts || []);}, [details]);+ useEffect(() => {+ if (!isSinglePassExtract) {+ return;+ }+ setActiveKey("2");+ setTriggerRunSinglePass((prev) => !prev);+ }, [isSinglePassExtract]);+const onChange = (key) => {setActiveKey(key);};@@ -123,10 +135,26 @@ function ToolsMain() {});};+ const handleSinglePassExtraction = () => {+ updateCustomTool({ isSinglePassExtract: true });+ };+return (<div className="tools-main-layout">- <div className="tools-main-tabs">- <Tabs activeKey={activeKey} items={items} onChange={onChange} />+ <div className="doc-manager-header">+ <div className="tools-main-tabs">+ <Tabs activeKey={activeKey} items={items} onChange={onChange} />+ </div>+ <div className="display-flex-align-center">+ <Tooltip title="Single Pass Extraction">+ <Button+ onClick={handleSinglePassExtraction}+ loading={isSinglePassExtract}+ disabled={disableLlmOrDocChange?.length > 0}+ icon={<PlayCircleOutlined />}+ />+ </Tooltip>+ </div></div><div className="tools-main-body">{activeKey === "1" && (@@ -137,7 +165,10 @@ function ToolsMain() {/>)}{activeKey === "2" && (- <CombinedOutput docId={selectedDoc?.document_id} />+ <CombinedOutput+ docId={selectedDoc?.document_id}+ triggerRunSinglePass={triggerRunSinglePass}+ />)}</div><div className="tools-main-footer">diff --git a/frontend/src/store/custom-tool-store.js b/frontend/src/store/custom-tool-store.jsindex 9fb8689a0..2bac346dc 100644--- a/frontend/src/store/custom-tool-store.js+++ b/frontend/src/store/custom-tool-store.js@@ -13,6 +13,7 @@ const defaultState = {indexDocs: [],rawIndexStatus: [],summarizeIndexStatus: [],+ isSinglePassExtract: false,};const defaultPromptInstance = {diff --git a/prompt-service/src/unstract/prompt_service/constants.py b/prompt-service/src/unstract/prompt_service/constants.pyindex a397d7a57..5a7a1e207 100644--- a/prompt-service/src/unstract/prompt_service/constants.py+++ b/prompt-service/src/unstract/prompt_service/constants.py@@ -86,6 +86,7 @@ class PromptServiceContants:EVAL_SETTINGS_EVALUATE = "evaluate"EVAL_SETTINGS_MONITOR_LLM = "monitor_llm"EVAL_SETTINGS_EXCLUDE_FAILED = "exclude_failed"+ LLM_PROFILE_MANAGER = "llm_profile_manager"class Query:diff --git a/prompt-service/src/unstract/prompt_service/main.py b/prompt-service/src/unstract/prompt_service/main.pyindex b83e8a5be..6be1d019f 100644--- a/prompt-service/src/unstract/prompt_service/main.py+++ b/prompt-service/src/unstract/prompt_service/main.py@@ -392,7 +392,11 @@ def authentication_middleware(func: Any) -> Any:return wrapper[email protected]("/answer-prompt", methods=["POST", "GET", "DELETE"])+ "/answer-prompt",+ endpoint="answer_prompt",+ methods=["POST", "GET", "DELETE"],+)@authentication_middlewaredef prompt_processor() -> Any:result: dict[str, Any] = {}@@ -520,7 +524,7 @@ def prompt_processor() -> Any:].find(" ")if first_space_index > 0:answer = output[PSKeys.ASSERTION_FAILURE_PROMPT][- first_space_index + 1 : # noqa+ first_space_index + 1]app.logger.info(f"[Assigning] {answer} to the output")else:@@ -925,6 +929,18 @@ def extract_variable(# f.write(json.dumps(structured_output, indent=2))+def enable_single_pass_extraction():+ """Enables single-pass-extraction plugin if available."""+ single_pass_extration_plugin: dict[str, Any] = plugins.get(+ "single-pass-extraction", {}+ )+ if single_pass_extration_plugin:+ single_pass_extration_plugin["entrypoint_cls"](app)+++enable_single_pass_extraction()++if __name__ == "__main__":# Start the serverapp.run(host="0.0.0.0", port=5003)