gllm-pipeline-binary 0.4.21__cp312-cp312-macosx_13_0_arm64.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.
Files changed (77) hide show
  1. gllm_pipeline/__init__.pyi +0 -0
  2. gllm_pipeline/alias.pyi +7 -0
  3. gllm_pipeline/exclusions/__init__.pyi +4 -0
  4. gllm_pipeline/exclusions/exclusion_manager.pyi +74 -0
  5. gllm_pipeline/exclusions/exclusion_set.pyi +46 -0
  6. gllm_pipeline/pipeline/__init__.pyi +4 -0
  7. gllm_pipeline/pipeline/composer/__init__.pyi +8 -0
  8. gllm_pipeline/pipeline/composer/composer.pyi +350 -0
  9. gllm_pipeline/pipeline/composer/guard_composer.pyi +58 -0
  10. gllm_pipeline/pipeline/composer/if_else_composer.pyi +57 -0
  11. gllm_pipeline/pipeline/composer/parallel_composer.pyi +47 -0
  12. gllm_pipeline/pipeline/composer/switch_composer.pyi +57 -0
  13. gllm_pipeline/pipeline/composer/toggle_composer.pyi +48 -0
  14. gllm_pipeline/pipeline/pipeline.pyi +280 -0
  15. gllm_pipeline/pipeline/states.pyi +139 -0
  16. gllm_pipeline/router/__init__.pyi +6 -0
  17. gllm_pipeline/router/aurelio_semantic_router/__init__.pyi +3 -0
  18. gllm_pipeline/router/aurelio_semantic_router/aurelio_semantic_router.pyi +86 -0
  19. gllm_pipeline/router/aurelio_semantic_router/bytes_compat_route.pyi +40 -0
  20. gllm_pipeline/router/aurelio_semantic_router/encoders/__init__.pyi +5 -0
  21. gllm_pipeline/router/aurelio_semantic_router/encoders/em_invoker_encoder.pyi +46 -0
  22. gllm_pipeline/router/aurelio_semantic_router/encoders/langchain_encoder.pyi +50 -0
  23. gllm_pipeline/router/aurelio_semantic_router/encoders/tei_encoder.pyi +49 -0
  24. gllm_pipeline/router/aurelio_semantic_router/index/__init__.pyi +4 -0
  25. gllm_pipeline/router/aurelio_semantic_router/index/aurelio_index.pyi +65 -0
  26. gllm_pipeline/router/aurelio_semantic_router/index/azure_ai_search_aurelio_index.pyi +71 -0
  27. gllm_pipeline/router/aurelio_semantic_router/index/vector_store_adapter_index.pyi +119 -0
  28. gllm_pipeline/router/lm_based_router.pyi +60 -0
  29. gllm_pipeline/router/preset/__init__.pyi +0 -0
  30. gllm_pipeline/router/preset/aurelio/__init__.pyi +0 -0
  31. gllm_pipeline/router/preset/aurelio/router_image_domain_specific.pyi +21 -0
  32. gllm_pipeline/router/preset/lm_based/__init__.pyi +0 -0
  33. gllm_pipeline/router/preset/lm_based/router_image_domain_specific.pyi +14 -0
  34. gllm_pipeline/router/preset/preset_loader.pyi +24 -0
  35. gllm_pipeline/router/router.pyi +46 -0
  36. gllm_pipeline/router/rule_based_router.pyi +80 -0
  37. gllm_pipeline/router/similarity_based_router.pyi +72 -0
  38. gllm_pipeline/router/utils.pyi +26 -0
  39. gllm_pipeline/steps/__init__.pyi +17 -0
  40. gllm_pipeline/steps/_func.pyi +958 -0
  41. gllm_pipeline/steps/branching_step.pyi +24 -0
  42. gllm_pipeline/steps/component_step.pyi +82 -0
  43. gllm_pipeline/steps/composite_step.pyi +65 -0
  44. gllm_pipeline/steps/conditional_step.pyi +161 -0
  45. gllm_pipeline/steps/guard_step.pyi +71 -0
  46. gllm_pipeline/steps/log_step.pyi +53 -0
  47. gllm_pipeline/steps/map_reduce_step.pyi +92 -0
  48. gllm_pipeline/steps/no_op_step.pyi +40 -0
  49. gllm_pipeline/steps/parallel_step.pyi +128 -0
  50. gllm_pipeline/steps/pipeline_step.pyi +231 -0
  51. gllm_pipeline/steps/state_operator_step.pyi +75 -0
  52. gllm_pipeline/steps/step_error_handler/__init__.pyi +6 -0
  53. gllm_pipeline/steps/step_error_handler/empty_step_error_handler.pyi +20 -0
  54. gllm_pipeline/steps/step_error_handler/fallback_step_error_handler.pyi +24 -0
  55. gllm_pipeline/steps/step_error_handler/keep_step_error_handler.pyi +9 -0
  56. gllm_pipeline/steps/step_error_handler/raise_step_error_handler.pyi +9 -0
  57. gllm_pipeline/steps/step_error_handler/step_error_handler.pyi +46 -0
  58. gllm_pipeline/steps/subgraph_step.pyi +90 -0
  59. gllm_pipeline/steps/terminator_step.pyi +57 -0
  60. gllm_pipeline/types.pyi +10 -0
  61. gllm_pipeline/utils/__init__.pyi +9 -0
  62. gllm_pipeline/utils/async_utils.pyi +21 -0
  63. gllm_pipeline/utils/copy.pyi +11 -0
  64. gllm_pipeline/utils/error_handling.pyi +61 -0
  65. gllm_pipeline/utils/graph.pyi +16 -0
  66. gllm_pipeline/utils/has_inputs_mixin.pyi +50 -0
  67. gllm_pipeline/utils/input_map.pyi +12 -0
  68. gllm_pipeline/utils/mermaid.pyi +29 -0
  69. gllm_pipeline/utils/retry_converter.pyi +25 -0
  70. gllm_pipeline/utils/step_execution.pyi +19 -0
  71. gllm_pipeline.build/.gitignore +1 -0
  72. gllm_pipeline.cpython-312-darwin.so +0 -0
  73. gllm_pipeline.pyi +86 -0
  74. gllm_pipeline_binary-0.4.21.dist-info/METADATA +105 -0
  75. gllm_pipeline_binary-0.4.21.dist-info/RECORD +77 -0
  76. gllm_pipeline_binary-0.4.21.dist-info/WHEEL +5 -0
  77. gllm_pipeline_binary-0.4.21.dist-info/top_level.txt +1 -0
