Types#
This module defines type aliases used throughout the Core.Service
module.
The classes and special types in this module can include data models, data structures, and other types that are defined for type hinting.
- class PipelineRunnerFunction(*args, **kwargs)[source]#
Bases:
Protocol
Protocol for pipeline running.
- __call__(message, ctx_id=None, update_ctx_misc=None)[source]#
- Parameters:
message (
Message
) – User request for pipeline to process.ctx_id (
Optional
[Hashable
]) – ID of the context that the new request belongs to. Optional, None by default. If set to None, a new context will be created with message being the first request.update_ctx_misc (
Optional
[dict
]) – Dictionary to be passed as an argument to ctx.misc.update. This argument can be used to store values in the misc dictionary before anything else runs. Optional; None by default. If set to None, ctx.misc.update will not be called.
- Return type:
Awaitable
[Context
]- Returns:
Context instance that pipeline processed. The context instance has the id of ctx_id. If ctx_id is None, context instance has an id generated with uuid.uuid4.
- _is_protocol = True#
- class ComponentExecutionState(value)[source]#
Bases:
str
,Enum
Enum, representing pipeline component execution state. These states are stored in
service_states
, that should always be requested withNOT_RUN
being default fallback. Following states are supported:NOT_RUN: component has not been executed yet (the default one),
RUNNING: component is currently being executed,
FINISHED: component executed successfully,
FAILED: component execution failed.
- NOT_RUN = 'NOT_RUN'#
- RUNNING = 'RUNNING'#
- FINISHED = 'FINISHED'#
- FAILED = 'FAILED'#
- _generate_next_value_(start, count, last_values)#
Generate the next value when not given.
name: the name of the member start: the initial start value or None count: the number of existing members last_value: the last value assigned or None
- _member_names_ = ['NOT_RUN', 'RUNNING', 'FINISHED', 'FAILED']#
- _member_map_ = {'FAILED': ComponentExecutionState.FAILED, 'FINISHED': ComponentExecutionState.FINISHED, 'NOT_RUN': ComponentExecutionState.NOT_RUN, 'RUNNING': ComponentExecutionState.RUNNING}#
- _member_type_#
alias of
str
- _value2member_map_ = {'FAILED': ComponentExecutionState.FAILED, 'FINISHED': ComponentExecutionState.FINISHED, 'NOT_RUN': ComponentExecutionState.NOT_RUN, 'RUNNING': ComponentExecutionState.RUNNING}#
- class ExtraHandlerType(value)[source]#
Bases:
str
,Enum
Enum, representing extra handler execution stage: before or after the wrapped function. The following types are supported:
BEFORE: extra handler function called before component,
AFTER: extra handler function called after component.
- BEFORE = 'BEFORE'#
- AFTER = 'AFTER'#
- _generate_next_value_(start, count, last_values)#
Generate the next value when not given.
name: the name of the member start: the initial start value or None count: the number of existing members last_value: the last value assigned or None
- _member_names_ = ['BEFORE', 'AFTER']#
- _member_map_ = {'AFTER': ExtraHandlerType.AFTER, 'BEFORE': ExtraHandlerType.BEFORE}#
- _member_type_#
alias of
str
- _value2member_map_ = {'AFTER': ExtraHandlerType.AFTER, 'BEFORE': ExtraHandlerType.BEFORE}#
- ExtraHandlerConditionFunction#
A function type used when adding an extra handler to a service group to determine whether extra handler should be added to components of the service group.
Accepts a single argument - path of a subcomponent in a group. Return bool - whether to add extra handler to the subcomponent.
alias of
Callable
[[str
],bool
]
- ExtraHandlerFunction#
A function type for creating extra handler (before and after functions). Can accept current dialog context and current extra handler info.
alias of
Union
[Callable
[[Context
],Any
],Callable
[[Context
,ExtraHandlerRuntimeInfo
],Any
]]
- class ExtraHandlerRuntimeInfo(**data)[source]#
Bases:
BaseModel
Information passed to
ExtraHandlerFunction
.- stage: ExtraHandlerType#
ExtraHandlerType
– either “BEFORE” or “AFTER”.
- component: PipelineComponent#
Component object that called the extra handler.