parallel-web 0.1.2__tar.gz → 0.2.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.
Potentially problematic release.
This version of parallel-web might be problematic. Click here for more details.
- {parallel_web-0.1.2 → parallel_web-0.2.0}/.gitignore +0 -1
- parallel_web-0.2.0/.release-please-manifest.json +3 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/CHANGELOG.md +54 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/PKG-INFO +48 -136
- {parallel_web-0.1.2 → parallel_web-0.2.0}/README.md +43 -135
- parallel_web-0.2.0/api.md +94 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/bin/check-release-environment +1 -1
- {parallel_web-0.1.2 → parallel_web-0.2.0}/pyproject.toml +7 -2
- {parallel_web-0.1.2 → parallel_web-0.2.0}/requirements-dev.lock +32 -2
- {parallel_web-0.1.2 → parallel_web-0.2.0}/requirements.lock +29 -2
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/__init__.py +2 -1
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/_base_client.py +34 -2
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/_client.py +9 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/_compat.py +1 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/_constants.py +2 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/_files.py +4 -4
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/_models.py +32 -8
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/_types.py +35 -1
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/_utils/__init__.py +1 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/_utils/_typing.py +5 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/_version.py +1 -1
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/lib/_pydantic.py +1 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/lib/_time.py +2 -2
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/resources/__init__.py +14 -0
- parallel_web-0.2.0/src/parallel/resources/beta/__init__.py +47 -0
- parallel_web-0.2.0/src/parallel/resources/beta/beta.py +301 -0
- parallel_web-0.2.0/src/parallel/resources/beta/task_group.py +632 -0
- parallel_web-0.2.0/src/parallel/resources/beta/task_run.py +499 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/resources/task_run.py +47 -18
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/types/__init__.py +15 -0
- parallel_web-0.2.0/src/parallel/types/auto_schema.py +13 -0
- parallel_web-0.2.0/src/parallel/types/auto_schema_param.py +12 -0
- parallel_web-0.2.0/src/parallel/types/beta/__init__.py +30 -0
- parallel_web-0.2.0/src/parallel/types/beta/beta_run_input.py +63 -0
- parallel_web-0.2.0/src/parallel/types/beta/beta_run_input_param.py +65 -0
- parallel_web-0.2.0/src/parallel/types/beta/beta_search_params.py +47 -0
- parallel_web-0.2.0/src/parallel/types/beta/beta_task_run_result.py +74 -0
- parallel_web-0.2.0/src/parallel/types/beta/error_event.py +16 -0
- parallel_web-0.2.0/src/parallel/types/beta/mcp_server.py +25 -0
- parallel_web-0.2.0/src/parallel/types/beta/mcp_server_param.py +25 -0
- parallel_web-0.2.0/src/parallel/types/beta/mcp_tool_call.py +27 -0
- parallel_web-0.2.0/src/parallel/types/beta/parallel_beta_param.py +12 -0
- parallel_web-0.2.0/src/parallel/types/beta/search_result.py +16 -0
- parallel_web-0.2.0/src/parallel/types/beta/task_group.py +24 -0
- parallel_web-0.2.0/src/parallel/types/beta/task_group_add_runs_params.py +30 -0
- parallel_web-0.2.0/src/parallel/types/beta/task_group_create_params.py +13 -0
- parallel_web-0.2.0/src/parallel/types/beta/task_group_events_params.py +16 -0
- parallel_web-0.2.0/src/parallel/types/beta/task_group_events_response.py +28 -0
- parallel_web-0.2.0/src/parallel/types/beta/task_group_get_runs_params.py +18 -0
- parallel_web-0.2.0/src/parallel/types/beta/task_group_get_runs_response.py +12 -0
- parallel_web-0.2.0/src/parallel/types/beta/task_group_run_response.py +30 -0
- parallel_web-0.2.0/src/parallel/types/beta/task_group_status.py +27 -0
- parallel_web-0.2.0/src/parallel/types/beta/task_run_create_params.py +70 -0
- parallel_web-0.2.0/src/parallel/types/beta/task_run_event.py +32 -0
- parallel_web-0.2.0/src/parallel/types/beta/task_run_events_response.py +58 -0
- parallel_web-0.2.0/src/parallel/types/beta/task_run_result_params.py +18 -0
- parallel_web-0.2.0/src/parallel/types/beta/web_search_result.py +18 -0
- parallel_web-0.2.0/src/parallel/types/beta/webhook.py +16 -0
- parallel_web-0.2.0/src/parallel/types/beta/webhook_param.py +16 -0
- parallel_web-0.2.0/src/parallel/types/citation.py +21 -0
- parallel_web-0.2.0/src/parallel/types/field_basis.py +25 -0
- parallel_web-0.2.0/src/parallel/types/json_schema.py +16 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/types/json_schema_param.py +2 -1
- parallel_web-0.2.0/src/parallel/types/parsed_task_run_result.py +38 -0
- parallel_web-0.2.0/src/parallel/types/shared/__init__.py +6 -0
- parallel_web-0.2.0/src/parallel/types/shared/error_object.py +18 -0
- parallel_web-0.2.0/src/parallel/types/shared/error_response.py +16 -0
- parallel_web-0.2.0/src/parallel/types/shared/source_policy.py +21 -0
- parallel_web-0.2.0/src/parallel/types/shared/warning.py +22 -0
- parallel_web-0.2.0/src/parallel/types/shared_params/__init__.py +3 -0
- parallel_web-0.2.0/src/parallel/types/shared_params/source_policy.py +22 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/types/task_run.py +17 -18
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/types/task_run_create_params.py +12 -3
- parallel_web-0.2.0/src/parallel/types/task_run_json_output.py +46 -0
- parallel_web-0.2.0/src/parallel/types/task_run_result.py +52 -0
- parallel_web-0.2.0/src/parallel/types/task_run_text_output.py +37 -0
- parallel_web-0.2.0/src/parallel/types/task_spec.py +31 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/types/task_spec_param.py +3 -2
- parallel_web-0.2.0/src/parallel/types/text_schema.py +16 -0
- parallel_web-0.2.0/tests/api_resources/beta/__init__.py +1 -0
- parallel_web-0.2.0/tests/api_resources/beta/test_task_group.py +613 -0
- parallel_web-0.2.0/tests/api_resources/beta/test_task_run.py +349 -0
- parallel_web-0.2.0/tests/api_resources/test_beta.py +104 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/tests/api_resources/test_task_run.py +37 -63
- {parallel_web-0.1.2 → parallel_web-0.2.0}/tests/conftest.py +37 -6
- {parallel_web-0.1.2 → parallel_web-0.2.0}/tests/test_client.py +30 -12
- {parallel_web-0.1.2 → parallel_web-0.2.0}/tests/test_models.py +73 -1
- {parallel_web-0.1.2 → parallel_web-0.2.0}/tests/utils.py +9 -1
- parallel_web-0.1.2/.release-please-manifest.json +0 -3
- parallel_web-0.1.2/api.md +0 -18
- parallel_web-0.1.2/src/parallel/types/parsed_task_run_result.py +0 -29
- parallel_web-0.1.2/src/parallel/types/task_run_result.py +0 -122
- {parallel_web-0.1.2 → parallel_web-0.2.0}/CONTRIBUTING.md +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/LICENSE +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/SECURITY.md +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/bin/publish-pypi +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/examples/.keep +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/mypy.ini +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/noxfile.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/release-please-config.json +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/_exceptions.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/_qs.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/_resource.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/_response.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/_streaming.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/_utils/_logs.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/_utils/_proxy.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/_utils/_reflection.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/_utils/_resources_proxy.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/_utils/_streams.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/_utils/_sync.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/_utils/_transform.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/_utils/_utils.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/lib/.keep +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/lib/__init__.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/lib/_parsing/__init__.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/lib/_parsing/_task_run_result.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/lib/_parsing/_task_spec.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/py.typed +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/types/task_run_result_params.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/src/parallel/types/text_schema_param.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/tests/__init__.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/tests/api_resources/__init__.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/tests/sample_file.txt +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/tests/test_deepcopy.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/tests/test_extract_files.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/tests/test_files.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/tests/test_qs.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/tests/test_required_args.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/tests/test_response.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/tests/test_streaming.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/tests/test_transform.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/tests/test_utils/test_proxy.py +0 -0
- {parallel_web-0.1.2 → parallel_web-0.2.0}/tests/test_utils/test_typing.py +0 -0
|
@@ -1,5 +1,59 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.0 (2025-09-01)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v0.1.3...v0.2.0](https://github.com/parallel-web/parallel-sdk-python/compare/v0.1.3...v0.2.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **api:** update via SDK Studio ([b048bd7](https://github.com/parallel-web/parallel-sdk-python/commit/b048bd7e1c5a992ae274aa4b6df16a9d5b0f843e))
|
|
10
|
+
* **api:** update via SDK Studio ([b9abf3c](https://github.com/parallel-web/parallel-sdk-python/commit/b9abf3c8b0e22b260149f01b1ef608924eefe735))
|
|
11
|
+
* **api:** update via SDK Studio ([4326698](https://github.com/parallel-web/parallel-sdk-python/commit/43266988c2123fa1aff00bf0b62c355b0c2bf04e))
|
|
12
|
+
* clean up environment call outs ([3a102e9](https://github.com/parallel-web/parallel-sdk-python/commit/3a102e9a05476e4d28c0ac386cd156cc0fe8b5cf))
|
|
13
|
+
* **client:** add support for aiohttp ([4e2aa32](https://github.com/parallel-web/parallel-sdk-python/commit/4e2aa32ad8242745f56e5a8b810d33c362967dad))
|
|
14
|
+
* **client:** support file upload requests ([ec0c2cf](https://github.com/parallel-web/parallel-sdk-python/commit/ec0c2cf30bd24524567232ad0f661facda124203))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* add types for backwards compatibility ([c975302](https://github.com/parallel-web/parallel-sdk-python/commit/c975302c0d61d1d6731ccaeb7977c2009cb0b666))
|
|
20
|
+
* avoid newer type syntax ([2ea196d](https://github.com/parallel-web/parallel-sdk-python/commit/2ea196d5d4c7881e61dc848a1387770b4e27e304))
|
|
21
|
+
* **ci:** correct conditional ([99d37f6](https://github.com/parallel-web/parallel-sdk-python/commit/99d37f657a249987ccae60dd0e62f296ab0c1d85))
|
|
22
|
+
* **ci:** release-doctor — report correct token name ([310076b](https://github.com/parallel-web/parallel-sdk-python/commit/310076b2f8a75ed29ba2a1fae0f6e840ec43bb5b))
|
|
23
|
+
* **client:** don't send Content-Type header on GET requests ([f103b4a](https://github.com/parallel-web/parallel-sdk-python/commit/f103b4a72fc25f6a8dd1bda0c8d040aba1f527d1))
|
|
24
|
+
* **parsing:** correctly handle nested discriminated unions ([c9a2300](https://github.com/parallel-web/parallel-sdk-python/commit/c9a23002be2d78a11b5c1b7c901f4ddb32663393))
|
|
25
|
+
* **parsing:** ignore empty metadata ([ab434aa](https://github.com/parallel-web/parallel-sdk-python/commit/ab434aa7bd088fc16279255ae36138ab6dff0730))
|
|
26
|
+
* **parsing:** parse extra field types ([85f5cd4](https://github.com/parallel-web/parallel-sdk-python/commit/85f5cd4191ae168ed443e78a2c7bd747d51404b3))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Chores
|
|
30
|
+
|
|
31
|
+
* **ci:** change upload type ([40dbd3b](https://github.com/parallel-web/parallel-sdk-python/commit/40dbd3b7d5becf0fe54b62a4acd8696957380053))
|
|
32
|
+
* **ci:** only run for pushes and fork pull requests ([d55fbea](https://github.com/parallel-web/parallel-sdk-python/commit/d55fbea54037d2d833ecc281cbddbc8d6700d24d))
|
|
33
|
+
* **internal:** add Sequence related utils ([cb9a7a9](https://github.com/parallel-web/parallel-sdk-python/commit/cb9a7a905ca4a4a9ba35e540f6c47a8bf89c87d2))
|
|
34
|
+
* **internal:** bump pinned h11 dep ([818f1dd](https://github.com/parallel-web/parallel-sdk-python/commit/818f1ddb3ba1be6bfdb9aee1322d6a3d8a98667a))
|
|
35
|
+
* **internal:** change ci workflow machines ([a90da34](https://github.com/parallel-web/parallel-sdk-python/commit/a90da34910585453eac918a5f273749c00d2f743))
|
|
36
|
+
* **internal:** codegen related update ([47ea68b](https://github.com/parallel-web/parallel-sdk-python/commit/47ea68bd44ad52ac1c18e7215c013f408914890c))
|
|
37
|
+
* **internal:** fix ruff target version ([4e5dbda](https://github.com/parallel-web/parallel-sdk-python/commit/4e5dbda03907f45ac31d18d89714e86f26e79866))
|
|
38
|
+
* **internal:** update comment in script ([631b045](https://github.com/parallel-web/parallel-sdk-python/commit/631b045ae2f138e4c8098fafd9466451d61ca82a))
|
|
39
|
+
* **internal:** update pyright exclude list ([8d2fb29](https://github.com/parallel-web/parallel-sdk-python/commit/8d2fb29b5d80a2fa9ee81a6f9510134fb7bab908))
|
|
40
|
+
* **internal:** version bump ([90d26a5](https://github.com/parallel-web/parallel-sdk-python/commit/90d26a5e8db8bd6a27f9bbc96595da87bd7ea0f3))
|
|
41
|
+
* **package:** mark python 3.13 as supported ([6fa54c4](https://github.com/parallel-web/parallel-sdk-python/commit/6fa54c42a17f5e731f5e97214f0212a0828d3cb8))
|
|
42
|
+
* **project:** add settings file for vscode ([acdeda2](https://github.com/parallel-web/parallel-sdk-python/commit/acdeda2f1f95f5bade2da52d5a2aa8560e71369d))
|
|
43
|
+
* **readme:** fix version rendering on pypi ([2bf10b0](https://github.com/parallel-web/parallel-sdk-python/commit/2bf10b073ab7e015b08c106d265a9091752df51a))
|
|
44
|
+
* **readme:** Remove references to methods, update FAQ for beta ([cefefbf](https://github.com/parallel-web/parallel-sdk-python/commit/cefefbfccba78fdabcc925728836d70400d4e5aa))
|
|
45
|
+
* **tests:** skip some failing tests on the latest python versions ([13b1533](https://github.com/parallel-web/parallel-sdk-python/commit/13b153381e9b7c998a7ebef878518222678dfa83))
|
|
46
|
+
* update @stainless-api/prism-cli to v5.15.0 ([56b5aab](https://github.com/parallel-web/parallel-sdk-python/commit/56b5aab87a833c27b8e1a2bc7c4bf2169ee281a8))
|
|
47
|
+
* update github action ([3d90e19](https://github.com/parallel-web/parallel-sdk-python/commit/3d90e196184e540242fb310cc55b0219d20dff45))
|
|
48
|
+
|
|
49
|
+
## 0.1.3 (2025-08-09)
|
|
50
|
+
|
|
51
|
+
Full Changelog: [v0.1.2...v0.1.3](https://github.com/parallel-web/parallel-sdk-python/compare/v0.1.2...v0.1.3)
|
|
52
|
+
|
|
53
|
+
### Chores
|
|
54
|
+
|
|
55
|
+
* **readme:** update descriptions ([3212a0f](https://github.com/parallel-web/parallel-sdk-python/commit/3212a0fc32d744e7df3d0dcedf527b176a73a91b))
|
|
56
|
+
|
|
3
57
|
## 0.1.2 (2025-06-25)
|
|
4
58
|
|
|
5
59
|
Full Changelog: [v0.1.1...v0.1.2](https://github.com/parallel-web/parallel-sdk-python/compare/v0.1.1...v0.1.2)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: parallel-web
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: The official Python library for the Parallel API
|
|
5
5
|
Project-URL: Homepage, https://github.com/parallel-web/parallel-sdk-python
|
|
6
6
|
Project-URL: Repository, https://github.com/parallel-web/parallel-sdk-python
|
|
@@ -18,6 +18,7 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.10
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.11
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
22
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
23
|
Classifier: Typing :: Typed
|
|
23
24
|
Requires-Python: >=3.8
|
|
@@ -27,11 +28,15 @@ Requires-Dist: httpx<1,>=0.23.0
|
|
|
27
28
|
Requires-Dist: pydantic<3,>=1.9.0
|
|
28
29
|
Requires-Dist: sniffio
|
|
29
30
|
Requires-Dist: typing-extensions<5,>=4.10
|
|
31
|
+
Provides-Extra: aiohttp
|
|
32
|
+
Requires-Dist: aiohttp; extra == 'aiohttp'
|
|
33
|
+
Requires-Dist: httpx-aiohttp>=0.1.8; extra == 'aiohttp'
|
|
30
34
|
Description-Content-Type: text/markdown
|
|
31
35
|
|
|
32
36
|
# Parallel Python API library
|
|
33
37
|
|
|
34
|
-
|
|
38
|
+
<!-- prettier-ignore -->
|
|
39
|
+
[)](https://pypi.org/project/parallel-web/)
|
|
35
40
|
|
|
36
41
|
The Parallel Python library provides convenient access to the Parallel REST API from any Python 3.8+
|
|
37
42
|
application. The library includes type definitions for all request params and response fields,
|
|
@@ -42,7 +47,7 @@ It is generated with [Stainless](https://www.stainless.com/).
|
|
|
42
47
|
|
|
43
48
|
## Documentation
|
|
44
49
|
|
|
45
|
-
The REST API documentation can be found
|
|
50
|
+
The REST API documentation can be found in our [docs](https://docs.parallel.ai).
|
|
46
51
|
The full API of this Python library can be found in [api.md](https://github.com/parallel-web/parallel-sdk-python/tree/main/api.md).
|
|
47
52
|
|
|
48
53
|
## Installation
|
|
@@ -64,12 +69,12 @@ client = Parallel(
|
|
|
64
69
|
api_key=os.environ.get("PARALLEL_API_KEY"), # This is the default and can be omitted
|
|
65
70
|
)
|
|
66
71
|
|
|
67
|
-
|
|
72
|
+
task_run = client.task_run.create(
|
|
68
73
|
input="France (2023)",
|
|
69
74
|
processor="core",
|
|
70
|
-
output="GDP"
|
|
71
75
|
)
|
|
72
|
-
|
|
76
|
+
task_run_result = client.task_run.result(run_id=task_run.run_id)
|
|
77
|
+
print(task_run_result.output)
|
|
73
78
|
```
|
|
74
79
|
|
|
75
80
|
While you can provide an `api_key` keyword argument,
|
|
@@ -77,6 +82,11 @@ we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
|
|
|
77
82
|
to add `PARALLEL_API_KEY="My API Key"` to your `.env` file
|
|
78
83
|
so that your API Key is not stored in source control.
|
|
79
84
|
|
|
85
|
+
The API also supports typed inputs and outputs via Pydantic objects. See the relevant
|
|
86
|
+
section on [convenience methods](https://github.com/parallel-web/parallel-sdk-python/tree/main/#convenience-methods).
|
|
87
|
+
|
|
88
|
+
For information on what tasks are and how to specify them, see [our docs](https://docs.parallel.ai/task-api/core-concepts/specify-a-task).
|
|
89
|
+
|
|
80
90
|
## Async usage
|
|
81
91
|
|
|
82
92
|
Simply import `AsyncParallel` instead of `Parallel` and use `await` with each API call:
|
|
@@ -92,12 +102,9 @@ client = AsyncParallel(
|
|
|
92
102
|
|
|
93
103
|
|
|
94
104
|
async def main() -> None:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
output="GDP"
|
|
99
|
-
)
|
|
100
|
-
print(run_result.output)
|
|
105
|
+
task_run = await client.task_run.create(input="France (2023)", processor="core")
|
|
106
|
+
run_result = await client.task_run.result(run_id=task_run.run_id)
|
|
107
|
+
print(run_result.output.content)
|
|
101
108
|
|
|
102
109
|
|
|
103
110
|
if __name__ == "__main__":
|
|
@@ -106,115 +113,35 @@ if __name__ == "__main__":
|
|
|
106
113
|
|
|
107
114
|
To get the best performance out of Parallel's API, we recommend
|
|
108
115
|
using the asynchronous client, especially for executing multiple Task Runs concurrently.
|
|
109
|
-
Functionality between the synchronous and asynchronous clients is identical
|
|
116
|
+
Functionality between the synchronous and asynchronous clients is identical, including
|
|
117
|
+
the convenience methods.
|
|
110
118
|
|
|
111
|
-
##
|
|
119
|
+
## Frequently Asked Questions
|
|
112
120
|
|
|
113
|
-
|
|
121
|
+
**Does the Task API accept prompts or objectives?**
|
|
114
122
|
|
|
115
|
-
|
|
116
|
-
|
|
123
|
+
No, there are no `objective` or `prompt` parameters that can be specified for calls to
|
|
124
|
+
the Task API. Instead, provide any directives or instructions via the schemas. For
|
|
125
|
+
more information, check [our docs](https://docs.parallel.ai/task-api/core-concepts/specify-a-task).
|
|
117
126
|
|
|
118
|
-
|
|
119
|
-
specified in the call to `.execute()`, the response content will be parsed into an
|
|
120
|
-
instance of the provided output type. The parsed output can be accessed via the
|
|
121
|
-
`parsed` property on the output field of the response.
|
|
127
|
+
**Can I access beta parameters or endpoints via the SDK?**
|
|
122
128
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
import asyncio
|
|
126
|
-
from parallel import AsyncParallel
|
|
127
|
-
from pydantic import BaseModel
|
|
129
|
+
Yes, the SDK supports both beta endpoints and beta header parameters for the Task API.
|
|
130
|
+
All beta parameters are accessible via the `client.beta` namespace in the SDK.
|
|
128
131
|
|
|
129
|
-
|
|
132
|
+
**Can I specify a timeout for API calls?**
|
|
130
133
|
|
|
131
|
-
|
|
132
|
-
output: str
|
|
134
|
+
Yes, all methods support a timeout. For more information, see [Timeouts](https://github.com/parallel-web/parallel-sdk-python/tree/main/#timeouts).
|
|
133
135
|
|
|
134
|
-
|
|
135
|
-
# with pydantic
|
|
136
|
-
run_result = await client.task_run.execute(
|
|
137
|
-
input="France (2023)",
|
|
138
|
-
processor="core",
|
|
139
|
-
output=SampleOutputStructure,
|
|
140
|
-
)
|
|
141
|
-
# parsed output of type SampleOutputStructure
|
|
142
|
-
print(run_result.output.parsed)
|
|
143
|
-
# without pydantic
|
|
144
|
-
run_result = await client.task_run.execute(
|
|
145
|
-
input="France (2023)",
|
|
146
|
-
processor="core",
|
|
147
|
-
output="GDP"
|
|
148
|
-
)
|
|
149
|
-
print(run_result.output)
|
|
136
|
+
**Can I specify retries via the SDK?**
|
|
150
137
|
|
|
138
|
+
Yes, errors can be retried via the SDK — the default retry count is 2. The maximum number
|
|
139
|
+
of retries can be configured at the client level. For information on which errors
|
|
140
|
+
are automatically retried and how to configure retry settings, see [Retries](https://github.com/parallel-web/parallel-sdk-python/tree/main/#retries).
|
|
151
141
|
|
|
152
|
-
|
|
153
|
-
asyncio.run(main())
|
|
154
|
-
```
|
|
142
|
+
## Low‑level API access
|
|
155
143
|
|
|
156
|
-
The
|
|
157
|
-
To create multiple task runs in one go, call execute and then gather the results at the end.
|
|
158
|
-
|
|
159
|
-
```python
|
|
160
|
-
import asyncio
|
|
161
|
-
import os
|
|
162
|
-
|
|
163
|
-
from parallel import AsyncParallel
|
|
164
|
-
from pydantic import BaseModel, Field
|
|
165
|
-
from typing import List
|
|
166
|
-
|
|
167
|
-
class CountryInput(BaseModel):
|
|
168
|
-
country: str = Field(
|
|
169
|
-
description="Name of the country to research. Must be a recognized "
|
|
170
|
-
"sovereign nation (e.g., 'France', 'Japan')."
|
|
171
|
-
)
|
|
172
|
-
year: int = Field(
|
|
173
|
-
description="Year for which to retrieve data. Must be 2000 or later. "
|
|
174
|
-
"Use most recent full-year estimates if year is current."
|
|
175
|
-
)
|
|
176
|
-
|
|
177
|
-
class CountryOutput(BaseModel):
|
|
178
|
-
gdp: str = Field(
|
|
179
|
-
description="GDP in USD for the year, formatted like '$3.1 trillion (2023)'."
|
|
180
|
-
)
|
|
181
|
-
top_exports: List[str] = Field(
|
|
182
|
-
description="Top 3 exported goods/services by value. Use credible sources."
|
|
183
|
-
)
|
|
184
|
-
top_imports: List[str] = Field(
|
|
185
|
-
description="Top 3 imported goods/services by value. Use credible sources."
|
|
186
|
-
)
|
|
187
|
-
|
|
188
|
-
async def main():
|
|
189
|
-
# Initialize the Parallel client
|
|
190
|
-
client = AsyncParallel(api_key=os.environ.get("PARALLEL_API_KEY"))
|
|
191
|
-
|
|
192
|
-
# Prepare structured input
|
|
193
|
-
input_data = [
|
|
194
|
-
CountryInput(country="France", year=2023),
|
|
195
|
-
CountryInput(country="Germany", year=2023),
|
|
196
|
-
CountryInput(country="Italy", year=2023)
|
|
197
|
-
]
|
|
198
|
-
|
|
199
|
-
run_results = await asyncio.gather(*[
|
|
200
|
-
client.task_run.execute(
|
|
201
|
-
input=datum,
|
|
202
|
-
output=CountryOutput,
|
|
203
|
-
processor="core"
|
|
204
|
-
)
|
|
205
|
-
for datum in input_data
|
|
206
|
-
])
|
|
207
|
-
|
|
208
|
-
for run_input, run_result in zip(input_data, run_results):
|
|
209
|
-
print(f"Task run output for {run_input}: {run_result.output.parsed}")
|
|
210
|
-
|
|
211
|
-
if __name__ == "__main__":
|
|
212
|
-
asyncio.run(main())
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
## Low level API Access
|
|
216
|
-
|
|
217
|
-
The library also provides access to the low level API for accessing the Parallel API.
|
|
144
|
+
The library also provides low‑level access to the Parallel API.
|
|
218
145
|
|
|
219
146
|
```python
|
|
220
147
|
from parallel import Parallel
|
|
@@ -262,13 +189,13 @@ task_run = client.task_run.create(
|
|
|
262
189
|
)
|
|
263
190
|
|
|
264
191
|
run_result = client.task_run.result(task_run.run_id)
|
|
265
|
-
print(run_result.output)
|
|
192
|
+
print(run_result.output.content)
|
|
266
193
|
```
|
|
267
194
|
|
|
268
195
|
For more information, please check out the relevant section in our docs:
|
|
269
196
|
|
|
270
|
-
- [Task Spec](https://docs.parallel.ai/core-concepts/task
|
|
271
|
-
- [Task Runs](https://docs.parallel.ai/core-concepts/task-
|
|
197
|
+
- [Task Spec](https://docs.parallel.ai/task-api/core-concepts/specify-a-task)
|
|
198
|
+
- [Task Runs](https://docs.parallel.ai/task-api/core-concepts/execute-task-run)
|
|
272
199
|
|
|
273
200
|
## Handling errors
|
|
274
201
|
|
|
@@ -286,11 +213,7 @@ from parallel import Parallel
|
|
|
286
213
|
client = Parallel()
|
|
287
214
|
|
|
288
215
|
try:
|
|
289
|
-
client.task_run.
|
|
290
|
-
input="France (2023)",
|
|
291
|
-
processor="core",
|
|
292
|
-
output="GDP"
|
|
293
|
-
)
|
|
216
|
+
client.task_run.create(input="France (2023)", processor="core")
|
|
294
217
|
except parallel.APIConnectionError as e:
|
|
295
218
|
print("The server could not be reached")
|
|
296
219
|
print(e.__cause__) # an underlying Exception, likely raised within httpx.
|
|
@@ -333,11 +256,7 @@ client = Parallel(
|
|
|
333
256
|
)
|
|
334
257
|
|
|
335
258
|
# Or, configure per-request:
|
|
336
|
-
client.with_options(max_retries=5).task_run.
|
|
337
|
-
input="France (2023)",
|
|
338
|
-
processor="core",
|
|
339
|
-
output="GDP"
|
|
340
|
-
)
|
|
259
|
+
client.with_options(max_retries=5).task_run.create(input="France (2023)", processor="core")
|
|
341
260
|
```
|
|
342
261
|
|
|
343
262
|
### Timeouts
|
|
@@ -360,11 +279,7 @@ client = Parallel(
|
|
|
360
279
|
)
|
|
361
280
|
|
|
362
281
|
# Override per-request:
|
|
363
|
-
client.with_options(timeout=5.0).task_run.
|
|
364
|
-
input="France (2023)",
|
|
365
|
-
processor="core",
|
|
366
|
-
output="GDP"
|
|
367
|
-
)
|
|
282
|
+
client.with_options(timeout=5.0).task_run.create(input="France (2023)", processor="core")
|
|
368
283
|
```
|
|
369
284
|
|
|
370
285
|
On timeout, an `APITimeoutError` is thrown.
|
|
@@ -405,15 +320,14 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
|
|
|
405
320
|
from parallel import Parallel
|
|
406
321
|
|
|
407
322
|
client = Parallel()
|
|
408
|
-
response = client.task_run.with_raw_response.
|
|
323
|
+
response = client.task_run.with_raw_response.create(
|
|
409
324
|
input="France (2023)",
|
|
410
325
|
processor="core",
|
|
411
|
-
output="GDP"
|
|
412
326
|
)
|
|
413
327
|
print(response.headers.get('X-My-Header'))
|
|
414
328
|
|
|
415
|
-
task_run = response.parse()
|
|
416
|
-
print(task_run.
|
|
329
|
+
task_run = response.parse()
|
|
330
|
+
print(task_run.run_id)
|
|
417
331
|
```
|
|
418
332
|
|
|
419
333
|
These methods return an [`APIResponse`](https://github.com/parallel-web/parallel-sdk-python/tree/main/src/parallel/_response.py) object.
|
|
@@ -427,10 +341,8 @@ The above interface eagerly reads the full response body when you make the reque
|
|
|
427
341
|
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.
|
|
428
342
|
|
|
429
343
|
```python
|
|
430
|
-
with client.task_run.with_streaming_response.
|
|
431
|
-
input="France (2023)",
|
|
432
|
-
processor="core",
|
|
433
|
-
output="GDP"
|
|
344
|
+
with client.task_run.with_streaming_response.create(
|
|
345
|
+
input="France (2023)", processor="core"
|
|
434
346
|
) as response:
|
|
435
347
|
print(response.headers.get("X-My-Header"))
|
|
436
348
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Parallel Python API library
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<!-- prettier-ignore -->
|
|
4
|
+
[)](https://pypi.org/project/parallel-web/)
|
|
4
5
|
|
|
5
6
|
The Parallel Python library provides convenient access to the Parallel REST API from any Python 3.8+
|
|
6
7
|
application. The library includes type definitions for all request params and response fields,
|
|
@@ -11,7 +12,7 @@ It is generated with [Stainless](https://www.stainless.com/).
|
|
|
11
12
|
|
|
12
13
|
## Documentation
|
|
13
14
|
|
|
14
|
-
The REST API documentation can be found
|
|
15
|
+
The REST API documentation can be found in our [docs](https://docs.parallel.ai).
|
|
15
16
|
The full API of this Python library can be found in [api.md](api.md).
|
|
16
17
|
|
|
17
18
|
## Installation
|
|
@@ -33,12 +34,12 @@ client = Parallel(
|
|
|
33
34
|
api_key=os.environ.get("PARALLEL_API_KEY"), # This is the default and can be omitted
|
|
34
35
|
)
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
task_run = client.task_run.create(
|
|
37
38
|
input="France (2023)",
|
|
38
39
|
processor="core",
|
|
39
|
-
output="GDP"
|
|
40
40
|
)
|
|
41
|
-
|
|
41
|
+
task_run_result = client.task_run.result(run_id=task_run.run_id)
|
|
42
|
+
print(task_run_result.output)
|
|
42
43
|
```
|
|
43
44
|
|
|
44
45
|
While you can provide an `api_key` keyword argument,
|
|
@@ -46,6 +47,11 @@ we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
|
|
|
46
47
|
to add `PARALLEL_API_KEY="My API Key"` to your `.env` file
|
|
47
48
|
so that your API Key is not stored in source control.
|
|
48
49
|
|
|
50
|
+
The API also supports typed inputs and outputs via Pydantic objects. See the relevant
|
|
51
|
+
section on [convenience methods](#convenience-methods).
|
|
52
|
+
|
|
53
|
+
For information on what tasks are and how to specify them, see [our docs](https://docs.parallel.ai/task-api/core-concepts/specify-a-task).
|
|
54
|
+
|
|
49
55
|
## Async usage
|
|
50
56
|
|
|
51
57
|
Simply import `AsyncParallel` instead of `Parallel` and use `await` with each API call:
|
|
@@ -61,12 +67,9 @@ client = AsyncParallel(
|
|
|
61
67
|
|
|
62
68
|
|
|
63
69
|
async def main() -> None:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
output="GDP"
|
|
68
|
-
)
|
|
69
|
-
print(run_result.output)
|
|
70
|
+
task_run = await client.task_run.create(input="France (2023)", processor="core")
|
|
71
|
+
run_result = await client.task_run.result(run_id=task_run.run_id)
|
|
72
|
+
print(run_result.output.content)
|
|
70
73
|
|
|
71
74
|
|
|
72
75
|
if __name__ == "__main__":
|
|
@@ -75,115 +78,35 @@ if __name__ == "__main__":
|
|
|
75
78
|
|
|
76
79
|
To get the best performance out of Parallel's API, we recommend
|
|
77
80
|
using the asynchronous client, especially for executing multiple Task Runs concurrently.
|
|
78
|
-
Functionality between the synchronous and asynchronous clients is identical
|
|
81
|
+
Functionality between the synchronous and asynchronous clients is identical, including
|
|
82
|
+
the convenience methods.
|
|
79
83
|
|
|
80
|
-
##
|
|
84
|
+
## Frequently Asked Questions
|
|
81
85
|
|
|
82
|
-
|
|
86
|
+
**Does the Task API accept prompts or objectives?**
|
|
83
87
|
|
|
84
|
-
|
|
85
|
-
|
|
88
|
+
No, there are no `objective` or `prompt` parameters that can be specified for calls to
|
|
89
|
+
the Task API. Instead, provide any directives or instructions via the schemas. For
|
|
90
|
+
more information, check [our docs](https://docs.parallel.ai/task-api/core-concepts/specify-a-task).
|
|
86
91
|
|
|
87
|
-
|
|
88
|
-
specified in the call to `.execute()`, the response content will be parsed into an
|
|
89
|
-
instance of the provided output type. The parsed output can be accessed via the
|
|
90
|
-
`parsed` property on the output field of the response.
|
|
92
|
+
**Can I access beta parameters or endpoints via the SDK?**
|
|
91
93
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
import asyncio
|
|
95
|
-
from parallel import AsyncParallel
|
|
96
|
-
from pydantic import BaseModel
|
|
94
|
+
Yes, the SDK supports both beta endpoints and beta header parameters for the Task API.
|
|
95
|
+
All beta parameters are accessible via the `client.beta` namespace in the SDK.
|
|
97
96
|
|
|
98
|
-
|
|
97
|
+
**Can I specify a timeout for API calls?**
|
|
99
98
|
|
|
100
|
-
|
|
101
|
-
output: str
|
|
99
|
+
Yes, all methods support a timeout. For more information, see [Timeouts](#timeouts).
|
|
102
100
|
|
|
103
|
-
|
|
104
|
-
# with pydantic
|
|
105
|
-
run_result = await client.task_run.execute(
|
|
106
|
-
input="France (2023)",
|
|
107
|
-
processor="core",
|
|
108
|
-
output=SampleOutputStructure,
|
|
109
|
-
)
|
|
110
|
-
# parsed output of type SampleOutputStructure
|
|
111
|
-
print(run_result.output.parsed)
|
|
112
|
-
# without pydantic
|
|
113
|
-
run_result = await client.task_run.execute(
|
|
114
|
-
input="France (2023)",
|
|
115
|
-
processor="core",
|
|
116
|
-
output="GDP"
|
|
117
|
-
)
|
|
118
|
-
print(run_result.output)
|
|
101
|
+
**Can I specify retries via the SDK?**
|
|
119
102
|
|
|
103
|
+
Yes, errors can be retried via the SDK — the default retry count is 2. The maximum number
|
|
104
|
+
of retries can be configured at the client level. For information on which errors
|
|
105
|
+
are automatically retried and how to configure retry settings, see [Retries](#retries).
|
|
120
106
|
|
|
121
|
-
|
|
122
|
-
asyncio.run(main())
|
|
123
|
-
```
|
|
107
|
+
## Low‑level API access
|
|
124
108
|
|
|
125
|
-
The
|
|
126
|
-
To create multiple task runs in one go, call execute and then gather the results at the end.
|
|
127
|
-
|
|
128
|
-
```python
|
|
129
|
-
import asyncio
|
|
130
|
-
import os
|
|
131
|
-
|
|
132
|
-
from parallel import AsyncParallel
|
|
133
|
-
from pydantic import BaseModel, Field
|
|
134
|
-
from typing import List
|
|
135
|
-
|
|
136
|
-
class CountryInput(BaseModel):
|
|
137
|
-
country: str = Field(
|
|
138
|
-
description="Name of the country to research. Must be a recognized "
|
|
139
|
-
"sovereign nation (e.g., 'France', 'Japan')."
|
|
140
|
-
)
|
|
141
|
-
year: int = Field(
|
|
142
|
-
description="Year for which to retrieve data. Must be 2000 or later. "
|
|
143
|
-
"Use most recent full-year estimates if year is current."
|
|
144
|
-
)
|
|
145
|
-
|
|
146
|
-
class CountryOutput(BaseModel):
|
|
147
|
-
gdp: str = Field(
|
|
148
|
-
description="GDP in USD for the year, formatted like '$3.1 trillion (2023)'."
|
|
149
|
-
)
|
|
150
|
-
top_exports: List[str] = Field(
|
|
151
|
-
description="Top 3 exported goods/services by value. Use credible sources."
|
|
152
|
-
)
|
|
153
|
-
top_imports: List[str] = Field(
|
|
154
|
-
description="Top 3 imported goods/services by value. Use credible sources."
|
|
155
|
-
)
|
|
156
|
-
|
|
157
|
-
async def main():
|
|
158
|
-
# Initialize the Parallel client
|
|
159
|
-
client = AsyncParallel(api_key=os.environ.get("PARALLEL_API_KEY"))
|
|
160
|
-
|
|
161
|
-
# Prepare structured input
|
|
162
|
-
input_data = [
|
|
163
|
-
CountryInput(country="France", year=2023),
|
|
164
|
-
CountryInput(country="Germany", year=2023),
|
|
165
|
-
CountryInput(country="Italy", year=2023)
|
|
166
|
-
]
|
|
167
|
-
|
|
168
|
-
run_results = await asyncio.gather(*[
|
|
169
|
-
client.task_run.execute(
|
|
170
|
-
input=datum,
|
|
171
|
-
output=CountryOutput,
|
|
172
|
-
processor="core"
|
|
173
|
-
)
|
|
174
|
-
for datum in input_data
|
|
175
|
-
])
|
|
176
|
-
|
|
177
|
-
for run_input, run_result in zip(input_data, run_results):
|
|
178
|
-
print(f"Task run output for {run_input}: {run_result.output.parsed}")
|
|
179
|
-
|
|
180
|
-
if __name__ == "__main__":
|
|
181
|
-
asyncio.run(main())
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
## Low level API Access
|
|
185
|
-
|
|
186
|
-
The library also provides access to the low level API for accessing the Parallel API.
|
|
109
|
+
The library also provides low‑level access to the Parallel API.
|
|
187
110
|
|
|
188
111
|
```python
|
|
189
112
|
from parallel import Parallel
|
|
@@ -231,13 +154,13 @@ task_run = client.task_run.create(
|
|
|
231
154
|
)
|
|
232
155
|
|
|
233
156
|
run_result = client.task_run.result(task_run.run_id)
|
|
234
|
-
print(run_result.output)
|
|
157
|
+
print(run_result.output.content)
|
|
235
158
|
```
|
|
236
159
|
|
|
237
160
|
For more information, please check out the relevant section in our docs:
|
|
238
161
|
|
|
239
|
-
- [Task Spec](https://docs.parallel.ai/core-concepts/task
|
|
240
|
-
- [Task Runs](https://docs.parallel.ai/core-concepts/task-
|
|
162
|
+
- [Task Spec](https://docs.parallel.ai/task-api/core-concepts/specify-a-task)
|
|
163
|
+
- [Task Runs](https://docs.parallel.ai/task-api/core-concepts/execute-task-run)
|
|
241
164
|
|
|
242
165
|
## Handling errors
|
|
243
166
|
|
|
@@ -255,11 +178,7 @@ from parallel import Parallel
|
|
|
255
178
|
client = Parallel()
|
|
256
179
|
|
|
257
180
|
try:
|
|
258
|
-
client.task_run.
|
|
259
|
-
input="France (2023)",
|
|
260
|
-
processor="core",
|
|
261
|
-
output="GDP"
|
|
262
|
-
)
|
|
181
|
+
client.task_run.create(input="France (2023)", processor="core")
|
|
263
182
|
except parallel.APIConnectionError as e:
|
|
264
183
|
print("The server could not be reached")
|
|
265
184
|
print(e.__cause__) # an underlying Exception, likely raised within httpx.
|
|
@@ -302,11 +221,7 @@ client = Parallel(
|
|
|
302
221
|
)
|
|
303
222
|
|
|
304
223
|
# Or, configure per-request:
|
|
305
|
-
client.with_options(max_retries=5).task_run.
|
|
306
|
-
input="France (2023)",
|
|
307
|
-
processor="core",
|
|
308
|
-
output="GDP"
|
|
309
|
-
)
|
|
224
|
+
client.with_options(max_retries=5).task_run.create(input="France (2023)", processor="core")
|
|
310
225
|
```
|
|
311
226
|
|
|
312
227
|
### Timeouts
|
|
@@ -329,11 +244,7 @@ client = Parallel(
|
|
|
329
244
|
)
|
|
330
245
|
|
|
331
246
|
# Override per-request:
|
|
332
|
-
client.with_options(timeout=5.0).task_run.
|
|
333
|
-
input="France (2023)",
|
|
334
|
-
processor="core",
|
|
335
|
-
output="GDP"
|
|
336
|
-
)
|
|
247
|
+
client.with_options(timeout=5.0).task_run.create(input="France (2023)", processor="core")
|
|
337
248
|
```
|
|
338
249
|
|
|
339
250
|
On timeout, an `APITimeoutError` is thrown.
|
|
@@ -374,15 +285,14 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
|
|
|
374
285
|
from parallel import Parallel
|
|
375
286
|
|
|
376
287
|
client = Parallel()
|
|
377
|
-
response = client.task_run.with_raw_response.
|
|
288
|
+
response = client.task_run.with_raw_response.create(
|
|
378
289
|
input="France (2023)",
|
|
379
290
|
processor="core",
|
|
380
|
-
output="GDP"
|
|
381
291
|
)
|
|
382
292
|
print(response.headers.get('X-My-Header'))
|
|
383
293
|
|
|
384
|
-
task_run = response.parse()
|
|
385
|
-
print(task_run.
|
|
294
|
+
task_run = response.parse()
|
|
295
|
+
print(task_run.run_id)
|
|
386
296
|
```
|
|
387
297
|
|
|
388
298
|
These methods return an [`APIResponse`](https://github.com/parallel-web/parallel-sdk-python/tree/main/src/parallel/_response.py) object.
|
|
@@ -396,10 +306,8 @@ The above interface eagerly reads the full response body when you make the reque
|
|
|
396
306
|
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.
|
|
397
307
|
|
|
398
308
|
```python
|
|
399
|
-
with client.task_run.with_streaming_response.
|
|
400
|
-
input="France (2023)",
|
|
401
|
-
processor="core",
|
|
402
|
-
output="GDP"
|
|
309
|
+
with client.task_run.with_streaming_response.create(
|
|
310
|
+
input="France (2023)", processor="core"
|
|
403
311
|
) as response:
|
|
404
312
|
print(response.headers.get("X-My-Header"))
|
|
405
313
|
|