parallel-web 0.1.2__py3-none-any.whl → 0.2.0__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.

Files changed (74) hide show
  1. parallel/__init__.py +2 -1
  2. parallel/_base_client.py +34 -2
  3. parallel/_client.py +9 -0
  4. parallel/_compat.py +1 -0
  5. parallel/_constants.py +2 -0
  6. parallel/_files.py +4 -4
  7. parallel/_models.py +32 -8
  8. parallel/_types.py +35 -1
  9. parallel/_utils/__init__.py +1 -0
  10. parallel/_utils/_typing.py +5 -0
  11. parallel/_version.py +1 -1
  12. parallel/lib/_pydantic.py +1 -0
  13. parallel/lib/_time.py +2 -2
  14. parallel/resources/__init__.py +14 -0
  15. parallel/resources/beta/__init__.py +47 -0
  16. parallel/resources/beta/beta.py +301 -0
  17. parallel/resources/beta/task_group.py +632 -0
  18. parallel/resources/beta/task_run.py +499 -0
  19. parallel/resources/task_run.py +47 -18
  20. parallel/types/__init__.py +15 -0
  21. parallel/types/auto_schema.py +13 -0
  22. parallel/types/auto_schema_param.py +12 -0
  23. parallel/types/beta/__init__.py +30 -0
  24. parallel/types/beta/beta_run_input.py +63 -0
  25. parallel/types/beta/beta_run_input_param.py +65 -0
  26. parallel/types/beta/beta_search_params.py +47 -0
  27. parallel/types/beta/beta_task_run_result.py +74 -0
  28. parallel/types/beta/error_event.py +16 -0
  29. parallel/types/beta/mcp_server.py +25 -0
  30. parallel/types/beta/mcp_server_param.py +25 -0
  31. parallel/types/beta/mcp_tool_call.py +27 -0
  32. parallel/types/beta/parallel_beta_param.py +12 -0
  33. parallel/types/beta/search_result.py +16 -0
  34. parallel/types/beta/task_group.py +24 -0
  35. parallel/types/beta/task_group_add_runs_params.py +30 -0
  36. parallel/types/beta/task_group_create_params.py +13 -0
  37. parallel/types/beta/task_group_events_params.py +16 -0
  38. parallel/types/beta/task_group_events_response.py +28 -0
  39. parallel/types/beta/task_group_get_runs_params.py +18 -0
  40. parallel/types/beta/task_group_get_runs_response.py +12 -0
  41. parallel/types/beta/task_group_run_response.py +30 -0
  42. parallel/types/beta/task_group_status.py +27 -0
  43. parallel/types/beta/task_run_create_params.py +70 -0
  44. parallel/types/beta/task_run_event.py +32 -0
  45. parallel/types/beta/task_run_events_response.py +58 -0
  46. parallel/types/beta/task_run_result_params.py +18 -0
  47. parallel/types/beta/web_search_result.py +18 -0
  48. parallel/types/beta/webhook.py +16 -0
  49. parallel/types/beta/webhook_param.py +16 -0
  50. parallel/types/citation.py +21 -0
  51. parallel/types/field_basis.py +25 -0
  52. parallel/types/json_schema.py +16 -0
  53. parallel/types/json_schema_param.py +2 -1
  54. parallel/types/parsed_task_run_result.py +13 -4
  55. parallel/types/shared/__init__.py +6 -0
  56. parallel/types/shared/error_object.py +18 -0
  57. parallel/types/shared/error_response.py +16 -0
  58. parallel/types/shared/source_policy.py +21 -0
  59. parallel/types/shared/warning.py +22 -0
  60. parallel/types/shared_params/__init__.py +3 -0
  61. parallel/types/shared_params/source_policy.py +22 -0
  62. parallel/types/task_run.py +17 -18
  63. parallel/types/task_run_create_params.py +12 -3
  64. parallel/types/task_run_json_output.py +46 -0
  65. parallel/types/task_run_result.py +24 -94
  66. parallel/types/task_run_text_output.py +37 -0
  67. parallel/types/task_spec.py +31 -0
  68. parallel/types/task_spec_param.py +3 -2
  69. parallel/types/text_schema.py +16 -0
  70. {parallel_web-0.1.2.dist-info → parallel_web-0.2.0.dist-info}/METADATA +48 -136
  71. parallel_web-0.2.0.dist-info/RECORD +94 -0
  72. parallel_web-0.1.2.dist-info/RECORD +0 -47
  73. {parallel_web-0.1.2.dist-info → parallel_web-0.2.0.dist-info}/WHEEL +0 -0
  74. {parallel_web-0.1.2.dist-info → parallel_web-0.2.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,632 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any, Dict, List, Union, Iterable, Optional, cast
6
+ from typing_extensions import Literal
7
+
8
+ import httpx
9
+
10
+ from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
11
+ from ..._utils import is_given, maybe_transform, strip_not_given, async_maybe_transform
12
+ from ..._compat import cached_property
13
+ from ..._resource import SyncAPIResource, AsyncAPIResource
14
+ from ..._response import (
15
+ to_raw_response_wrapper,
16
+ to_streamed_response_wrapper,
17
+ async_to_raw_response_wrapper,
18
+ async_to_streamed_response_wrapper,
19
+ )
20
+ from ..._streaming import Stream, AsyncStream
21
+ from ...types.beta import (
22
+ task_group_create_params,
23
+ task_group_events_params,
24
+ task_group_add_runs_params,
25
+ task_group_get_runs_params,
26
+ )
27
+ from ..._base_client import make_request_options
28
+ from ...types.beta.task_group import TaskGroup
29
+ from ...types.task_spec_param import TaskSpecParam
30
+ from ...types.beta.parallel_beta_param import ParallelBetaParam
31
+ from ...types.beta.beta_run_input_param import BetaRunInputParam
32
+ from ...types.beta.task_group_run_response import TaskGroupRunResponse
33
+ from ...types.beta.task_group_events_response import TaskGroupEventsResponse
34
+ from ...types.beta.task_group_get_runs_response import TaskGroupGetRunsResponse
35
+
36
+ __all__ = ["TaskGroupResource", "AsyncTaskGroupResource"]
37
+
38
+
39
+ class TaskGroupResource(SyncAPIResource):
40
+ @cached_property
41
+ def with_raw_response(self) -> TaskGroupResourceWithRawResponse:
42
+ """
43
+ This property can be used as a prefix for any HTTP method call to return
44
+ the raw response object instead of the parsed content.
45
+
46
+ For more information, see https://www.github.com/parallel-web/parallel-sdk-python#accessing-raw-response-data-eg-headers
47
+ """
48
+ return TaskGroupResourceWithRawResponse(self)
49
+
50
+ @cached_property
51
+ def with_streaming_response(self) -> TaskGroupResourceWithStreamingResponse:
52
+ """
53
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
54
+
55
+ For more information, see https://www.github.com/parallel-web/parallel-sdk-python#with_streaming_response
56
+ """
57
+ return TaskGroupResourceWithStreamingResponse(self)
58
+
59
+ def create(
60
+ self,
61
+ *,
62
+ metadata: Optional[Dict[str, Union[str, float, bool]]] | NotGiven = NOT_GIVEN,
63
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
64
+ # The extra values given here take precedence over values defined on the client or passed to this method.
65
+ extra_headers: Headers | None = None,
66
+ extra_query: Query | None = None,
67
+ extra_body: Body | None = None,
68
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
69
+ ) -> TaskGroup:
70
+ """
71
+ Initiates a TaskGroup to group and track multiple runs.
72
+
73
+ Args:
74
+ metadata: User-provided metadata stored with the task group.
75
+
76
+ extra_headers: Send extra headers
77
+
78
+ extra_query: Add additional query parameters to the request
79
+
80
+ extra_body: Add additional JSON properties to the request
81
+
82
+ timeout: Override the client-level default timeout for this request, in seconds
83
+ """
84
+ return self._post(
85
+ "/v1beta/tasks/groups",
86
+ body=maybe_transform({"metadata": metadata}, task_group_create_params.TaskGroupCreateParams),
87
+ options=make_request_options(
88
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
89
+ ),
90
+ cast_to=TaskGroup,
91
+ )
92
+
93
+ def retrieve(
94
+ self,
95
+ task_group_id: str,
96
+ *,
97
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
98
+ # The extra values given here take precedence over values defined on the client or passed to this method.
99
+ extra_headers: Headers | None = None,
100
+ extra_query: Query | None = None,
101
+ extra_body: Body | None = None,
102
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
103
+ ) -> TaskGroup:
104
+ """
105
+ Retrieves aggregated status across runs in a TaskGroup.
106
+
107
+ Args:
108
+ extra_headers: Send extra headers
109
+
110
+ extra_query: Add additional query parameters to the request
111
+
112
+ extra_body: Add additional JSON properties to the request
113
+
114
+ timeout: Override the client-level default timeout for this request, in seconds
115
+ """
116
+ if not task_group_id:
117
+ raise ValueError(f"Expected a non-empty value for `task_group_id` but received {task_group_id!r}")
118
+ return self._get(
119
+ f"/v1beta/tasks/groups/{task_group_id}",
120
+ options=make_request_options(
121
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
122
+ ),
123
+ cast_to=TaskGroup,
124
+ )
125
+
126
+ def add_runs(
127
+ self,
128
+ task_group_id: str,
129
+ *,
130
+ inputs: Iterable[BetaRunInputParam],
131
+ default_task_spec: Optional[TaskSpecParam] | NotGiven = NOT_GIVEN,
132
+ betas: List[ParallelBetaParam] | NotGiven = NOT_GIVEN,
133
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
134
+ # The extra values given here take precedence over values defined on the client or passed to this method.
135
+ extra_headers: Headers | None = None,
136
+ extra_query: Query | None = None,
137
+ extra_body: Body | None = None,
138
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
139
+ ) -> TaskGroupRunResponse:
140
+ """
141
+ Initiates multiple task runs within a TaskGroup.
142
+
143
+ Args:
144
+ inputs: List of task runs to execute.
145
+
146
+ default_task_spec: Specification for a task.
147
+
148
+ Auto output schemas can be specified by setting `output_schema={"type":"auto"}`.
149
+ Not specifying a TaskSpec is the same as setting an auto output schema.
150
+
151
+ For convenience bare strings are also accepted as input or output schemas.
152
+
153
+ betas: Optional header to specify the beta version(s) to enable.
154
+
155
+ extra_headers: Send extra headers
156
+
157
+ extra_query: Add additional query parameters to the request
158
+
159
+ extra_body: Add additional JSON properties to the request
160
+
161
+ timeout: Override the client-level default timeout for this request, in seconds
162
+ """
163
+ if not task_group_id:
164
+ raise ValueError(f"Expected a non-empty value for `task_group_id` but received {task_group_id!r}")
165
+ extra_headers = {
166
+ **strip_not_given({"parallel-beta": ",".join(str(e) for e in betas) if is_given(betas) else NOT_GIVEN}),
167
+ **(extra_headers or {}),
168
+ }
169
+ return self._post(
170
+ f"/v1beta/tasks/groups/{task_group_id}/runs",
171
+ body=maybe_transform(
172
+ {
173
+ "inputs": inputs,
174
+ "default_task_spec": default_task_spec,
175
+ },
176
+ task_group_add_runs_params.TaskGroupAddRunsParams,
177
+ ),
178
+ options=make_request_options(
179
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
180
+ ),
181
+ cast_to=TaskGroupRunResponse,
182
+ )
183
+
184
+ def events(
185
+ self,
186
+ task_group_id: str,
187
+ *,
188
+ last_event_id: Optional[str] | NotGiven = NOT_GIVEN,
189
+ api_timeout: Optional[float] | NotGiven = NOT_GIVEN,
190
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
191
+ # The extra values given here take precedence over values defined on the client or passed to this method.
192
+ extra_headers: Headers | None = None,
193
+ extra_query: Query | None = None,
194
+ extra_body: Body | None = None,
195
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
196
+ ) -> Stream[TaskGroupEventsResponse]:
197
+ """
198
+ Streams events from a TaskGroup: status updates and run completions.
199
+
200
+ The connection will remain open for up to 10 minutes as long as at least one run
201
+ in the TaskGroup is active.
202
+
203
+ Args:
204
+ extra_headers: Send extra headers
205
+
206
+ extra_query: Add additional query parameters to the request
207
+
208
+ extra_body: Add additional JSON properties to the request
209
+
210
+ timeout: Override the client-level default timeout for this request, in seconds
211
+ """
212
+ if not task_group_id:
213
+ raise ValueError(f"Expected a non-empty value for `task_group_id` but received {task_group_id!r}")
214
+ extra_headers = {"Accept": "text/event-stream", **(extra_headers or {})}
215
+ return self._get(
216
+ f"/v1beta/tasks/groups/{task_group_id}/events",
217
+ options=make_request_options(
218
+ extra_headers=extra_headers,
219
+ extra_query=extra_query,
220
+ extra_body=extra_body,
221
+ timeout=timeout,
222
+ query=maybe_transform(
223
+ {
224
+ "last_event_id": last_event_id,
225
+ "api_timeout": api_timeout,
226
+ },
227
+ task_group_events_params.TaskGroupEventsParams,
228
+ ),
229
+ ),
230
+ cast_to=cast(
231
+ Any, TaskGroupEventsResponse
232
+ ), # Union types cannot be passed in as arguments in the type system
233
+ stream=True,
234
+ stream_cls=Stream[TaskGroupEventsResponse],
235
+ )
236
+
237
+ def get_runs(
238
+ self,
239
+ task_group_id: str,
240
+ *,
241
+ include_input: bool | NotGiven = NOT_GIVEN,
242
+ include_output: bool | NotGiven = NOT_GIVEN,
243
+ last_event_id: Optional[str] | NotGiven = NOT_GIVEN,
244
+ status: Optional[
245
+ Literal["queued", "action_required", "running", "completed", "failed", "cancelling", "cancelled"]
246
+ ]
247
+ | NotGiven = NOT_GIVEN,
248
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
249
+ # The extra values given here take precedence over values defined on the client or passed to this method.
250
+ extra_headers: Headers | None = None,
251
+ extra_query: Query | None = None,
252
+ extra_body: Body | None = None,
253
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
254
+ ) -> Stream[TaskGroupGetRunsResponse]:
255
+ """
256
+ Retrieves task runs in a TaskGroup and optionally their inputs and outputs.
257
+
258
+ Args:
259
+ extra_headers: Send extra headers
260
+
261
+ extra_query: Add additional query parameters to the request
262
+
263
+ extra_body: Add additional JSON properties to the request
264
+
265
+ timeout: Override the client-level default timeout for this request, in seconds
266
+ """
267
+ if not task_group_id:
268
+ raise ValueError(f"Expected a non-empty value for `task_group_id` but received {task_group_id!r}")
269
+ extra_headers = {"Accept": "text/event-stream", **(extra_headers or {})}
270
+ return self._get(
271
+ f"/v1beta/tasks/groups/{task_group_id}/runs",
272
+ options=make_request_options(
273
+ extra_headers=extra_headers,
274
+ extra_query=extra_query,
275
+ extra_body=extra_body,
276
+ timeout=timeout,
277
+ query=maybe_transform(
278
+ {
279
+ "include_input": include_input,
280
+ "include_output": include_output,
281
+ "last_event_id": last_event_id,
282
+ "status": status,
283
+ },
284
+ task_group_get_runs_params.TaskGroupGetRunsParams,
285
+ ),
286
+ ),
287
+ cast_to=cast(
288
+ Any, TaskGroupGetRunsResponse
289
+ ), # Union types cannot be passed in as arguments in the type system
290
+ stream=True,
291
+ stream_cls=Stream[TaskGroupGetRunsResponse],
292
+ )
293
+
294
+
295
+ class AsyncTaskGroupResource(AsyncAPIResource):
296
+ @cached_property
297
+ def with_raw_response(self) -> AsyncTaskGroupResourceWithRawResponse:
298
+ """
299
+ This property can be used as a prefix for any HTTP method call to return
300
+ the raw response object instead of the parsed content.
301
+
302
+ For more information, see https://www.github.com/parallel-web/parallel-sdk-python#accessing-raw-response-data-eg-headers
303
+ """
304
+ return AsyncTaskGroupResourceWithRawResponse(self)
305
+
306
+ @cached_property
307
+ def with_streaming_response(self) -> AsyncTaskGroupResourceWithStreamingResponse:
308
+ """
309
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
310
+
311
+ For more information, see https://www.github.com/parallel-web/parallel-sdk-python#with_streaming_response
312
+ """
313
+ return AsyncTaskGroupResourceWithStreamingResponse(self)
314
+
315
+ async def create(
316
+ self,
317
+ *,
318
+ metadata: Optional[Dict[str, Union[str, float, bool]]] | NotGiven = NOT_GIVEN,
319
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
320
+ # The extra values given here take precedence over values defined on the client or passed to this method.
321
+ extra_headers: Headers | None = None,
322
+ extra_query: Query | None = None,
323
+ extra_body: Body | None = None,
324
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
325
+ ) -> TaskGroup:
326
+ """
327
+ Initiates a TaskGroup to group and track multiple runs.
328
+
329
+ Args:
330
+ metadata: User-provided metadata stored with the task group.
331
+
332
+ extra_headers: Send extra headers
333
+
334
+ extra_query: Add additional query parameters to the request
335
+
336
+ extra_body: Add additional JSON properties to the request
337
+
338
+ timeout: Override the client-level default timeout for this request, in seconds
339
+ """
340
+ return await self._post(
341
+ "/v1beta/tasks/groups",
342
+ body=await async_maybe_transform({"metadata": metadata}, task_group_create_params.TaskGroupCreateParams),
343
+ options=make_request_options(
344
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
345
+ ),
346
+ cast_to=TaskGroup,
347
+ )
348
+
349
+ async def retrieve(
350
+ self,
351
+ task_group_id: str,
352
+ *,
353
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
354
+ # The extra values given here take precedence over values defined on the client or passed to this method.
355
+ extra_headers: Headers | None = None,
356
+ extra_query: Query | None = None,
357
+ extra_body: Body | None = None,
358
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
359
+ ) -> TaskGroup:
360
+ """
361
+ Retrieves aggregated status across runs in a TaskGroup.
362
+
363
+ Args:
364
+ extra_headers: Send extra headers
365
+
366
+ extra_query: Add additional query parameters to the request
367
+
368
+ extra_body: Add additional JSON properties to the request
369
+
370
+ timeout: Override the client-level default timeout for this request, in seconds
371
+ """
372
+ if not task_group_id:
373
+ raise ValueError(f"Expected a non-empty value for `task_group_id` but received {task_group_id!r}")
374
+ return await self._get(
375
+ f"/v1beta/tasks/groups/{task_group_id}",
376
+ options=make_request_options(
377
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
378
+ ),
379
+ cast_to=TaskGroup,
380
+ )
381
+
382
+ async def add_runs(
383
+ self,
384
+ task_group_id: str,
385
+ *,
386
+ inputs: Iterable[BetaRunInputParam],
387
+ default_task_spec: Optional[TaskSpecParam] | NotGiven = NOT_GIVEN,
388
+ betas: List[ParallelBetaParam] | NotGiven = NOT_GIVEN,
389
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
390
+ # The extra values given here take precedence over values defined on the client or passed to this method.
391
+ extra_headers: Headers | None = None,
392
+ extra_query: Query | None = None,
393
+ extra_body: Body | None = None,
394
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
395
+ ) -> TaskGroupRunResponse:
396
+ """
397
+ Initiates multiple task runs within a TaskGroup.
398
+
399
+ Args:
400
+ inputs: List of task runs to execute.
401
+
402
+ default_task_spec: Specification for a task.
403
+
404
+ Auto output schemas can be specified by setting `output_schema={"type":"auto"}`.
405
+ Not specifying a TaskSpec is the same as setting an auto output schema.
406
+
407
+ For convenience bare strings are also accepted as input or output schemas.
408
+
409
+ betas: Optional header to specify the beta version(s) to enable.
410
+
411
+ extra_headers: Send extra headers
412
+
413
+ extra_query: Add additional query parameters to the request
414
+
415
+ extra_body: Add additional JSON properties to the request
416
+
417
+ timeout: Override the client-level default timeout for this request, in seconds
418
+ """
419
+ if not task_group_id:
420
+ raise ValueError(f"Expected a non-empty value for `task_group_id` but received {task_group_id!r}")
421
+ extra_headers = {
422
+ **strip_not_given({"parallel-beta": ",".join(str(e) for e in betas) if is_given(betas) else NOT_GIVEN}),
423
+ **(extra_headers or {}),
424
+ }
425
+ return await self._post(
426
+ f"/v1beta/tasks/groups/{task_group_id}/runs",
427
+ body=await async_maybe_transform(
428
+ {
429
+ "inputs": inputs,
430
+ "default_task_spec": default_task_spec,
431
+ },
432
+ task_group_add_runs_params.TaskGroupAddRunsParams,
433
+ ),
434
+ options=make_request_options(
435
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
436
+ ),
437
+ cast_to=TaskGroupRunResponse,
438
+ )
439
+
440
+ async def events(
441
+ self,
442
+ task_group_id: str,
443
+ *,
444
+ last_event_id: Optional[str] | NotGiven = NOT_GIVEN,
445
+ api_timeout: Optional[float] | NotGiven = NOT_GIVEN,
446
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
447
+ # The extra values given here take precedence over values defined on the client or passed to this method.
448
+ extra_headers: Headers | None = None,
449
+ extra_query: Query | None = None,
450
+ extra_body: Body | None = None,
451
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
452
+ ) -> AsyncStream[TaskGroupEventsResponse]:
453
+ """
454
+ Streams events from a TaskGroup: status updates and run completions.
455
+
456
+ The connection will remain open for up to 10 minutes as long as at least one run
457
+ in the TaskGroup is active.
458
+
459
+ Args:
460
+ extra_headers: Send extra headers
461
+
462
+ extra_query: Add additional query parameters to the request
463
+
464
+ extra_body: Add additional JSON properties to the request
465
+
466
+ timeout: Override the client-level default timeout for this request, in seconds
467
+ """
468
+ if not task_group_id:
469
+ raise ValueError(f"Expected a non-empty value for `task_group_id` but received {task_group_id!r}")
470
+ extra_headers = {"Accept": "text/event-stream", **(extra_headers or {})}
471
+ return await self._get(
472
+ f"/v1beta/tasks/groups/{task_group_id}/events",
473
+ options=make_request_options(
474
+ extra_headers=extra_headers,
475
+ extra_query=extra_query,
476
+ extra_body=extra_body,
477
+ timeout=timeout,
478
+ query=await async_maybe_transform(
479
+ {
480
+ "last_event_id": last_event_id,
481
+ "api_timeout": api_timeout,
482
+ },
483
+ task_group_events_params.TaskGroupEventsParams,
484
+ ),
485
+ ),
486
+ cast_to=cast(
487
+ Any, TaskGroupEventsResponse
488
+ ), # Union types cannot be passed in as arguments in the type system
489
+ stream=True,
490
+ stream_cls=AsyncStream[TaskGroupEventsResponse],
491
+ )
492
+
493
+ async def get_runs(
494
+ self,
495
+ task_group_id: str,
496
+ *,
497
+ include_input: bool | NotGiven = NOT_GIVEN,
498
+ include_output: bool | NotGiven = NOT_GIVEN,
499
+ last_event_id: Optional[str] | NotGiven = NOT_GIVEN,
500
+ status: Optional[
501
+ Literal["queued", "action_required", "running", "completed", "failed", "cancelling", "cancelled"]
502
+ ]
503
+ | NotGiven = NOT_GIVEN,
504
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
505
+ # The extra values given here take precedence over values defined on the client or passed to this method.
506
+ extra_headers: Headers | None = None,
507
+ extra_query: Query | None = None,
508
+ extra_body: Body | None = None,
509
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
510
+ ) -> AsyncStream[TaskGroupGetRunsResponse]:
511
+ """
512
+ Retrieves task runs in a TaskGroup and optionally their inputs and outputs.
513
+
514
+ Args:
515
+ extra_headers: Send extra headers
516
+
517
+ extra_query: Add additional query parameters to the request
518
+
519
+ extra_body: Add additional JSON properties to the request
520
+
521
+ timeout: Override the client-level default timeout for this request, in seconds
522
+ """
523
+ if not task_group_id:
524
+ raise ValueError(f"Expected a non-empty value for `task_group_id` but received {task_group_id!r}")
525
+ extra_headers = {"Accept": "text/event-stream", **(extra_headers or {})}
526
+ return await self._get(
527
+ f"/v1beta/tasks/groups/{task_group_id}/runs",
528
+ options=make_request_options(
529
+ extra_headers=extra_headers,
530
+ extra_query=extra_query,
531
+ extra_body=extra_body,
532
+ timeout=timeout,
533
+ query=await async_maybe_transform(
534
+ {
535
+ "include_input": include_input,
536
+ "include_output": include_output,
537
+ "last_event_id": last_event_id,
538
+ "status": status,
539
+ },
540
+ task_group_get_runs_params.TaskGroupGetRunsParams,
541
+ ),
542
+ ),
543
+ cast_to=cast(
544
+ Any, TaskGroupGetRunsResponse
545
+ ), # Union types cannot be passed in as arguments in the type system
546
+ stream=True,
547
+ stream_cls=AsyncStream[TaskGroupGetRunsResponse],
548
+ )
549
+
550
+
551
+ class TaskGroupResourceWithRawResponse:
552
+ def __init__(self, task_group: TaskGroupResource) -> None:
553
+ self._task_group = task_group
554
+
555
+ self.create = to_raw_response_wrapper(
556
+ task_group.create,
557
+ )
558
+ self.retrieve = to_raw_response_wrapper(
559
+ task_group.retrieve,
560
+ )
561
+ self.add_runs = to_raw_response_wrapper(
562
+ task_group.add_runs,
563
+ )
564
+ self.events = to_raw_response_wrapper(
565
+ task_group.events,
566
+ )
567
+ self.get_runs = to_raw_response_wrapper(
568
+ task_group.get_runs,
569
+ )
570
+
571
+
572
+ class AsyncTaskGroupResourceWithRawResponse:
573
+ def __init__(self, task_group: AsyncTaskGroupResource) -> None:
574
+ self._task_group = task_group
575
+
576
+ self.create = async_to_raw_response_wrapper(
577
+ task_group.create,
578
+ )
579
+ self.retrieve = async_to_raw_response_wrapper(
580
+ task_group.retrieve,
581
+ )
582
+ self.add_runs = async_to_raw_response_wrapper(
583
+ task_group.add_runs,
584
+ )
585
+ self.events = async_to_raw_response_wrapper(
586
+ task_group.events,
587
+ )
588
+ self.get_runs = async_to_raw_response_wrapper(
589
+ task_group.get_runs,
590
+ )
591
+
592
+
593
+ class TaskGroupResourceWithStreamingResponse:
594
+ def __init__(self, task_group: TaskGroupResource) -> None:
595
+ self._task_group = task_group
596
+
597
+ self.create = to_streamed_response_wrapper(
598
+ task_group.create,
599
+ )
600
+ self.retrieve = to_streamed_response_wrapper(
601
+ task_group.retrieve,
602
+ )
603
+ self.add_runs = to_streamed_response_wrapper(
604
+ task_group.add_runs,
605
+ )
606
+ self.events = to_streamed_response_wrapper(
607
+ task_group.events,
608
+ )
609
+ self.get_runs = to_streamed_response_wrapper(
610
+ task_group.get_runs,
611
+ )
612
+
613
+
614
+ class AsyncTaskGroupResourceWithStreamingResponse:
615
+ def __init__(self, task_group: AsyncTaskGroupResource) -> None:
616
+ self._task_group = task_group
617
+
618
+ self.create = async_to_streamed_response_wrapper(
619
+ task_group.create,
620
+ )
621
+ self.retrieve = async_to_streamed_response_wrapper(
622
+ task_group.retrieve,
623
+ )
624
+ self.add_runs = async_to_streamed_response_wrapper(
625
+ task_group.add_runs,
626
+ )
627
+ self.events = async_to_streamed_response_wrapper(
628
+ task_group.events,
629
+ )
630
+ self.get_runs = async_to_streamed_response_wrapper(
631
+ task_group.get_runs,
632
+ )