-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
56 changed files
with
2,545 additions
and
3,485 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
# flake8: noqa: F401 | ||
|
||
from chatsky.core.service.types import ExtraHandlerRuntimeInfo, StartConditionCheckerFunction, ComponentExecutionState | ||
from chatsky.core.service.types import ExtraHandlerRuntimeInfo, ComponentExecutionState | ||
from chatsky.core import Context, Script | ||
from chatsky.core.script import Node | ||
from chatsky.core.pipeline import Pipeline | ||
from chatsky.slots.slots import SlotManager | ||
from chatsky.core.context import FrameworkData | ||
from chatsky.core.context import FrameworkData, ServiceState | ||
from chatsky.core.service import PipelineComponent | ||
|
||
PipelineComponent.model_rebuild() | ||
Pipeline.model_rebuild() | ||
Script.model_rebuild() | ||
Context.model_rebuild() | ||
ExtraHandlerRuntimeInfo.model_rebuild() | ||
FrameworkData.model_rebuild() | ||
ServiceState.model_rebuild() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
""" | ||
Service Conditions | ||
------------------ | ||
Provides service-related conditions | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
from chatsky.core.context import Context | ||
from chatsky.core.script_function import BaseCondition | ||
|
||
from chatsky.core.service.types import ( | ||
ComponentExecutionState, | ||
) | ||
|
||
|
||
class ServiceFinished(BaseCondition): | ||
""" | ||
Check if a :py:class:`~chatsky.core.service.service.Service` was executed successfully. | ||
""" | ||
|
||
path: str | ||
"""The path of the condition pipeline component.""" | ||
wait: bool = False | ||
""" | ||
Whether to wait for the service to be finished. | ||
This eliminates possible service states ``NOT_RUN`` and ``RUNNING``. | ||
""" | ||
|
||
def __init__(self, path: str, *, wait: bool = False): | ||
super().__init__(path=path, wait=wait) | ||
|
||
async def call(self, ctx: Context) -> bool: | ||
if self.wait: | ||
await ctx.framework_data.service_states[self.path].finished_event.wait() | ||
|
||
state = ctx.framework_data.service_states[self.path].execution_status | ||
|
||
return ComponentExecutionState[state] == ComponentExecutionState.FINISHED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.