Skip to content

Commit ea487f3

Browse files
feat(api): Add Search and Extract v1 and associated types
1 parent 08080bc commit ea487f3

29 files changed

Lines changed: 1164 additions & 95 deletions

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 22
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/parallel-web%2Fparallel-sdk-728ba63c23bc2eb4fe37b429fb084ed7600ae50c8c652aeb0c787216c3ece07a.yml
3-
openapi_spec_hash: 3568175d488fc927f1710b3ebca87cfc
4-
config_hash: a398d153133d8884bed4e5256a0ae818
1+
configured_endpoints: 23
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/parallel-web%2Fparallel-sdk-44048676c9b07d49ed9dbee5fad53d145eddaea5ba682b6557681c5a7e04f8ed.yml
3+
openapi_spec_hash: e239787937742b1bc15e7f211fe3c518
4+
config_hash: 42d4e6039ef223ba2a824414a94da176

api.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,28 @@
44
from parallel.types import ErrorObject, ErrorResponse, SourcePolicy, Warning
55
```
66

7+
# Parallel
8+
9+
Types:
10+
11+
```python
12+
from parallel.types import (
13+
ExcerptSettings,
14+
ExtractError,
15+
ExtractResponse,
16+
ExtractResult,
17+
FetchPolicy,
18+
SearchResult,
19+
UsageItem,
20+
WebSearchResult,
21+
)
22+
```
23+
24+
Methods:
25+
26+
- <code title="post /v1/extract">client.<a href="./src/parallel/_client.py">extract</a>(\*\*<a href="src/parallel/types/client_extract_params.py">params</a>) -> <a href="./src/parallel/types/extract_response.py">ExtractResponse</a></code>
27+
- <code title="post /v1/search">client.<a href="./src/parallel/_client.py">search</a>(\*\*<a href="src/parallel/types/client_search_params.py">params</a>) -> <a href="./src/parallel/types/search_result.py">SearchResult</a></code>
28+
729
# TaskRun
830

931
Types:

src/parallel/_client.py

Lines changed: 359 additions & 3 deletions
Large diffs are not rendered by default.

src/parallel/resources/beta/api.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ Types:
55
```python
66
from parallel.types.beta import (
77
ExcerptSettings,
8-
ExtractError,
98
ExtractResponse,
109
ExtractResult,
11-
FetchPolicy,
1210
SearchResult,
13-
UsageItem,
1411
WebSearchResult,
12+
ExtractError,
13+
FetchPolicy,
14+
UsageItem,
1515
)
1616
```
1717

src/parallel/resources/beta/beta.py

Lines changed: 101 additions & 19 deletions
Large diffs are not rendered by default.

src/parallel/resources/beta/task_group.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,17 @@
3838

3939

4040
class TaskGroupResource(SyncAPIResource):
41-
"""
42-
The Task Group API is currently in beta and enables batch execution of many independent Task runs with group-level monitoring and failure handling.
41+
"""The Task API executes web research and extraction tasks.
42+
43+
Clients submit a natural-language objective with an optional input schema; the service plans retrieval, fetches relevant URLs, and returns outputs that conform to a provided or inferred JSON schema. Supports deep research style queries and can return rich structured JSON outputs. Processors trade-off between cost, latency, and quality. Each processor supports calibrated confidences.
44+
- Output metadata: citations, excerpts, reasoning, and confidence per field
45+
46+
Task Groups enable batch execution of many independent Task runs with group-level monitoring and failure handling.
4347
- Submit hundreds or thousands of Tasks as a single group
4448
- Observe group progress and receive results as they complete
4549
- Real-time updates via Server-Sent Events (SSE)
4650
- Add tasks to an existing group while it is running
4751
- Group-level retry and error aggregation
48-
Status: beta and subject to change.
4952
"""
5053

5154
@cached_property
@@ -332,14 +335,17 @@ def get_runs(
332335

333336

334337
class AsyncTaskGroupResource(AsyncAPIResource):
335-
"""
336-
The Task Group API is currently in beta and enables batch execution of many independent Task runs with group-level monitoring and failure handling.
338+
"""The Task API executes web research and extraction tasks.
339+
340+
Clients submit a natural-language objective with an optional input schema; the service plans retrieval, fetches relevant URLs, and returns outputs that conform to a provided or inferred JSON schema. Supports deep research style queries and can return rich structured JSON outputs. Processors trade-off between cost, latency, and quality. Each processor supports calibrated confidences.
341+
- Output metadata: citations, excerpts, reasoning, and confidence per field
342+
343+
Task Groups enable batch execution of many independent Task runs with group-level monitoring and failure handling.
337344
- Submit hundreds or thousands of Tasks as a single group
338345
- Observe group progress and receive results as they complete
339346
- Real-time updates via Server-Sent Events (SSE)
340347
- Add tasks to an existing group while it is running
341348
- Group-level retry and error aggregation
342-
Status: beta and subject to change.
343349
"""
344350

345351
@cached_property

src/parallel/resources/beta/task_run.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ class TaskRunResource(SyncAPIResource):
3737
3838
Clients submit a natural-language objective with an optional input schema; the service plans retrieval, fetches relevant URLs, and returns outputs that conform to a provided or inferred JSON schema. Supports deep research style queries and can return rich structured JSON outputs. Processors trade-off between cost, latency, and quality. Each processor supports calibrated confidences.
3939
- Output metadata: citations, excerpts, reasoning, and confidence per field
40+
41+
Task Groups enable batch execution of many independent Task runs with group-level monitoring and failure handling.
42+
- Submit hundreds or thousands of Tasks as a single group
43+
- Observe group progress and receive results as they complete
44+
- Real-time updates via Server-Sent Events (SSE)
45+
- Add tasks to an existing group while it is running
46+
- Group-level retry and error aggregation
4047
"""
4148

4249
@cached_property
@@ -265,6 +272,13 @@ class AsyncTaskRunResource(AsyncAPIResource):
265272
266273
Clients submit a natural-language objective with an optional input schema; the service plans retrieval, fetches relevant URLs, and returns outputs that conform to a provided or inferred JSON schema. Supports deep research style queries and can return rich structured JSON outputs. Processors trade-off between cost, latency, and quality. Each processor supports calibrated confidences.
267274
- Output metadata: citations, excerpts, reasoning, and confidence per field
275+
276+
Task Groups enable batch execution of many independent Task runs with group-level monitoring and failure handling.
277+
- Submit hundreds or thousands of Tasks as a single group
278+
- Observe group progress and receive results as they complete
279+
- Real-time updates via Server-Sent Events (SSE)
280+
- Add tasks to an existing group while it is running
281+
- Group-level retry and error aggregation
268282
"""
269283

270284
@cached_property

src/parallel/resources/task_run.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ class TaskRunResource(SyncAPIResource):
4141
4242
Clients submit a natural-language objective with an optional input schema; the service plans retrieval, fetches relevant URLs, and returns outputs that conform to a provided or inferred JSON schema. Supports deep research style queries and can return rich structured JSON outputs. Processors trade-off between cost, latency, and quality. Each processor supports calibrated confidences.
4343
- Output metadata: citations, excerpts, reasoning, and confidence per field
44+
45+
Task Groups enable batch execution of many independent Task runs with group-level monitoring and failure handling.
46+
- Submit hundreds or thousands of Tasks as a single group
47+
- Observe group progress and receive results as they complete
48+
- Real-time updates via Server-Sent Events (SSE)
49+
- Add tasks to an existing group while it is running
50+
- Group-level retry and error aggregation
4451
"""
4552

4653
@cached_property
@@ -340,6 +347,13 @@ class AsyncTaskRunResource(AsyncAPIResource):
340347
341348
Clients submit a natural-language objective with an optional input schema; the service plans retrieval, fetches relevant URLs, and returns outputs that conform to a provided or inferred JSON schema. Supports deep research style queries and can return rich structured JSON outputs. Processors trade-off between cost, latency, and quality. Each processor supports calibrated confidences.
342349
- Output metadata: citations, excerpts, reasoning, and confidence per field
350+
351+
Task Groups enable batch execution of many independent Task runs with group-level monitoring and failure handling.
352+
- Submit hundreds or thousands of Tasks as a single group
353+
- Observe group progress and receive results as they complete
354+
- Real-time updates via Server-Sent Events (SSE)
355+
- Add tasks to an existing group while it is running
356+
- Group-level retry and error aggregation
343357
"""
344358

345359
@cached_property

src/parallel/types/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,18 @@
2020
from .auto_schema_param import AutoSchemaParam as AutoSchemaParam
2121
from .json_schema_param import JsonSchemaParam as JsonSchemaParam
2222
from .text_schema_param import TextSchemaParam as TextSchemaParam
23+
from .web_search_result import WebSearchResult as WebSearchResult
24+
from .fetch_policy_param import FetchPolicyParam as FetchPolicyParam
25+
from .client_search_params import ClientSearchParams as ClientSearchParams
2326
from .task_run_json_output import TaskRunJsonOutput as TaskRunJsonOutput
2427
from .task_run_text_output import TaskRunTextOutput as TaskRunTextOutput
2528
from .parsed_task_run_result import ParsedTaskRunResult as ParsedTaskRunResult
29+
from .usage_item import UsageItem as UsageItem
30+
from .extract_error import ExtractError as ExtractError
31+
from .search_result import SearchResult as SearchResult
32+
from .extract_result import ExtractResult as ExtractResult
33+
from .extract_response import ExtractResponse as ExtractResponse
34+
from .client_extract_params import ClientExtractParams as ClientExtractParams
35+
from .excerpt_settings_param import ExcerptSettingsParam as ExcerptSettingsParam
2636
from .task_run_create_params import TaskRunCreateParams as TaskRunCreateParams
2737
from .task_run_result_params import TaskRunResultParams as TaskRunResultParams

src/parallel/types/beta/beta_extract_params.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,33 @@
77

88
from ..._types import SequenceNotStr
99
from ..._utils import PropertyInfo
10-
from .fetch_policy_param import FetchPolicyParam
10+
from ..fetch_policy_param import FetchPolicyParam
1111
from .parallel_beta_param import ParallelBetaParam
1212
from .excerpt_settings_param import ExcerptSettingsParam
1313

14-
__all__ = ["BetaExtractParams", "Excerpts"]
14+
__all__ = ["BetaExtractParams", "Excerpts", "FullContent", "FullContentFullContentSettings"]
1515

1616

1717
class BetaExtractParams(TypedDict, total=False):
1818
urls: Required[SequenceNotStr[str]]
1919

2020
excerpts: Excerpts
21-
"""Include excerpts from each URL relevant to the search objective and queries."""
21+
"""Include excerpts from each URL relevant to the search objective and queries.
22+
23+
Note that if neither objective nor search_queries is provided, excerpts are
24+
redundant with full content.
25+
"""
2226

2327
fetch_policy: Optional[FetchPolicyParam]
2428
"""Policy for live fetching web results."""
2529

30+
full_content: FullContent
31+
"""Include full content from each URL.
32+
33+
Note that if neither objective nor search_queries is provided, excerpts are
34+
redundant with full content.
35+
"""
36+
2637
objective: Optional[str]
2738
"""If provided, focuses extracted content on the specified search objective."""
2839

@@ -34,3 +45,17 @@ class BetaExtractParams(TypedDict, total=False):
3445

3546

3647
Excerpts: TypeAlias = Union[bool, ExcerptSettingsParam]
48+
49+
50+
class FullContentFullContentSettings(TypedDict, total=False):
51+
"""Optional settings for returning full content."""
52+
53+
max_chars_per_result: Optional[int]
54+
"""
55+
Optional limit on the number of characters to include in the full content for
56+
each url. Full content always starts at the beginning of the page and is
57+
truncated at the limit if necessary.
58+
"""
59+
60+
61+
FullContent: TypeAlias = Union[bool, FullContentFullContentSettings]

0 commit comments

Comments
 (0)