Skip to content

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

PR comments addressed sdk version update in requirements ocr_adapter.process() used to write output readme updated tools json typo fix

vishnuszipstack8484bf602c78
diff --git a/tools/ocr/README.md b/tools/ocr/README.md
index 4ba66babb..5b0d49411 100644
--- a/tools/ocr/README.md
+++ b/tools/ocr/README.md
@@ -72,15 +72,14 @@ python main.py --command VARIABLES
#### Run RUN command
-The format of the jsons required for settings and params can be found by running the SPEC command and the PROPERTIES
-command respectively. Alternatively if you have access to the code base, it is located in the `config` folder
-as `spec.json` and `properties.json`.
+The schema of the JSON required for settings can be found by running the [SPEC](#run-spec-command) command. Alternatively if you have access to the code base, it is located in the `config` folder as `spec.json`.
```commandline
python main.py \
--command RUN \
--settings '{
+ "ocrAdapterId": "<ocr_adapter_id of adapter>"
}' \
--workflow-id '00000000-0000-0000-0000-000000000000' \
--log-level DEBUG
@@ -90,7 +89,7 @@ python main.py \
Build the tool docker image from the folder containing the `Dockerfile` with
```commandline
-docker build -t unstract/tool-example:0.0.1 .
+docker build -t unstract/tool-ocr:0.0.1 .
```
Make sure the directory pointed by `TOOL_DATA_DIR` has the required information for the tool to run and
@@ -102,9 +101,10 @@ docker run -it \
--network unstract-network \
--env-file .env \
-v "$(pwd)"/data_dir:/app/data_dir \
- unstract/tool-example:0.0.1 \
+ unstract/tool-ocr:0.0.1 \
--command RUN \
--settings '{
+ "ocrAdapterId": "<ocr_adapter_id of adapter>"
}' \
--workflow-id '00000000-0000-0000-0000-000000000000' \
--log-level DEBUG
diff --git a/tools/ocr/requirements.txt b/tools/ocr/requirements.txt
index cfbb98360..1d381f5ee 100644
--- a/tools/ocr/requirements.txt
+++ b/tools/ocr/requirements.txt
@@ -6,4 +6,4 @@ requests==2.31.0
pillow~=10.2.0
# Required for all unstract tools
-unstract-sdk==0.12.0
+unstract-sdk~=0.12.1
diff --git a/tools/ocr/src/config/properties.json b/tools/ocr/src/config/properties.json
index a34a5bc81..4c8c7554e 100644
--- a/tools/ocr/src/config/properties.json
+++ b/tools/ocr/src/config/properties.json
@@ -8,7 +8,7 @@
"description": "The file on which OCR operation is to be performed"
},
"output": {
- "description": "Places the file into a folder (bin) that its OCR opertation performed into."
+ "description": "Places the file into a folder (bin) that its OCR operation performed into."
},
"result": {
"type": "JSON",
diff --git a/tools/ocr/src/main.py b/tools/ocr/src/main.py
index dd2127917..2f4fef7a2 100644
--- a/tools/ocr/src/main.py
+++ b/tools/ocr/src/main.py
@@ -85,11 +85,7 @@ class UnstractOCR(BaseTool):
self.stream_log("Writing tool output")
source_name = self.get_exec_metadata.get(MetadataKey.SOURCE_NAME)
output_path = Path(output_dir) / f"{Path(source_name).stem}.txt"
- try:
- with open(output_path, "w", encoding="utf-8") as f:
- f.write(result_text)
- except Exception as e:
- self.stream_error_and_exit(f"Error creating output file: {e}")
+ ocr_adapter.process(input_file_path=input_file, output_file_path=output_path)
# Log output
if len(result_text) > 1000:
diff --git a/unstract/tool-registry/src/unstract/tool_registry/public_tools.json b/unstract/tool-registry/src/unstract/tool_registry/public_tools.json
index 31b00467b..045c57343 100644
--- a/unstract/tool-registry/src/unstract/tool_registry/public_tools.json
+++ b/unstract/tool-registry/src/unstract/tool_registry/public_tools.json
@@ -659,7 +659,7 @@
"description": "The file on which OCR operation is to be performed"
},
"output": {
- "description": "Places the file into a folder (bin) that its OCR opertation performed into."
+ "description": "Places the file into a folder (bin) that its OCR operation performed into."
},
"result": {
"type": "JSON",