Skip to content

Commit

Permalink
change event names
Browse files Browse the repository at this point in the history
  • Loading branch information
20081984 authored and 20081984 committed Feb 14, 2024
1 parent 920ffb5 commit ad9fdf6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class Events(SmartEnum):
3. Ответ для любого ассистента;
"""

STATIC_STORAGE_EVENT_1 = "STATIC_STORAGE_EVENT_1"
STATIC_STORAGE_EVENT_2 = "STATIC_STORAGE_EVENT_2"
STATIC_STORAGE_EVENT_3 = "STATIC_STORAGE_EVENT_3"
STATIC_STORAGE_EVENT_4 = "STATIC_STORAGE_EVENT_4"
GET_DATA = "GET_DATA"
CREATE_DATA = "CREATE_DATA"
UPDATE_DATA = "UPDATE_DATA"
DELETE_DATA = "DELETE_DATA"


class OriginalTextClassifier(Classifier):
Expand Down Expand Up @@ -53,10 +53,10 @@ def run(self, message: MessageToSkill, context: Context, form: Dict) -> Optional
if token.get("token_type") == NUM_TOKEN:
text = token.get("text")
if text == "1":
return Events.STATIC_STORAGE_EVENT_1
return Events.GET_DATA
elif text == "2":
return Events.STATIC_STORAGE_EVENT_2
return Events.CREATE_DATA
elif text == "3":
return Events.STATIC_STORAGE_EVENT_3
return Events.UPDATE_DATA
elif text == "4":
return Events.STATIC_STORAGE_EVENT_4
return Events.DELETE_DATA
8 changes: 4 additions & 4 deletions nlpf_statemachine/example/app/sc/example_1_static_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

# 4. Добавим обработчики событии Events.STATIC_STORAGE_EVENT_X.
# Ответ сгенерируем из example_storage.
@scenario.on_event(event=Events.STATIC_STORAGE_EVENT_1)
@scenario.on_event(event=Events.GET_DATA)
def example_storage_action_1() -> AnswerToUser:
"""
## Кейс 1.
Expand All @@ -39,7 +39,7 @@ def example_storage_action_1() -> AnswerToUser:
return example_storage.answer_to_user(code="EXAMPLE_1")


@scenario.on_event(event=Events.STATIC_STORAGE_EVENT_2)
@scenario.on_event(event=Events.CREATE_DATA)
def example_storage_action_2(context: Context) -> AnswerToUser:
"""
## Кейс 2.
Expand All @@ -53,7 +53,7 @@ def example_storage_action_2(context: Context) -> AnswerToUser:
return example_storage.answer_to_user(code="EXAMPLE_2", context=context)


@scenario.on_event(event=Events.STATIC_STORAGE_EVENT_3)
@scenario.on_event(event=Events.UPDATE_DATA)
def example_storage_action_3(context: Context) -> AnswerToUser:
"""
## Кейс 3.
Expand All @@ -67,7 +67,7 @@ def example_storage_action_3(context: Context) -> AnswerToUser:
return example_storage.answer_to_user(code="EXAMPLE_3", context=context)


@scenario.on_event(event=Events.STATIC_STORAGE_EVENT_4)
@scenario.on_event(event=Events.DELETE_DATA)
def example_storage_action_4(context: Context) -> AnswerToUser:
"""
## Кейс 4.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async def _run_character(character_id: AssistantId, tokenized_elements_list: Lis

# ==== Asserts ====
self.assert_debug_info(
called_event=Events.STATIC_STORAGE_EVENT_1,
called_event=Events.GET_DATA,
called_action="StaticStorageExample.example_storage_action_1",
static_code="EXAMPLE_1",
)
Expand Down Expand Up @@ -95,7 +95,7 @@ async def _run_character(character_id: AssistantId, tokenized_elements_list: Lis

# ==== Asserts ====
self.assert_debug_info(
called_event=Events.STATIC_STORAGE_EVENT_2,
called_event=Events.CREATE_DATA,
called_action="StaticStorageExample.example_storage_action_2",
static_code="EXAMPLE_2",
)
Expand Down Expand Up @@ -147,7 +147,7 @@ async def _run_character(character_id: AssistantId, tokenized_elements_list: Lis

# ==== Asserts ====
self.assert_debug_info(
called_event=Events.STATIC_STORAGE_EVENT_3,
called_event=Events.UPDATE_DATA,
called_action="StaticStorageExample.example_storage_action_3",
static_code="EXAMPLE_3",
)
Expand Down Expand Up @@ -191,7 +191,7 @@ async def _run_character(character_id: AssistantId, tokenized_elements_list: Lis

# ==== Asserts ====
self.assert_debug_info(
called_event=Events.STATIC_STORAGE_EVENT_4,
called_event=Events.DELETE_DATA,
called_action="StaticStorageExample.example_storage_action_4",
static_code="EXAMPLE_4",
)
Expand Down

0 comments on commit ad9fdf6

Please sign in to comment.