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.
- gllm_pipeline/__init__.pyi +0 -0
- gllm_pipeline/alias.pyi +7 -0
- gllm_pipeline/exclusions/__init__.pyi +4 -0
- gllm_pipeline/exclusions/exclusion_manager.pyi +74 -0
- gllm_pipeline/exclusions/exclusion_set.pyi +46 -0
- gllm_pipeline/pipeline/__init__.pyi +4 -0
- 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 +280 -0
- gllm_pipeline/pipeline/states.pyi +139 -0
- gllm_pipeline/router/__init__.pyi +6 -0
- gllm_pipeline/router/aurelio_semantic_router/__init__.pyi +3 -0
- gllm_pipeline/router/aurelio_semantic_router/aurelio_semantic_router.pyi +86 -0
- gllm_pipeline/router/aurelio_semantic_router/bytes_compat_route.pyi +40 -0
- gllm_pipeline/router/aurelio_semantic_router/encoders/__init__.pyi +5 -0
- gllm_pipeline/router/aurelio_semantic_router/encoders/em_invoker_encoder.pyi +46 -0
- gllm_pipeline/router/aurelio_semantic_router/encoders/langchain_encoder.pyi +50 -0
- gllm_pipeline/router/aurelio_semantic_router/encoders/tei_encoder.pyi +49 -0
- gllm_pipeline/router/aurelio_semantic_router/index/__init__.pyi +4 -0
- gllm_pipeline/router/aurelio_semantic_router/index/aurelio_index.pyi +65 -0
- gllm_pipeline/router/aurelio_semantic_router/index/azure_ai_search_aurelio_index.pyi +71 -0
- gllm_pipeline/router/aurelio_semantic_router/index/vector_store_adapter_index.pyi +119 -0
- gllm_pipeline/router/lm_based_router.pyi +60 -0
- gllm_pipeline/router/preset/__init__.pyi +0 -0
- gllm_pipeline/router/preset/aurelio/__init__.pyi +0 -0
- gllm_pipeline/router/preset/aurelio/router_image_domain_specific.pyi +21 -0
- gllm_pipeline/router/preset/lm_based/__init__.pyi +0 -0
- gllm_pipeline/router/preset/lm_based/router_image_domain_specific.pyi +14 -0
- gllm_pipeline/router/preset/preset_loader.pyi +24 -0
- gllm_pipeline/router/router.pyi +46 -0
- gllm_pipeline/router/rule_based_router.pyi +80 -0
- gllm_pipeline/router/similarity_based_router.pyi +72 -0
- gllm_pipeline/router/utils.pyi +26 -0
- gllm_pipeline/steps/__init__.pyi +17 -0
- gllm_pipeline/steps/_func.pyi +958 -0
- gllm_pipeline/steps/branching_step.pyi +24 -0
- gllm_pipeline/steps/component_step.pyi +82 -0
- gllm_pipeline/steps/composite_step.pyi +65 -0
- gllm_pipeline/steps/conditional_step.pyi +161 -0
- gllm_pipeline/steps/guard_step.pyi +71 -0
- gllm_pipeline/steps/log_step.pyi +53 -0
- gllm_pipeline/steps/map_reduce_step.pyi +92 -0
- gllm_pipeline/steps/no_op_step.pyi +40 -0
- gllm_pipeline/steps/parallel_step.pyi +128 -0
- gllm_pipeline/steps/pipeline_step.pyi +231 -0
- gllm_pipeline/steps/state_operator_step.pyi +75 -0
- gllm_pipeline/steps/step_error_handler/__init__.pyi +6 -0
- gllm_pipeline/steps/step_error_handler/empty_step_error_handler.pyi +20 -0
- gllm_pipeline/steps/step_error_handler/fallback_step_error_handler.pyi +24 -0
- gllm_pipeline/steps/step_error_handler/keep_step_error_handler.pyi +9 -0
- gllm_pipeline/steps/step_error_handler/raise_step_error_handler.pyi +9 -0
- gllm_pipeline/steps/step_error_handler/step_error_handler.pyi +46 -0
- gllm_pipeline/steps/subgraph_step.pyi +90 -0
- gllm_pipeline/steps/terminator_step.pyi +57 -0
- gllm_pipeline/types.pyi +10 -0
- gllm_pipeline/utils/__init__.pyi +9 -0
- gllm_pipeline/utils/async_utils.pyi +21 -0
- gllm_pipeline/utils/copy.pyi +11 -0
- gllm_pipeline/utils/error_handling.pyi +61 -0
- gllm_pipeline/utils/graph.pyi +16 -0
- gllm_pipeline/utils/has_inputs_mixin.pyi +50 -0
- gllm_pipeline/utils/input_map.pyi +12 -0
- gllm_pipeline/utils/mermaid.pyi +29 -0
- gllm_pipeline/utils/retry_converter.pyi +25 -0
- gllm_pipeline/utils/step_execution.pyi +19 -0
- gllm_pipeline.build/.gitignore +1 -0
- gllm_pipeline.cpython-312-darwin.so +0 -0
- gllm_pipeline.pyi +86 -0
- gllm_pipeline_binary-0.4.21.dist-info/METADATA +105 -0
- gllm_pipeline_binary-0.4.21.dist-info/RECORD +77 -0
- gllm_pipeline_binary-0.4.21.dist-info/WHEEL +5 -0
- gllm_pipeline_binary-0.4.21.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from _typeshed import Incomplete
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
PRESET_REGISTRY: Incomplete
|
|
5
|
+
|
|
6
|
+
def get_preset(router_type: str, modality: str, preset_name: str, **kwargs: Any) -> dict[str, Any]:
|
|
7
|
+
'''Retrieve and execute a preset function based on router configuration.
|
|
8
|
+
|
|
9
|
+
This function looks up a preset function from the `PRESET_REGISTRY` using the
|
|
10
|
+
combination of router type, input modality, and preset name. If found, it executes
|
|
11
|
+
the function with the given keyword arguments.
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
router_type (str): The type of router (e.g., "router").
|
|
15
|
+
modality (str): The input modality (e.g., "image", "text").
|
|
16
|
+
preset_name (str): The name of the preset (e.g., "domain_specific", "generic").
|
|
17
|
+
**kwargs: Additional keyword arguments passed to the preset function.
|
|
18
|
+
|
|
19
|
+
Returns:
|
|
20
|
+
dict[str, Any]: A dictionary of router components (varies by router type).
|
|
21
|
+
|
|
22
|
+
Raises:
|
|
23
|
+
ValueError: If no matching preset is found in the registry.
|
|
24
|
+
'''
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import abc
|
|
2
|
+
from _typeshed import Incomplete
|
|
3
|
+
from abc import ABC
|
|
4
|
+
from gllm_core.schema import Component
|
|
5
|
+
|
|
6
|
+
class BaseRouter(Component, ABC, metaclass=abc.ABCMeta):
|
|
7
|
+
"""An abstract base class for the routers used in Gen AI applications.
|
|
8
|
+
|
|
9
|
+
This class provides a foundation for building routers in Gen AI applications. It includes initialization for
|
|
10
|
+
default and valid routes and abstract routing logic that subclasses must implement.
|
|
11
|
+
|
|
12
|
+
Attributes:
|
|
13
|
+
default_route (str): The default route to use.
|
|
14
|
+
valid_routes (set[str]): A set of valid routes for the router.
|
|
15
|
+
"""
|
|
16
|
+
default_route: Incomplete
|
|
17
|
+
valid_routes: Incomplete
|
|
18
|
+
logger: Incomplete
|
|
19
|
+
def __init__(self, default_route: str, valid_routes: set[str]) -> None:
|
|
20
|
+
"""Initializes a new instance of the BaseRouter class.
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
default_route (str): The default route to use.
|
|
24
|
+
valid_routes (set[str]): A set of valid routes for the router.
|
|
25
|
+
|
|
26
|
+
Raises:
|
|
27
|
+
ValueError: If the provided default route is not in the set of valid routes.
|
|
28
|
+
"""
|
|
29
|
+
async def route(self, source: str | bytes, route_filter: set[str] | None = None) -> str:
|
|
30
|
+
"""Routes an input source to the appropriate path.
|
|
31
|
+
|
|
32
|
+
This method is a wrapper around the `_select_route` method. It first calls `_select_route` to get the selected
|
|
33
|
+
route and then checks if the route is in the set of valid routes. If it is not, it returns the default route.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
source (str | bytes): The input source to be routed.
|
|
37
|
+
route_filter (set[str] | None, optional): An optional set of allowed routes. If provided, only the routes
|
|
38
|
+
in the set are considered valid. Defaults to None.
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
str: The selected route for the input source.
|
|
42
|
+
|
|
43
|
+
Raises:
|
|
44
|
+
ValueError: If the provided route filter contains invalid routes or if the default route is not included
|
|
45
|
+
in the route filter.
|
|
46
|
+
"""
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
from _typeshed import Incomplete
|
|
2
|
+
from gllm_pipeline.router.router import BaseRouter as BaseRouter
|
|
3
|
+
from pydantic import BaseModel
|
|
4
|
+
|
|
5
|
+
class RouterSplitRule(BaseModel):
|
|
6
|
+
'''Configuration class for defining input string splitting rules in rule-based router operations.
|
|
7
|
+
|
|
8
|
+
Attributes:
|
|
9
|
+
splitter (list[str]): A list of string delimiters used to split the input string. Defaults to [" "].
|
|
10
|
+
beg_index (int | None, optional): Optional beginning index of the portion of the split result to keep.
|
|
11
|
+
If None, the split result will be kept from the first element. Defaults to None.
|
|
12
|
+
end_index (int | None, optional): Optional ending index of the portion of the split result to keep.
|
|
13
|
+
If None, the split result will be kept until the last element. Defaults to None.
|
|
14
|
+
'''
|
|
15
|
+
splitter: list[str]
|
|
16
|
+
beg_index: int | None
|
|
17
|
+
end_index: int | None
|
|
18
|
+
|
|
19
|
+
class RouterRule(BaseModel):
|
|
20
|
+
"""Configuration class for defining keyword matching rules in rule-based router operations.
|
|
21
|
+
|
|
22
|
+
Attributes:
|
|
23
|
+
keywords (list[str]): A list of keywords to match against the input string.
|
|
24
|
+
allow_substring (bool, optional): If True, allows matching if a keyword is a substring of the input.
|
|
25
|
+
If False, requires an exact match between a keyword and either the full input or any of its split parts.
|
|
26
|
+
Defaults to True.
|
|
27
|
+
case_sensitive (bool, optional): If True, keyword matching will be case-sensitive. Defaults to True.
|
|
28
|
+
alphanumeric_only (bool, optional): If True, only alphanumeric and whitespace characters will be considered
|
|
29
|
+
during matching. Defaults to True.
|
|
30
|
+
split_rule (list[RouterSplitRule] | None, optional): A list of `RouterSplitRule` objects that define how to
|
|
31
|
+
split the input string before matching. If multiple are provided, the splits will be done sequentially.
|
|
32
|
+
If None, no splitting will be applied. Defaults to None.
|
|
33
|
+
"""
|
|
34
|
+
keywords: list[str]
|
|
35
|
+
allow_substring: bool
|
|
36
|
+
case_sensitive: bool
|
|
37
|
+
alphanumeric_only: bool
|
|
38
|
+
split_rule: list[RouterSplitRule] | None
|
|
39
|
+
|
|
40
|
+
class RouterRuleset(BaseModel):
|
|
41
|
+
"""Configuration class for defining a set of rules in rule-based router operations.
|
|
42
|
+
|
|
43
|
+
Attributes:
|
|
44
|
+
rules (list[RouterRule]): A list of `RouterRule` objects that define individual routing rules.
|
|
45
|
+
match_all (bool, optional): If True, all rules must be matched for the ruleset to return True. If False,
|
|
46
|
+
matching any rule will result in the ruleset returning True. Defaults to True.
|
|
47
|
+
"""
|
|
48
|
+
rules: list[RouterRule]
|
|
49
|
+
match_all: bool
|
|
50
|
+
|
|
51
|
+
class RuleBasedRouter(BaseRouter):
|
|
52
|
+
"""A rule-based router that directs the input text to an appropriate route based on a set of rules.
|
|
53
|
+
|
|
54
|
+
The `RuleBasedRouter` routes incoming input text to different paths by evaluating a set of rules encapsulated in
|
|
55
|
+
`RouterRuleset` objects. Each ruleset consists of multiple `RouterRule` objects, and the router determines which
|
|
56
|
+
route to take based on the input text and the rules defined in the ruleset.
|
|
57
|
+
|
|
58
|
+
If `match_all` is True in a `RouterRuleset`, all rules in that ruleset must match the input text for the
|
|
59
|
+
associated route to be selected. If False, matching any rule in the ruleset will cause that route to be selected.
|
|
60
|
+
If no match is found, the router defaults to the `default_route`.
|
|
61
|
+
|
|
62
|
+
Attributes:
|
|
63
|
+
ruleset_map (dict[str, RouterRuleset]): A mapping of route names to their corresponding rulesets.
|
|
64
|
+
default_route (str): The default route to be taken if no ruleset matches the input text.
|
|
65
|
+
valid_routes (set[str]): A set of valid routes that the router can direct to.
|
|
66
|
+
"""
|
|
67
|
+
ruleset_map: Incomplete
|
|
68
|
+
def __init__(self, ruleset_map: dict[str, RouterRuleset], default_route: str, valid_routes: set[str]) -> None:
|
|
69
|
+
"""Initializes a new instance of the RuleBasedRouter class.
|
|
70
|
+
|
|
71
|
+
Args:
|
|
72
|
+
ruleset_map (dict[str, RouterRuleset]): A mapping of route names to their corresponding rulesets.
|
|
73
|
+
default_route (str): The default route to be taken if no ruleset matches the input text.
|
|
74
|
+
valid_routes (set[str]): A set of valid routes for the router.
|
|
75
|
+
|
|
76
|
+
Raises:
|
|
77
|
+
ValueError:
|
|
78
|
+
1. If the `ruleset_map` contains routes that are not in the set of valid routes.
|
|
79
|
+
2. If the provided default route is not in the set of valid routes.
|
|
80
|
+
"""
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
from _typeshed import Incomplete
|
|
2
|
+
from gllm_inference.em_invoker.em_invoker import BaseEMInvoker as BaseEMInvoker
|
|
3
|
+
from gllm_pipeline.router.router import BaseRouter as BaseRouter
|
|
4
|
+
|
|
5
|
+
class SimilarityBasedRouter(BaseRouter):
|
|
6
|
+
"""A router that utilizes an embedding model to determine the appropriate route for an input text.
|
|
7
|
+
|
|
8
|
+
This class routes a given input text to an appropriate path based on semantic similarity between
|
|
9
|
+
the input text and predefined route examples. It calculates cosine similarity between the input
|
|
10
|
+
text embedding and the embeddings of route examples, then selects the route with the highest
|
|
11
|
+
similarity score above a threshold.
|
|
12
|
+
|
|
13
|
+
Attributes:
|
|
14
|
+
em_invoker (BaseEMInvoker): The embedding model invoker to use for vectorization.
|
|
15
|
+
route_examples (dict[str, list[str]]): A mapping of route names to their example texts.
|
|
16
|
+
similarity_threshold (float): The minimum similarity score required for a route to be selected.
|
|
17
|
+
default_route (str): The default route to be used if no route meets the similarity threshold.
|
|
18
|
+
valid_routes (set[str]): A set of valid routes for the router.
|
|
19
|
+
"""
|
|
20
|
+
em_invoker: Incomplete
|
|
21
|
+
route_examples: Incomplete
|
|
22
|
+
similarity_threshold: Incomplete
|
|
23
|
+
def __init__(self, em_invoker: BaseEMInvoker, route_examples: dict[str, list[str]], default_route: str, similarity_threshold: float = 0.5) -> None:
|
|
24
|
+
'''Initializes a new instance of the SimilarityBasedRouter class.
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
em_invoker (BaseEMInvoker): The embedding model invoker to use for vectorization.
|
|
28
|
+
route_examples (dict[str, list[str]]): A mapping of route names to their example texts.
|
|
29
|
+
The keys define the valid routes, and values are example texts for each route.
|
|
30
|
+
default_route (str): The default route to be used if no route meets the similarity threshold.
|
|
31
|
+
Must be one of the keys in route_examples.
|
|
32
|
+
Examples: "general", "fallback", "customer_service"
|
|
33
|
+
similarity_threshold (float, optional): The minimum similarity score required for a route to be selected.
|
|
34
|
+
Must be between 0 and 1. This threshold is compared against normalized cosine similarity scores,
|
|
35
|
+
which are derived from the standard cosine similarity (ranging from -1 to 1) and converted to
|
|
36
|
+
a 0-1 range where 0 indicates maximum dissimilarity and 1 indicates maximum similarity.
|
|
37
|
+
Examples of route_examples:
|
|
38
|
+
{
|
|
39
|
+
"tech_support": [
|
|
40
|
+
"I can\'t log in to my account",
|
|
41
|
+
"The app keeps crashing",
|
|
42
|
+
"Password reset not working",
|
|
43
|
+
"Getting error code 500"
|
|
44
|
+
],
|
|
45
|
+
"billing": [
|
|
46
|
+
"How much do I owe?",
|
|
47
|
+
"I want to dispute a charge",
|
|
48
|
+
"When is my payment due?",
|
|
49
|
+
"Can I get a refund?"
|
|
50
|
+
],
|
|
51
|
+
"general": [
|
|
52
|
+
"What are your business hours?",
|
|
53
|
+
"How do I contact support?",
|
|
54
|
+
"Tell me about your services",
|
|
55
|
+
"Where are you located?"
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
Raises:
|
|
60
|
+
ValueError:
|
|
61
|
+
1. If route_examples is not a dictionary.
|
|
62
|
+
2. If route_examples is falsy (None, empty dict, etc.).
|
|
63
|
+
3. If the similarity threshold is not between 0 and 1.
|
|
64
|
+
4. If the provided default route is not in the route_examples keys.
|
|
65
|
+
5. If any route has an empty list of examples.
|
|
66
|
+
'''
|
|
67
|
+
def clear_cache(self) -> None:
|
|
68
|
+
"""Clears the cached route embeddings.
|
|
69
|
+
|
|
70
|
+
This method clears the cached embeddings, forcing them to be regenerated
|
|
71
|
+
on the next routing operation.
|
|
72
|
+
"""
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
def encode_bytes(value: Any, recursive: bool = False) -> Any:
|
|
4
|
+
"""Encode `bytes` objects into base64 strings for JSON serialization.
|
|
5
|
+
|
|
6
|
+
This function converts `bytes` objects into UTF-8 base64-encoded strings. If
|
|
7
|
+
`recursive` is enabled, it will traverse nested structures (lists and dictionaries)
|
|
8
|
+
and encode all `bytes` instances found within them. Other data types remain
|
|
9
|
+
unchanged.
|
|
10
|
+
|
|
11
|
+
Behavior:
|
|
12
|
+
1. If `value` is `bytes`, it is converted to a base64-encoded UTF-8 string.
|
|
13
|
+
2. If `value` is a list or dict and `recursive` is True, encoding is applied
|
|
14
|
+
to all nested elements.
|
|
15
|
+
3. For unsupported types or when `recursive` is False, the original value is
|
|
16
|
+
returned as-is.
|
|
17
|
+
|
|
18
|
+
Args:
|
|
19
|
+
value (Any): The value to process. Can be `bytes`, list, dict, or any other type.
|
|
20
|
+
recursive (bool): If True, apply encoding recursively to all elements within
|
|
21
|
+
lists and dictionaries. Defaults to False.
|
|
22
|
+
|
|
23
|
+
Returns:
|
|
24
|
+
Any: The base64-encoded string if `value` is `bytes`, a recursively processed
|
|
25
|
+
structure if `recursive` is True, or the original value otherwise.
|
|
26
|
+
"""
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from gllm_pipeline.steps._func import bundle as bundle, guard as guard, if_else as if_else, log as log, map_reduce as map_reduce, no_op as no_op, parallel as parallel, step as step, subgraph as subgraph, switch as switch, terminate as terminate, toggle as toggle, transform as transform
|
|
2
|
+
from gllm_pipeline.steps.component_step import ComponentStep as ComponentStep
|
|
3
|
+
from gllm_pipeline.steps.conditional_step import ConditionalStep as ConditionalStep
|
|
4
|
+
from gllm_pipeline.steps.guard_step import GuardStep as GuardStep
|
|
5
|
+
from gllm_pipeline.steps.log_step import LogStep as LogStep
|
|
6
|
+
from gllm_pipeline.steps.map_reduce_step import MapReduceStep as MapReduceStep
|
|
7
|
+
from gllm_pipeline.steps.no_op_step import NoOpStep as NoOpStep
|
|
8
|
+
from gllm_pipeline.steps.parallel_step import ParallelStep as ParallelStep
|
|
9
|
+
from gllm_pipeline.steps.state_operator_step import StateOperatorStep as StateOperatorStep
|
|
10
|
+
from gllm_pipeline.steps.step_error_handler.empty_step_error_handler import EmptyStepErrorHandler as EmptyStepErrorHandler
|
|
11
|
+
from gllm_pipeline.steps.step_error_handler.fallback_step_error_handler import FallbackStepErrorHandler as FallbackStepErrorHandler
|
|
12
|
+
from gllm_pipeline.steps.step_error_handler.keep_step_error_handler import KeepStepErrorHandler as KeepStepErrorHandler
|
|
13
|
+
from gllm_pipeline.steps.step_error_handler.raise_step_error_handler import RaiseStepErrorHandler as RaiseStepErrorHandler
|
|
14
|
+
from gllm_pipeline.steps.subgraph_step import SubgraphStep as SubgraphStep
|
|
15
|
+
from gllm_pipeline.steps.terminator_step import TerminatorStep as TerminatorStep
|
|
16
|
+
|
|
17
|
+
__all__ = ['ComponentStep', 'ConditionalStep', 'GuardStep', 'LogStep', 'MapReduceStep', 'NoOpStep', 'ParallelStep', 'StateOperatorStep', 'SubgraphStep', 'TerminatorStep', 'EmptyStepErrorHandler', 'FallbackStepErrorHandler', 'KeepStepErrorHandler', 'RaiseStepErrorHandler', 'bundle', 'guard', 'if_else', 'log', 'map_reduce', 'no_op', 'parallel', 'step', 'subgraph', 'switch', 'terminate', 'toggle', 'transform']
|