Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

[FIX] Making cell type merge backward compatible in APIs (#1280)

harini-venkataraman9f7839c4d7bf
diff --git a/backend/sample.env b/backend/sample.env
index 117a97e3a..c5c6f53c6 100644
--- a/backend/sample.env
+++ b/backend/sample.env
@@ -75,9 +75,9 @@ PROMPT_STUDIO_FILE_PATH=/app/prompt-studio-data
# Structure Tool Image (Runs prompt studio exported tools)
# https://hub.docker.com/r/unstract/tool-structure
-STRUCTURE_TOOL_IMAGE_URL="docker:unstract/tool-structure:0.0.76"
+STRUCTURE_TOOL_IMAGE_URL="docker:unstract/tool-structure:0.0.77"
STRUCTURE_TOOL_IMAGE_NAME="unstract/tool-structure"
-STRUCTURE_TOOL_IMAGE_TAG="0.0.76"
+STRUCTURE_TOOL_IMAGE_TAG="0.0.77"
# Feature Flags
EVALUATION_SERVER_IP=unstract-flipt
diff --git a/prompt-service/src/unstract/prompt_service/constants.py b/prompt-service/src/unstract/prompt_service/constants.py
index b8660eb4f..6107dfd02 100644
--- a/prompt-service/src/unstract/prompt_service/constants.py
+++ b/prompt-service/src/unstract/prompt_service/constants.py
@@ -92,6 +92,7 @@ class PromptServiceConstants:
"Please try again after some time"
)
COMBINED_PROMPT = "combined_prompt"
+ TOOL = "tool"
class RunLevel(Enum):
diff --git a/prompt-service/src/unstract/prompt_service/controllers/answer_prompt.py b/prompt-service/src/unstract/prompt_service/controllers/answer_prompt.py
index 1fad52806..218e38452 100644
--- a/prompt-service/src/unstract/prompt_service/controllers/answer_prompt.py
+++ b/prompt-service/src/unstract/prompt_service/controllers/answer_prompt.py
@@ -81,6 +81,19 @@ def prompt_processor() -> Any:
app.logger.info(f"[{tool_id}] chunk size: {chunk_size}")
util = PromptServiceBaseTool(platform_key=platform_key)
index = Index(tool=util, run_id=run_id, capture_metrics=True)
+ # To support backward compatability for cell types
+ # line-item, table and record.
+ if execution_source == PSKeys.TOOL:
+ if output[PSKeys.TYPE] == PSKeys.LINE_ITEM:
+ try:
+ output[PSKeys.TABLE_SETTINGS]
+ except KeyError:
+ output[PSKeys.TYPE] == PSKeys.JSON
+ if (output[PSKeys.TYPE] == PSKeys.TABLE) or (
+ output[PSKeys.TYPE] == PSKeys.RECORD
+ ):
+ output[PSKeys.TYPE] = PSKeys.LINE_ITEM
+
if VariableReplacementService.is_variables_present(prompt_text=prompt_text):
prompt_text = VariableReplacementService.replace_variables_in_prompt(
prompt=output,
diff --git a/tools/structure/src/config/properties.json b/tools/structure/src/config/properties.json
index dfa8e2142..26102158a 100644
--- a/tools/structure/src/config/properties.json
+++ b/tools/structure/src/config/properties.json
@@ -2,7 +2,7 @@
"schemaVersion": "0.0.1",
"displayName": "Structure Tool",
"functionName": "structure_tool",
- "toolVersion": "0.0.76",
+ "toolVersion": "0.0.77",
"description": "This is a template tool which can answer set of input prompts designed in the Prompt Studio",
"input": {
"description": "File that needs to be indexed and parsed for answers"
diff --git a/tools/structure/src/constants.py b/tools/structure/src/constants.py
index 8d71ae163..822c061ab 100644
--- a/tools/structure/src/constants.py
+++ b/tools/structure/src/constants.py
@@ -78,6 +78,7 @@ class SettingsKeys:
METRICS = "metrics"
INDEXING = "indexing"
EXECUTION_ID = "execution_id"
+ IS_DIRECTORY_MODE = "is_directory_mode"
class IndexingConstants:
diff --git a/tools/structure/src/main.py b/tools/structure/src/main.py
index bc2430156..189b5506c 100644
--- a/tools/structure/src/main.py
+++ b/tools/structure/src/main.py
@@ -208,7 +208,11 @@ class StructureTool(BaseTool):
for output in outputs:
if SettingsKeys.TABLE_SETTINGS in output:
table_settings = output[SettingsKeys.TABLE_SETTINGS]
+ is_directory_mode: bool = table_settings.get(
+ SettingsKeys.IS_DIRECTORY_MODE, False
+ )
table_settings[SettingsKeys.INPUT_FILE] = extracted_input_file
+ table_settings[SettingsKeys.IS_DIRECTORY_MODE] = is_directory_mode
output.update({SettingsKeys.TABLE_SETTINGS: table_settings})
self.stream_log(f"Fetching responses for {len(outputs)} prompt(s)...")