parallel-web 0.1.2__py3-none-any.whl → 0.1.3__py3-none-any.whl

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/_constants.py CHANGED
@@ -5,6 +5,8 @@ import httpx
5
5
  RAW_RESPONSE_HEADER = "X-Stainless-Raw-Response"
6
6
  OVERRIDE_CAST_TO_HEADER = "____stainless_override_cast_to"
7
7
 
8
+ # default timeout for execution requests which wait for results is 1 hour.
9
+ DEFAULT_EXECUTE_TIMEOUT_SECONDS = 3600
8
10
  # default timeout for http requests is 10 minutes.
9
11
  DEFAULT_TIMEOUT_SECONDS = 600
10
12
  DEFAULT_TIMEOUT = httpx.Timeout(timeout=DEFAULT_TIMEOUT_SECONDS, connect=5.0)
parallel/_version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "parallel"
4
- __version__ = "0.1.2" # x-release-please-version
4
+ __version__ = "0.1.3" # x-release-please-version
parallel/lib/_time.py CHANGED
@@ -5,7 +5,7 @@ from typing import Union, Iterator, NoReturn
5
5
  import httpx
6
6
 
7
7
  from .._types import NotGiven
8
- from .._constants import DEFAULT_TIMEOUT_SECONDS
8
+ from .._constants import DEFAULT_EXECUTE_TIMEOUT_SECONDS
9
9
  from .._exceptions import APIStatusError, APITimeoutError
10
10
  from .._utils._utils import is_given
11
11
 
@@ -19,7 +19,7 @@ def prepare_timeout_float(timeout: Union[float, httpx.Timeout, None, NotGiven])
19
19
  timeout = timeout.read
20
20
 
21
21
  if not is_given(timeout) or timeout is None:
22
- return DEFAULT_TIMEOUT_SECONDS
22
+ return DEFAULT_EXECUTE_TIMEOUT_SECONDS
23
23
 
24
24
  return timeout
