parallel-web 0.1.3__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 (72) 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/_files.py +4 -4
  6. parallel/_models.py +32 -8
  7. parallel/_types.py +35 -1
  8. parallel/_utils/__init__.py +1 -0
  9. parallel/_utils/_typing.py +5 -0
  10. parallel/_version.py +1 -1
  11. parallel/lib/_pydantic.py +1 -0
  12. parallel/resources/__init__.py +14 -0
  13. parallel/resources/beta/__init__.py +47 -0
  14. parallel/resources/beta/beta.py +301 -0
  15. parallel/resources/beta/task_group.py +632 -0
  16. parallel/resources/beta/task_run.py +499 -0
  17. parallel/resources/task_run.py +47 -18
  18. parallel/types/__init__.py +15 -0
  19. parallel/types/auto_schema.py +13 -0
  20. parallel/types/auto_schema_param.py +12 -0
  21. parallel/types/beta/__init__.py +30 -0
  22. parallel/types/beta/beta_run_input.py +63 -0
  23. parallel/types/beta/beta_run_input_param.py +65 -0
  24. parallel/types/beta/beta_search_params.py +47 -0
  25. parallel/types/beta/beta_task_run_result.py +74 -0
  26. parallel/types/beta/error_event.py +16 -0
  27. parallel/types/beta/mcp_server.py +25 -0
  28. parallel/types/beta/mcp_server_param.py +25 -0
  29. parallel/types/beta/mcp_tool_call.py +27 -0
  30. parallel/types/beta/parallel_beta_param.py +12 -0
  31. parallel/types/beta/search_result.py +16 -0
  32. parallel/types/beta/task_group.py +24 -0
  33. parallel/types/beta/task_group_add_runs_params.py +30 -0
  34. parallel/types/beta/task_group_create_params.py +13 -0
  35. parallel/types/beta/task_group_events_params.py +16 -0
  36. parallel/types/beta/task_group_events_response.py +28 -0
  37. parallel/types/beta/task_group_get_runs_params.py +18 -0
  38. parallel/types/beta/task_group_get_runs_response.py +12 -0
  39. parallel/types/beta/task_group_run_response.py +30 -0
  40. parallel/types/beta/task_group_status.py +27 -0
  41. parallel/types/beta/task_run_create_params.py +70 -0
  42. parallel/types/beta/task_run_event.py +32 -0
  43. parallel/types/beta/task_run_events_response.py +58 -0
  44. parallel/types/beta/task_run_result_params.py +18 -0
  45. parallel/types/beta/web_search_result.py +18 -0
  46. parallel/types/beta/webhook.py +16 -0
  47. parallel/types/beta/webhook_param.py +16 -0
  48. parallel/types/citation.py +21 -0
  49. parallel/types/field_basis.py +25 -0
  50. parallel/types/json_schema.py +16 -0
  51. parallel/types/json_schema_param.py +2 -1
  52. parallel/types/parsed_task_run_result.py +13 -4
  53. parallel/types/shared/__init__.py +6 -0
  54. parallel/types/shared/error_object.py +18 -0
  55. parallel/types/shared/error_response.py +16 -0
  56. parallel/types/shared/source_policy.py +21 -0
  57. parallel/types/shared/warning.py +22 -0
  58. parallel/types/shared_params/__init__.py +3 -0
  59. parallel/types/shared_params/source_policy.py +22 -0
  60. parallel/types/task_run.py +17 -18
  61. parallel/types/task_run_create_params.py +12 -3
  62. parallel/types/task_run_json_output.py +46 -0
  63. parallel/types/task_run_result.py +24 -94
  64. parallel/types/task_run_text_output.py +37 -0
  65. parallel/types/task_spec.py +31 -0
  66. parallel/types/task_spec_param.py +3 -2
  67. parallel/types/text_schema.py +16 -0
  68. {parallel_web-0.1.3.dist-info → parallel_web-0.2.0.dist-info}/METADATA +23 -159
  69. parallel_web-0.2.0.dist-info/RECORD +94 -0
  70. parallel_web-0.1.3.dist-info/RECORD +0 -47
  71. {parallel_web-0.1.3.dist-info → parallel_web-0.2.0.dist-info}/WHEEL +0 -0
  72. {parallel_web-0.1.3.dist-info → parallel_web-0.2.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,22 @@
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 List
6
+ from typing_extensions import TypedDict
7
+
8
+ __all__ = ["SourcePolicy"]
9
+
10
+
11
+ class SourcePolicy(TypedDict, total=False):
12
+ exclude_domains: List[str]
13
+ """List of domains to exclude from results.
14
+
15
+ If specified, sources from these domains will be excluded.
16
+ """
17
+
18
+ include_domains: List[str]
19
+ """List of domains to restrict the results to.
20
+
21
+ If specified, only sources from these domains will be included.
22
+ """
@@ -3,23 +3,16 @@
3
3
  from typing import Dict, List, Union, Optional
4
4
  from typing_extensions import Literal
5
5
 
6
- from .._models import BaseModel
7
-
8
- __all__ = ["TaskRun", "Warning"]
9
-
10
-
11
- class Warning(BaseModel):
12
- message: str
13
- """Human-readable message."""
14
-
15
- type: str
16
- """Type of warning.
6
+ from pydantic import Field as FieldInfo
17
7
 
18
- Note that adding new warning types is considered a backward-compatible change.
19
- """
8
+ from .._models import BaseModel
9
+ from .shared.warning import Warning
10
+ from .shared.error_object import ErrorObject
20
11
 
21
- detail: Optional[object] = None
22
- """Optional detail supporting the warning."""
12
+ __all__ = [
13
+ "TaskRun",
14
+ "Warning", # for backwards compatibility with v0.1.3
15
+ ]
23
16
 
24
17
 
25
18
  class TaskRun(BaseModel):
@@ -27,9 +20,9 @@ class TaskRun(BaseModel):
27
20
  """Timestamp of the creation of the task, as an RFC 3339 string."""
28
21
 
29
22
  is_active: bool
30
- """Whether the run is currently active; i.e.
23
+ """Whether the run is currently active, i.e.
31
24
 
32
- status is one of {'running', 'queued', 'cancelling'}.
25
+ status is one of {'cancelling', 'queued', 'running'}.
33
26
  """
34
27
 
35
28
  modified_at: Optional[str] = None
@@ -44,8 +37,14 @@ class TaskRun(BaseModel):
44
37
  status: Literal["queued", "action_required", "running", "completed", "failed", "cancelling", "cancelled"]
45
38
  """Status of the run."""
46
39
 
40
+ error: Optional[ErrorObject] = None
41
+ """An error message."""
42
+
47
43
  metadata: Optional[Dict[str, Union[str, float, bool]]] = None
48
44
  """User-provided metadata stored with the run."""
49
45
 
46
+ task_group_id: Optional[str] = FieldInfo(alias="taskgroup_id", default=None)
47
+ """ID of the taskgroup to which the run belongs."""
48
+
50
49
  warnings: Optional[List[Warning]] = None
51
- """Warnings for the run."""
50
+ """Warnings for the run, if any."""
@@ -6,12 +6,13 @@ from typing import Dict, Union, Optional
6
6
  from typing_extensions import Required, TypedDict
7
7
 
8
8
  from .task_spec_param import TaskSpecParam
9
+ from .shared_params.source_policy import SourcePolicy
9
10
 
10
11
  __all__ = ["TaskRunCreateParams"]
11
12
 
12
13
 
13
14
  class TaskRunCreateParams(TypedDict, total=False):
14
- input: Required[Union[str, object]]
15
+ input: Required[Union[str, Dict[str, object]]]
15
16
  """Input to the task, either text or a JSON object."""
16
17
 
17
18
  processor: Required[str]
@@ -24,9 +25,17 @@ class TaskRunCreateParams(TypedDict, total=False):
24
25
  respectively.
25
26
  """
26
27
 
28
+ source_policy: Optional[SourcePolicy]
29
+ """Source policy for web search results.
30
+
31
+ This policy governs which sources are allowed/disallowed in results.
32
+ """
33
+
27
34
  task_spec: Optional[TaskSpecParam]
28
35
  """Specification for a task.
29
36
 
30
- For convenience we allow bare strings as input or output schemas, which is
31
- equivalent to a text schema with the same description.
37
+ Auto output schemas can be specified by setting `output_schema={"type":"auto"}`.
38
+ Not specifying a TaskSpec is the same as setting an auto output schema.
39
+
40
+ For convenience bare strings are also accepted as input or output schemas.
32
41
  """
@@ -0,0 +1,46 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from typing import Dict, List, Optional
4
+ from typing_extensions import Literal
5
+
6
+ from .._models import BaseModel
7
+ from .field_basis import FieldBasis
8
+
9
+ __all__ = ["TaskRunJsonOutput"]
10
+
11
+
12
+ class TaskRunJsonOutput(BaseModel):
13
+ basis: List[FieldBasis]
14
+ """Basis for each top-level field in the JSON output."""
15
+
16
+ content: Dict[str, object]
17
+ """
18
+ Output from the task as a native JSON object, as determined by the output schema
19
+ of the task spec.
20
+ """
21
+
22
+ type: Literal["json"]
23
+ """
24
+ The type of output being returned, as determined by the output schema of the
25
+ task spec.
26
+ """
27
+
28
+ beta_fields: Optional[Dict[str, object]] = None
29
+ """Additional fields from beta features used in this task run.
30
+
31
+ When beta features are specified during both task run creation and result
32
+ retrieval, this field will be empty and instead the relevant beta attributes
33
+ will be directly included in the `BetaTaskRunJsonOutput` or corresponding output
34
+ type. However, if beta features were specified during task run creation but not
35
+ during result retrieval, this field will contain the dump of fields from those
36
+ beta features. Each key represents the beta feature version (one amongst
37
+ parallel-beta headers) and the values correspond to the beta feature attributes,
38
+ if any. For now, only MCP server beta features have attributes. For example,
39
+ `{mcp-server-2025-07-17: [{'server_name':'mcp_server', 'tool_call_id': 'tc_123', ...}]}}`
40
+ """
41
+
42
+ output_schema: Optional[Dict[str, object]] = None
43
+ """Output schema for the Task Run.
44
+
45
+ Populated only if the task was executed with an auto schema.
46
+ """
@@ -1,117 +1,47 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- from typing import List, Union, Optional
4
- from typing_extensions import Literal, TypeAlias
3
+ from typing import Union
4
+ from typing_extensions import Annotated, TypeAlias
5
5
 
6
+ from .._utils import PropertyInfo
6
7
  from .._models import BaseModel
8
+ from .citation import Citation
7
9
  from .task_run import TaskRun
10
+ from .field_basis import FieldBasis
11
+ from .task_run_json_output import TaskRunJsonOutput
12
+ from .task_run_text_output import TaskRunTextOutput
8
13
 
9
14
  __all__ = [
10
15
  "TaskRunResult",
11
16
  "Output",
12
- "OutputTaskRunTextOutput",
13
- "OutputTaskRunTextOutputBasis",
14
- "OutputTaskRunTextOutputBasisCitation",
15
17
  "OutputTaskRunJsonOutput",
16
18
  "OutputTaskRunJsonOutputBasis",
17
19
  "OutputTaskRunJsonOutputBasisCitation",
20
+ "OutputTaskRunTextOutput",
21
+ "OutputTaskRunTextOutputBasis",
22
+ "OutputTaskRunTextOutputBasisCitation",
18
23
  ]
19
24
 
25
+ OutputTaskRunJsonOutput = TaskRunJsonOutput # for backwards compatibility with v0.1.3
26
+ """This is deprecated, `TaskRunJsonOutput` should be used instead"""
20
27
 
21
- class OutputTaskRunTextOutputBasisCitation(BaseModel):
22
- url: str
23
- """URL of the citation."""
24
-
25
- excerpts: Optional[List[str]] = None
26
- """Excerpts from the citation supporting the output.
27
-
28
- Only certain processors provide excerpts.
29
- """
30
-
31
- title: Optional[str] = None
32
- """Title of the citation."""
33
-
34
-
35
- class OutputTaskRunTextOutputBasis(BaseModel):
36
- field: str
37
- """Name of the output field."""
38
-
39
- reasoning: str
40
- """Reasoning for the output field."""
41
-
42
- citations: Optional[List[OutputTaskRunTextOutputBasisCitation]] = None
43
- """List of citations supporting the output field."""
44
-
45
- confidence: Optional[str] = None
46
- """Confidence level for the output field.
47
-
48
- Only certain processors provide confidence levels.
49
- """
50
-
51
-
52
- class OutputTaskRunTextOutput(BaseModel):
53
- basis: List[OutputTaskRunTextOutputBasis]
54
- """Basis for the output. The basis has a single field 'output'."""
55
-
56
- content: str
57
- """Text output from the task."""
58
-
59
- type: Literal["text"]
60
- """
61
- The type of output being returned, as determined by the output schema of the
62
- task spec.
63
- """
64
-
65
-
66
- class OutputTaskRunJsonOutputBasisCitation(BaseModel):
67
- url: str
68
- """URL of the citation."""
69
-
70
- excerpts: Optional[List[str]] = None
71
- """Excerpts from the citation supporting the output.
72
-
73
- Only certain processors provide excerpts.
74
- """
75
-
76
- title: Optional[str] = None
77
- """Title of the citation."""
78
-
79
-
80
- class OutputTaskRunJsonOutputBasis(BaseModel):
81
- field: str
82
- """Name of the output field."""
83
-
84
- reasoning: str
85
- """Reasoning for the output field."""
86
-
87
- citations: Optional[List[OutputTaskRunJsonOutputBasisCitation]] = None
88
- """List of citations supporting the output field."""
89
-
90
- confidence: Optional[str] = None
91
- """Confidence level for the output field.
92
-
93
- Only certain processors provide confidence levels.
94
- """
28
+ OutputTaskRunJsonOutputBasis = FieldBasis # for backwards compatibility with v0.1.3
29
+ """This is deprecated, `FieldBasis` should be used instead"""
95
30
 
31
+ OutputTaskRunJsonOutputBasisCitation = Citation # for backwards compatibility with v0.1.3
32
+ """This is deprecated, `Citation` should be used instead"""
96
33
 
97
- class OutputTaskRunJsonOutput(BaseModel):
98
- basis: List[OutputTaskRunJsonOutputBasis]
99
- """Basis for each top-level field in the JSON output."""
34
+ OutputTaskRunTextOutput = TaskRunTextOutput # for backwards compatibility with v0.1.3
35
+ """This is deprecated, `TaskRunTextOutput` should be used instead"""
100
36
 
101
- content: object
102
- """
103
- Output from the task as a native JSON object, as determined by the output schema
104
- of the task spec.
105
- """
37
+ OutputTaskRunTextOutputBasis = FieldBasis # for backwards compatibility with v0.1.3
38
+ """This is deprecated, `FieldBasis` should be used instead"""
106
39
 
107
- type: Literal["json"]
108
- """
109
- The type of output being returned, as determined by the output schema of the
110
- task spec.
111
- """
40
+ OutputTaskRunTextOutputBasisCitation = Citation # for backwards compatibility with v0.1.3
41
+ """This is deprecated, `Citation` should be used instead"""
112
42
 
113
43
 
114
- Output: TypeAlias = Union[OutputTaskRunTextOutput, OutputTaskRunJsonOutput]
44
+ Output: TypeAlias = Annotated[Union[TaskRunTextOutput, TaskRunJsonOutput], PropertyInfo(discriminator="type")]
115
45
 
116
46
 
117
47
  class TaskRunResult(BaseModel):
@@ -119,4 +49,4 @@ class TaskRunResult(BaseModel):
119
49
  """Output from the task conforming to the output schema."""
120
50
 
121
51
  run: TaskRun
122
- """Status of a task."""
52
+ """Status of a task run."""
@@ -0,0 +1,37 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from typing import Dict, List, Optional
4
+ from typing_extensions import Literal
5
+
6
+ from .._models import BaseModel
7
+ from .field_basis import FieldBasis
8
+
9
+ __all__ = ["TaskRunTextOutput"]
10
+
11
+
12
+ class TaskRunTextOutput(BaseModel):
13
+ basis: List[FieldBasis]
14
+ """Basis for the output. The basis has a single field 'output'."""
15
+
16
+ content: str
17
+ """Text output from the task."""
18
+
19
+ type: Literal["text"]
20
+ """
21
+ The type of output being returned, as determined by the output schema of the
22
+ task spec.
23
+ """
24
+
25
+ beta_fields: Optional[Dict[str, object]] = None
26
+ """Additional fields from beta features used in this task run.
27
+
28
+ When beta features are specified during both task run creation and result
29
+ retrieval, this field will be empty and instead the relevant beta attributes
30
+ will be directly included in the `BetaTaskRunJsonOutput` or corresponding output
31
+ type. However, if beta features were specified during task run creation but not
32
+ during result retrieval, this field will contain the dump of fields from those
33
+ beta features. Each key represents the beta feature version (one amongst
34
+ parallel-beta headers) and the values correspond to the beta feature attributes,
35
+ if any. For now, only MCP server beta features have attributes. For example,
36
+ `{mcp-server-2025-07-17: [{'server_name':'mcp_server', 'tool_call_id': 'tc_123', ...}]}}`
37
+ """
@@ -0,0 +1,31 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from typing import Union, Optional
4
+ from typing_extensions import TypeAlias
5
+
6
+ from .._models import BaseModel
7
+ from .auto_schema import AutoSchema
8
+ from .json_schema import JsonSchema
9
+ from .text_schema import TextSchema
10
+
11
+ __all__ = ["TaskSpec", "OutputSchema", "InputSchema"]
12
+
13
+ OutputSchema: TypeAlias = Union[JsonSchema, TextSchema, AutoSchema, str]
14
+
15
+ InputSchema: TypeAlias = Union[str, JsonSchema, TextSchema, None]
16
+
17
+
18
+ class TaskSpec(BaseModel):
19
+ output_schema: OutputSchema
20
+ """JSON schema or text fully describing the desired output from the task.
21
+
22
+ Descriptions of output fields will determine the form and content of the
23
+ response. A bare string is equivalent to a text schema with the same
24
+ description.
25
+ """
26
+
27
+ input_schema: Optional[InputSchema] = None
28
+ """Optional JSON schema or text description of expected input to the task.
29
+
30
+ A bare string is equivalent to a text schema with the same description.
31
+ """
@@ -7,14 +7,15 @@ from typing_extensions import TypeVar, Required, TypeAlias, TypedDict, NotRequir
7
7
 
8
8
  from pydantic import BaseModel
9
9
 
10
+ from .auto_schema_param import AutoSchemaParam
10
11
  from .json_schema_param import JsonSchemaParam
11
12
  from .text_schema_param import TextSchemaParam
12
13
 
13
14
  __all__ = ["TaskSpecParam", "OutputSchema", "InputSchema"]
14
15
 
15
- OutputSchema: TypeAlias = Union[JsonSchemaParam, TextSchemaParam, str]
16
+ OutputSchema: TypeAlias = Union[JsonSchemaParam, TextSchemaParam, AutoSchemaParam, str]
16
17
 
17
- InputSchema: TypeAlias = Union[JsonSchemaParam, TextSchemaParam, str]
18
+ InputSchema: TypeAlias = Union[str, JsonSchemaParam, TextSchemaParam]
18
19
 
19
20
  OutputT = TypeVar("OutputT", bound=BaseModel)
20
21
 
@@ -0,0 +1,16 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from typing import Optional
4
+ from typing_extensions import Literal
5
+
6
+ from .._models import BaseModel
7
+
8
+ __all__ = ["TextSchema"]
9
+
10
+
11
+ class TextSchema(BaseModel):
12
+ description: str
13
+ """A text description of the desired output from the task."""
14
+
15
+ type: Optional[Literal["text"]] = None
16
+ """The type of schema being defined. Always `text`."""