-
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.
Merge branch 'dev' into merge/extended_conditions
- Loading branch information
Showing
210 changed files
with
9,322 additions
and
8,416 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
# flake8: noqa: F401 | ||
|
||
from chatsky.pipeline import Pipeline | ||
from chatsky.pipeline.types import ExtraHandlerRuntimeInfo | ||
from chatsky.script import Context, Script | ||
from chatsky.core.service.types import ExtraHandlerRuntimeInfo, StartConditionCheckerFunction, 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 | ||
|
||
Pipeline.model_rebuild() | ||
Script.model_rebuild() | ||
Context.model_rebuild() | ||
ExtraHandlerRuntimeInfo.model_rebuild() | ||
FrameworkData.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from chatsky.conditions.standard import ( | ||
ExactMatch, | ||
HasText, | ||
Regexp, | ||
Any, | ||
All, | ||
Negation, | ||
CheckLastLabels, | ||
Not, | ||
HasCallbackQuery, | ||
) | ||
from chatsky.conditions.slots import SlotsExtracted |
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,38 @@ | ||
""" | ||
Slot Conditions | ||
--------------------------- | ||
Provides slot-related conditions. | ||
""" | ||
|
||
from __future__ import annotations | ||
from typing import Literal, List | ||
|
||
from chatsky.core import Context, BaseCondition | ||
from chatsky.slots.slots import SlotName | ||
|
||
|
||
class SlotsExtracted(BaseCondition): | ||
""" | ||
Check if :py:attr:`.slots` are extracted. | ||
:param mode: Whether to check if all slots are extracted or any slot is extracted. | ||
""" | ||
|
||
slots: List[SlotName] | ||
""" | ||
Names of the slots that need to be checked. | ||
""" | ||
mode: Literal["any", "all"] = "all" | ||
""" | ||
Whether to check if all slots are extracted or any slot is extracted. | ||
""" | ||
|
||
def __init__(self, *slots: SlotName, mode: Literal["any", "all"] = "all"): | ||
super().__init__(slots=slots, mode=mode) | ||
|
||
async def call(self, ctx: Context) -> bool: | ||
manager = ctx.framework_data.slot_manager | ||
if self.mode == "all": | ||
return all(manager.is_slot_extracted(slot) for slot in self.slots) | ||
elif self.mode == "any": | ||
return any(manager.is_slot_extracted(slot) for slot in self.slots) |
Oops, something went wrong.