Skip to content

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

[FIX] Fixed issue where summary context not being used properly (#1260)

Deepak K66dcbd2ca65e
diff --git a/backend/sample.env b/backend/sample.env
index c149e73e6..117a97e3a 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.75"
+STRUCTURE_TOOL_IMAGE_URL="docker:unstract/tool-structure:0.0.76"
STRUCTURE_TOOL_IMAGE_NAME="unstract/tool-structure"
-STRUCTURE_TOOL_IMAGE_TAG="0.0.75"
+STRUCTURE_TOOL_IMAGE_TAG="0.0.76"
# Feature Flags
EVALUATION_SERVER_IP=unstract-flipt
diff --git a/prompt-service/src/unstract/prompt_service/services/extraction.py b/prompt-service/src/unstract/prompt_service/services/extraction.py
index 6d188425f..c6f0377b7 100644
--- a/prompt-service/src/unstract/prompt_service/services/extraction.py
+++ b/prompt-service/src/unstract/prompt_service/services/extraction.py
@@ -86,7 +86,7 @@ class ExtractionService:
metadata = {X2TextConstants.WHISPER_HASH: whisper_hash_value}
for key, value in metadata.items():
tool_exec_metadata[key] = value
- metadata_path = str(Path(execution_run_data_folder / IKeys.METADATA_FILE))
+ metadata_path = str(Path(execution_run_data_folder) / IKeys.METADATA_FILE)
ToolUtils.dump_json(
file_to_dump=metadata_path,
json_to_dump=metadata,
diff --git a/tools/structure/src/config/properties.json b/tools/structure/src/config/properties.json
index 9b618c952..dfa8e2142 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.75",
+ "toolVersion": "0.0.76",
"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/main.py b/tools/structure/src/main.py
index 0f0d79492..cc84e236f 100644
--- a/tools/structure/src/main.py
+++ b/tools/structure/src/main.py
@@ -131,7 +131,7 @@ class StructureTool(BaseTool):
if tool_settings[SettingsKeys.ENABLE_SINGLE_PASS_EXTRACTION]:
if summarize_as_source:
- summarize_file_hash = self._summarize_and_index(
+ summarize_file_path, summarize_file_hash = self._summarize_and_index(
tool_settings=tool_settings,
tool_data_dir=tool_data_dir,
responder=responder,
@@ -139,6 +139,7 @@ class StructureTool(BaseTool):
usage_kwargs=usage_kwargs,
)
payload[SettingsKeys.FILE_HASH] = summarize_file_hash
+ payload[SettingsKeys.FILE_PATH] = summarize_file_path
self.stream_log("Fetching response for single pass extraction")
# Since indexing is not involved for single pass
index_metrics = {"time_taken(s)": 0}
@@ -152,15 +153,18 @@ class StructureTool(BaseTool):
reindex = True
for output in outputs:
if summarize_as_source:
- summarize_file_hash = self._summarize_and_index(
- tool_settings=tool_settings,
- tool_data_dir=tool_data_dir,
- responder=responder,
- outputs=outputs,
- usage_kwargs=usage_kwargs,
+ summarize_file_path, summarize_file_hash = (
+ self._summarize_and_index(
+ tool_settings=tool_settings,
+ tool_data_dir=tool_data_dir,
+ responder=responder,
+ outputs=outputs,
+ usage_kwargs=usage_kwargs,
+ )
)
payload[SettingsKeys.OUTPUTS] = outputs
payload[SettingsKeys.FILE_HASH] = summarize_file_hash
+ payload[SettingsKeys.FILE_PATH] = summarize_file_path
# Since indexing is not involved for summary
index_metrics[output[SettingsKeys.NAME]] = {"time_taken(s)": 0}
break
@@ -282,7 +286,7 @@ class StructureTool(BaseTool):
responder: PromptTool,
outputs: dict[str, Any],
usage_kwargs: dict[Any, Any] = {},
- ) -> str:
+ ) -> tuple[str, str]:
"""Summarizes the context of the file and indexes the summarized
content.
@@ -345,11 +349,10 @@ class StructureTool(BaseTool):
path=summarize_file_path, mode="w", data=summarized_context
)
- self.stream_log("Indexing summarized context")
summarize_file_hash: str = self.workflow_filestorage.get_hash_from_file(
path=summarize_file_path
)
- return summarize_file_hash
+ return str(summarize_file_path), summarize_file_hash
if __name__ == "__main__":