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
@@ -0,0 +1,128 @@
1
+ from _typeshed import Incomplete
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, PipelineSteps as PipelineSteps
5
+ from gllm_pipeline.steps.branching_step import BranchingStep as BranchingStep
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 gllm_pipeline.utils.copy import safe_deepcopy as safe_deepcopy
9
+ from gllm_pipeline.utils.error_handling import ValidationError as ValidationError, create_error_context as create_error_context
10
+ from gllm_pipeline.utils.graph import create_edge as create_edge
11
+ from gllm_pipeline.utils.has_inputs_mixin import HasInputsMixin as HasInputsMixin
12
+ from gllm_pipeline.utils.input_map import shallow_dump as shallow_dump
13
+ from gllm_pipeline.utils.mermaid import MERMAID_HEADER as MERMAID_HEADER
14
+ from gllm_pipeline.utils.step_execution import execute_sequential_steps as execute_sequential_steps
15
+ from langgraph.graph import StateGraph as StateGraph
16
+ from langgraph.runtime import Runtime as Runtime
17
+ from langgraph.types import RetryPolicy as RetryPolicy
18
+ from pydantic import BaseModel as BaseModel
19
+ from typing import Any
20
+
21
+ class ParallelStep(BranchingStep, HasInputsMixin):
22
+ """A pipeline step that executes multiple branches in parallel.
23
+
24
+ This step wraps multiple branches and executes them concurrently, then merges their results.
25
+ Each branch can be either a single step or a list of steps to be executed sequentially.
26
+
27
+ The step supports two execution modes controlled by the `squash` parameter:
28
+ 1. Squashed (default): Uses asyncio.gather() to run branches in parallel within a single LangGraph node. Use for:
29
+ a. Better raw performance
30
+ b. Simpler implementation
31
+ c. Less overhead
32
+ d. Less transparent for debugging and tracing
33
+ 2. Expanded (squash=False): Creates a native LangGraph structure with multiple parallel paths. Use for:
34
+ a. More native LangGraph integration
35
+ b. More transparent for debugging and tracing
36
+
37
+ For memory optimization, you can specify input_states to pass only specific keys to branches.
38
+ This is especially useful when the state is large but branches only need specific parts of it.
39
+ If input_states is None (default), all state keys will be passed.
40
+
41
+ Attributes:
42
+ name (str): A unique identifier for this pipeline step.
43
+ branches (dict[str, PipelineSteps]): The branches to execute in parallel.
44
+ input_map (dict[str, str | Val] | None): Unified input map.
45
+ squash (bool): Whether to squash execution into a single node.
46
+ 1. If True, uses asyncio.gather() to run branches in parallel. This will create a single node.
47
+ 2. If False, uses native LangGraph structures for parallelism. This will create multiple nodes.
48
+ retry_policy (RetryPolicy | None): Configuration for retry behavior using LangGraph's RetryPolicy.
49
+ """
50
+ squash: Incomplete
51
+ branches: Incomplete
52
+ def __init__(self, name: str, branches: list[PipelineSteps] | dict[str, PipelineSteps], input_states: list[str] | None = None, squash: bool = True, runtime_config_map: dict[str, str] | None = None, fixed_args: dict[str, Any] | 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) -> None:
53
+ '''Initialize a new ParallelStep.
54
+
55
+ Args:
56
+ name (str): A unique identifier for this pipeline step.
57
+ branches (list | dict[str, PipelineSteps]): The branches to execute in parallel. Can be either:
58
+ **List format:**
59
+ Each branch can be:
60
+ 1. A single step
61
+ 2. A list of steps to execute sequentially
62
+ Example: [step1, [step2, step3], step4]
63
+ **Dict format:**
64
+ Keys are branch names, values can be:
65
+ 1. A single step
66
+ 2. A list of steps to execute sequentially
67
+ Example: {"analysis": step1, "validation": [step2, step3], "cleanup": step4}
68
+ Enables more intuitive step exclusion using branch names.
69
+ input_states (list[str] | None, optional): Keys from the state to pass to branches.
70
+ If None, all state keys will be passed. Defaults to None.
71
+ squash (bool, optional): Whether to squash execution into a single node.
72
+ 1. If True, uses asyncio.gather() to run branches in parallel. This will create a single node.
73
+ 2. If False, uses native LangGraph structures for parallelism. This will create multiple nodes.
74
+ Defaults to True.
75
+ runtime_config_map (dict[str, str] | None, optional): Mapping of input keys to runtime config keys.
76
+ Defaults to None.
77
+ fixed_args (dict[str, Any] | None, optional): Fixed arguments to be passed to the component.
78
+ Defaults to None, in which case an empty dictionary is used.
79
+ input_map (InputMapSpec | None, optional):
80
+ Unified input map. Can be a dict (arg -> str|Val) or a list with elements:
81
+ 1. str for identity mapping
82
+ 2. dict[str, str] for state/config mapping
83
+ 3. dict[str, Val] for fixed args.
84
+ Defaults to None.
85
+ retry_config (RetryConfig | None, optional): Configuration for retry behavior using
86
+ GLLM Core\'s RetryConfig. Defaults to None, in which case no retry config is applied.
87
+ error_handler (BaseStepErrorHandler | None, optional): Strategy to handle errors during execution.
88
+ Defaults to None, in which case the RaiseStepErrorHandler is used.
89
+ cache_store ("BaseCache" | None, optional): Cache store to be used for caching.
90
+ Defaults to None, in which case no cache store is used.
91
+ cache_config (dict[str, Any] | None, optional): Cache configuration to be used for caching.
92
+ Defaults to None, in which case no cache configuration is used.
93
+ '''
94
+ def add_to_graph(self, graph: StateGraph, previous_endpoints: list[str], retry_policy: RetryPolicy | None = None) -> list[str]:
95
+ """Handle both squashed and expanded modes.
96
+
97
+ For squashed mode: add the parallel step as a single node.
98
+ For expanded mode: add the parallel step as a single node and add children to graph.
99
+
100
+ Args:
101
+ graph (StateGraph): The graph to add this step to.
102
+ previous_endpoints (list[str]): Endpoints from previous steps to connect to.
103
+ retry_policy (RetryPolicy | None, optional): Retry policy to propagate to child steps.
104
+ Defaults to None, in which case the retry policy of the step is used.
105
+
106
+ Returns:
107
+ list[str]: Exit points after adding all child steps.
108
+ """
109
+ async def execute(self, state: dict[str, Any], runtime: Runtime[dict[str, Any] | BaseModel]) -> dict[str, Any] | None:
110
+ """Execute all branches in parallel and merge their results.
111
+
112
+ This method is only used for the squashed approach. For the expanded approach,
113
+ the execution is handled by the graph structure.
114
+
115
+ Args:
116
+ state (dict[str, Any]): The current state of the pipeline.
117
+ runtime (Runtime[dict[str, Any] | BaseModel]): Runtime information for this step's execution.
118
+
119
+ Returns:
120
+ dict[str, Any] | None: The merged results from all parallel branches, or None if no updates were produced.
121
+
122
+ Raises:
123
+ asyncio.CancelledError: If execution is cancelled, preserved with added context.
124
+ BaseInvokerError: If an error occurs during LM invocation.
125
+ RuntimeError: For all other exceptions during execution, wrapped with context information.
126
+ TimeoutError: If execution times out, preserved with added context.
127
+ ValidationError: If input validation fails.
128
+ """
@@ -0,0 +1,231 @@
1
+ import abc
2
+ from _typeshed import Incomplete
3
+ from abc import ABC, abstractmethod
4
+ from gllm_core.utils.retry import RetryConfig as RetryConfig
5
+ from gllm_datastore.cache.cache import BaseCache as BaseCache
6
+ from gllm_pipeline.alias import PipelineState as PipelineState
7
+ from gllm_pipeline.exclusions import ExclusionSet as ExclusionSet
8
+ from gllm_pipeline.pipeline.pipeline import Pipeline as Pipeline
9
+ from gllm_pipeline.steps.step_error_handler import RaiseStepErrorHandler as RaiseStepErrorHandler
10
+ from gllm_pipeline.steps.step_error_handler.step_error_handler import BaseStepErrorHandler as BaseStepErrorHandler
11
+ from gllm_pipeline.utils.error_handling import ErrorContext as ErrorContext
12
+ from gllm_pipeline.utils.graph import create_edge as create_edge
13
+ from gllm_pipeline.utils.retry_converter import retry_config_to_langgraph_policy as retry_config_to_langgraph_policy
14
+ from langgraph.graph import StateGraph as StateGraph
15
+ from langgraph.runtime import Runtime as Runtime
16
+ from langgraph.types import RetryPolicy as RetryPolicy
17
+ from pydantic import BaseModel as BaseModel
18
+ from typing import Any
19
+
20
+ LANGGRAPH_CONFIG_PREFIX: str
21
+
22
+ class BasePipelineStep(ABC, metaclass=abc.ABCMeta):
23
+ '''The base class for all pipeline steps.
24
+
25
+ A pipeline step represents a single operation or task within a larger processing pipeline.
26
+ Each step must implement:
27
+ 1. execute() - to perform the actual operation
28
+ 2. add_to_graph() - to integrate with the pipeline structure (optional, default implementation provided)
29
+
30
+ The default implementation of add_to_graph is suitable for steps that:
31
+ 1. Have a single entry point
32
+ 2. Have a single exit point
33
+ 3. Connect to all previous endpoints
34
+
35
+ For more complex graph structures (e.g., conditional branching), steps should override add_to_graph.
36
+
37
+ Examples:
38
+ 1. Basic Usage:
39
+ ```python
40
+ step = MyCustomStep("my_step")
41
+ ```
42
+
43
+ 2. Adding Step Level Caching:
44
+ ```python
45
+ step = MyCustomStep(
46
+ "my_step",
47
+ cache_store=cache_store,
48
+ cache_config={"ttl": 1800}
49
+ )
50
+
51
+ 3. Retry Configuration:
52
+ ```python
53
+ retry_config = RetryConfig(max_retries=3, backoff_factor=2)
54
+ step = MyCustomStep(
55
+ "my_step",
56
+ retry_config=retry_config
57
+ )
58
+ ```
59
+
60
+ 4. Error Handling:
61
+ ```python
62
+ step = MyCustomStep(
63
+ "my_step",
64
+ error_handler=error_handler
65
+ )
66
+ ```
67
+
68
+ Attributes:
69
+ name (str): A unique identifier for the pipeline step.
70
+ retry_policy (RetryPolicy | None): Configuration for retry behavior using LangGraph\'s RetryPolicy.
71
+ cache_store ("BaseCache" | None): The cache store used for caching step results, if configured.
72
+ is_cache_enabled (bool): Property indicating whether caching is enabled for this step.
73
+ '''
74
+ name: Incomplete
75
+ error_handler: Incomplete
76
+ retry_policy: Incomplete
77
+ cache_store: Incomplete
78
+ def __init__(self, name: str, retry_config: RetryConfig | None = None, error_handler: BaseStepErrorHandler | None = None, cache_store: BaseCache | None = None, cache_config: dict[str, Any] | None = None) -> None:
79
+ '''Initializes a new pipeline step.
80
+
81
+ Args:
82
+ name (str): A unique identifier for the pipeline step.
83
+ retry_config (RetryConfig | None, optional): Configuration for retry behavior using
84
+ GLLM Core\'s RetryConfig. Defaults to None, in which case no retry config is applied.
85
+ The RetryConfig is automatically converted to LangGraph\'s RetryPolicy when needed for internal use.
86
+ Note that `timeout` is not supported and will be ignored.
87
+ error_handler (BaseStepErrorHandler | None, optional): Strategy to handle errors during execution.
88
+ Defaults to None, in which case the RaiseStepErrorHandler is used.
89
+ cache_store ("BaseCache" | None, optional): The cache store to use for caching step results.
90
+ Defaults to None. If None, no caching will be used.
91
+ cache_config (dict[str, Any] | None, optional): Configuration for the cache store.
92
+ 1. key_func: A function to generate cache keys. If None, the cache instance will use its own key
93
+ function.
94
+ 2. name: The name of the cache. If None, the cache instance will use its own key function.
95
+ 3. ttl: The time-to-live for the cache. If None, the cache will not have a TTL.
96
+ 4. matching_strategy: The strategy for matching cache keys.
97
+ If None, the cache instance will use "exact".
98
+ 5. matching_config: Configuration for the matching strategy.
99
+ If None, the cache instance will use its own default matching strategy configuration.
100
+
101
+ Caching Mechanism:
102
+ When a cache_store is provided, the step\'s execution method is automatically
103
+ wrapped with a cache decorator. This means:
104
+ 1. Before execution, the cache is checked for existing results based on input parameters
105
+ 2. If a cached result exists and is valid, it\'s returned immediately
106
+ 3. If no cached result exists, the step executes normally and the result is cached
107
+ 4. Cache keys are generated from the step\'s input state and configuration
108
+ 5. The cache name defaults to "step_{step_name}" if not specified
109
+ '''
110
+ @property
111
+ def is_cache_enabled(self) -> bool:
112
+ """Check if this step has caching enabled.
113
+
114
+ Returns:
115
+ bool: True if caching is enabled, False otherwise.
116
+ """
117
+ @property
118
+ def is_excluded(self) -> bool:
119
+ """Whether this step is excluded from execution/graph integration.
120
+
121
+ Returns:
122
+ bool: True if the step is excluded, False otherwise.
123
+ """
124
+ @is_excluded.setter
125
+ def is_excluded(self, value: bool) -> None:
126
+ """Set the exclusion state for this step.
127
+
128
+ Args:
129
+ value (bool): Exclusion flag.
130
+ """
131
+ def add_to_graph(self, graph: StateGraph, previous_endpoints: list[str], retry_policy: RetryPolicy | None = None) -> list[str]:
132
+ """Integrates this step into the pipeline's internal structure.
133
+
134
+ This method is responsible for:
135
+ 1. Adding the step's node(s) to the graph if not already present
136
+ 2. Creating edges from previous endpoints to this step's entry points
137
+ 3. Returning this step's exit points (endpoints)
138
+
139
+ This method provides a default implementation suitable for simple steps.
140
+ Steps with more complex graph structures should override this method.
141
+
142
+ This method is used by `Pipeline` to manage the pipeline's execution flow.
143
+ It should not be called directly by users.
144
+
145
+ Args:
146
+ graph (StateGraph): The internal representation of the pipeline structure.
147
+ previous_endpoints (list[str]): The endpoints from previous steps to connect to.
148
+ retry_policy (RetryPolicy | None): Configuration for retry behavior using LangGraph's RetryPolicy.
149
+ If None, the retry policy of the step is used. If the step is not a retryable step,
150
+ this parameter is ignored.
151
+
152
+ Returns:
153
+ list[str]: The exit points (endpoints) of this step.
154
+ """
155
+ @abstractmethod
156
+ async def execute(self, state: PipelineState, runtime: Runtime[dict[str, Any] | BaseModel]) -> dict[str, Any] | None:
157
+ """Executes the operation defined for this pipeline step.
158
+
159
+ This method should be implemented by subclasses to perform the actual processing or computation for this step.
160
+
161
+ Args:
162
+ state (PipelineState): The current state of the pipeline, containing all data.
163
+ runtime (Runtime[dict[str, Any] | BaseModel]): Runtime information for this step's execution.
164
+
165
+ Returns:
166
+ dict[str, Any] | None: The update to the pipeline state after this step's operation.
167
+ This should include new or modified data produced by this step, not the entire state.
168
+ Returns None if no state update is needed.
169
+
170
+ Raises:
171
+ NotImplementedError: If the subclass does not implement this method.
172
+ """
173
+ async def execute_direct(self, state: dict[str, Any], runtime: Runtime[dict[str, Any] | BaseModel]) -> dict[str, Any] | None:
174
+ """Execute this step directly, bypassing graph-based execution.
175
+
176
+ This method is used when a step needs to be executed directly, such as in parallel execution.
177
+ The default implementation calls _execute_with_error_handling for consistent error handling.
178
+
179
+ Args:
180
+ state (dict[str, Any]): The current state of the pipeline.
181
+ runtime (Runtime[dict[str, Any] | BaseModel]): Runtime information for this step's execution.
182
+
183
+ Returns:
184
+ dict[str, Any] | None: Updates to apply to the pipeline state, or None if no updates.
185
+ """
186
+ def apply_exclusions(self, exclusions: ExclusionSet) -> None:
187
+ """Apply exclusions to this step.
188
+
189
+ Args:
190
+ exclusions (ExclusionSet): The exclusion set to apply.
191
+ """
192
+ def get_mermaid_diagram(self) -> str:
193
+ """Generates a Mermaid diagram representation of the pipeline step.
194
+
195
+ This method provides a default implementation that can be overridden by subclasses
196
+ to provide more detailed or specific diagrams.
197
+
198
+ It is recommended to implement this method for subclasses that have multiple connections to other steps.
199
+
200
+ Returns:
201
+ str: Empty string.
202
+ """
203
+ def __or__(self, other: BasePipelineStep | Pipeline) -> Pipeline:
204
+ """Combines this step with another step or pipeline.
205
+
206
+ This method allows for easy composition of pipeline steps using the | operator.
207
+
208
+ Args:
209
+ other (BasePipelineStep | Pipeline): Another step or pipeline to combine with this one.
210
+
211
+ Returns:
212
+ Pipeline: A new pipeline containing the combined steps.
213
+ """
214
+ def __lshift__(self, other: BasePipelineStep | Pipeline) -> Pipeline:
215
+ """Combines this step with another step or pipeline using the '<<' operator.
216
+
217
+ Args:
218
+ other (BasePipelineStep | Pipeline): The step or pipeline to add after this step.
219
+
220
+ Returns:
221
+ Pipeline: A new pipeline with this step followed by the other step or pipeline.
222
+ """
223
+ def __rshift__(self, other: BasePipelineStep | Pipeline) -> Pipeline:
224
+ """Combines this step with another step or pipeline using the '>>' operator.
225
+
226
+ Args:
227
+ other (BasePipelineStep | Pipeline): The step or pipeline to include this step in.
228
+
229
+ Returns:
230
+ Pipeline: A new pipeline with this step included in the other step or pipeline.
231
+ """
@@ -0,0 +1,75 @@
1
+ from _typeshed import Incomplete
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, PipelineState as PipelineState
5
+ from gllm_pipeline.steps.pipeline_step import BasePipelineStep as BasePipelineStep
6
+ from gllm_pipeline.steps.step_error_handler.step_error_handler import BaseStepErrorHandler as BaseStepErrorHandler
7
+ from gllm_pipeline.utils.async_utils import execute_callable as execute_callable
8
+ from gllm_pipeline.utils.error_handling import ErrorContext as ErrorContext
9
+ from gllm_pipeline.utils.has_inputs_mixin import HasInputsMixin as HasInputsMixin
10
+ from gllm_pipeline.utils.input_map import shallow_dump as shallow_dump
11
+ from langgraph.runtime import Runtime
12
+ from pydantic import BaseModel as BaseModel
13
+ from typing import Any, Callable
14
+
15
+ class StateOperatorStep(BasePipelineStep, HasInputsMixin):
16
+ """A pipeline step that performs an operation on the pipeline state and updates it.
17
+
18
+ This step executes a given operation using selected data from the current pipeline state and runtime configuration,
19
+ then updates the state with the operation's result.
20
+
21
+ Attributes:
22
+ name (str): A unique identifier for this pipeline step.
23
+ input_map (dict[str, str | Val] | None): Unified input map.
24
+ output_state (str | list[str]): Key(s) to store the operation result in the pipeline state.
25
+ operation (Callable[[dict[str, Any]], Any]): The operation to execute.
26
+ Accepts a dictionary of input data, which consists of the extracted state and runtime configuration.
27
+ retry_policy (RetryPolicy | None): Configuration for retry behavior using LangGraph's RetryPolicy.
28
+ """
29
+ output_state: Incomplete
30
+ operation: Incomplete
31
+ def __init__(self, name: str, input_states: list[str] | None = None, output_state: str | list[str] | None = None, operation: Callable[[dict[str, Any]], Any] | None = None, runtime_config_map: dict[str, str] | None = None, fixed_args: dict[str, Any] | 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) -> None:
32
+ '''Initializes a new StateOperatorStep.
33
+
34
+ Args:
35
+ name (str): A unique identifier for this pipeline step.
36
+ input_states (list[str]): Keys of the state data required by the operation.
37
+ output_state (str | list[str]): Key(s) to store the operation result in the pipeline state.
38
+ operation (Callable[[dict[str, Any]], Any]): The operation to execute.
39
+ It should accept a dictionary of input data and return the operation result.
40
+ runtime_config_map (dict[str, str] | None, optional): Mapping of operation input arguments to
41
+ runtime configuration keys. Defaults to None.
42
+ fixed_args (dict[str, Any] | None, optional): Fixed arguments to be passed to the operation.
43
+ Defaults to None.
44
+ input_map (InputMapSpec | None, optional):
45
+ Unified input map. Can be a dict (arg -> str|Val) or a list with elements:
46
+ 1. str for identity mapping
47
+ 2. dict[str, str] for state/config mapping
48
+ 3. dict[str, Val] for fixed args.
49
+ Defaults to None.
50
+ retry_config (RetryConfig | None, optional): Configuration for retry behavior using
51
+ GLLM Core\'s RetryConfig. Defaults to None, in which case no retry config is applied.
52
+ error_handler (BaseStepErrorHandler | None, optional): Strategy to handle errors during execution.
53
+ Defaults to None, in which case the RaiseStepErrorHandler is used.
54
+ cache_store ("BaseCache" | None, optional): Cache store to be used for caching.
55
+ Defaults to None, in which case no cache store is used.
56
+ cache_config (dict[str, Any] | None, optional): Cache configuration to be used for caching.
57
+ Defaults to None, in which case no cache configuration is used.
58
+ '''
59
+ async def execute(self, state: PipelineState, runtime: Runtime[dict[str, Any] | BaseModel]) -> dict[str, Any]:
60
+ """Executes the operation and processes its output.
61
+
62
+ This method validates inputs, prepares data, executes the operation, and formats the output for integration
63
+ into the pipeline state.
64
+
65
+ Args:
66
+ state (PipelineState): The current state of the pipeline, containing all data.
67
+ runtime (Runtime[dict[str, Any] | BaseModel]): Runtime information for this step's execution.
68
+
69
+ Returns:
70
+ dict[str, Any]: The update to the pipeline state after this step's operation.
71
+ This includes new or modified data produced by the operation, not the entire state.
72
+
73
+ Raises:
74
+ RuntimeError: If an error occurs during operation execution.
75
+ """
@@ -0,0 +1,6 @@
1
+ from gllm_pipeline.steps.step_error_handler.empty_step_error_handler import EmptyStepErrorHandler as EmptyStepErrorHandler
2
+ from gllm_pipeline.steps.step_error_handler.fallback_step_error_handler import FallbackStepErrorHandler as FallbackStepErrorHandler
3
+ from gllm_pipeline.steps.step_error_handler.keep_step_error_handler import KeepStepErrorHandler as KeepStepErrorHandler
4
+ from gllm_pipeline.steps.step_error_handler.raise_step_error_handler import RaiseStepErrorHandler as RaiseStepErrorHandler
5
+
6
+ __all__ = ['EmptyStepErrorHandler', 'FallbackStepErrorHandler', 'KeepStepErrorHandler', 'RaiseStepErrorHandler']
@@ -0,0 +1,20 @@
1
+ from _typeshed import Incomplete
2
+ from gllm_pipeline.steps.step_error_handler.step_error_handler import BaseStepErrorHandler as BaseStepErrorHandler
3
+ from gllm_pipeline.utils.error_handling import ErrorContext as ErrorContext
4
+ from langgraph.runtime import Runtime as Runtime
5
+ from pydantic import BaseModel as BaseModel
6
+
7
+ class EmptyStepErrorHandler(BaseStepErrorHandler):
8
+ """Strategy that replace the current state of the output states to None on error.
9
+
10
+ Attributes:
11
+ output_state (list[str]): Output key(s) to map input values to.
12
+ """
13
+ output_state: Incomplete
14
+ def __init__(self, output_state: str | list[str]) -> None:
15
+ """Initialize the strategy with optional output state mapping.
16
+
17
+ Args:
18
+ output_state (str | list[str]): Output key(s) to map input values to.
19
+ Can be a single string, list of strings.
20
+ """
@@ -0,0 +1,24 @@
1
+ from _typeshed import Incomplete
2
+ from gllm_pipeline.steps.step_error_handler.step_error_handler import BaseStepErrorHandler as BaseStepErrorHandler
3
+ from gllm_pipeline.utils.error_handling import ErrorContext as ErrorContext
4
+ from langgraph.runtime import Runtime as Runtime
5
+ from pydantic import BaseModel as BaseModel
6
+ from typing import Any, Callable
7
+
8
+ class FallbackStepErrorHandler(BaseStepErrorHandler):
9
+ """Strategy that executes a fallback callable on error.
10
+
11
+ Attributes:
12
+ fallback (Callable[[Exception, dict[str, Any], Runtime[dict[str, Any] | BaseModel], ErrorContext], Any]):
13
+ A callable that generates the fallback state dynamically.
14
+ It should accept (error, state, runtime, context) and return a fallback state.
15
+ """
16
+ fallback: Incomplete
17
+ def __init__(self, fallback: Callable[[Exception, dict[str, Any], Runtime[dict[str, Any] | BaseModel], ErrorContext], Any]) -> None:
18
+ """Initialize the strategy with a fallback callable.
19
+
20
+ Args:
21
+ fallback (Callable[[Exception, dict[str, Any], Runtime[dict[str, Any] | BaseModel], ErrorContext], Any]):
22
+ A callable that generates the fallback state dynamically.
23
+ It should accept (error, state, runtime, context) and return a fallback state.
24
+ """
@@ -0,0 +1,9 @@
1
+ from gllm_pipeline.steps.step_error_handler.step_error_handler import BaseStepErrorHandler as BaseStepErrorHandler
2
+ from gllm_pipeline.utils.error_handling import ErrorContext as ErrorContext
3
+ from langgraph.runtime import Runtime as Runtime
4
+ from pydantic import BaseModel as BaseModel
5
+
6
+ class KeepStepErrorHandler(BaseStepErrorHandler):
7
+ """Strategy that preserves the current state on error."""
8
+ def __init__(self) -> None:
9
+ """Initialize the keep error handler."""
@@ -0,0 +1,9 @@
1
+ from gllm_pipeline.steps.step_error_handler.step_error_handler import BaseStepErrorHandler as BaseStepErrorHandler
2
+ from gllm_pipeline.utils.error_handling import ErrorContext as ErrorContext
3
+ from langgraph.runtime import Runtime as Runtime
4
+ from pydantic import BaseModel as BaseModel
5
+
6
+ class RaiseStepErrorHandler(BaseStepErrorHandler):
7
+ """Strategy that raises exceptions with enhanced context."""
8
+ def __init__(self) -> None:
9
+ """Initialize the raise error handler."""
@@ -0,0 +1,46 @@
1
+ import abc
2
+ from _typeshed import Incomplete
3
+ from abc import ABC
4
+ from gllm_pipeline.utils.error_handling import ErrorContext as ErrorContext
5
+ from langgraph.runtime import Runtime as Runtime
6
+ from pydantic import BaseModel as BaseModel
7
+ from typing import Any
8
+
9
+ class BaseStepErrorHandler(ABC, metaclass=abc.ABCMeta):
10
+ """Abstract base class for error handling strategies.
11
+
12
+ Attributes:
13
+ log_level (int): The logging level to use when logging errors.
14
+ logger (logging.Logger): The logger to use when logging errors.
15
+ """
16
+ log_level: Incomplete
17
+ logger: Incomplete
18
+ def __init__(self, log_level: int = ...) -> None:
19
+ """Initialize the error handler with a specific log level.
20
+
21
+ Args:
22
+ log_level (int): The logging level to use when logging errors.
23
+ Defaults to logging.ERROR. Common values:
24
+ 1. logging.DEBUG: Detailed information for debugging.
25
+ 2. logging.INFO: General information messages.
26
+ 3. logging.WARNING: Warning messages.
27
+ 4. logging.ERROR: Error messages (default).
28
+ 5. logging.CRITICAL: Critical error messages.
29
+ """
30
+ def handle(self, error: Exception, state: dict[str, Any], runtime: Runtime[dict[str, Any] | BaseModel], context: ErrorContext) -> dict[str, Any] | None:
31
+ """Handle an error that occurred during pipeline step execution.
32
+
33
+ This method logs the error first, then delegates to the concrete implementation.
34
+
35
+ Args:
36
+ error (Exception): The exception that was raised.
37
+ state (dict[str, Any]): The current pipeline state when the error occurred.
38
+ runtime (Runtime[dict[str, Any] | BaseModel]): Runtime information for this step's execution.
39
+ context (ErrorContext): Additional context about the error.
40
+
41
+ Returns:
42
+ dict[str, Any] | None: State updates to apply, or None if no updates needed.
43
+
44
+ Raises:
45
+ Exception: May raise exceptions based on the strategy implementation.
46
+ """
@@ -0,0 +1,90 @@
1
+ from _typeshed import Incomplete
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, PipelineState as PipelineState
5
+ from gllm_pipeline.exclusions import ExclusionSet as ExclusionSet
6
+ from gllm_pipeline.pipeline.pipeline import Pipeline as Pipeline
7
+ from gllm_pipeline.steps.composite_step import BaseCompositeStep as BaseCompositeStep
8
+ from gllm_pipeline.steps.pipeline_step import BasePipelineStep as BasePipelineStep
9
+ from gllm_pipeline.steps.step_error_handler.step_error_handler import BaseStepErrorHandler as BaseStepErrorHandler
10
+ from gllm_pipeline.utils.error_handling import ErrorContext as ErrorContext
11
+ from gllm_pipeline.utils.has_inputs_mixin import HasInputsMixin as HasInputsMixin
12
+ from gllm_pipeline.utils.input_map import shallow_dump as shallow_dump
13
+ from langgraph.runtime import Runtime as Runtime
14
+ from pydantic import BaseModel as BaseModel
15
+ from typing import Any
16
+
17
+ class SubgraphStep(BaseCompositeStep, HasInputsMixin):
18
+ """A pipeline step that executes another pipeline as a subgraph.
19
+
20
+ This step allows for encapsulation and reuse of pipeline logic by treating another pipeline as a step.
21
+ The subgraph can have its own state schema, and this step handles the mapping between the parent and
22
+ subgraph states.
23
+
24
+ Attributes:
25
+ name (str): A unique identifier for this pipeline step.
26
+ subgraph (Pipeline): The pipeline to be executed as a subgraph.
27
+ input_map (dict[str, str | Val] | None): Unified input map.
28
+ output_state_map (dict[str, str]): Mapping of parent pipeline state keys to subgraph output keys.
29
+ retry_policy (RetryPolicy | None): Configuration for retry behavior using LangGraph's RetryPolicy.
30
+ """
31
+ subgraph: Incomplete
32
+ output_state_map: Incomplete
33
+ def __init__(self, name: str, subgraph: Pipeline, input_state_map: dict[str, str] | None = None, output_state_map: dict[str, str] | None = None, runtime_config_map: dict[str, str] | None = None, fixed_args: dict[str, Any] | 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) -> None:
34
+ '''Initializes a new SubgraphStep.
35
+
36
+ Args:
37
+ name (str): A unique identifier for this pipeline step.
38
+ subgraph (Pipeline): The pipeline to be executed as a subgraph.
39
+ input_state_map (dict[str, str]): Mapping of subgraph input keys to parent pipeline state keys.
40
+ Defaults to None.
41
+ output_state_map (dict[str, str] | None, optional): Mapping of parent pipeline state keys to
42
+ subgraph output keys. Defaults to None.
43
+ runtime_config_map (dict[str, str] | None, optional): Mapping of subgraph input keys to runtime
44
+ configuration keys. Defaults to None, in which case an empty dictionary is used.
45
+ fixed_args (dict[str, Any] | None, optional): Fixed arguments to be passed to the subgraph.
46
+ Defaults to None, in which case an empty dictionary is used.
47
+ input_map (InputMapSpec | None, optional):
48
+ Unified input map. Can be a dict (arg -> str|Val) or a list with elements:
49
+ 1. str for identity mapping
50
+ 2. dict[str, str] for state/config mapping
51
+ 3. dict[str, Val] for fixed args.
52
+ Defaults to None.
53
+ retry_config (RetryConfig | None, optional): Configuration for retry behavior using the SDK\'s RetryConfig.
54
+ If None, no retry policy is applied.
55
+ error_handler (BaseStepErrorHandler | None, optional): Error handler to be used for this step.
56
+ If None, no error handler is applied.
57
+ cache_store ("BaseCache" | None, optional): Cache store to be used for caching.
58
+ Defaults to None, in which case no cache store is used.
59
+ cache_config (dict[str, Any] | None, optional): Cache configuration to be used for caching.
60
+ Defaults to None, in which case no cache configuration is used.
61
+ '''
62
+ async def execute(self, state: PipelineState, runtime: Runtime[dict[str, Any] | BaseModel]) -> dict[str, Any]:
63
+ """Executes the subgraph and processes its output.
64
+
65
+ This method prepares data, executes the subgraph, and formats the output for integration
66
+ into the parent pipeline state. It only uses keys that are actually present in the state,
67
+ ignoring missing keys to prevent errors.
68
+
69
+ Args:
70
+ state (PipelineState): The current state of the pipeline, containing all data.
71
+ runtime (Runtime[dict[str, Any] | BaseModel]): Runtime information for this step's execution.
72
+
73
+ Returns:
74
+ dict[str, Any]: The update to the pipeline state after this step's operation.
75
+ This includes new or modified data produced by the subgraph, not the entire state.
76
+ If a requested output key is not present in the subgraph result, its value will be None.
77
+
78
+ Raises:
79
+ RuntimeError: If an error occurs during subgraph execution, with details about which step caused the error.
80
+ """
81
+ is_excluded: Incomplete
82
+ def apply_exclusions(self, exclusions: ExclusionSet) -> None:
83
+ """Apply exclusions to this subgraph and its children.
84
+
85
+ Subgraph has no internal structural changes. It marks itself and
86
+ uniformly propagates child exclusions to all subgraph steps.
87
+
88
+ Args:
89
+ exclusions (ExclusionSet): The exclusion set to apply.
90
+ """