parallel-web 0.1.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.
- parallel/__init__.py +94 -0
- parallel/_base_client.py +1943 -0
- parallel/_client.py +403 -0
- parallel/_compat.py +230 -0
- parallel/_constants.py +16 -0
- parallel/_exceptions.py +108 -0
- parallel/_files.py +123 -0
- parallel/_models.py +803 -0
- parallel/_qs.py +150 -0
- parallel/_resource.py +43 -0
- parallel/_response.py +830 -0
- parallel/_streaming.py +333 -0
- parallel/_types.py +217 -0
- parallel/_utils/__init__.py +58 -0
- parallel/_utils/_logs.py +25 -0
- parallel/_utils/_proxy.py +62 -0
- parallel/_utils/_reflection.py +42 -0
- parallel/_utils/_streams.py +12 -0
- parallel/_utils/_sync.py +86 -0
- parallel/_utils/_transform.py +447 -0
- parallel/_utils/_typing.py +151 -0
- parallel/_utils/_utils.py +426 -0
- parallel/_version.py +4 -0
- parallel/lib/.keep +4 -0
- parallel/lib/__init__.py +0 -0
- parallel/lib/_parsing/__init__.py +2 -0
- parallel/lib/_parsing/_task_run_result.py +100 -0
- parallel/lib/_parsing/_task_spec.py +93 -0
- parallel/lib/_pydantic.py +29 -0
- parallel/lib/_time.py +57 -0
- parallel/py.typed +0 -0
- parallel/resources/__init__.py +19 -0
- parallel/resources/task_run.py +643 -0
- parallel/types/__init__.py +12 -0
- parallel/types/json_schema_param.py +15 -0
- parallel/types/parsed_task_run_result.py +29 -0
- parallel/types/task_run.py +54 -0
- parallel/types/task_run_create_params.py +32 -0
- parallel/types/task_run_result.py +122 -0
- parallel/types/task_run_result_params.py +13 -0
- parallel/types/task_spec_param.py +35 -0
- parallel/types/text_schema_param.py +15 -0
- parallel_web-0.1.0.dist-info/METADATA +544 -0
- parallel_web-0.1.0.dist-info/RECORD +46 -0
- parallel_web-0.1.0.dist-info/WHEEL +4 -0
- parallel_web-0.1.0.dist-info/licenses/LICENSE +7 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from typing import Union, Generic, TypeVar, Optional
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel
|
|
4
|
+
|
|
5
|
+
from .._models import GenericModel
|
|
6
|
+
from .task_run_result import TaskRunResult, OutputTaskRunJsonOutput, OutputTaskRunTextOutput
|
|
7
|
+
|
|
8
|
+
ContentType = TypeVar("ContentType", bound=BaseModel)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
# we need to disable this check because we're overriding properties
|
|
12
|
+
# with subclasses of their types which is technically unsound as
|
|
13
|
+
# properties can be mutated.
|
|
14
|
+
# pyright: reportIncompatibleVariableOverride=false
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ParsedOutputTaskRunTextOutput(OutputTaskRunTextOutput, GenericModel, Generic[ContentType]):
|
|
18
|
+
parsed: None
|
|
19
|
+
"""The parsed output from the task run."""
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ParsedOutputTaskRunJsonOutput(OutputTaskRunJsonOutput, GenericModel, Generic[ContentType]):
|
|
23
|
+
parsed: Optional[ContentType] = None
|
|
24
|
+
"""The parsed output from the task run."""
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class ParsedTaskRunResult(TaskRunResult, GenericModel, Generic[ContentType]):
|
|
28
|
+
output: Union[ParsedOutputTaskRunTextOutput[ContentType], ParsedOutputTaskRunJsonOutput[ContentType]] # type: ignore[assignment]
|
|
29
|
+
"""The parsed output from the task run."""
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from typing import Dict, List, Union, Optional
|
|
4
|
+
from typing_extensions import Literal
|
|
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.
|
|
17
|
+
|
|
18
|
+
Note that adding new warning types is considered a backward-compatible change.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
detail: Optional[object] = None
|
|
22
|
+
"""Optional detail supporting the warning."""
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class TaskRun(BaseModel):
|
|
26
|
+
created_at: Optional[str] = None
|
|
27
|
+
"""Timestamp of the creation of the task, as an RFC 3339 string."""
|
|
28
|
+
|
|
29
|
+
is_active: bool
|
|
30
|
+
"""Whether the run is currently active; i.e.
|
|
31
|
+
|
|
32
|
+
status is one of {'queued', 'running', 'cancelling'}.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
message: Optional[str] = None
|
|
36
|
+
"""Human-readable status message for the run."""
|
|
37
|
+
|
|
38
|
+
modified_at: Optional[str] = None
|
|
39
|
+
"""Timestamp of the last modification to the task, as an RFC 3339 string."""
|
|
40
|
+
|
|
41
|
+
processor: str
|
|
42
|
+
"""Processor used for the run."""
|
|
43
|
+
|
|
44
|
+
run_id: str
|
|
45
|
+
"""ID of the task run."""
|
|
46
|
+
|
|
47
|
+
status: Literal["queued", "action_required", "running", "completed", "failed", "cancelling", "cancelled"]
|
|
48
|
+
"""Status of the run."""
|
|
49
|
+
|
|
50
|
+
metadata: Optional[Dict[str, Union[str, float, bool]]] = None
|
|
51
|
+
"""User-provided metadata stored with the run."""
|
|
52
|
+
|
|
53
|
+
warnings: Optional[List[Warning]] = None
|
|
54
|
+
"""Warnings for the run."""
|
|
@@ -0,0 +1,32 @@
|
|
|
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 Dict, Union, Optional
|
|
6
|
+
from typing_extensions import Required, TypedDict
|
|
7
|
+
|
|
8
|
+
from .task_spec_param import TaskSpecParam
|
|
9
|
+
|
|
10
|
+
__all__ = ["TaskRunCreateParams"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class TaskRunCreateParams(TypedDict, total=False):
|
|
14
|
+
input: Required[Union[str, object]]
|
|
15
|
+
"""Input to the task, either text or a JSON object."""
|
|
16
|
+
|
|
17
|
+
processor: Required[str]
|
|
18
|
+
"""Processor to use for the task."""
|
|
19
|
+
|
|
20
|
+
metadata: Optional[Dict[str, Union[str, float, bool]]]
|
|
21
|
+
"""User-provided metadata stored with the run.
|
|
22
|
+
|
|
23
|
+
Keys and values must be strings with a maximum length of 16 and 512 characters
|
|
24
|
+
respectively.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
task_spec: Optional[TaskSpecParam]
|
|
28
|
+
"""Specification for a task.
|
|
29
|
+
|
|
30
|
+
For convenience we allow bare strings as input or output schemas, which is
|
|
31
|
+
equivalent to a text schema with the same description.
|
|
32
|
+
"""
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from typing import List, Union, Optional
|
|
4
|
+
from typing_extensions import Literal, TypeAlias
|
|
5
|
+
|
|
6
|
+
from .._models import BaseModel
|
|
7
|
+
from .task_run import TaskRun
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"TaskRunResult",
|
|
11
|
+
"Output",
|
|
12
|
+
"OutputTaskRunTextOutput",
|
|
13
|
+
"OutputTaskRunTextOutputBasis",
|
|
14
|
+
"OutputTaskRunTextOutputBasisCitation",
|
|
15
|
+
"OutputTaskRunJsonOutput",
|
|
16
|
+
"OutputTaskRunJsonOutputBasis",
|
|
17
|
+
"OutputTaskRunJsonOutputBasisCitation",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
|
|
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
|
+
"""
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
class OutputTaskRunJsonOutput(BaseModel):
|
|
98
|
+
basis: List[OutputTaskRunJsonOutputBasis]
|
|
99
|
+
"""Basis for each top-level field in the JSON output."""
|
|
100
|
+
|
|
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
|
+
"""
|
|
106
|
+
|
|
107
|
+
type: Literal["json"]
|
|
108
|
+
"""
|
|
109
|
+
The type of output being returned, as determined by the output schema of the
|
|
110
|
+
task spec.
|
|
111
|
+
"""
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
Output: TypeAlias = Union[OutputTaskRunTextOutput, OutputTaskRunJsonOutput]
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
class TaskRunResult(BaseModel):
|
|
118
|
+
output: Output
|
|
119
|
+
"""Output from the task conforming to the output schema."""
|
|
120
|
+
|
|
121
|
+
run: TaskRun
|
|
122
|
+
"""Status of a task."""
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing_extensions import Annotated, TypedDict
|
|
6
|
+
|
|
7
|
+
from .._utils import PropertyInfo
|
|
8
|
+
|
|
9
|
+
__all__ = ["TaskRunResultParams"]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class TaskRunResultParams(TypedDict, total=False):
|
|
13
|
+
api_timeout: Annotated[int, PropertyInfo(alias="timeout")]
|
|
@@ -0,0 +1,35 @@
|
|
|
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 Union, Optional
|
|
6
|
+
from typing_extensions import TypeVar, Required, TypeAlias, TypedDict, NotRequired
|
|
7
|
+
|
|
8
|
+
from pydantic import BaseModel
|
|
9
|
+
|
|
10
|
+
from .json_schema_param import JsonSchemaParam
|
|
11
|
+
from .text_schema_param import TextSchemaParam
|
|
12
|
+
|
|
13
|
+
__all__ = ["TaskSpecParam", "OutputSchema", "InputSchema"]
|
|
14
|
+
|
|
15
|
+
OutputSchema: TypeAlias = Union[JsonSchemaParam, TextSchemaParam, str]
|
|
16
|
+
|
|
17
|
+
InputSchema: TypeAlias = Union[JsonSchemaParam, TextSchemaParam, str]
|
|
18
|
+
|
|
19
|
+
OutputT = TypeVar("OutputT", bound=BaseModel)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class TaskSpecParam(TypedDict, total=False):
|
|
23
|
+
output_schema: Required[OutputSchema]
|
|
24
|
+
"""JSON schema or text fully describing the desired output from the task.
|
|
25
|
+
|
|
26
|
+
Descriptions of output fields will determine the form and content of the
|
|
27
|
+
response. A bare string is equivalent to a text schema with the same
|
|
28
|
+
description.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
input_schema: NotRequired[Optional[InputSchema]]
|
|
32
|
+
"""Optional JSON schema or text description of expected input to the task.
|
|
33
|
+
|
|
34
|
+
A bare string is equivalent to a text schema with the same description.
|
|
35
|
+
"""
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing_extensions import Literal, Required, TypedDict
|
|
6
|
+
|
|
7
|
+
__all__ = ["TextSchemaParam"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class TextSchemaParam(TypedDict, total=False):
|
|
11
|
+
description: Required[str]
|
|
12
|
+
"""A text description of the desired output from the task."""
|
|
13
|
+
|
|
14
|
+
type: Literal["text"]
|
|
15
|
+
"""The type of schema being defined. Always `text`."""
|