File without changes
@@ -0,0 +1,7 @@
1
+ from gllm_pipeline.steps.pipeline_step import BasePipelineStep as BasePipelineStep
2
+ from gllm_pipeline.types import Val as Val
3
+ from typing import TypeAlias
4
+
5
+ PipelineSteps: TypeAlias
6
+ PipelineState: TypeAlias
7
+ InputMapSpec: TypeAlias
@@ -0,0 +1,4 @@
1
+ from gllm_pipeline.exclusions.exclusion_manager import ExclusionManager as ExclusionManager
2
+ from gllm_pipeline.exclusions.exclusion_set import ExclusionSet as ExclusionSet
3
+
4
+ __all__ = ['ExclusionSet', 'ExclusionManager']
@@ -0,0 +1,74 @@
1
+ from _typeshed import Incomplete
2
+ from gllm_pipeline.exclusions.exclusion_set import ExclusionSet as ExclusionSet
3
+ from gllm_pipeline.pipeline.pipeline import Pipeline as Pipeline
4
+
5
+ class ExclusionManager:
6
+ """Exclusion manager for managing exclusions in a pipeline.
7
+
8
+ This class provides a high-level interface for managing step exclusions in a pipeline.
9
+ It handles the creation of exclusion sets, application to pipeline steps, and graph
10
+ rebuilding when exclusions change.
11
+
12
+ Attributes:
13
+ pipeline (Pipeline): The pipeline instance to manage exclusions for.
14
+ """
15
+ pipeline: Incomplete
16
+ def __init__(self, pipeline: Pipeline) -> None:
17
+ """Initialize the exclusion manager.
18
+
19
+ Args:
20
+ pipeline: The pipeline instance to manage exclusions for.
21
+ """
22
+ def exclude(self, *paths: str) -> None:
23
+ """Exclude one or more paths from execution.
24
+
25
+ This method creates an exclusion set from the provided paths, applies the
26
+ exclusions to all pipeline steps, updates the pipeline's exclusion state,
27
+ and rebuilds the graph to reflect the new structure.
28
+
29
+ Notes:
30
+ This operation REPLACES the current exclusion set with the provided paths
31
+ (it is not additive).
32
+
33
+ Args:
34
+ *paths: Variable number of dot-notation paths to exclude.
35
+ """
36
+ def include(self, *paths: str) -> None:
37
+ """Include (un-exclude) one or more paths.
38
+
39
+ This method removes the specified paths from the current exclusions by
40
+ getting the current exclusion list, filtering out the specified paths,
41
+ and applying the remaining exclusions.
42
+
43
+ Notes:
44
+ 1. Mutually exclusive with `exclude` in intent: `include` removes from
45
+ the existing exclusion set, whereas `exclude` replaces the entire set.
46
+ 2. If there are no current exclusions, calling `include` is a no-op.
47
+
48
+ Args:
49
+ *paths: Variable number of dot-notation paths to include (un-exclude).
50
+ """
51
+ def clear(self) -> None:
52
+ """Clear all exclusions.
53
+
54
+ This method removes all current exclusions from the pipeline, effectively
55
+ including all steps in execution.
56
+ """
57
+ def list_excluded(self) -> list[str]:
58
+ """List currently excluded steps.
59
+
60
+ This method iterates through all pipeline steps and returns the names
61
+ of steps that are currently marked as excluded.
62
+
63
+ Returns:
64
+ list[str]: List of step names that are currently excluded.
65
+ """
66
+ def get_current_exclusions(self) -> list[str]:
67
+ """Get current exclusion paths.
68
+
69
+ This method returns the list of paths that are currently excluded
70
+ in the pipeline. If no exclusions are set, returns an empty list.
71
+
72
+ Returns:
73
+ list[str]: List of currently excluded paths.
74
+ """
@@ -0,0 +1,46 @@
1
+ from pydantic import BaseModel
2
+
3
+ class ExclusionSet(BaseModel):
4
+ """Simple set of excluded step paths.
5
+
6
+ This class manages a collection of step paths that should be excluded from execution.
7
+ It provides methods to check if paths are excluded and to extract child exclusions
8
+ for hierarchical step structures.
9
+
10
+ Attributes:
11
+ excluded_paths (set[str]): The set of excluded step paths.
12
+ """
13
+ excluded_paths: set[str]
14
+ @classmethod
15
+ def from_list(cls, paths: list[str]) -> ExclusionSet:
16
+ """Create exclusion set from list of paths.
17
+
18
+ Args:
19
+ paths: List of dot-notation paths to exclude.
20
+
21
+ Returns:
22
+ ExclusionSet: New exclusion set containing the provided paths.
23
+ """
24
+ def is_excluded(self, path: str) -> bool:
25
+ """Check if a path is excluded.
26
+
27
+ Args:
28
+ path: The step path to check for exclusion.
29
+
30
+ Returns:
31
+ bool: True if the path is excluded, False otherwise.
32
+ """
33
+ def get_child_exclusions(self, parent_path: str) -> ExclusionSet:
34
+ '''Get exclusions for children of a parent path.
35
+
36
+ This method extracts all exclusions that apply to children of the specified
37
+ parent path. For example, if the exclusion set contains "parent.child1" and
38
+ "parent.child2.grandchild", calling this method with "parent" will return
39
+ an ExclusionSet containing "child1" and "child2.grandchild".
40
+
41
+ Args:
42
+ parent_path: The parent path to get child exclusions for.
43
+
44
+ Returns:
45
+ ExclusionSet: New exclusion set containing only child exclusions.
46
+ '''
@@ -0,0 +1,4 @@
1
+ from gllm_pipeline.pipeline.pipeline import Pipeline as Pipeline
2
+ from gllm_pipeline.pipeline.states import RAGState as RAGState
3
+
4
+ __all__ = ['Pipeline', 'RAGState']
@@ -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
+ """