reducto-cli 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- reducto_cli-0.1.0/PKG-INFO +175 -0
- reducto_cli-0.1.0/README.md +165 -0
- reducto_cli-0.1.0/main.py +5 -0
- reducto_cli-0.1.0/pyproject.toml +25 -0
- reducto_cli-0.1.0/reducto_cli/INSTRUCTIONS.md +152 -0
- reducto_cli-0.1.0/reducto_cli/__init__.py +10 -0
- reducto_cli-0.1.0/reducto_cli/__main__.py +5 -0
- reducto_cli-0.1.0/reducto_cli/auth.py +173 -0
- reducto_cli-0.1.0/reducto_cli/cli.py +81 -0
- reducto_cli-0.1.0/reducto_cli/config.py +67 -0
- reducto_cli-0.1.0/reducto_cli/editor.py +60 -0
- reducto_cli-0.1.0/reducto_cli/extractor.py +89 -0
- reducto_cli-0.1.0/reducto_cli/files.py +52 -0
- reducto_cli-0.1.0/reducto_cli/help_text.py +24 -0
- reducto_cli-0.1.0/reducto_cli/parser.py +89 -0
- reducto_cli-0.1.0/reducto_cli/schema.py +26 -0
- reducto_cli-0.1.0/reducto_cli.egg-info/PKG-INFO +175 -0
- reducto_cli-0.1.0/reducto_cli.egg-info/SOURCES.txt +21 -0
- reducto_cli-0.1.0/reducto_cli.egg-info/dependency_links.txt +1 -0
- reducto_cli-0.1.0/reducto_cli.egg-info/entry_points.txt +2 -0
- reducto_cli-0.1.0/reducto_cli.egg-info/requires.txt +3 -0
- reducto_cli-0.1.0/reducto_cli.egg-info/top_level.txt +1 -0
- reducto_cli-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: reducto-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: CLI for Reducto document processing
|
|
5
|
+
Requires-Python: >=3.11
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: async-typer>=0.1.10
|
|
8
|
+
Requires-Dist: reductoai>=0.13.0
|
|
9
|
+
Requires-Dist: typer>=0.20.0
|
|
10
|
+
|
|
11
|
+
# Reducto CLI
|
|
12
|
+
|
|
13
|
+
Welcome to the Reducto CLI. This tool lets you parse documents, extract structured data, and modify documents using Reducto’s platform.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
Install the Reducto CLI using pip:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install reducto-cli
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Authentication
|
|
24
|
+
|
|
25
|
+
Before using the CLI, authenticate with your Reducto API key:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
reducto login
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Examples
|
|
32
|
+
|
|
33
|
+
- Parse a single file: `reducto parse path/to/document.pdf`
|
|
34
|
+
- Parse an entire folder: `reducto parse ./docs`
|
|
35
|
+
- Extract with a schema (path or inline JSON): `reducto extract ./docs/invoice.pdf -s schemas/invoice.json`
|
|
36
|
+
- Edit a single file: `reducto edit path/to/document.pdf --instructions "Your editing instructions here"`
|
|
37
|
+
|
|
38
|
+
Parsed outputs are written as `<filename>.parse.md`. Extraction reuses existing parses when possible and saves `<filename>.extract.json` containing only the payload.
|
|
39
|
+
|
|
40
|
+
## Supported File Types
|
|
41
|
+
|
|
42
|
+
• PDF: `.pdf`
|
|
43
|
+
• Images: `.png`, `.jpg`, `.jpeg`
|
|
44
|
+
• Office documents: `.doc`, `.docx`, `.ppt`, `.pptx`
|
|
45
|
+
• Spreadsheets: `.xls`, `.xlsx`
|
|
46
|
+
|
|
47
|
+
Commands accept either a file or a directory. Directories are scanned recursively, and only the supported file types listed above are processed.
|
|
48
|
+
|
|
49
|
+
## Parse Command Options
|
|
50
|
+
|
|
51
|
+
The `parse` command supports several flags to customize parsing behavior:
|
|
52
|
+
|
|
53
|
+
### Flags
|
|
54
|
+
|
|
55
|
+
| Flag | Description |
|
|
56
|
+
|------|-------------|
|
|
57
|
+
| `--agentic` | Enables all agentic options for tables, text, and figures. Increases accuracy but also increases latency. Use when document quality or complex layouts require enhanced processing. |
|
|
58
|
+
| `--change-tracking` | Enables change tracking during parsing. Returns `<s>` tags around strikethrough text, `<u>` tags around underlined text, and `<change>` tags around colored adjacent strikethrough and underlined text. Useful for documents with revision history. |
|
|
59
|
+
| `--highlights` | Include highlighted text in the parsed output. |
|
|
60
|
+
| `--hyperlinks` | Include embedded hyperlinks in the parsed output. |
|
|
61
|
+
| `--comments` | Include document comments in the parsed output. |
|
|
62
|
+
|
|
63
|
+
### Examples
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Basic parse
|
|
67
|
+
reducto parse document.pdf
|
|
68
|
+
|
|
69
|
+
# Parse with maximum accuracy (slower)
|
|
70
|
+
reducto parse document.pdf --agentic
|
|
71
|
+
|
|
72
|
+
# Parse a contract with change tracking
|
|
73
|
+
reducto parse contract.pdf --change-tracking
|
|
74
|
+
|
|
75
|
+
# Parse with all metadata
|
|
76
|
+
reducto parse document.pdf --hyperlinks --comments --highlights
|
|
77
|
+
|
|
78
|
+
# Combine flags as needed
|
|
79
|
+
reducto parse legal_doc.pdf --agentic --change-tracking --comments
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Extract Command Overview
|
|
83
|
+
|
|
84
|
+
The `extract` command enables you to pull specific, structured data from your documents according to a schema you provide (using JSON Schema). It is designed to automate information extraction by mapping complex or unstructured documents—such as invoices, receipts, reports, forms, contracts, financial statements, or tables—into machine-readable JSON.
|
|
85
|
+
|
|
86
|
+
Common use cases include:
|
|
87
|
+
- Extracting line items, totals, vendor/customer info from invoices and receipts
|
|
88
|
+
- Pulling key fields, tables, or sections from contracts or legal documents
|
|
89
|
+
- Capturing form field values from scanned forms or applications
|
|
90
|
+
- Summarizing structured results from reports, statements, or medical records
|
|
91
|
+
|
|
92
|
+
By providing a schema, you ensure consistency and determinism, so the extracted JSON conforms exactly to your business requirements. This is especially valuable for automating downstream processing pipelines, integrating with databases, or feeding data to other tools.
|
|
93
|
+
|
|
94
|
+
You can perform extraction on individual files or batches (folders), and extracted payloads are saved as `<filename>.extract.json`.
|
|
95
|
+
|
|
96
|
+
## Schema Guidelines for `reducto extract`
|
|
97
|
+
|
|
98
|
+
• Schemas must be valid JSON Schema documents.
|
|
99
|
+
• The top-level schema **must** be an object (`{"type": "object", ...}`) — inline strings or arrays are not permitted.
|
|
100
|
+
• Provide explicit property definitions so the extractor can map fields deterministically.
|
|
101
|
+
• Schemas may be supplied as file paths or inline JSON strings.
|
|
102
|
+
|
|
103
|
+
### Example Schema
|
|
104
|
+
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"type": "object",
|
|
108
|
+
"properties": {
|
|
109
|
+
"items": {
|
|
110
|
+
"type": "array",
|
|
111
|
+
"items": {
|
|
112
|
+
"type": "object",
|
|
113
|
+
"properties": {
|
|
114
|
+
"article_number": {"type": "string"},
|
|
115
|
+
"description": {"type": "string"},
|
|
116
|
+
"quantity": {"type": "number"},
|
|
117
|
+
"unit_price": {"type": "number"},
|
|
118
|
+
"total_price": {"type": "number"}
|
|
119
|
+
},
|
|
120
|
+
"required": [
|
|
121
|
+
"article_number",
|
|
122
|
+
"description",
|
|
123
|
+
"quantity",
|
|
124
|
+
"unit_price",
|
|
125
|
+
"total_price"
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
"required": ["items"]
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
You can reuse parses across multiple extractions: the CLI automatically detects existing `.parse.md` files, rehydrates the recorded job ID, and uses `jobid://<id>` references to accelerate extraction jobs.
|
|
135
|
+
|
|
136
|
+
## Editing Documents with `reducto edit`
|
|
137
|
+
|
|
138
|
+
The `edit` command allows you to modify documents using natural language instructions. It uploads the document, applies the specified edits, and downloads the resulting file.
|
|
139
|
+
|
|
140
|
+
### Usage
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
reducto edit path/to/document.pdf --instructions "Your editing instructions here"
|
|
144
|
+
reducto edit path/to/document.pdf -i "Your editing instructions here"
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Parameters
|
|
148
|
+
|
|
149
|
+
| Parameter | Required | Description |
|
|
150
|
+
|-----------|----------|-------------|
|
|
151
|
+
| `path` | Yes | Path to a file or directory. Directories are scanned recursively for supported file types. |
|
|
152
|
+
| `--instructions`, `-i` | Yes | Natural language instructions describing the edits to apply. |
|
|
153
|
+
|
|
154
|
+
### Output
|
|
155
|
+
|
|
156
|
+
Edited files are saved alongside the original with the naming pattern `<filename>.edited.<extension>`. For example:
|
|
157
|
+
- `invoice.pdf` → `invoice.edited.pdf`
|
|
158
|
+
- `report.docx` → `report.edited.docx`
|
|
159
|
+
|
|
160
|
+
### Examples
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
reducto edit contract.pdf -i "Fill in the client name as 'Acme Corporation' and set the contract date to January 15, 2024"
|
|
164
|
+
|
|
165
|
+
reducto edit document.pdf -i "Fill out the form with: Name: John Doe, Email: john@example.com, Select 'Yes' for newsletter subscription"
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Effective Instructions
|
|
169
|
+
|
|
170
|
+
For best results with the `--instructions` flag:
|
|
171
|
+
- Be specific about what content to modify and how
|
|
172
|
+
- Reference specific elements (headers, footers, tables, specific text)
|
|
173
|
+
- Describe the desired outcome clearly
|
|
174
|
+
- For bulk operations on directories, ensure instructions apply uniformly to all file types
|
|
175
|
+
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Reducto CLI
|
|
2
|
+
|
|
3
|
+
Welcome to the Reducto CLI. This tool lets you parse documents, extract structured data, and modify documents using Reducto’s platform.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install the Reducto CLI using pip:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install reducto-cli
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Authentication
|
|
14
|
+
|
|
15
|
+
Before using the CLI, authenticate with your Reducto API key:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
reducto login
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Examples
|
|
22
|
+
|
|
23
|
+
- Parse a single file: `reducto parse path/to/document.pdf`
|
|
24
|
+
- Parse an entire folder: `reducto parse ./docs`
|
|
25
|
+
- Extract with a schema (path or inline JSON): `reducto extract ./docs/invoice.pdf -s schemas/invoice.json`
|
|
26
|
+
- Edit a single file: `reducto edit path/to/document.pdf --instructions "Your editing instructions here"`
|
|
27
|
+
|
|
28
|
+
Parsed outputs are written as `<filename>.parse.md`. Extraction reuses existing parses when possible and saves `<filename>.extract.json` containing only the payload.
|
|
29
|
+
|
|
30
|
+
## Supported File Types
|
|
31
|
+
|
|
32
|
+
• PDF: `.pdf`
|
|
33
|
+
• Images: `.png`, `.jpg`, `.jpeg`
|
|
34
|
+
• Office documents: `.doc`, `.docx`, `.ppt`, `.pptx`
|
|
35
|
+
• Spreadsheets: `.xls`, `.xlsx`
|
|
36
|
+
|
|
37
|
+
Commands accept either a file or a directory. Directories are scanned recursively, and only the supported file types listed above are processed.
|
|
38
|
+
|
|
39
|
+
## Parse Command Options
|
|
40
|
+
|
|
41
|
+
The `parse` command supports several flags to customize parsing behavior:
|
|
42
|
+
|
|
43
|
+
### Flags
|
|
44
|
+
|
|
45
|
+
| Flag | Description |
|
|
46
|
+
|------|-------------|
|
|
47
|
+
| `--agentic` | Enables all agentic options for tables, text, and figures. Increases accuracy but also increases latency. Use when document quality or complex layouts require enhanced processing. |
|
|
48
|
+
| `--change-tracking` | Enables change tracking during parsing. Returns `<s>` tags around strikethrough text, `<u>` tags around underlined text, and `<change>` tags around colored adjacent strikethrough and underlined text. Useful for documents with revision history. |
|
|
49
|
+
| `--highlights` | Include highlighted text in the parsed output. |
|
|
50
|
+
| `--hyperlinks` | Include embedded hyperlinks in the parsed output. |
|
|
51
|
+
| `--comments` | Include document comments in the parsed output. |
|
|
52
|
+
|
|
53
|
+
### Examples
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# Basic parse
|
|
57
|
+
reducto parse document.pdf
|
|
58
|
+
|
|
59
|
+
# Parse with maximum accuracy (slower)
|
|
60
|
+
reducto parse document.pdf --agentic
|
|
61
|
+
|
|
62
|
+
# Parse a contract with change tracking
|
|
63
|
+
reducto parse contract.pdf --change-tracking
|
|
64
|
+
|
|
65
|
+
# Parse with all metadata
|
|
66
|
+
reducto parse document.pdf --hyperlinks --comments --highlights
|
|
67
|
+
|
|
68
|
+
# Combine flags as needed
|
|
69
|
+
reducto parse legal_doc.pdf --agentic --change-tracking --comments
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Extract Command Overview
|
|
73
|
+
|
|
74
|
+
The `extract` command enables you to pull specific, structured data from your documents according to a schema you provide (using JSON Schema). It is designed to automate information extraction by mapping complex or unstructured documents—such as invoices, receipts, reports, forms, contracts, financial statements, or tables—into machine-readable JSON.
|
|
75
|
+
|
|
76
|
+
Common use cases include:
|
|
77
|
+
- Extracting line items, totals, vendor/customer info from invoices and receipts
|
|
78
|
+
- Pulling key fields, tables, or sections from contracts or legal documents
|
|
79
|
+
- Capturing form field values from scanned forms or applications
|
|
80
|
+
- Summarizing structured results from reports, statements, or medical records
|
|
81
|
+
|
|
82
|
+
By providing a schema, you ensure consistency and determinism, so the extracted JSON conforms exactly to your business requirements. This is especially valuable for automating downstream processing pipelines, integrating with databases, or feeding data to other tools.
|
|
83
|
+
|
|
84
|
+
You can perform extraction on individual files or batches (folders), and extracted payloads are saved as `<filename>.extract.json`.
|
|
85
|
+
|
|
86
|
+
## Schema Guidelines for `reducto extract`
|
|
87
|
+
|
|
88
|
+
• Schemas must be valid JSON Schema documents.
|
|
89
|
+
• The top-level schema **must** be an object (`{"type": "object", ...}`) — inline strings or arrays are not permitted.
|
|
90
|
+
• Provide explicit property definitions so the extractor can map fields deterministically.
|
|
91
|
+
• Schemas may be supplied as file paths or inline JSON strings.
|
|
92
|
+
|
|
93
|
+
### Example Schema
|
|
94
|
+
|
|
95
|
+
```json
|
|
96
|
+
{
|
|
97
|
+
"type": "object",
|
|
98
|
+
"properties": {
|
|
99
|
+
"items": {
|
|
100
|
+
"type": "array",
|
|
101
|
+
"items": {
|
|
102
|
+
"type": "object",
|
|
103
|
+
"properties": {
|
|
104
|
+
"article_number": {"type": "string"},
|
|
105
|
+
"description": {"type": "string"},
|
|
106
|
+
"quantity": {"type": "number"},
|
|
107
|
+
"unit_price": {"type": "number"},
|
|
108
|
+
"total_price": {"type": "number"}
|
|
109
|
+
},
|
|
110
|
+
"required": [
|
|
111
|
+
"article_number",
|
|
112
|
+
"description",
|
|
113
|
+
"quantity",
|
|
114
|
+
"unit_price",
|
|
115
|
+
"total_price"
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"required": ["items"]
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
You can reuse parses across multiple extractions: the CLI automatically detects existing `.parse.md` files, rehydrates the recorded job ID, and uses `jobid://<id>` references to accelerate extraction jobs.
|
|
125
|
+
|
|
126
|
+
## Editing Documents with `reducto edit`
|
|
127
|
+
|
|
128
|
+
The `edit` command allows you to modify documents using natural language instructions. It uploads the document, applies the specified edits, and downloads the resulting file.
|
|
129
|
+
|
|
130
|
+
### Usage
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
reducto edit path/to/document.pdf --instructions "Your editing instructions here"
|
|
134
|
+
reducto edit path/to/document.pdf -i "Your editing instructions here"
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Parameters
|
|
138
|
+
|
|
139
|
+
| Parameter | Required | Description |
|
|
140
|
+
|-----------|----------|-------------|
|
|
141
|
+
| `path` | Yes | Path to a file or directory. Directories are scanned recursively for supported file types. |
|
|
142
|
+
| `--instructions`, `-i` | Yes | Natural language instructions describing the edits to apply. |
|
|
143
|
+
|
|
144
|
+
### Output
|
|
145
|
+
|
|
146
|
+
Edited files are saved alongside the original with the naming pattern `<filename>.edited.<extension>`. For example:
|
|
147
|
+
- `invoice.pdf` → `invoice.edited.pdf`
|
|
148
|
+
- `report.docx` → `report.edited.docx`
|
|
149
|
+
|
|
150
|
+
### Examples
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
reducto edit contract.pdf -i "Fill in the client name as 'Acme Corporation' and set the contract date to January 15, 2024"
|
|
154
|
+
|
|
155
|
+
reducto edit document.pdf -i "Fill out the form with: Name: John Doe, Email: john@example.com, Select 'Yes' for newsletter subscription"
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Effective Instructions
|
|
159
|
+
|
|
160
|
+
For best results with the `--instructions` flag:
|
|
161
|
+
- Be specific about what content to modify and how
|
|
162
|
+
- Reference specific elements (headers, footers, tables, specific text)
|
|
163
|
+
- Describe the desired outcome clearly
|
|
164
|
+
- For bulk operations on directories, ensure instructions apply uniformly to all file types
|
|
165
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "reducto-cli"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "CLI for Reducto document processing"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.11"
|
|
7
|
+
dependencies = [
|
|
8
|
+
"async-typer>=0.1.10",
|
|
9
|
+
"reductoai>=0.13.0",
|
|
10
|
+
"typer>=0.20.0",
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
[tool.setuptools]
|
|
14
|
+
include-package-data = true
|
|
15
|
+
|
|
16
|
+
[tool.setuptools.package-data]
|
|
17
|
+
reducto_cli = ["INSTRUCTIONS.md"]
|
|
18
|
+
|
|
19
|
+
[tool.uv.workspace]
|
|
20
|
+
members = [
|
|
21
|
+
"reducto-cli",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
[project.scripts]
|
|
25
|
+
reducto = "reducto_cli.cli:app"
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Reducto CLI
|
|
2
|
+
|
|
3
|
+
Welcome to the Reducto CLI. This tool lets you parse documents, extract structured data, and modify documents using Reducto’s platform.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
- Both commands accept a single file or a directory. Directories are scanned recursively and only supported files (below) are processed.
|
|
8
|
+
|
|
9
|
+
### Examples
|
|
10
|
+
|
|
11
|
+
- Parse a single file: `reducto parse path/to/document.pdf`
|
|
12
|
+
- Parse an entire folder: `reducto parse ./docs`
|
|
13
|
+
- Extract with a schema (path or inline JSON): `reducto extract ./docs/invoice.pdf -s schemas/invoice.json`
|
|
14
|
+
|
|
15
|
+
Parsed outputs are written as `<filename>.parse.md` with YAML front matter. Extraction reuses existing parses when possible and saves `<filename>.extract.json` containing only the payload.
|
|
16
|
+
|
|
17
|
+
## Supported File Types
|
|
18
|
+
|
|
19
|
+
• PDF: `.pdf`
|
|
20
|
+
• Images: `.png`, `.jpg`, `.jpeg`
|
|
21
|
+
• Office documents: `.doc`, `.docx`, `.ppt`, `.pptx`
|
|
22
|
+
• Spreadsheets: `.xls`, `.xlsx`
|
|
23
|
+
|
|
24
|
+
Commands accept either a file or a directory. Directories are scanned recursively, and only the supported file types listed above are processed.
|
|
25
|
+
|
|
26
|
+
## Parse Command Options
|
|
27
|
+
|
|
28
|
+
The `parse` command supports several flags to customize parsing behavior:
|
|
29
|
+
|
|
30
|
+
### Flags
|
|
31
|
+
|
|
32
|
+
| Flag | Description |
|
|
33
|
+
|------|-------------|
|
|
34
|
+
| `--agentic` | Enables all agentic options for tables, text, and figures. Increases accuracy but also increases latency. Use when document quality or complex layouts require enhanced processing. |
|
|
35
|
+
| `--change-tracking` | Enables change tracking during parsing. Returns `<s>` tags around strikethrough text, `<u>` tags around underlined text, and `<change>` tags around colored adjacent strikethrough and underlined text. Useful for documents with revision history. |
|
|
36
|
+
| `--highlights` | Include highlighted text in the parsed output. |
|
|
37
|
+
| `--hyperlinks` | Include embedded hyperlinks in the parsed output. |
|
|
38
|
+
| `--comments` | Include document comments in the parsed output. |
|
|
39
|
+
|
|
40
|
+
### Examples
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Basic parse
|
|
44
|
+
reducto parse document.pdf
|
|
45
|
+
|
|
46
|
+
# Parse with maximum accuracy (slower)
|
|
47
|
+
reducto parse document.pdf --agentic
|
|
48
|
+
|
|
49
|
+
# Parse a contract with change tracking
|
|
50
|
+
reducto parse contract.pdf --change-tracking
|
|
51
|
+
|
|
52
|
+
# Parse with all metadata
|
|
53
|
+
reducto parse document.pdf --hyperlinks --comments --highlights
|
|
54
|
+
|
|
55
|
+
# Combine flags as needed
|
|
56
|
+
reducto parse legal_doc.pdf --agentic --change-tracking --comments
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Extract Command Overview
|
|
60
|
+
|
|
61
|
+
The `extract` command enables you to pull specific, structured data from your documents according to a schema you provide (using JSON Schema). It is designed to automate information extraction by mapping complex or unstructured documents—such as invoices, receipts, reports, forms, contracts, financial statements, or tables—into machine-readable JSON.
|
|
62
|
+
|
|
63
|
+
Common use cases include:
|
|
64
|
+
- Extracting line items, totals, vendor/customer info from invoices and receipts
|
|
65
|
+
- Pulling key fields, tables, or sections from contracts or legal documents
|
|
66
|
+
- Capturing form field values from scanned forms or applications
|
|
67
|
+
- Summarizing structured results from reports, statements, or medical records
|
|
68
|
+
|
|
69
|
+
By providing a schema, you ensure consistency and determinism, so the extracted JSON conforms exactly to your business requirements. This is especially valuable for automating downstream processing pipelines, integrating with databases, or feeding data to other tools.
|
|
70
|
+
|
|
71
|
+
You can perform extraction on individual files or batches (folders), and extracted payloads are saved as `<filename>.extract.json`.
|
|
72
|
+
|
|
73
|
+
## Schema Guidelines for `reducto extract`
|
|
74
|
+
|
|
75
|
+
• Schemas must be valid JSON Schema documents.
|
|
76
|
+
• The top-level schema **must** be an object (`{"type": "object", ...}`) — inline strings or arrays are not permitted.
|
|
77
|
+
• Provide explicit property definitions so the extractor can map fields deterministically.
|
|
78
|
+
• Schemas may be supplied as file paths or inline JSON strings.
|
|
79
|
+
|
|
80
|
+
### Example Schema
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"type": "object",
|
|
85
|
+
"properties": {
|
|
86
|
+
"items": {
|
|
87
|
+
"type": "array",
|
|
88
|
+
"items": {
|
|
89
|
+
"type": "object",
|
|
90
|
+
"properties": {
|
|
91
|
+
"article_number": {"type": "string"},
|
|
92
|
+
"description": {"type": "string"},
|
|
93
|
+
"quantity": {"type": "number"},
|
|
94
|
+
"unit_price": {"type": "number"},
|
|
95
|
+
"total_price": {"type": "number"}
|
|
96
|
+
},
|
|
97
|
+
"required": [
|
|
98
|
+
"article_number",
|
|
99
|
+
"description",
|
|
100
|
+
"quantity",
|
|
101
|
+
"unit_price",
|
|
102
|
+
"total_price"
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
"required": ["items"]
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
You can reuse parses across multiple extractions: the CLI automatically detects existing `.parse.md` files, rehydrates the recorded job ID, and uses `jobid://<id>` references to accelerate extraction jobs.
|
|
112
|
+
|
|
113
|
+
## Editing Documents with `reducto edit`
|
|
114
|
+
|
|
115
|
+
The `edit` command allows you to modify documents using natural language instructions. It uploads the document, applies the specified edits, and downloads the resulting file.
|
|
116
|
+
|
|
117
|
+
### Usage
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
reducto edit path/to/document.pdf --instructions "Your editing instructions here"
|
|
121
|
+
reducto edit path/to/document.pdf -i "Your editing instructions here"
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Parameters
|
|
125
|
+
|
|
126
|
+
| Parameter | Required | Description |
|
|
127
|
+
|-----------|----------|-------------|
|
|
128
|
+
| `path` | Yes | Path to a file or directory. Directories are scanned recursively for supported file types. |
|
|
129
|
+
| `--instructions`, `-i` | Yes | Natural language instructions describing the edits to apply. |
|
|
130
|
+
|
|
131
|
+
### Output
|
|
132
|
+
|
|
133
|
+
Edited files are saved alongside the original with the naming pattern `<filename>.edited.<extension>`. For example:
|
|
134
|
+
- `invoice.pdf` → `invoice.edited.pdf`
|
|
135
|
+
- `report.docx` → `report.edited.docx`
|
|
136
|
+
|
|
137
|
+
### Examples
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
reducto edit contract.pdf -i "Fill in the client name as 'Acme Corporation' and set the contract date to January 15, 2024"
|
|
141
|
+
|
|
142
|
+
reducto edit document.pdf -i "Fill out the form with: Name: John Doe, Email: john@example.com, Select 'Yes' for newsletter subscription"
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Effective Instructions
|
|
146
|
+
|
|
147
|
+
For best results with the `--instructions` flag:
|
|
148
|
+
- Be specific about what content to modify and how
|
|
149
|
+
- Reference specific elements (headers, footers, tables, specific text)
|
|
150
|
+
- Describe the desired outcome clearly
|
|
151
|
+
- For bulk operations on directories, ensure instructions apply uniformly to all file types
|
|
152
|
+
|