Skip to content

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

UN-2444 [FIX] Fixing output format for Rent rolls (#1417)

harini-venkataraman02f04304f52d
diff --git a/backend/prompt_studio/prompt_studio_output_manager_v2/output_manager_helper.py b/backend/prompt_studio/prompt_studio_output_manager_v2/output_manager_helper.py
index 39cff534a..f20d3c88d 100644
--- a/backend/prompt_studio/prompt_studio_output_manager_v2/output_manager_helper.py
+++ b/backend/prompt_studio/prompt_studio_output_manager_v2/output_manager_helper.py
@@ -141,7 +141,8 @@ class OutputManagerHelper:
continue
if not is_single_pass_extract:
- context = context.get(prompt.prompt_key)
+ if context:
+ context = context.get(prompt.prompt_key)
if highlight_data:
highlight_data = highlight_data.get(prompt.prompt_key)
if confidence_data:
@@ -152,12 +153,12 @@ class OutputManagerHelper:
if challenge_data:
challenge_data["file_name"] = metadata.get("file_name")
- output = outputs.get(prompt.prompt_key)
# TODO: use enums here
+ output = outputs.get(prompt.prompt_key)
if prompt.enforce_type in {"json", "table", "record", "line-item"}:
output = json.dumps(output)
- profile_manager = default_profile
eval_metrics = outputs.get(f"{prompt.prompt_key}__evaluation", [])
+ profile_manager = default_profile
# Update or create the prompt output
prompt_output = update_or_create_prompt_output(
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 3e8ad369b..52bf7dfd2 100644
--- a/prompt-service/src/unstract/prompt_service/controllers/answer_prompt.py
+++ b/prompt-service/src/unstract/prompt_service/controllers/answer_prompt.py
@@ -227,8 +227,9 @@ def prompt_processor() -> Any:
# Update structured output with the extraction result
# TODO: Add metrics
# TODO: Add metadata
+ structured_output[output[PSKeys.NAME]] = extraction_result
response = {
- PSKeys.OUTPUT: extraction_result,
+ PSKeys.OUTPUT: structured_output,
PSKeys.METADATA: {},
PSKeys.METRICS: {},
}