datalab-python-sdk 0.4.0__tar.gz → 0.6.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.
Files changed (66) hide show
  1. datalab_python_sdk-0.6.0/.github/workflows/ci.yml +31 -0
  2. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/.pre-commit-config.yaml +1 -1
  3. datalab_python_sdk-0.6.0/CHANGELOG.md +47 -0
  4. datalab_python_sdk-0.6.0/PKG-INFO +151 -0
  5. datalab_python_sdk-0.6.0/README.md +130 -0
  6. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/datalab_sdk/__init__.py +47 -1
  7. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/datalab_sdk/cli.py +515 -71
  8. datalab_python_sdk-0.6.0/datalab_sdk/client.py +3470 -0
  9. datalab_python_sdk-0.6.0/datalab_sdk/exceptions.py +110 -0
  10. datalab_python_sdk-0.6.0/datalab_sdk/models.py +946 -0
  11. datalab_python_sdk-0.6.0/datalab_sdk/settings.py +26 -0
  12. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/pyproject.toml +16 -2
  13. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/recipes/workflows/README.md +2 -0
  14. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/recipes/workflows/end_to_end_workflow.py +27 -36
  15. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/recipes/workflows/workflow_api_tutorial/1_get_step_types.py +6 -5
  16. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/recipes/workflows/workflow_api_tutorial/2_get_workflows.py +1 -1
  17. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/recipes/workflows/workflow_api_tutorial/4_execute_workflow.py +8 -16
  18. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/recipes/workflows/workflow_api_tutorial/5_poll_workflow.py +17 -21
  19. datalab_python_sdk-0.6.0/tests/test_api_consistency.py +378 -0
  20. datalab_python_sdk-0.6.0/tests/test_cli_options.py +144 -0
  21. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/tests/test_client_methods.py +499 -8
  22. datalab_python_sdk-0.6.0/tests/test_errors.py +143 -0
  23. datalab_python_sdk-0.6.0/tests/test_new_endpoints.py +267 -0
  24. datalab_python_sdk-0.6.0/tests/test_results.py +153 -0
  25. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/tests/test_workflows.py +42 -33
  26. datalab_python_sdk-0.6.0/uv.lock +1382 -0
  27. datalab_python_sdk-0.4.0/.github/workflows/ci.yml +0 -19
  28. datalab_python_sdk-0.4.0/.github/workflows/publish.yml +0 -38
  29. datalab_python_sdk-0.4.0/PKG-INFO +0 -80
  30. datalab_python_sdk-0.4.0/README.md +0 -62
  31. datalab_python_sdk-0.4.0/datalab_sdk/client.py +0 -2053
  32. datalab_python_sdk-0.4.0/datalab_sdk/exceptions.py +0 -38
  33. datalab_python_sdk-0.4.0/datalab_sdk/models.py +0 -511
  34. datalab_python_sdk-0.4.0/datalab_sdk/settings.py +0 -16
  35. datalab_python_sdk-0.4.0/poetry.lock +0 -1201
  36. datalab_python_sdk-0.4.0/uv.lock +0 -1372
  37. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/.gitignore +0 -0
  38. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/.python-version +0 -0
  39. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/LICENSE +0 -0
  40. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/data/08-Lambda-Calculus.pptx +0 -0
  41. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/data/adversarial.pdf +0 -0
  42. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/data/bid_evaluation.docx +0 -0
  43. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/data/book_review.ppt +0 -0
  44. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/data/book_store.xls +0 -0
  45. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/data/chi_hind.png +0 -0
  46. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/data/how_to_read.doc +0 -0
  47. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/data/normandy.epub +0 -0
  48. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/data/sample-1-sheet.xlsx +0 -0
  49. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/data/thinkpython.pdf +0 -0
  50. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/data/vibe.html +0 -0
  51. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/datalab_sdk/mimetypes.py +0 -0
  52. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/integration/README.md +0 -0
  53. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/integration/__init__.py +0 -0
  54. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/integration/test_live_api.py +0 -0
  55. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/integration/test_readme_examples.py +0 -0
  56. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/pytest.ini +0 -0
  57. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/recipes/workflows/workflow_api_tutorial/3_create_workflow.py +0 -0
  58. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/recipes/workflows/workflow_api_tutorial/README.md +0 -0
  59. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/recipes/workflows/workflow_definitions/README.md +0 -0
  60. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/recipes/workflows/workflow_definitions/eval_segmentation.json +0 -0
  61. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/recipes/workflows/workflow_definitions/parse_segment.json +0 -0
  62. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/recipes/workflows/workflow_definitions/segment_parallel_extract.json +0 -0
  63. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/recipes/workflows/workflow_definitions/slack_alert.json +0 -0
  64. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/tests/__init__.py +0 -0
  65. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/tests/conftest.py +0 -0
  66. {datalab_python_sdk-0.4.0 → datalab_python_sdk-0.6.0}/tests/test_cli_simple.py +0 -0
