LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows
Python ai-agentsdata-engineeringdocument-aigenerative-aiidpjson-extractionllmmcp-serverocrpdf-extractionprompt-engineeringstructured-output
[FIX] Table extractor fix for structure tool (#609)
Deepak Kad4f61f5c7c7
diff --git a/tools/structure/sample.env b/tools/structure/sample.envindex e9ccffce9..d2d2ec900 100644--- a/tools/structure/sample.env+++ b/tools/structure/sample.env@@ -2,6 +2,7 @@ PLATFORM_SERVICE_HOST=http://unstract-platform-servicePLATFORM_SERVICE_PORT=3001PLATFORM_SERVICE_API_KEY=<add_platform_key_from_Unstract_frontend>TOOL_DATA_DIR=../data_dir+EXECUTION_RUN_DATA_FOLDER=../data_dirPROMPT_HOST=http://unstract-prompt-servicePROMPT_PORT=3003diff --git a/tools/structure/src/constants.py b/tools/structure/src/constants.pyindex cc341e447..20a8edfd1 100644--- a/tools/structure/src/constants.py+++ b/tools/structure/src/constants.py@@ -73,3 +73,4 @@ class SettingsKeys:METADATA = "metadata"EPILOGUE = "epilogue"HIGHLIGHT_DATA = "highlight_data"+ EXECUTION_RUN_DATA_FOLDER = "EXECUTION_RUN_DATA_FOLDER"diff --git a/tools/structure/src/main.py b/tools/structure/src/main.pyindex aa5551e50..234f88fcc 100644--- a/tools/structure/src/main.py+++ b/tools/structure/src/main.py@@ -69,6 +69,9 @@ class StructureTool(BaseTool):if summarize_as_source:file_name = SettingsKeys.SUMMARIZEtool_data_dir = Path(self.get_env_or_die(SettingsKeys.TOOL_DATA_DIR))+ execution_run_data_folder = Path(+ self.get_env_or_die(SettingsKeys.EXECUTION_RUN_DATA_FOLDER)+ )run_id = CommonUtils.generate_uuid()# TODO : Resolve and pass log events IDpayload = {@@ -170,8 +173,10 @@ class StructureTool(BaseTool):for output in outputs:try:table_settings = output[SettingsKeys.TABLE_SETTINGS]- extracted_input_file = tool_data_dir / SettingsKeys.EXTRACT- table_settings[SettingsKeys.INPUT_FILE] = extracted_input_file+ extracted_input_file = (+ execution_run_data_folder / SettingsKeys.EXTRACT+ )+ table_settings[SettingsKeys.INPUT_FILE] = str(extracted_input_file)output.update({SettingsKeys.TABLE_SETTINGS: table_settings})except KeyError:diff --git a/worker/src/unstract/worker/clients/docker.py b/worker/src/unstract/worker/clients/docker.pyindex 8879f15af..2391d61d7 100644--- a/worker/src/unstract/worker/clients/docker.py+++ b/worker/src/unstract/worker/clients/docker.py@@ -168,18 +168,20 @@ class Client(ContainerClientInterface):envs = {}mounts = []if organization_id and workflow_id and execution_id:+ source_path = os.path.join(+ os.getenv(Env.WORKFLOW_DATA_DIR, ""),+ organization_id,+ workflow_id,+ execution_id,+ )mounts.append({"type": "bind",- "source": os.path.join(- os.getenv(Env.WORKFLOW_DATA_DIR, ""),- organization_id,- workflow_id,- execution_id,- ),+ "source": source_path,"target": os.getenv(Env.TOOL_DATA_DIR, "/data"),})+ envs[Env.EXECUTION_RUN_DATA_FOLDER] = source_pathreturn {"name": ContainerClientHelper.normalize_container_name(self.image_name),"image": self.get_image(),diff --git a/worker/src/unstract/worker/clients/test_docker.py b/worker/src/unstract/worker/clients/test_docker.pyindex 5e1d18635..4d2deead5 100644--- a/worker/src/unstract/worker/clients/test_docker.py+++ b/worker/src/unstract/worker/clients/test_docker.py@@ -132,7 +132,10 @@ def test_get_container_run_config(docker_client, mocker):assert config["name"] == "test-image"assert config["image"] == "test-image:latest"assert config["command"] == ["echo", "hello"]- assert config["environment"] == {"KEY": "VALUE"}+ assert config["environment"] == {+ "KEY": "VALUE",+ "EXECUTION_RUN_DATA_FOLDER": "/source/org123/wf123/ex123",+ }assert config["mounts"] == [{"type": "bind",diff --git a/worker/src/unstract/worker/constants.py b/worker/src/unstract/worker/constants.pyindex 92c3a7b11..4481d96a9 100644--- a/worker/src/unstract/worker/constants.py+++ b/worker/src/unstract/worker/constants.py@@ -21,6 +21,7 @@ class Env:TOOL_CONTAINER_NETWORK = "TOOL_CONTAINER_NETWORK"TOOL_CONTAINER_LABELS = "TOOL_CONTAINER_LABELS"WORKFLOW_DATA_DIR = "WORKFLOW_DATA_DIR"+ EXECUTION_RUN_DATA_FOLDER = "EXECUTION_RUN_DATA_FOLDER"TOOL_DATA_DIR = "TOOL_DATA_DIR"PRIVATE_REGISTRY_CREDENTIAL_PATH = "PRIVATE_REGISTRY_CREDENTIAL_PATH"PRIVATE_REGISTRY_USERNAME = "PRIVATE_REGISTRY_USERNAME"