gllm-pipeline-binary 0.4.17__cp312-cp312-win_amd64.whl → 0.4.18__cp312-cp312-win_amd64.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.
- gllm_pipeline/pipeline/composer/__init__.pyi +8 -0
- gllm_pipeline/pipeline/composer/composer.pyi +350 -0
- gllm_pipeline/pipeline/composer/guard_composer.pyi +58 -0
- gllm_pipeline/pipeline/composer/if_else_composer.pyi +57 -0
- gllm_pipeline/pipeline/composer/parallel_composer.pyi +47 -0
- gllm_pipeline/pipeline/composer/switch_composer.pyi +57 -0
- gllm_pipeline/pipeline/composer/toggle_composer.pyi +48 -0
- gllm_pipeline/pipeline/pipeline.pyi +19 -1
- gllm_pipeline.cp312-win_amd64.pyd +0 -0
- gllm_pipeline.pyi +8 -4
- {gllm_pipeline_binary-0.4.17.dist-info → gllm_pipeline_binary-0.4.18.dist-info}/METADATA +1 -1
- {gllm_pipeline_binary-0.4.17.dist-info → gllm_pipeline_binary-0.4.18.dist-info}/RECORD +14 -7
- {gllm_pipeline_binary-0.4.17.dist-info → gllm_pipeline_binary-0.4.18.dist-info}/WHEEL +0 -0
- {gllm_pipeline_binary-0.4.17.dist-info → gllm_pipeline_binary-0.4.18.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
from gllm_pipeline.pipeline.composer.composer import Composer as Composer
|
|
2
|
+
from gllm_pipeline.pipeline.composer.guard_composer import GuardComposer as GuardComposer
|
|
3
|
+
from gllm_pipeline.pipeline.composer.if_else_composer import IfElseComposer as IfElseComposer
|
|
4
|
+
from gllm_pipeline.pipeline.composer.parallel_composer import ParallelComposer as ParallelComposer
|
|
5
|
+
from gllm_pipeline.pipeline.composer.switch_composer import SwitchComposer as SwitchComposer
|
|
6
|
+
from gllm_pipeline.pipeline.composer.toggle_composer import ToggleComposer as ToggleComposer
|
|
7
|
+
|
|
8
|
+
__all__ = ['Composer', 'GuardComposer', 'IfElseComposer', 'ParallelComposer', 'SwitchComposer', 'ToggleComposer']
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
from gllm_core.schema import Component as Component
|
|
2
|
+
from gllm_core.utils.retry import RetryConfig as RetryConfig
|
|
3
|
+
from gllm_datastore.cache.cache import BaseCache as BaseCache
|
|
4
|
+
from gllm_pipeline.alias import InputMapSpec as InputMapSpec
|
|
5
|
+
from gllm_pipeline.pipeline.composer.guard_composer import GuardComposer as GuardComposer
|
|
6
|
+
from gllm_pipeline.pipeline.composer.if_else_composer import IfElseComposer as IfElseComposer
|
|
7
|
+
from gllm_pipeline.pipeline.composer.parallel_composer import ParallelComposer as ParallelComposer
|
|
8
|
+
from gllm_pipeline.pipeline.composer.switch_composer import SwitchComposer as SwitchComposer
|
|
9
|
+
from gllm_pipeline.pipeline.composer.toggle_composer import ToggleComposer as ToggleComposer
|
|
10
|
+
from gllm_pipeline.pipeline.pipeline import Pipeline as Pipeline
|
|
11
|
+
from gllm_pipeline.schema import PipelineSteps as PipelineSteps
|
|
12
|
+
from gllm_pipeline.steps.pipeline_step import BasePipelineStep as BasePipelineStep
|
|
13
|
+
from gllm_pipeline.steps.step_error_handler.step_error_handler import BaseStepErrorHandler as BaseStepErrorHandler
|
|
14
|
+
from typing import Any, Callable, Self, overload
|
|
15
|
+
|
|
16
|
+
class Composer:
|
|
17
|
+
"""Fluent API for composing a pipeline out of simple steps.
|
|
18
|
+
|
|
19
|
+
The composer accumulates steps in order and can build a `Pipeline` with
|
|
20
|
+
a specified state type, recursion limit, and optional name.
|
|
21
|
+
|
|
22
|
+
The Composer uses a manager-style API:
|
|
23
|
+
1. When initialized with an existing `Pipeline` instance, it manages the pipeline in place.
|
|
24
|
+
2. If none is provided, a new empty `Pipeline` with the default `RAGState` is created.
|
|
25
|
+
|
|
26
|
+
Examples:
|
|
27
|
+
```python
|
|
28
|
+
# With existing pipeline
|
|
29
|
+
composer = Composer(existing_pipeline).no_op().terminate()
|
|
30
|
+
pipeline = composer.done()
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
# With new pipeline
|
|
35
|
+
composer = Composer().no_op().terminate()
|
|
36
|
+
pipeline = composer.done()
|
|
37
|
+
```
|
|
38
|
+
"""
|
|
39
|
+
def __init__(self, pipeline: Pipeline | None = None) -> None:
|
|
40
|
+
"""Create a composer that manages a pipeline instance.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
pipeline (Pipeline | None, optional): Pipeline to modify. Defaults to None,
|
|
44
|
+
in which case a new empty pipeline with the default `RAGState` is created.
|
|
45
|
+
"""
|
|
46
|
+
def step(self, component: Component, input_map: InputMapSpec, output_state: str | list[str] | None = None, retry_config: RetryConfig | None = None, error_handler: BaseStepErrorHandler | None = None, name: str | None = None, cache_store: BaseCache | None = None, cache_config: dict[str, Any] | None = None) -> Self:
|
|
47
|
+
'''Append a component step.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
component (Component): The component to execute.
|
|
51
|
+
input_map (InputMapSpec): Unified input mapping for the component.
|
|
52
|
+
output_state (str | list[str] | None, optional): Key to store the result in the pipeline state.
|
|
53
|
+
Defaults to None.
|
|
54
|
+
retry_config (RetryConfig | None, optional): Configuration for retry behavior using
|
|
55
|
+
GLLM Core\'s RetryConfig. Defaults to None, in which case no retry config is applied.
|
|
56
|
+
error_handler (BaseStepErrorHandler | None, optional): Error handler to use for this step.
|
|
57
|
+
Defaults to None, in which case no error handler is used.
|
|
58
|
+
name (str | None, optional): A unique identifier for this step. If None, a name will be
|
|
59
|
+
auto-generated with the prefix "step_". Defaults to None.
|
|
60
|
+
cache_store (BaseCache | None, optional): Cache store to be used for caching.
|
|
61
|
+
Defaults to None, in which case no cache store is used.
|
|
62
|
+
cache_config (dict[str, Any] | None, optional): Cache configuration to be used for caching.
|
|
63
|
+
Defaults to None, in which case no cache configuration is used.
|
|
64
|
+
|
|
65
|
+
Returns:
|
|
66
|
+
Self: The composer instance with this step appended.
|
|
67
|
+
'''
|
|
68
|
+
def map_reduce(self, input_map: InputMapSpec, output_state: str, map_func: Component | Callable[[dict[str, Any]], Any], reduce_func: Callable[[list[Any]], Any] = ..., retry_config: RetryConfig | None = None, error_handler: BaseStepErrorHandler | None = None, cache_store: BaseCache | None = None, cache_config: dict[str, Any] | None = None, name: str | None = None) -> Self:
|
|
69
|
+
"""Append a map-reduce step.
|
|
70
|
+
|
|
71
|
+
Args:
|
|
72
|
+
input_map (InputMapSpec): Unified input mapping for the map function.
|
|
73
|
+
output_state (str): Key to store the reduced result in the pipeline state.
|
|
74
|
+
map_func (Component | Callable[[dict[str, Any]], Any]): Function to apply to each input item.
|
|
75
|
+
reduce_func (Callable[[list[Any]], Any], optional): Function to reduce mapped results.
|
|
76
|
+
Defaults to a function that returns the list of results as is.
|
|
77
|
+
retry_config (RetryConfig | None, optional): Retry behavior configuration.
|
|
78
|
+
Defaults to None, in which case no retry config is applied.
|
|
79
|
+
error_handler (BaseStepErrorHandler | None, optional): Error handler to use for this step.
|
|
80
|
+
Defaults to None, in which case the default error handler is used.
|
|
81
|
+
cache_store (BaseCache | None, optional): Cache store to be used for caching.
|
|
82
|
+
Defaults to None, in which case no cache store is used.
|
|
83
|
+
cache_config (dict[str, Any] | None, optional): Cache configuration to be used for caching.
|
|
84
|
+
Defaults to None, in which case no cache configuration is used.
|
|
85
|
+
name (str | None, optional): Optional name for the step. Defaults to None.
|
|
86
|
+
|
|
87
|
+
Returns:
|
|
88
|
+
Self: The composer instance with this step appended.
|
|
89
|
+
"""
|
|
90
|
+
def subgraph(self, subgraph: Pipeline, input_map: InputMapSpec | None = None, output_state_map: dict[str, str] | None = None, retry_config: RetryConfig | None = None, error_handler: BaseStepErrorHandler | None = None, cache_store: BaseCache | None = None, cache_config: dict[str, Any] | None = None, name: str | None = None) -> Self:
|
|
91
|
+
"""Append a subgraph step that executes another pipeline.
|
|
92
|
+
|
|
93
|
+
Args:
|
|
94
|
+
subgraph (Pipeline): The pipeline to be executed as a subgraph.
|
|
95
|
+
input_map (InputMapSpec | None, optional): Unified input mapping for the subgraph. Defaults to None.
|
|
96
|
+
output_state_map (dict[str, str] | None, optional): Map parent state keys to subgraph output keys.
|
|
97
|
+
Defaults to None, in which case all outputs are passed through.
|
|
98
|
+
retry_config (RetryConfig | None, optional): Retry behavior configuration.
|
|
99
|
+
Defaults to None, in which case no retry config is applied.
|
|
100
|
+
error_handler (BaseStepErrorHandler | None, optional): Error handler to use for this step.
|
|
101
|
+
Defaults to None, in which case the default error handler is used.
|
|
102
|
+
cache_store (BaseCache | None, optional): Cache store to be used for caching.
|
|
103
|
+
Defaults to None, in which case no cache store is used.
|
|
104
|
+
cache_config (dict[str, Any] | None, optional): Cache configuration to be used for caching.
|
|
105
|
+
Defaults to None, in which case no cache configuration is used.
|
|
106
|
+
name (str | None, optional): Optional name for the step. Defaults to None.
|
|
107
|
+
|
|
108
|
+
Returns:
|
|
109
|
+
Self: The composer instance with this step appended.
|
|
110
|
+
"""
|
|
111
|
+
def log(self, message: str, is_template: bool = True, emit_kwargs: dict[str, Any] | None = None, retry_config: RetryConfig | None = None, name: str | None = None, cache_store: BaseCache | None = None, cache_config: dict[str, Any] | None = None) -> Self:
|
|
112
|
+
'''Append a log step.
|
|
113
|
+
|
|
114
|
+
Args:
|
|
115
|
+
message (str): The message to log.
|
|
116
|
+
is_template (bool, optional): Whether the message is a template. Defaults to True.
|
|
117
|
+
emit_kwargs (dict[str, Any] | None, optional): Keyword arguments to pass to the emit function.
|
|
118
|
+
Defaults to None.
|
|
119
|
+
retry_config (RetryConfig | None, optional): Configuration for retry behavior using
|
|
120
|
+
GLLM Core\'s RetryConfig. Defaults to None, in which case no retry config is applied.
|
|
121
|
+
name (str | None, optional): A unique identifier for this step. If None, a name will be
|
|
122
|
+
auto-generated with the prefix "step_". Defaults to None.
|
|
123
|
+
cache_store (BaseCache | None, optional): Cache store to be used for caching.
|
|
124
|
+
Defaults to None, in which case no cache store is used.
|
|
125
|
+
cache_config (dict[str, Any] | None, optional): Cache configuration to be used for caching.
|
|
126
|
+
Defaults to None, in which case no cache configuration is used.
|
|
127
|
+
|
|
128
|
+
Returns:
|
|
129
|
+
Self: The composer instance with this step appended.
|
|
130
|
+
'''
|
|
131
|
+
def no_op(self, name: str | None = None) -> Self:
|
|
132
|
+
'''Append a no-op step.
|
|
133
|
+
|
|
134
|
+
Args:
|
|
135
|
+
name (str | None, optional): A unique identifier for this step. If None, a name will be
|
|
136
|
+
auto-generated with the prefix "no_op_". Defaults to None.
|
|
137
|
+
|
|
138
|
+
Returns:
|
|
139
|
+
Self: The composer instance with this step appended.
|
|
140
|
+
'''
|
|
141
|
+
def bundle(self, input_states: list[str] | dict[str, str], output_state: str | list[str], retry_config: RetryConfig | None = None, error_handler: BaseStepErrorHandler | None = None, cache_store: BaseCache | None = None, cache_config: dict[str, Any] | None = None, name: str | None = None) -> Self:
|
|
142
|
+
"""Append a bundle step to combine multiple state keys.
|
|
143
|
+
|
|
144
|
+
Args:
|
|
145
|
+
input_states (list[str] | dict[str, str]): List of keys to bundle as-is or mapping of
|
|
146
|
+
output field names to source state keys.
|
|
147
|
+
output_state (str | list[str]): State key(s) to store the bundled result.
|
|
148
|
+
retry_config (RetryConfig | None, optional): Retry configuration for the step. Defaults to None.
|
|
149
|
+
error_handler (BaseStepErrorHandler | None, optional): Error handler for this step. Defaults to None.
|
|
150
|
+
cache_store (BaseCache | None, optional): Cache store for this step. Defaults to None.
|
|
151
|
+
cache_config (dict[str, Any] | None, optional): Cache configuration for this step. Defaults to None.
|
|
152
|
+
name (str | None, optional): Optional name for the step. Defaults to None.
|
|
153
|
+
|
|
154
|
+
Returns:
|
|
155
|
+
Self: The composer instance with this step appended.
|
|
156
|
+
"""
|
|
157
|
+
def transform(self, operation: Callable[[dict[str, Any]], Any], input_map: InputMapSpec, output_state: str | list[str], retry_config: RetryConfig | None = None, error_handler: BaseStepErrorHandler | None = None, name: str | None = None, cache_store: BaseCache | None = None, cache_config: dict[str, Any] | None = None) -> Self:
|
|
158
|
+
'''Append a state operator step.
|
|
159
|
+
|
|
160
|
+
Args:
|
|
161
|
+
operation (Callable[[dict[str, Any]], Any]): The operation to apply to the state.
|
|
162
|
+
input_map (InputMapSpec): Unified input mapping for the operation.
|
|
163
|
+
output_state (str | list[str]): State key(s) to store the result in.
|
|
164
|
+
retry_config (RetryConfig | None, optional): Configuration for retry behavior using
|
|
165
|
+
GLLM Core\'s RetryConfig. Defaults to None, in which case no retry config is applied.
|
|
166
|
+
error_handler (BaseStepErrorHandler | None, optional): Error handler to use for this step.
|
|
167
|
+
Defaults to None, in which case no error handler is used.
|
|
168
|
+
name (str | None, optional): A unique identifier for this step. If None, a name will be
|
|
169
|
+
auto-generated with the prefix "transform_". Defaults to None.
|
|
170
|
+
cache_store (BaseCache | None, optional): Cache store to be used for caching.
|
|
171
|
+
Defaults to None, in which case no cache store is used.
|
|
172
|
+
cache_config (dict[str, Any] | None, optional): Cache configuration to be used for caching.
|
|
173
|
+
Defaults to None, in which case no cache configuration is used.
|
|
174
|
+
|
|
175
|
+
Returns:
|
|
176
|
+
Self: The composer instance with this step appended.
|
|
177
|
+
'''
|
|
178
|
+
def terminate(self, name: str | None = None, retry_config: RetryConfig | None = None, error_handler: BaseStepErrorHandler | None = None, cache_store: BaseCache | None = None, cache_config: dict[str, Any] | None = None) -> Self:
|
|
179
|
+
'''Append a terminator step.
|
|
180
|
+
|
|
181
|
+
Args:
|
|
182
|
+
name (str | None, optional): A unique identifier for this step. If None, a name will be
|
|
183
|
+
auto-generated with the prefix "terminator_". Defaults to None.
|
|
184
|
+
retry_config (RetryConfig | None, optional): Configuration for retry behavior using
|
|
185
|
+
GLLM Core\'s RetryConfig. Defaults to None, in which case no retry config is applied.
|
|
186
|
+
error_handler (BaseStepErrorHandler | None, optional): Error handler to use for this step.
|
|
187
|
+
Defaults to None, in which case no error handler is used.
|
|
188
|
+
cache_store (BaseCache | None, optional): Cache store to be used for caching.
|
|
189
|
+
Defaults to None, in which case no cache store is used.
|
|
190
|
+
cache_config (dict[str, Any] | None, optional): Cache configuration to be used for caching.
|
|
191
|
+
Defaults to None, in which case no cache configuration is used.
|
|
192
|
+
|
|
193
|
+
Returns:
|
|
194
|
+
Self: The composer instance with this step appended.
|
|
195
|
+
'''
|
|
196
|
+
def if_else(self, condition: Component | Callable[[dict[str, Any]], bool], if_branch: BasePipelineStep | list[BasePipelineStep], else_branch: BasePipelineStep | list[BasePipelineStep], input_map: InputMapSpec | None = None, output_state: str | None = None, retry_config: RetryConfig | None = None, error_handler: BaseStepErrorHandler | None = None, cache_store: BaseCache | None = None, cache_config: dict[str, Any] | None = None, name: str | None = None) -> Self:
|
|
197
|
+
"""Append a direct if/else conditional step.
|
|
198
|
+
|
|
199
|
+
This is the direct-style counterpart to the builder returned by `when(...)`.
|
|
200
|
+
Use this when you already have both branches available and prefer a single call.
|
|
201
|
+
|
|
202
|
+
Args:
|
|
203
|
+
condition (Component | Callable[[dict[str, Any]], bool]): The condition to evaluate.
|
|
204
|
+
if_branch (BasePipelineStep | list[BasePipelineStep]): Step(s) to execute if condition is true.
|
|
205
|
+
else_branch (BasePipelineStep | list[BasePipelineStep]): Step(s) to execute if condition is false.
|
|
206
|
+
input_map (InputMapSpec | None, optional): Unified input mapping for the condition. Defaults to None.
|
|
207
|
+
output_state (str | None, optional): Optional state key to store the condition result. Defaults to None.
|
|
208
|
+
retry_config (RetryConfig | None, optional): Configuration for retry behavior using GLLM Core's
|
|
209
|
+
`RetryConfig`. Defaults to None.
|
|
210
|
+
error_handler (BaseStepErrorHandler | None, optional): Strategy to handle errors during execution.
|
|
211
|
+
Defaults to None.
|
|
212
|
+
cache_store (BaseCache | None, optional): Cache store to be used for caching. Defaults to None.
|
|
213
|
+
cache_config (dict[str, Any] | None, optional): Cache configuration to be used for caching.
|
|
214
|
+
Defaults to None.
|
|
215
|
+
name (str | None, optional): A unique identifier for the conditional step. If None, a name will be
|
|
216
|
+
auto-generated. Defaults to None.
|
|
217
|
+
|
|
218
|
+
Returns:
|
|
219
|
+
Self: The composer instance with this step appended.
|
|
220
|
+
"""
|
|
221
|
+
def when(self, condition: Component | Callable[[dict[str, Any]], bool], input_map: InputMapSpec | None = None, output_state: str | None = None, retry_config: RetryConfig | None = None, error_handler: BaseStepErrorHandler | None = None, cache_store: BaseCache | None = None, cache_config: dict[str, Any] | None = None, name: str | None = None) -> IfElseComposer:
|
|
222
|
+
"""Begin an if/else conditional using a fluent builder.
|
|
223
|
+
|
|
224
|
+
Returns an `IfElseComposer` bound to this composer. Use `.then(...)` on the returned
|
|
225
|
+
builder to set the true-branch, `.otherwise(...)` to set the false-branch, and `.end()`
|
|
226
|
+
to finalize and return to the parent composer.
|
|
227
|
+
|
|
228
|
+
Args:
|
|
229
|
+
condition (Component | Callable[[dict[str, Any]], bool]): The condition to evaluate.
|
|
230
|
+
input_map (InputMapSpec | None, optional): Unified input mapping for this conditional. Defaults to None.
|
|
231
|
+
output_state (str | None, optional): Key to store the outcome state. Defaults to None.
|
|
232
|
+
retry_config (RetryConfig | None, optional): Retry behavior configuration. Defaults to None.
|
|
233
|
+
error_handler (BaseStepErrorHandler | None, optional): Error handler. Defaults to None.
|
|
234
|
+
cache_store (BaseCache | None, optional): Cache store to be used for caching. Defaults to None.
|
|
235
|
+
cache_config (dict[str, Any] | None, optional): Cache configuration. Defaults to None.
|
|
236
|
+
name (str | None, optional): Optional name for the step. Defaults to None.
|
|
237
|
+
|
|
238
|
+
Returns:
|
|
239
|
+
IfElseComposer: A builder to define the branches and finalize with `.end()`.
|
|
240
|
+
"""
|
|
241
|
+
@overload
|
|
242
|
+
def switch(self, condition: Component | Callable[[dict[str, Any]], str], *, input_map: InputMapSpec | None = ..., output_state: str | None = ..., retry_config: RetryConfig | None = ..., error_handler: BaseStepErrorHandler | None = ..., cache_store: BaseCache | None = ..., cache_config: dict[str, Any] | None = ..., name: str | None = ...) -> SwitchComposer: ...
|
|
243
|
+
@overload
|
|
244
|
+
def switch(self, condition: Component | Callable[[dict[str, Any]], str], *, branches: dict[str, BasePipelineStep | list['BasePipelineStep']], input_map: InputMapSpec | None = ..., output_state: str | None = ..., default: BasePipelineStep | list['BasePipelineStep'] | None = ..., retry_config: RetryConfig | None = ..., error_handler: BaseStepErrorHandler | None = ..., cache_store: BaseCache | None = ..., cache_config: dict[str, Any] | None = ..., name: str | None = ...) -> Self: ...
|
|
245
|
+
@overload
|
|
246
|
+
def parallel(self, *, squash: bool = ..., input_map: InputMapSpec | None = ..., retry_config: RetryConfig | None = ..., error_handler: BaseStepErrorHandler | None = ..., cache_store: BaseCache | None = ..., cache_config: dict[str, Any] | None = ..., name: str | None = ...) -> ParallelComposer: ...
|
|
247
|
+
@overload
|
|
248
|
+
def parallel(self, *, branches: list['PipelineSteps'] | dict[str, 'PipelineSteps'], squash: bool = ..., input_map: InputMapSpec | None = ..., retry_config: RetryConfig | None = ..., error_handler: BaseStepErrorHandler | None = ..., cache_store: BaseCache | None = ..., cache_config: dict[str, Any] | None = ..., name: str | None = ...) -> Self: ...
|
|
249
|
+
def parallel(self, *, branches: list['PipelineSteps'] | dict[str, 'PipelineSteps'] | None = None, squash: bool = True, input_map: InputMapSpec | None = None, retry_config: RetryConfig | None = None, error_handler: BaseStepErrorHandler | None = None, cache_store: BaseCache | None = None, cache_config: dict[str, Any] | None = None, name: str | None = None) -> Self | ParallelComposer:
|
|
250
|
+
'''Create a parallel step (builder-style or direct-style).
|
|
251
|
+
|
|
252
|
+
This method supports two usage patterns:
|
|
253
|
+
1) Builder-style (no `branches` provided):
|
|
254
|
+
```python
|
|
255
|
+
composer.parallel(input_states=["query"], squash=True, name="p") .fork(step_a) .fork([step_b1, step_b2]) .end()
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
2) Direct-style (provide `branches` list or dict):
|
|
259
|
+
```python
|
|
260
|
+
composer.parallel(
|
|
261
|
+
branches=[step_a, [step_b1, step_b2]],
|
|
262
|
+
input_states=["query"],
|
|
263
|
+
squash=True,
|
|
264
|
+
name="p_direct",
|
|
265
|
+
)
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
Args:
|
|
269
|
+
branches (list[PipelineSteps] | dict[str, PipelineSteps] | None, optional):
|
|
270
|
+
Branches to execute in parallel. Each branch can be a single step or a list of steps to run
|
|
271
|
+
sequentially. If omitted (builder-style), a `ParallelComposer` is returned to define forks via
|
|
272
|
+
`.fork()`; if provided (direct-style), the parallel step is created and appended immediately.
|
|
273
|
+
Defaults to None.
|
|
274
|
+
squash (bool, optional): Whether to squash execution into a single node (async gather). If True, the
|
|
275
|
+
parallel execution is represented by a single node; if False, native graph structures are used.
|
|
276
|
+
Defaults to True.
|
|
277
|
+
input_map (InputMapSpec | None, optional): Unified input mapping for all branches. Defaults to None.
|
|
278
|
+
retry_config (RetryConfig | None, optional): Retry behavior configuration. Defaults to None, in which case
|
|
279
|
+
no retry config is applied.
|
|
280
|
+
error_handler (BaseStepErrorHandler | None, optional): Strategy to handle errors during execution.
|
|
281
|
+
Defaults to None, in which case the default error handler is used.
|
|
282
|
+
cache_store (BaseCache | None, optional): Cache store to be used for caching. Defaults to None, in which
|
|
283
|
+
case no cache store is used.
|
|
284
|
+
cache_config (dict[str, Any] | None, optional): Cache configuration to be used for caching. Defaults to
|
|
285
|
+
None, in which case no cache configuration is used.
|
|
286
|
+
name (str | None, optional): A unique identifier for the parallel step. Defaults to None.
|
|
287
|
+
|
|
288
|
+
Returns:
|
|
289
|
+
ParallelComposer | Self: If `branches` is omitted, returns a `ParallelComposer` builder; otherwise,
|
|
290
|
+
returns the current composer after appending the constructed step.
|
|
291
|
+
'''
|
|
292
|
+
@overload
|
|
293
|
+
def guard(self, condition: Component | Callable[[dict[str, Any]], bool], *, success_branch: BasePipelineStep | list[BasePipelineStep], failure_branch: BasePipelineStep | list[BasePipelineStep] | None = ..., input_map: InputMapSpec | None = ..., output_state: str | None = ..., retry_config: RetryConfig | None = ..., error_handler: BaseStepErrorHandler | None = ..., cache_store: BaseCache | None = ..., cache_config: dict[str, Any] | None = ..., name: str | None = ...) -> Self: ...
|
|
294
|
+
@overload
|
|
295
|
+
def guard(self, condition: Component | Callable[[dict[str, Any]], bool], *, success_branch: None = ..., failure_branch: BasePipelineStep | list[BasePipelineStep] | None = ..., input_map: InputMapSpec | None = ..., output_state: str | None = ..., retry_config: RetryConfig | None = ..., error_handler: BaseStepErrorHandler | None = ..., cache_store: BaseCache | None = ..., cache_config: dict[str, Any] | None = ..., name: str | None = ...) -> GuardComposer: ...
|
|
296
|
+
@overload
|
|
297
|
+
def toggle(self, condition: Component | Callable[[dict[str, Any]], bool] | str, *, if_branch: BasePipelineStep | list[BasePipelineStep], input_map: InputMapSpec | None = ..., output_state: str | None = ..., retry_config: RetryConfig | None = ..., error_handler: BaseStepErrorHandler | None = ..., cache_store: BaseCache | None = ..., cache_config: dict[str, Any] | None = ..., name: str | None = ...) -> Self: ...
|
|
298
|
+
@overload
|
|
299
|
+
def toggle(self, condition: Component | Callable[[dict[str, Any]], bool] | str, *, if_branch: None = ..., input_map: InputMapSpec | None = ..., output_state: str | None = ..., retry_config: RetryConfig | None = ..., error_handler: BaseStepErrorHandler | None = ..., cache_store: BaseCache | None = ..., cache_config: dict[str, Any] | None = ..., name: str | None = ...) -> ToggleComposer: ...
|
|
300
|
+
def toggle(self, condition: Component | Callable[[dict[str, Any]], bool] | str, *, if_branch: BasePipelineStep | list[BasePipelineStep] | None = None, input_map: InputMapSpec | None = None, output_state: str | None = None, retry_config: RetryConfig | None = None, error_handler: BaseStepErrorHandler | None = None, cache_store: BaseCache | None = None, cache_config: dict[str, Any] | None = None, name: str | None = None) -> Self | ToggleComposer:
|
|
301
|
+
"""Create a toggle conditional (builder-style or direct-style).
|
|
302
|
+
|
|
303
|
+
This method supports two usage patterns:
|
|
304
|
+
1) Builder-style (no `if_branch` provided):
|
|
305
|
+
```python
|
|
306
|
+
composer.toggle(condition) .then(enabled_steps) .end()
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
2) Direct-style (provide `if_branch`):
|
|
310
|
+
```python
|
|
311
|
+
composer.toggle(
|
|
312
|
+
condition,
|
|
313
|
+
if_branch=enabled_steps,
|
|
314
|
+
)
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
Args:
|
|
318
|
+
condition (Component | Callable[[dict[str, Any]], bool] | str): The condition to evaluate.
|
|
319
|
+
If a `Component`, it must return a boolean value. If a `Callable`, it must return
|
|
320
|
+
a boolean value. If a `str`, it will be looked up in the merged state data.
|
|
321
|
+
if_branch (BasePipelineStep | list[BasePipelineStep] | None, optional):
|
|
322
|
+
Steps to execute if condition is true. If omitted (builder-style), a `ToggleComposer`
|
|
323
|
+
is returned to define the branch via `.then()`; if provided (direct-style),
|
|
324
|
+
the toggle step is created and appended immediately. Defaults to None, in which case
|
|
325
|
+
a `ToggleComposer` is returned.
|
|
326
|
+
input_map (InputMapSpec | None, optional): Unified input mapping for the condition. Defaults to None.
|
|
327
|
+
output_state (str | None, optional): Optional state key to store the condition result. Defaults to None.
|
|
328
|
+
retry_config (RetryConfig | None, optional): Configuration for retry behavior using GLLM Core's
|
|
329
|
+
`RetryConfig`. Defaults to None.
|
|
330
|
+
error_handler (BaseStepErrorHandler | None, optional): Strategy to handle errors during execution.
|
|
331
|
+
Defaults to None.
|
|
332
|
+
cache_store (BaseCache | None, optional): Cache store to be used for caching. Defaults to None.
|
|
333
|
+
cache_config (dict[str, Any] | None, optional): Cache configuration to be used for caching.
|
|
334
|
+
Defaults to None.
|
|
335
|
+
name (str | None, optional): A unique identifier for the conditional step. If None, a name will be
|
|
336
|
+
auto-generated. Defaults to None.
|
|
337
|
+
|
|
338
|
+
Returns:
|
|
339
|
+
ToggleComposer | Self: If `if_branch` is omitted, returns a `ToggleComposer` builder; otherwise,
|
|
340
|
+
returns the current composer after appending the constructed step.
|
|
341
|
+
"""
|
|
342
|
+
def done(self) -> Pipeline:
|
|
343
|
+
"""Return the composed `Pipeline` instance.
|
|
344
|
+
|
|
345
|
+
This does not build the execution graph. The graph is built when
|
|
346
|
+
`Pipeline.graph` or `Pipeline.build_graph()` is accessed/called.
|
|
347
|
+
|
|
348
|
+
Returns:
|
|
349
|
+
Pipeline: The composed pipeline instance.
|
|
350
|
+
"""
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
from gllm_core.schema import Component as Component
|
|
2
|
+
from gllm_core.utils.retry import RetryConfig as RetryConfig
|
|
3
|
+
from gllm_datastore.cache.cache import BaseCache as BaseCache
|
|
4
|
+
from gllm_pipeline.alias import InputMapSpec as InputMapSpec
|
|
5
|
+
from gllm_pipeline.pipeline.composer.composer import Composer as Composer
|
|
6
|
+
from gllm_pipeline.steps.pipeline_step import BasePipelineStep as BasePipelineStep
|
|
7
|
+
from gllm_pipeline.steps.step_error_handler.step_error_handler import BaseStepErrorHandler as BaseStepErrorHandler
|
|
8
|
+
from typing import Any, Callable, Self
|
|
9
|
+
|
|
10
|
+
class GuardComposer:
|
|
11
|
+
"""Fluent builder for a guard conditional.
|
|
12
|
+
|
|
13
|
+
Usage:
|
|
14
|
+
composer.guard(condition).on_success(success_branch).on_failure(failure_branch).end()
|
|
15
|
+
composer.guard(condition).on_success(success_branch).end() # failure defaults to termination
|
|
16
|
+
|
|
17
|
+
After setting the branches, call `.end()` to append the guard step and
|
|
18
|
+
return back to the parent `Composer`.
|
|
19
|
+
"""
|
|
20
|
+
def __init__(self, parent: Composer, condition: Component | Callable[[dict[str, Any]], bool], output_state: str | None = None, input_map: InputMapSpec | None = None, retry_config: RetryConfig | None = None, error_handler: BaseStepErrorHandler | None = None, cache_store: BaseCache | None = None, cache_config: dict[str, Any] | None = None, name: str | None = None) -> None:
|
|
21
|
+
'''Initialize the GuardComposer.
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
parent (Composer): The parent composer instance.
|
|
25
|
+
condition (Component | Callable[[dict[str, Any]], bool]): The condition to evaluate.
|
|
26
|
+
output_state (str | None, optional): Optional state key to store condition result. Defaults to None.
|
|
27
|
+
input_map (InputMapSpec | None, optional): Unified input mapping for the condition. Defaults to None.
|
|
28
|
+
retry_config (RetryConfig | None, optional): Retry configuration. Defaults to None.
|
|
29
|
+
error_handler (BaseStepErrorHandler | None, optional): Error handler. Defaults to None.
|
|
30
|
+
cache_store (BaseCache | None, optional): Optional cache store. Defaults to None.
|
|
31
|
+
cache_config (dict[str, Any] | None, optional): Optional cache config. Defaults to None.
|
|
32
|
+
name (str | None, optional): Optional name for the resulting step. Defaults to None, in which case
|
|
33
|
+
a name will be auto-generated with the prefix "Guard_".
|
|
34
|
+
'''
|
|
35
|
+
def on_success(self, branch: BasePipelineStep | list[BasePipelineStep]) -> Self:
|
|
36
|
+
"""Define the branch to execute when the condition is true (successful).
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
branch (BasePipelineStep | list[BasePipelineStep]): The step(s) for the success branch.
|
|
40
|
+
|
|
41
|
+
Returns:
|
|
42
|
+
Self: The builder instance for chaining.
|
|
43
|
+
"""
|
|
44
|
+
def on_failure(self, branch: BasePipelineStep | list[BasePipelineStep]) -> Self:
|
|
45
|
+
"""Define the branch to execute when the condition is false (failed).
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
branch (BasePipelineStep | list[BasePipelineStep]): The step(s) for the failure branch.
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
Self: The builder instance for chaining.
|
|
52
|
+
"""
|
|
53
|
+
def end(self) -> Composer:
|
|
54
|
+
"""Finalize and append the guard step to the parent composer.
|
|
55
|
+
|
|
56
|
+
Returns:
|
|
57
|
+
Composer: The parent composer for continued chaining.
|
|
58
|
+
"""
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
from gllm_core.schema import Component as Component
|
|
2
|
+
from gllm_core.utils.retry import RetryConfig as RetryConfig
|
|
3
|
+
from gllm_datastore.cache.cache import BaseCache as BaseCache
|
|
4
|
+
from gllm_pipeline.alias import InputMapSpec as InputMapSpec
|
|
5
|
+
from gllm_pipeline.pipeline.composer.composer import Composer as Composer
|
|
6
|
+
from gllm_pipeline.steps.pipeline_step import BasePipelineStep as BasePipelineStep
|
|
7
|
+
from gllm_pipeline.steps.step_error_handler.step_error_handler import BaseStepErrorHandler as BaseStepErrorHandler
|
|
8
|
+
from typing import Any, Callable, Self
|
|
9
|
+
|
|
10
|
+
class IfElseComposer:
|
|
11
|
+
"""Fluent builder for an if/else conditional.
|
|
12
|
+
|
|
13
|
+
Usage:
|
|
14
|
+
composer.when(cond).then(if_branch).otherwise(else_branch).end()
|
|
15
|
+
|
|
16
|
+
After setting both branches, call `.end()` to append the conditional step and
|
|
17
|
+
return back to the parent `Composer`.
|
|
18
|
+
"""
|
|
19
|
+
def __init__(self, parent: Composer, condition: Component | Callable[[dict[str, Any]], bool], output_state: str | None = None, input_map: InputMapSpec | None = None, retry_config: RetryConfig | None = None, error_handler: BaseStepErrorHandler | None = None, cache_store: BaseCache | None = None, cache_config: dict[str, Any] | None = None, name: str | None = None) -> None:
|
|
20
|
+
'''Initialize the IfElseComposer.
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
parent (Composer): The parent composer instance.
|
|
24
|
+
condition (Component | Callable[[dict[str, Any]], bool]): The condition to evaluate.
|
|
25
|
+
output_state (str | None, optional): Optional state key to store condition result. Defaults to None.
|
|
26
|
+
input_map (InputMapSpec | None, optional): Unified input mapping for the condition. Defaults to None.
|
|
27
|
+
retry_config (RetryConfig | None, optional): Retry configuration. Defaults to None.
|
|
28
|
+
error_handler (BaseStepErrorHandler | None, optional): Error handler. Defaults to None.
|
|
29
|
+
cache_store (BaseCache | None, optional): Optional cache store. Defaults to None.
|
|
30
|
+
cache_config (dict[str, Any] | None, optional): Optional cache config. Defaults to None.
|
|
31
|
+
name (str | None, optional): Optional name for the resulting step. Defaults to None, in which case
|
|
32
|
+
a name will be auto-generated with the prefix "IfElse_".
|
|
33
|
+
'''
|
|
34
|
+
def then(self, branch: BasePipelineStep | list[BasePipelineStep]) -> Self:
|
|
35
|
+
"""Define the branch to execute when the condition is true.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
branch (BasePipelineStep | list[BasePipelineStep]): The step(s) for the true branch.
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
Self: The builder instance for chaining.
|
|
42
|
+
"""
|
|
43
|
+
def otherwise(self, branch: BasePipelineStep | list[BasePipelineStep]) -> Self:
|
|
44
|
+
"""Define the branch to execute when the condition is false.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
branch (BasePipelineStep | list[BasePipelineStep]): The step(s) for the false branch.
|
|
48
|
+
|
|
49
|
+
Returns:
|
|
50
|
+
Self: The builder instance for chaining.
|
|
51
|
+
"""
|
|
52
|
+
def end(self) -> Composer:
|
|
53
|
+
"""Finalize and append the conditional step to the parent composer.
|
|
54
|
+
|
|
55
|
+
Returns:
|
|
56
|
+
Composer: The parent composer for continued chaining.
|
|
57
|
+
"""
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from gllm_core.utils.retry import RetryConfig as RetryConfig
|
|
2
|
+
from gllm_datastore.cache.cache import BaseCache as BaseCache
|
|
3
|
+
from gllm_pipeline.alias import InputMapSpec as InputMapSpec
|
|
4
|
+
from gllm_pipeline.pipeline.composer.composer import Composer as Composer
|
|
5
|
+
from gllm_pipeline.schema import PipelineSteps as PipelineSteps
|
|
6
|
+
from gllm_pipeline.steps.pipeline_step import BasePipelineStep as BasePipelineStep
|
|
7
|
+
from gllm_pipeline.steps.step_error_handler.step_error_handler import BaseStepErrorHandler as BaseStepErrorHandler
|
|
8
|
+
from typing import Any, Self
|
|
9
|
+
|
|
10
|
+
class ParallelComposer:
|
|
11
|
+
'''Fluent builder for a parallel step.
|
|
12
|
+
|
|
13
|
+
Usage:
|
|
14
|
+
composer.parallel(name="p").fork(step_a).fork([step_b1, step_b2]).end()
|
|
15
|
+
|
|
16
|
+
The builder collects forks as branches and constructs a `ParallelStep`
|
|
17
|
+
using the functional helper `_func.parallel(...)`.
|
|
18
|
+
'''
|
|
19
|
+
def __init__(self, parent: Composer, *, squash: bool = True, input_map: InputMapSpec | None = None, retry_config: RetryConfig | None = None, error_handler: BaseStepErrorHandler | None = None, cache_store: BaseCache | None = None, cache_config: dict[str, Any] | None = None, name: str | None = None) -> None:
|
|
20
|
+
"""Initialize the ParallelComposer.
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
parent (Composer): The parent composer instance.
|
|
24
|
+
squash (bool, optional): Whether to squash execution into a single node (async gather).
|
|
25
|
+
Defaults to True.
|
|
26
|
+
input_map (InputMapSpec | None, optional): Unified input mapping for all branches. Defaults to None.
|
|
27
|
+
retry_config (RetryConfig | None, optional): Retry configuration. Defaults to None.
|
|
28
|
+
error_handler (BaseStepErrorHandler | None, optional): Error handler. Defaults to None.
|
|
29
|
+
cache_store (BaseCache | None, optional): Optional cache store. Defaults to None.
|
|
30
|
+
cache_config (dict[str, Any] | None, optional): Optional cache config. Defaults to None.
|
|
31
|
+
name (str | None, optional): Optional name for the resulting step. Defaults to None.
|
|
32
|
+
"""
|
|
33
|
+
def fork(self, branch: BasePipelineStep | list[BasePipelineStep]) -> Self:
|
|
34
|
+
"""Add a fork (branch) to execute in parallel.
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
branch (BasePipelineStep | list[BasePipelineStep]): Step(s) for this fork.
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
Self: The builder instance for chaining.
|
|
41
|
+
"""
|
|
42
|
+
def end(self) -> Composer:
|
|
43
|
+
"""Finalize and append the parallel step to the parent composer.
|
|
44
|
+
|
|
45
|
+
Returns:
|
|
46
|
+
Composer: The parent composer for continued chaining.
|
|
47
|
+
"""
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
from gllm_core.schema import Component as Component
|
|
2
|
+
from gllm_core.utils.retry import RetryConfig as RetryConfig
|
|
3
|
+
from gllm_datastore.cache.cache import BaseCache as BaseCache
|
|
4
|
+
from gllm_pipeline.alias import InputMapSpec as InputMapSpec
|
|
5
|
+
from gllm_pipeline.pipeline.composer.composer import Composer as Composer
|
|
6
|
+
from gllm_pipeline.steps.pipeline_step import BasePipelineStep as BasePipelineStep
|
|
7
|
+
from gllm_pipeline.steps.step_error_handler.step_error_handler import BaseStepErrorHandler as BaseStepErrorHandler
|
|
8
|
+
from typing import Any, Callable, Self
|
|
9
|
+
|
|
10
|
+
class SwitchComposer:
|
|
11
|
+
'''Fluent builder for a switch conditional.
|
|
12
|
+
|
|
13
|
+
Usage:
|
|
14
|
+
composer.switch(cond).case("A", step_a).case("B", step_b).end()
|
|
15
|
+
|
|
16
|
+
Optionally call `.default(...)` to set a fallback branch.
|
|
17
|
+
'''
|
|
18
|
+
def __init__(self, parent: Composer, condition: Component | Callable[[dict[str, Any]], str], output_state: str | None = None, input_map: InputMapSpec | None = None, retry_config: RetryConfig | None = None, error_handler: BaseStepErrorHandler | None = None, cache_store: BaseCache | None = None, cache_config: dict[str, Any] | None = None, name: str | None = None) -> None:
|
|
19
|
+
'''Initialize the SwitchComposer.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
parent (Composer): The parent composer instance.
|
|
23
|
+
condition (Component | Callable[[dict[str, Any]], str]): The condition to evaluate.
|
|
24
|
+
output_state (str | None, optional): Optional state key to store condition result. Defaults to None.
|
|
25
|
+
input_map (InputMapSpec | None, optional): Unified input mapping for the condition. Defaults to None.
|
|
26
|
+
retry_config (RetryConfig | None, optional): Retry configuration. Defaults to None.
|
|
27
|
+
error_handler (BaseStepErrorHandler | None, optional): Error handler. Defaults to None.
|
|
28
|
+
cache_store (BaseCache | None, optional): Optional cache store. Defaults to None.
|
|
29
|
+
cache_config (dict[str, Any] | None, optional): Optional cache config. Defaults to None.
|
|
30
|
+
name (str | None, optional): Optional name for the resulting step. Defaults to None, in which case
|
|
31
|
+
a name will be auto-generated with the prefix "Switch_".
|
|
32
|
+
'''
|
|
33
|
+
def case(self, key: str, branch: BasePipelineStep | list[BasePipelineStep]) -> Self:
|
|
34
|
+
"""Add a case branch.
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
key (str): Case key to match against condition result.
|
|
38
|
+
branch (BasePipelineStep | list[BasePipelineStep]): Step(s) to execute for this case.
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
Self: The builder instance for chaining.
|
|
42
|
+
"""
|
|
43
|
+
def default(self, branch: BasePipelineStep | list[BasePipelineStep]) -> Self:
|
|
44
|
+
"""Set the default branch for unmatched cases.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
branch (BasePipelineStep | list[BasePipelineStep]): Default fallback branch.
|
|
48
|
+
|
|
49
|
+
Returns:
|
|
50
|
+
Self: The builder instance for chaining.
|
|
51
|
+
"""
|
|
52
|
+
def end(self) -> Composer:
|
|
53
|
+
"""Finalize and append the switch conditional to the parent composer.
|
|
54
|
+
|
|
55
|
+
Returns:
|
|
56
|
+
Composer: The parent composer for continued chaining.
|
|
57
|
+
"""
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
from gllm_core.schema import Component as Component
|
|
2
|
+
from gllm_core.utils.retry import RetryConfig as RetryConfig
|
|
3
|
+
from gllm_datastore.cache.cache import BaseCache as BaseCache
|
|
4
|
+
from gllm_pipeline.alias import InputMapSpec as InputMapSpec
|
|
5
|
+
from gllm_pipeline.pipeline.composer.composer import Composer as Composer
|
|
6
|
+
from gllm_pipeline.steps.pipeline_step import BasePipelineStep as BasePipelineStep
|
|
7
|
+
from gllm_pipeline.steps.step_error_handler.step_error_handler import BaseStepErrorHandler as BaseStepErrorHandler
|
|
8
|
+
from typing import Any, Callable, Self
|
|
9
|
+
|
|
10
|
+
class ToggleComposer:
|
|
11
|
+
"""Fluent builder for a toggle conditional.
|
|
12
|
+
|
|
13
|
+
Usage:
|
|
14
|
+
composer.toggle(condition).then(enabled_branch).end()
|
|
15
|
+
|
|
16
|
+
After setting the enabled branch, call `.end()` to append the toggle step and
|
|
17
|
+
return back to the parent `Composer`.
|
|
18
|
+
"""
|
|
19
|
+
def __init__(self, parent: Composer, condition: Component | Callable[[dict[str, Any]], bool] | str, output_state: str | None = None, input_map: InputMapSpec | None = None, retry_config: RetryConfig | None = None, error_handler: BaseStepErrorHandler | None = None, cache_store: BaseCache | None = None, cache_config: dict[str, Any] | None = None, name: str | None = None) -> None:
|
|
20
|
+
'''Initialize the ToggleComposer.
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
parent (Composer): The parent composer instance.
|
|
24
|
+
condition (Component | Callable[[dict[str, Any]], bool] | str): The condition to evaluate.
|
|
25
|
+
output_state (str | None, optional): Optional state key to store condition result. Defaults to None.
|
|
26
|
+
input_map (InputMapSpec | None, optional): Unified input mapping for the condition. Defaults to None.
|
|
27
|
+
retry_config (RetryConfig | None, optional): Retry configuration. Defaults to None.
|
|
28
|
+
error_handler (BaseStepErrorHandler | None, optional): Error handler. Defaults to None.
|
|
29
|
+
cache_store (BaseCache | None, optional): Optional cache store. Defaults to None.
|
|
30
|
+
cache_config (dict[str, Any] | None, optional): Optional cache config. Defaults to None.
|
|
31
|
+
name (str | None, optional): Optional name for the resulting step. Defaults to None, in which case
|
|
32
|
+
a name will be auto-generated with the prefix "Toggle_".
|
|
33
|
+
'''
|
|
34
|
+
def then(self, branch: BasePipelineStep | list[BasePipelineStep]) -> Self:
|
|
35
|
+
"""Define the branch to execute when the condition is true.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
branch (BasePipelineStep | list[BasePipelineStep]): The step(s) for the enabled branch.
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
Self: The builder instance for chaining.
|
|
42
|
+
"""
|
|
43
|
+
def end(self) -> Composer:
|
|
44
|
+
"""Finalize and append the toggle step to the parent composer.
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
Composer: The parent composer for continued chaining.
|
|
48
|
+
"""
|
|
@@ -105,7 +105,7 @@ class Pipeline:
|
|
|
105
105
|
steps: Incomplete
|
|
106
106
|
recursion_limit: Incomplete
|
|
107
107
|
name: Incomplete
|
|
108
|
-
def __init__(self, steps: list[BasePipelineStep], state_type: TypedDict | type[BaseModel] = ..., input_type: TypedDict | type[BaseModel] | None = None, output_type: TypedDict | type[BaseModel] | None = None, recursion_limit: int = 30, name: str | None = None, cache_store: BaseCache | None = None, cache_config: dict[str, Any] | None = None) -> None:
|
|
108
|
+
def __init__(self, steps: list[BasePipelineStep] | None = None, state_type: TypedDict | type[BaseModel] = ..., input_type: TypedDict | type[BaseModel] | None = None, output_type: TypedDict | type[BaseModel] | None = None, recursion_limit: int = 30, name: str | None = None, cache_store: BaseCache | None = None, cache_config: dict[str, Any] | None = None) -> None:
|
|
109
109
|
'''Initializes the Pipeline with the given steps and state type.
|
|
110
110
|
|
|
111
111
|
Args:
|
|
@@ -176,6 +176,24 @@ class Pipeline:
|
|
|
176
176
|
Returns:
|
|
177
177
|
ExclusionManager: The exclusion manager for this pipeline.
|
|
178
178
|
"""
|
|
179
|
+
@property
|
|
180
|
+
def composer(self) -> Composer:
|
|
181
|
+
"""Get a Composer instance that manages this pipeline.
|
|
182
|
+
|
|
183
|
+
The Composer provides a fluent API for building pipelines by chaining
|
|
184
|
+
step-adding methods. It allows for easy composition of pipeline steps
|
|
185
|
+
in a readable, chainable manner.
|
|
186
|
+
|
|
187
|
+
Returns:
|
|
188
|
+
Composer: A composer instance that manages this pipeline.
|
|
189
|
+
"""
|
|
190
|
+
def clear(self) -> None:
|
|
191
|
+
"""Clears the pipeline by resetting steps, graph, and app to their initial state.
|
|
192
|
+
|
|
193
|
+
This method resets the pipeline to an empty state, clearing all steps and
|
|
194
|
+
invalidating any built graph or compiled app. Useful for reusing a pipeline
|
|
195
|
+
instance with different configurations.
|
|
196
|
+
"""
|
|
179
197
|
async def invoke(self, initial_state: dict[str, Any] | BaseModel, config: dict[str, Any] | None = None) -> dict[str, Any]:
|
|
180
198
|
'''Runs the pipeline asynchronously with the given initial state and configuration.
|
|
181
199
|
|
|
Binary file
|
gllm_pipeline.pyi
CHANGED
|
@@ -11,11 +11,16 @@ __name__ = ...
|
|
|
11
11
|
import os
|
|
12
12
|
import __future__
|
|
13
13
|
import pydantic
|
|
14
|
-
import asyncio
|
|
15
|
-
import copy
|
|
16
14
|
import typing
|
|
17
15
|
import gllm_core
|
|
16
|
+
import gllm_core.schema
|
|
18
17
|
import gllm_core.utils
|
|
18
|
+
import gllm_core.utils.retry
|
|
19
|
+
import gllm_datastore
|
|
20
|
+
import gllm_datastore.cache
|
|
21
|
+
import gllm_datastore.cache.cache
|
|
22
|
+
import asyncio
|
|
23
|
+
import copy
|
|
19
24
|
import gllm_core.utils.imports
|
|
20
25
|
import gllm_core.utils.logger_manager
|
|
21
26
|
import gllm_inference
|
|
@@ -24,12 +29,11 @@ import langgraph
|
|
|
24
29
|
import langgraph.graph
|
|
25
30
|
import langgraph.graph.state
|
|
26
31
|
import gllm_pipeline.exclusions.ExclusionManager
|
|
32
|
+
import gllm_pipeline.pipeline.composer.Composer
|
|
27
33
|
import gllm_core.event
|
|
28
34
|
import gllm_core.event.event_emitter
|
|
29
35
|
import random
|
|
30
36
|
import string
|
|
31
|
-
import gllm_core.schema
|
|
32
|
-
import gllm_core.utils.retry
|
|
33
37
|
import abc
|
|
34
38
|
import functools
|
|
35
39
|
import inspect
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: gllm-pipeline-binary
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.18
|
|
4
4
|
Summary: A library containing components related to Gen AI applications pipeline orchestration.
|
|
5
5
|
Author-email: Dimitrij Ray <dimitrij.ray@gdplabs.id>, Henry Wicaksono <henry.wicaksono@gdplabs.id>, Kadek Denaya <kadek.d.r.diana@gdplabs.id>
|
|
6
6
|
Requires-Python: <3.13,>=3.11
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
gllm_pipeline.cp312-win_amd64.pyd,sha256=
|
|
2
|
-
gllm_pipeline.pyi,sha256=
|
|
1
|
+
gllm_pipeline.cp312-win_amd64.pyd,sha256=ViARHONPCsEeMKM5d96xnZJR89FtN42V65gNgDd3A6w,1572352
|
|
2
|
+
gllm_pipeline.pyi,sha256=aentP4mHbDiRLyQ5Sn84-1sVyTbaLL9Vq60I1quEXNo,1108
|
|
3
3
|
gllm_pipeline/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
gllm_pipeline/alias.pyi,sha256=MbRJJjogWHp6PAmtoi_1xrRmxkvGq4C_NllWk8sYiog,272
|
|
5
5
|
gllm_pipeline/types.pyi,sha256=CV3cEAxlNsnVatYz5iCxqmEFPEqeKW5vv-qUD3FpF54,241
|
|
@@ -7,8 +7,15 @@ gllm_pipeline/exclusions/__init__.pyi,sha256=_LwIlqmH4Iiksn7p09d2vZG4Ek8CdKC8UcD
|
|
|
7
7
|
gllm_pipeline/exclusions/exclusion_manager.pyi,sha256=DzoL-2KeTRmFgJEo8rzYViFYKbzZVTZGJmKvzaoTC0M,2960
|
|
8
8
|
gllm_pipeline/exclusions/exclusion_set.pyi,sha256=11XTt6IfkHpzomcNybA78SfWlp752Z3AGhXfm2rL0Fk,1685
|
|
9
9
|
gllm_pipeline/pipeline/__init__.pyi,sha256=1IKGdMvmLWEiOOmAKFNUPm-gdw13zrnU1gs7tDNzgEU,168
|
|
10
|
-
gllm_pipeline/pipeline/pipeline.pyi,sha256=
|
|
10
|
+
gllm_pipeline/pipeline/pipeline.pyi,sha256=ykxgXD38TM9X5mXsPmzJSMxsCKoV6Q_tRbuRDk0bVXg,14226
|
|
11
11
|
gllm_pipeline/pipeline/states.pyi,sha256=EiyfBPwrVDZ336w5wyD1q8W4E6G1uZNzsP-bzrHDumo,6464
|
|
12
|
+
gllm_pipeline/pipeline/composer/__init__.pyi,sha256=-hcOUQgpTRt1QjQfRurTf-UApFnTrhilx6vN-gYd5J0,666
|
|
13
|
+
gllm_pipeline/pipeline/composer/composer.pyi,sha256=foztmOTsqdd6CW1CY4QQrObe2shy_yvEopz_knwAmFk,26697
|
|
14
|
+
gllm_pipeline/pipeline/composer/guard_composer.pyi,sha256=YfbXmzyU3CwAvGnCfM-6MVcTdxk53-j6Cv3IdzNr_-c,3335
|
|
15
|
+
gllm_pipeline/pipeline/composer/if_else_composer.pyi,sha256=uGyd1S7P5uXdER_fAzVIftg0yovZjMbN-L9JxgHxZNw,3196
|
|
16
|
+
gllm_pipeline/pipeline/composer/parallel_composer.pyi,sha256=rL6dc9Rm1Bzo_Acl0yLEEUZZQmNmfuNNpU4jhjt3Yzg,2593
|
|
17
|
+
gllm_pipeline/pipeline/composer/switch_composer.pyi,sha256=he78REg0v3Sguv89VTUck9Q3jpFYSg_9Xh0MUki9TxY,3146
|
|
18
|
+
gllm_pipeline/pipeline/composer/toggle_composer.pyi,sha256=7tEEDSSwOoPeiyYeFSjLqsamLtS-enuXsqBFIrjCNYA,2835
|
|
12
19
|
gllm_pipeline/steps/__init__.pyi,sha256=f_dgel-CsDow7nSWYQDVTQYOogwvty8tEeh2lZautqM,1967
|
|
13
20
|
gllm_pipeline/steps/_func.pyi,sha256=fKL6aCobBmjo7vznRKJeeML4VmJtoQhD8G5L5vG3Pao,60843
|
|
14
21
|
gllm_pipeline/steps/branching_step.pyi,sha256=iNarrcZgWfiRdr8CJfGm8GzUlYq13Rx5cgYXnBsNWN4,1041
|
|
@@ -39,7 +46,7 @@ gllm_pipeline/utils/mermaid.pyi,sha256=B096GTXxVAO--kw3UDsbysOsnjGOytYfozX39YaM2
|
|
|
39
46
|
gllm_pipeline/utils/retry_converter.pyi,sha256=JPUuaGzKpVLshrbhX9rQHYl5XmC9GDa59rGU-FtOpWM,1128
|
|
40
47
|
gllm_pipeline/utils/step_execution.pyi,sha256=8dGj6_VAHT7cgmg8QPJN65XDKTu3Kj4NTtkDM_AF7GA,930
|
|
41
48
|
gllm_pipeline.build/.gitignore,sha256=aEiIwOuxfzdCmLZe4oB1JsBmCUxwG8x-u-HBCV9JT8E,1
|
|
42
|
-
gllm_pipeline_binary-0.4.
|
|
43
|
-
gllm_pipeline_binary-0.4.
|
|
44
|
-
gllm_pipeline_binary-0.4.
|
|
45
|
-
gllm_pipeline_binary-0.4.
|
|
49
|
+
gllm_pipeline_binary-0.4.18.dist-info/METADATA,sha256=vQOhDqu4EmBX6XZC5fYlLDyr2dlK1ExS6LOdztrXgD8,3454
|
|
50
|
+
gllm_pipeline_binary-0.4.18.dist-info/WHEEL,sha256=x5rgv--I0NI0IT1Lh9tN1VG2cI637p3deednwYLKnxc,96
|
|
51
|
+
gllm_pipeline_binary-0.4.18.dist-info/top_level.txt,sha256=C3yeOtoE6ZhuOnBEq_FFc_Rp954IHJBlB6fBgSdAWYI,14
|
|
52
|
+
gllm_pipeline_binary-0.4.18.dist-info/RECORD,,
|
|
File without changes
|
{gllm_pipeline_binary-0.4.17.dist-info → gllm_pipeline_binary-0.4.18.dist-info}/top_level.txt
RENAMED
|
File without changes
|