@@ -0,0 +1,31 @@
1
+ name: Unit tests
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ matrix:
16
+ python-version: ["3.11", "3.12", "3.13", "3.14", "3.15"]
17
+ steps:
18
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
19
+ with:
20
+ persist-credentials: false
21
+ - uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
22
+ with:
23
+ python-version: ${{ matrix.python-version }}
24
+ - name: Install dependencies
25
+ run: uv sync --group dev --frozen
26
+ - name: Lint
27
+ run: |
28
+ uv run ruff check .
29
+ uv run ruff format --check .
30
+ - name: Run tests
31
+ run: uv run pytest tests/
@@ -1,7 +1,7 @@
1
1
  repos:
2
2
  - repo: https://github.com/astral-sh/ruff-pre-commit
3
3
  # Ruff version.
4
- rev: v0.12.3
4
+ rev: v0.17.1
5
5
  hooks:
6
6
  # Run the linter.
7
7
  - id: ruff-check
@@ -0,0 +1,47 @@
1
+ # Changelog
2
+
3
+ The newest release is at the top. Each export to this repository uses the
4
+ top section as its commit message.
5
+
6
+ ## 0.6.0
7
+
8
+ Breaking changes:
9
+
10
+ - The SDK requires Python 3.11 or later. Python 3.10 reached end of life in
11
+ October 2026.
12
+ - `ExtractOptions.mode` now defaults to `None`. The SDK sends `mode` only when
13
+ you set it, so the API picks the parse mode from `extraction_mode`. To keep
14
+ the old behavior, set `mode="fast"`.
15
+ - App-only evaluation controls are no longer accepted by SDK calls.
16
+
17
+ New:
18
+
19
+ - **Open beta:** `run_agent()` and the `agent` CLI command run existing
20
+ published processors. Processor design is not included.
21
+ - `form_fields()`, `generate_extraction_schemas()` and `delete_result()`,
22
+ each with a sync version on `DatalabClient`.
23
+ - Convert options: `merge_cross_page`, `word_bboxes`, `disable_html_prettify`,
24
+ `exact_transcription`, `keep_pageheader_in_output` and
25
+ `keep_pagefooter_in_output`.
26
+ - `processing_location` on the extract, segment, custom processor, track
27
+ changes, OCR, fill, document and upload calls.
28
+ - `run_pipeline()` sends `checkpoint_id` and `processing_location`.
29
+ `create_pipeline()` accepts `reuse_draft`.
30
+ - CLI commands `fill` and `form-fields`, and CLI flags for the new
31
+ convert and extract options.
32
+
33
+ Fixes:
34
+
35
+ - API errors keep the message from the API and map HTTP errors to exception
36
+ classes.
37
+ - The SDK downloads signed result URLs and keeps result fields that it
38
+ dropped before.
39
+ - The User-Agent header and `datalab --version` show the installed version.
40
+ - The CLI `--skip_cache` option is a flag. `--format` accepts a
41
+ comma-separated list.
42
+
43
+ Deprecated:
44
+
45
+ - The workflow methods, because the API no longer serves workflows. Use
46
+ pipelines.
47
+ - `run_custom_processor()`. Use `run_agent()`.
@@ -0,0 +1,151 @@
1
+ Metadata-Version: 2.5
2
+ Name: datalab-python-sdk
3
+ Version: 0.6.0
4
+ Summary: SDK for the Datalab document intelligence API
5
+ Project-URL: Homepage, https://www.datalab.to
6
+ Project-URL: Documentation, https://documentation.datalab.to
7
+ Project-URL: Repository, https://github.com/datalab-to/sdk
8
+ Author-email: Datalab Team <hi@datalab.to>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: api,datalab,document-intelligence,sdk
12
+ Requires-Python: >=3.11
13
+ Requires-Dist: aiohttp>=3.12.14
14
+ Requires-Dist: click>=8.2.1
15
+ Requires-Dist: ijson>=3.3.0
16
+ Requires-Dist: pydantic-settings>=2.10.1
17
+ Requires-Dist: pydantic>=2.11.7
18
+ Requires-Dist: tenacity>=8.2.3
19
+ Requires-Dist: tqdm>=4.66.0
20
+ Description-Content-Type: text/markdown
21
+
22
+ # Datalab SDK
23
+
24
+ A Python SDK for the [Datalab API](https://www.datalab.to/?utm_source=gh-sdk) - it turns documents into verifiable knowledge your agents act on. Datalab is the team behind [Chandra](https://github.com/datalab-to/chandra), [marker](https://github.com/datalab-to/marker), [surya](https://github.com/datalab-to/surya), and [lift](https://github.com/datalab-to/lift).
25
+
26
+ See the full documentation at [https://documentation.datalab.to](https://documentation.datalab.to).
27
+
28
+ ## Installation
29
+
30
+ ```bash
31
+ pip install datalab-python-sdk
32
+ ```
33
+
34
+ ## Quick Start
35
+
36
+ ### Authentication
37
+
38
+ [Sign up](https://www.datalab.to/?utm_source=gh-sdk), then get your API key from [https://www.datalab.to/app/keys](https://www.datalab.to/app/keys):
39
+
40
+ ```bash
41
+ export DATALAB_API_KEY="your_api_key_here"
42
+ ```
43
+
44
+ ### Basic Usage
45
+
46
+ ```python
47
+ from datalab_sdk import DatalabClient
48
+
49
+ client = DatalabClient() # use env var from above, or pass api_key="your_api_key_here"
50
+
51
+ # Convert PDF to markdown
52
+ result = client.convert("document.pdf")
53
+ print(result.markdown)
54
+ ```
55
+
56
+ `AsyncDatalabClient` has the same methods as `DatalabClient`, as coroutines.
57
+
58
+ ## Conversion options
59
+
60
+ ```python
61
+ from datalab_sdk import ConvertOptions
62
+
63
+ options = ConvertOptions(
64
+ mode="balanced", # lite, fast, balanced, accurate (SDK default: fast)
65
+ output_format="markdown,html", # markdown, html, json, chunks (comma-separated)
66
+ page_range="0-4",
67
+ extras="chart_understanding,table_cell_bboxes",
68
+ merge_cross_page=True, # merge tables, paragraphs and lists split across pages
69
+ word_bboxes=True, # per-word bounding boxes in the HTML output
70
+ save_checkpoint=True, # reuse the parse in extract() or segment()
71
+ )
72
+ result = client.convert("document.pdf", options=options)
73
+ ```
74
+
75
+ Other options include `paginate`, `add_block_ids`, `disable_html_prettify`, `exact_transcription`, `token_efficient_markdown`, `include_markdown_in_chunks`, `disable_image_extraction`, `disable_image_captions`, `fence_synthetic_captions`, `keep_spreadsheet_formatting`, `keep_pageheader_in_output`, `keep_pagefooter_in_output`, `additional_config`, `webhook_url`, `skip_cache` and `processing_location`. The [API reference](https://documentation.datalab.to/api-reference/convert-document) describes each option.
76
+
77
+ ## Structured extraction
78
+
79
+ ```python
80
+ from datalab_sdk import ExtractOptions
81
+
82
+ result = client.extract(
83
+ "invoice.pdf",
84
+ options=ExtractOptions(
85
+ page_schema='{"properties": {"total": {"type": "number"}}}', # or schema_id="sch_..."
86
+ extraction_mode="balanced", # turbo, fast, balanced, accurate
87
+ ),
88
+ )
89
+ print(result.extraction_schema_json, result.extraction_score_average)
90
+ ```
91
+
92
+ When you do not set the parse `mode`, the API picks the parse mode that matches `extraction_mode`.
93
+
94
+ ## Other endpoints
95
+
96
+ | Method | Endpoint |
97
+ | --- | --- |
98
+ | `run_agent()` | **Beta:** run an existing published processor (`AgentOptions(processor="cp_...")`) |
99
+ | `segment()` | Split a document into sections (`SegmentOptions`) |
100
+ | `fill()` | Fill a PDF or image form (`FormFillingOptions`) |
101
+ | `form_fields()` | Find the fillable fields in a PDF or image |
102
+ | `track_changes()` | Read tracked changes and comments from DOCX or PDF |
103
+ | `create_document()` | Make a DOCX from markdown with track changes markup |
104
+ | `generate_extraction_schemas()` | Suggest extraction schemas for a saved checkpoint |
105
+ | `delete_result()` | Result deletion, by `result.request_id` |
106
+ | `upload_files()`, `list_files()`, ... | File storage. Pass the returned `datalab://file-...` reference as `file_url` |
107
+ | `create_extraction_schema()`, ... | Saved extraction schemas |
108
+ | `create_pipeline()`, `run_pipeline()`, ... | [Pipelines](https://documentation.datalab.to/docs/welcome/sdk/pipelines) |
109
+
110
+ `run_custom_processor()` and `ocr()` call deprecated API endpoints. Use `run_agent()` and `convert()` instead.
111
+
112
+ Published-agent execution is in open beta; the API may change. Processor design and raw-prompt execution are not included.
113
+
114
+ ## Inputs, polling and errors
115
+
116
+ - Send a local file with `file_path`, or a URL or a `datalab://file-...` reference with `file_url`. When you set `processing_location`, send the document as `file_url`.
117
+ - Processing methods poll until the result is ready. Set `max_polls` and `poll_interval` to change the limit (default: 300 polls, 1 second apart). Use `stream_response_to` to write a large result straight to disk.
118
+ - The SDK retries a submission that gets HTTP 429 or 503, and polls that get 408, 429, 5xx or a connection error. It waits for the `Retry-After` header when the API sends one.
119
+ - API errors raise `DatalabAPIError` (with `status_code` and `response_data`) or one of its subclasses: `DatalabAuthenticationError` (401, 403), `DatalabPaymentRequiredError` (402), `DatalabNotFoundError` (404), `DatalabRateLimitError` (429) and `DatalabServerError` (5xx). Invalid arguments raise `DatalabValidationError`, which is also a `ValueError`.
120
+
121
+ ## Workflows
122
+
123
+ The Datalab API removed the Workflows API. The workflow methods and CLI commands in this SDK are deprecated, and the API does not answer them. Use pipelines instead.
124
+
125
+ ## CLI Usage
126
+
127
+ The SDK includes a command-line interface:
128
+
129
+ ```bash
130
+ # Convert a document or a directory of documents
131
+ datalab convert document.pdf --mode balanced --format markdown,html
132
+
133
+ # Extract with a saved schema
134
+ datalab extract invoice.pdf --schema_id sch_XXXXX --extraction_mode fast
135
+
136
+ # Other commands
137
+ datalab agent --help
138
+ datalab segment --help
139
+ datalab fill --help
140
+ datalab form-fields --help
141
+ datalab track-changes --help
142
+ datalab create-document --help
143
+ ```
144
+
145
+ ## Contributing
146
+
147
+ Issues and bug reports are welcome here. We develop the SDK in a private repository and mirror each release to this one, so we do not merge pull requests here directly. Open an issue, or open a pull request to show the change, and we will port it and credit you.
148
+
149
+ ## License
150
+
151
+ MIT License
@@ -0,0 +1,130 @@
1
+ # Datalab SDK
2
+
3
+ A Python SDK for the [Datalab API](https://www.datalab.to/?utm_source=gh-sdk) - it turns documents into verifiable knowledge your agents act on. Datalab is the team behind [Chandra](https://github.com/datalab-to/chandra), [marker](https://github.com/datalab-to/marker), [surya](https://github.com/datalab-to/surya), and [lift](https://github.com/datalab-to/lift).
4
+
5
+ See the full documentation at [https://documentation.datalab.to](https://documentation.datalab.to).
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pip install datalab-python-sdk
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ### Authentication
16
+
17
+ [Sign up](https://www.datalab.to/?utm_source=gh-sdk), then get your API key from [https://www.datalab.to/app/keys](https://www.datalab.to/app/keys):
18
+
19
+ ```bash
20
+ export DATALAB_API_KEY="your_api_key_here"
21
+ ```
22
+
23
+ ### Basic Usage
24
+
25
+ ```python
26
+ from datalab_sdk import DatalabClient
27
+
28
+ client = DatalabClient() # use env var from above, or pass api_key="your_api_key_here"
29
+
30
+ # Convert PDF to markdown
31
+ result = client.convert("document.pdf")
32
+ print(result.markdown)
33
+ ```
34
+
35
+ `AsyncDatalabClient` has the same methods as `DatalabClient`, as coroutines.
36
+
37
+ ## Conversion options
38
+
39
+ ```python
40
+ from datalab_sdk import ConvertOptions
41
+
42
+ options = ConvertOptions(
43
+ mode="balanced", # lite, fast, balanced, accurate (SDK default: fast)
44
+ output_format="markdown,html", # markdown, html, json, chunks (comma-separated)
45
+ page_range="0-4",
46
+ extras="chart_understanding,table_cell_bboxes",
47
+ merge_cross_page=True, # merge tables, paragraphs and lists split across pages
48
+ word_bboxes=True, # per-word bounding boxes in the HTML output
49
+ save_checkpoint=True, # reuse the parse in extract() or segment()
50
+ )
51
+ result = client.convert("document.pdf", options=options)
52
+ ```
53
+
54
+ Other options include `paginate`, `add_block_ids`, `disable_html_prettify`, `exact_transcription`, `token_efficient_markdown`, `include_markdown_in_chunks`, `disable_image_extraction`, `disable_image_captions`, `fence_synthetic_captions`, `keep_spreadsheet_formatting`, `keep_pageheader_in_output`, `keep_pagefooter_in_output`, `additional_config`, `webhook_url`, `skip_cache` and `processing_location`. The [API reference](https://documentation.datalab.to/api-reference/convert-document) describes each option.
55
+
56
+ ## Structured extraction
57
+
58
+ ```python
59
+ from datalab_sdk import ExtractOptions
60
+
61
+ result = client.extract(
62
+ "invoice.pdf",
63
+ options=ExtractOptions(
64
+ page_schema='{"properties": {"total": {"type": "number"}}}', # or schema_id="sch_..."
65
+ extraction_mode="balanced", # turbo, fast, balanced, accurate
66
+ ),
67
+ )
68
+ print(result.extraction_schema_json, result.extraction_score_average)
69
+ ```
70
+
71
+ When you do not set the parse `mode`, the API picks the parse mode that matches `extraction_mode`.
72
+
73
+ ## Other endpoints
74
+
75
+ | Method | Endpoint |
76
+ | --- | --- |
77
+ | `run_agent()` | **Beta:** run an existing published processor (`AgentOptions(processor="cp_...")`) |
78
+ | `segment()` | Split a document into sections (`SegmentOptions`) |
79
+ | `fill()` | Fill a PDF or image form (`FormFillingOptions`) |
80
+ | `form_fields()` | Find the fillable fields in a PDF or image |
81
+ | `track_changes()` | Read tracked changes and comments from DOCX or PDF |
82
+ | `create_document()` | Make a DOCX from markdown with track changes markup |
83
+ | `generate_extraction_schemas()` | Suggest extraction schemas for a saved checkpoint |
84
+ | `delete_result()` | Result deletion, by `result.request_id` |
85
+ | `upload_files()`, `list_files()`, ... | File storage. Pass the returned `datalab://file-...` reference as `file_url` |
86
+ | `create_extraction_schema()`, ... | Saved extraction schemas |
87
+ | `create_pipeline()`, `run_pipeline()`, ... | [Pipelines](https://documentation.datalab.to/docs/welcome/sdk/pipelines) |
88
+
89
+ `run_custom_processor()` and `ocr()` call deprecated API endpoints. Use `run_agent()` and `convert()` instead.
90
+
91
+ Published-agent execution is in open beta; the API may change. Processor design and raw-prompt execution are not included.
92
+
93
+ ## Inputs, polling and errors
94
+
95
+ - Send a local file with `file_path`, or a URL or a `datalab://file-...` reference with `file_url`. When you set `processing_location`, send the document as `file_url`.
96
+ - Processing methods poll until the result is ready. Set `max_polls` and `poll_interval` to change the limit (default: 300 polls, 1 second apart). Use `stream_response_to` to write a large result straight to disk.
97
+ - The SDK retries a submission that gets HTTP 429 or 503, and polls that get 408, 429, 5xx or a connection error. It waits for the `Retry-After` header when the API sends one.
98
+ - API errors raise `DatalabAPIError` (with `status_code` and `response_data`) or one of its subclasses: `DatalabAuthenticationError` (401, 403), `DatalabPaymentRequiredError` (402), `DatalabNotFoundError` (404), `DatalabRateLimitError` (429) and `DatalabServerError` (5xx). Invalid arguments raise `DatalabValidationError`, which is also a `ValueError`.
99
+
100
+ ## Workflows
101
+
102
+ The Datalab API removed the Workflows API. The workflow methods and CLI commands in this SDK are deprecated, and the API does not answer them. Use pipelines instead.
103
+
104
+ ## CLI Usage
105
+
106
+ The SDK includes a command-line interface:
107
+
108
+ ```bash
109
+ # Convert a document or a directory of documents
110
+ datalab convert document.pdf --mode balanced --format markdown,html
111
+
112
+ # Extract with a saved schema
113
+ datalab extract invoice.pdf --schema_id sch_XXXXX --extraction_mode fast
114
+
115
+ # Other commands
116
+ datalab agent --help
117
+ datalab segment --help
118
+ datalab fill --help
119
+ datalab form-fields --help
120
+ datalab track-changes --help
121
+ datalab create-document --help
122
+ ```
123
+
124
+ ## Contributing
125
+
126
+ Issues and bug reports are welcome here. We develop the SDK in a private repository and mirror each release to this one, so we do not merge pull requests here directly. Open an issue, or open a pull request to show the change, and we will port it and credit you.
127
+
128
+ ## License
129
+
130
+ MIT License
@@ -6,7 +6,18 @@ supporting document conversion, extraction, segmentation, and more.
6
6
  """
7
7
 
8
8
  from .client import DatalabClient, AsyncDatalabClient
9
- from .exceptions import DatalabError, DatalabAPIError, DatalabTimeoutError
9
+ from .exceptions import (
10
+ DatalabError,
11
+ DatalabAPIError,
12
+ DatalabAuthenticationError,
13
+ DatalabPaymentRequiredError,
14
+ DatalabNotFoundError,
15
+ DatalabRateLimitError,
16
+ DatalabServerError,
17
+ DatalabTimeoutError,
18
+ DatalabFileError,
19
+ DatalabValidationError,
20
+ )
10
21
  from .models import (
11
22
  ConversionResult,
12
23
  CreateDocumentResult,
@@ -15,16 +26,30 @@ from .models import (
15
26
  ConvertOptions,
16
27
  ExtractOptions,
17
28
  SegmentOptions,
29
+ CustomProcessorOptions,
18
30
  CustomPipelineOptions,
19
31
  TrackChangesOptions,
20
32
  OCROptions,
21
33
  FormFillingOptions,
22
34
  FormFillingResult,
35
+ FormFieldsOptions,
36
+ FormFieldsResult,
37
+ AgentOptions,
38
+ AgentResult,
39
+ ExtractionSchemaSuggestions,
23
40
  Workflow,
24
41
  WorkflowStep,
25
42
  WorkflowExecution,
26
43
  InputConfig,
27
44
  UploadedFileMetadata,
45
+ ExtractionSchema,
46
+ PipelineProcessor,
47
+ PipelineConfig,
48
+ PipelineVersion,
49
+ PipelineExecution,
50
+ PipelineExecutionStepResult,
51
+ CustomProcessor,
52
+ CustomProcessorVersion,
28
53
  )
29
54
  from .settings import settings
30
55
 
@@ -34,7 +59,14 @@ __all__ = [
34
59
  "AsyncDatalabClient",
35
60
  "DatalabError",
36
61
  "DatalabAPIError",
62
+ "DatalabAuthenticationError",
63
+ "DatalabPaymentRequiredError",
64
+ "DatalabNotFoundError",
65
+ "DatalabRateLimitError",
66
+ "DatalabServerError",
37
67
  "DatalabTimeoutError",
68
+ "DatalabFileError",
69
+ "DatalabValidationError",
38
70
  "ConversionResult",
39
71
  "CreateDocumentResult",
40
72
  "FileResult",
@@ -42,14 +74,28 @@ __all__ = [
42
74
  "ConvertOptions",
43
75
  "ExtractOptions",
44
76
  "SegmentOptions",
77
+ "CustomProcessorOptions",
45
78
  "CustomPipelineOptions",
46
79
  "TrackChangesOptions",
47
80
  "OCROptions",
48
81
  "FormFillingOptions",
49
82
  "FormFillingResult",
83
+ "FormFieldsOptions",
84
+ "FormFieldsResult",
85
+ "AgentOptions",
86
+ "AgentResult",
87
+ "ExtractionSchemaSuggestions",
50
88
  "Workflow",
51
89
  "WorkflowStep",
52
90
  "WorkflowExecution",
53
91
  "InputConfig",
54
92
  "UploadedFileMetadata",
93
+ "ExtractionSchema",
94
+ "PipelineProcessor",
95
+ "PipelineConfig",
96
+ "PipelineVersion",
97
+ "PipelineExecution",
98
+ "PipelineExecutionStepResult",
99
+ "CustomProcessor",
100
+ "CustomProcessorVersion",
55
101
  ]