25
25
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: parallel-web
3
- Version: 0.1.2
3
+ Version: 0.1.3
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
@@ -42,7 +42,7 @@ It is generated with [Stainless](https://www.stainless.com/).
42
42
 
43
43
  ## Documentation
44
44
 
45
- The REST API documentation can be found on our [docs](https://docs.parallel.ai).
45
+ The REST API documentation can be found in our [docs](https://docs.parallel.ai).
46
46
  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
47
 
48
48
  ## Installation
@@ -69,7 +69,7 @@ run_result = client.task_run.execute(
69
69
  processor="core",
70
70
  output="GDP"
71
71
  )
72
- print(run_result.output)
72
+ print(run_result.output.parsed)
73
73
  ```
74
74
 
75
75
  While you can provide an `api_key` keyword argument,
@@ -77,6 +77,11 @@ we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
77
77
  to add `PARALLEL_API_KEY="My API Key"` to your `.env` file
78
78
  so that your API Key is not stored in source control.
79
79
 
80
+ The API also supports typed inputs and outputs via Pydantic objects. See the relevant
81
+ section on [convenience methods](https://github.com/parallel-web/parallel-sdk-python/tree/main/#convenience-methods).
82
+
83
+ 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).
84
+
80
85
  ## Async usage
81
86
 
82
87
  Simply import `AsyncParallel` instead of `Parallel` and use `await` with each API call:
@@ -97,7 +102,7 @@ async def main() -> None:
97
102
  processor="core",
98
103
  output="GDP"
99
104
  )
100
- print(run_result.output)
105
+ print(run_result.output.parsed)
101
106
 
102
107
 
103
108
  if __name__ == "__main__":
@@ -106,16 +111,17 @@ if __name__ == "__main__":
106
111
 
107
112
  To get the best performance out of Parallel's API, we recommend
108
113
  using the asynchronous client, especially for executing multiple Task Runs concurrently.
109
- Functionality between the synchronous and asynchronous clients is identical.
114
+ Functionality between the synchronous and asynchronous clients is identical, including
115
+ the convenience methods.
110
116
 
111
117
  ## Convenience methods
112
118
 
113
119
  ### Execute
114
120
 
115
- The `execute` method provides a single call which combines creating a task run,
116
- polling until it is completed, and parsing structured outputs (if specified).
121
+ The `execute` method provides a single call that combines creating a task run,
122
+ polling until completion, and parsing structured outputs (if specified).
117
123
 
118
- If an output type which inherits from `BaseModel` is
124
+ If an output type that inherits from `BaseModel` is
119
125
  specified in the call to `.execute()`, the response content will be parsed into an
120
126
  instance of the provided output type. The parsed output can be accessed via the
121
127
  `parsed` property on the output field of the response.
@@ -146,15 +152,15 @@ async def main() -> None:
146
152
  processor="core",
147
153
  output="GDP"
148
154
  )
149
- print(run_result.output)
155
+ print(run_result.output.parsed)
150
156
 
151
157
 
152
158
  if __name__ == "__main__":
153
159
  asyncio.run(main())
154
160
  ```
155
161
 
156
- The async client allows creating several task runs without blocking.
157
- To create multiple task runs in one go, call execute and then gather the results at the end.
162
+ The async client lets you create multiple task runs without blocking.
163
+ To submit several at once, call `execute()` and gather the results at the end.
158
164
 
159
165
  ```python
160
166
  import asyncio
@@ -212,9 +218,51 @@ if __name__ == "__main__":
212
218
  asyncio.run(main())
213
219
  ```
214
220
 
215
- ## Low level API Access
221
+ #### `execute()` vs `create()`
222
+
223
+ The `execute` and `create` methods differ slightly in their signatures and
224
+ behavior — `create` requires a Task Spec object that contains the output schema,
225
+ while `execute` accepts an output schema as a top‑level parameter. `execute` is
226
+ also a one‑shot method that combines creation, polling, and parsing for you.
227
+
228
+ Use `create` when you want a run ID immediately and prefer to control polling
229
+ yourself. `execute` is best for one‑shot task execution and for typed inputs and
230
+ outputs — note that no outputs are available until the call finishes. Finally, for
231
+ the output of `execute`, parsed content is available via `run_result.output.parsed`.
232
+
233
+ Both `execute` and `create` validate inputs when appropriate input types are
234
+ provided. For `execute`, validation happens when a pydantic input is provided. For
235
+ `create`, validation occurs when the input schema is specified inside the task spec
236
+ parameter. Additionally, in both calls, the un-parsed result content is accessible via
237
+ the `run_result.output.content`.
238
+
239
+ ## Frequently Asked Questions
240
+
241
+ **Does the Task API accept prompts or objectives?**
242
+
243
+ No, there are no `objective` or `prompt` parameters that can be specified for calls to
244
+ the Task API. Instead, provide any directives or instructions via the schemas. For
245
+ more information, check [our docs](https://docs.parallel.ai/task-api/core-concepts/specify-a-task).
246
+
247
+ **Can I access beta parameters or endpoints via the SDK?**
248
+
249
+ The SDK currently does not support beta parameters in the Task API. You can consider
250
+ using [custom requests](https://github.com/parallel-web/parallel-sdk-python/tree/main/#making-customundocumented-requests) in conjunction with
251
+ [low level APIs](https://github.com/parallel-web/parallel-sdk-python/tree/main/#lowlevel-api-access).
252
+
253
+ **Can I specify a timeout for API calls?**
254
+
255
+ Yes, all methods support a timeout. For more information, see [Timeouts](https://github.com/parallel-web/parallel-sdk-python/tree/main/#timeouts).
256
+
257
+ **Can I specify retries via the SDK?**
258
+
259
+ Yes, errors can be retried via the SDK — the default retry count is 2. The maximum number
260
+ of retries can be configured at the client level. For information on which errors
261
+ are automatically retried and how to configure retry settings, see [Retries](https://github.com/parallel-web/parallel-sdk-python/tree/main/#retries).
262
+
263
+ ## Low‑level API access
216
264
 
217
- The library also provides access to the low level API for accessing the Parallel API.
265
+ The library also provides lowlevel access to the Parallel API.
218
266
 
219
267
  ```python
220
268
  from parallel import Parallel
@@ -262,13 +310,13 @@ task_run = client.task_run.create(
262
310
  )
263
311
 
264
312
  run_result = client.task_run.result(task_run.run_id)
265
- print(run_result.output)
313
+ print(run_result.output.content)
266
314
  ```
267
315
 
268
316
  For more information, please check out the relevant section in our docs:
269
317
 
270
- - [Task Spec](https://docs.parallel.ai/core-concepts/task-spec)
271
- - [Task Runs](https://docs.parallel.ai/core-concepts/task-runs)
318
+ - [Task Spec](https://docs.parallel.ai/task-api/core-concepts/specify-a-task)
319
+ - [Task Runs](https://docs.parallel.ai/task-api/core-concepts/execute-task-run)
272
320
 
273
321
  ## Handling errors
274
322
 
@@ -2,7 +2,7 @@ parallel/__init__.py,sha256=DLcZySDPIMWxygZrS91n0h7XUblDa7R2CKSqJCeBD-U,2587
2
2
  parallel/_base_client.py,sha256=CvhCKe_bvHxjG_KkjU7MN8epnRjDAoZercR16F7hKXo,65886
3
3
  parallel/_client.py,sha256=-33nTbpzQe0MaMSXkPisZdlPG_phXweSGfssI4UXIKQ,15024
4
4
  parallel/_compat.py,sha256=Bdw3skNpgAyCAWXJRUwTLiM0lOD1sLHEFKtw7peWp5U,6981
5
- parallel/_constants.py,sha256=NJrT2b4m0CuDGEVBF1xwsrHOWLGPupleFrL9jGAlLwk,567
5
+ parallel/_constants.py,sha256=B00HbROOxQXqSFOIFQjSmdePfscyYNuXyY__j2qBljg,681
6
6
  parallel/_exceptions.py,sha256=lP7_D_HALN-Nt5bfw4AefEB7tYkrQ8ZcjCRdxm_HrsQ,3224
7
7
  parallel/_files.py,sha256=mf4dOgL4b0ryyZlbqLhggD3GVgDf6XxdGFAgce01ugE,3549
8
8
  parallel/_models.py,sha256=G1vczEodX0vUySeVKbF-mbzlaObNL1oVAYH4c65agRk,29131
@@ -11,7 +11,7 @@ parallel/_resource.py,sha256=QvY8l_r03hNBsFTTn3g7Pkx8OrDwIwROHaSEViWcYLA,1112
11
11
  parallel/_response.py,sha256=zJKnQ9YzrMZCTPWis4CdyGCAH0kzT4m1OHE74jiF0jA,28800
12
12
  parallel/_streaming.py,sha256=vH45vK3-83ruFalbvSgpE70zfwy8fjW9UwrO1TwjIfE,10108
13
13
  parallel/_types.py,sha256=gdnumvz_C0ka1W865rehBsLCOgZyyHpKRedjJg7uRPY,6199
14
- parallel/_version.py,sha256=WUXkK8O3I2gOafOqu7g-L_9WsH2ZQxqi0tbVT_oXd8k,160
14
+ parallel/_version.py,sha256=KMXAJ_Bhy6F94HtkIbgFS_dFgeIsvbC6RKi-WdhkV28,160
15
15
  parallel/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  parallel/_utils/__init__.py,sha256=Z5F2puD-cRsBEwlAuuuXDuIuKuJyLhtg0667MRHeBj4,2084
17
17
  parallel/_utils/_logs.py,sha256=5tqZJRHHRqxJfftED6vN1CHcwhRZDSvzy9SaxozEAe4,780
@@ -26,7 +26,7 @@ parallel/_utils/_utils.py,sha256=nJWF6GJgM2imb1AYa1nZoE1f-Alo1EI0Y8L_q3a1gkw,123
26
26
  parallel/lib/.keep,sha256=wuNrz-5SXo3jJaJOJgz4vFHM41YH_g20F5cRQo0vLes,224
27
27
  parallel/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
28
  parallel/lib/_pydantic.py,sha256=B_-msp3_jrPP09s-f73Xv4WEG212ECDfc0a_Gf-YZGE,1115
29
- parallel/lib/_time.py,sha256=SAf1AP__EqprIPCqpe8JqfaB_rqv10uzhNBJbD_THSY,2542
29
+ parallel/lib/_time.py,sha256=54M_YhwW8WUa2KEUjYNdt3GkyQC9s_3u36-IH5hZr2U,2558
30
30
  parallel/lib/_parsing/__init__.py,sha256=aEM9F2sU4s-CFpQgjydjfCAdxpusJ81jXI6KCoB8VPs,150
31
31
  parallel/lib/_parsing/_task_run_result.py,sha256=9o95RcH4bX0UbI7ow5bnECrXMS6Ll0SEQR4leTK3VQU,3608
32
32
  parallel/lib/_parsing/_task_spec.py,sha256=XkNWo2Ovu-anld8PAOIsi722vOXbDf2ex4p9rwWW51I,3067
@@ -41,7 +41,7 @@ parallel/types/task_run_result.py,sha256=yd3Lz_YzCQGe5ynK5iI6J17tAs5nSG7FUJ3fSLO
41
41
  parallel/types/task_run_result_params.py,sha256=tL4CK5c0-Wo21O1pmT4pDvwzG-svtEwYujyCp0ZgATs,360
42
42
  parallel/types/task_spec_param.py,sha256=qTENHBp7vRg-VDzK8HsLpTn3EJWIV0UVQaf45r9SfCs,1179
43
43
  parallel/types/text_schema_param.py,sha256=M9WEl2aOh4_hNSdGm2BOmtm1VGqxxTh3f-Hs4OB4aCQ,445
44
- parallel_web-0.1.2.dist-info/METADATA,sha256=f0gLsNP4XHVGgWeL88tVMkLzsd_Yw4e0I9as2DR5o0Y,17626
45
- parallel_web-0.1.2.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
46
- parallel_web-0.1.2.dist-info/licenses/LICENSE,sha256=1rFsV0HhxaZBP55JM8Cu2w0Bw-uxTFtyTja_DE94oEM,1048
47
- parallel_web-0.1.2.dist-info/RECORD,,
44
+ parallel_web-0.1.3.dist-info/METADATA,sha256=fuS5BSxEaWrVTBlSb0OCUkUIgxCVP13QEqpqc9YR2TM,20379
45
+ parallel_web-0.1.3.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
46
+ parallel_web-0.1.3.dist-info/licenses/LICENSE,sha256=1rFsV0HhxaZBP55JM8Cu2w0Bw-uxTFtyTja_DE94oEM,1048
47
+ parallel_web-0.1.3.dist-info/RECORD,,