diff --git a/nlpf_statemachine/example/app/sc/classifiers/original_text_classifier.py b/nlpf_statemachine/example/app/sc/classifiers/original_text_classifier.py index dfc06426..4b6d08c2 100644 --- a/nlpf_statemachine/example/app/sc/classifiers/original_text_classifier.py +++ b/nlpf_statemachine/example/app/sc/classifiers/original_text_classifier.py @@ -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): @@ -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 diff --git a/nlpf_statemachine/example/app/sc/example_1_static_storage.py b/nlpf_statemachine/example/app/sc/example_1_static_storage.py index bbed9066..29c3860c 100644 --- a/nlpf_statemachine/example/app/sc/example_1_static_storage.py +++ b/nlpf_statemachine/example/app/sc/example_1_static_storage.py @@ -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. @@ -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. @@ -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. @@ -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. diff --git a/nlpf_statemachine/example/tests/sc/test_example_1_static_storage.py b/nlpf_statemachine/example/tests/sc/test_example_1_static_storage.py index fbeb8074..3a1cd617 100644 --- a/nlpf_statemachine/example/tests/sc/test_example_1_static_storage.py +++ b/nlpf_statemachine/example/tests/sc/test_example_1_static_storage.py @@ -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", ) @@ -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", ) @@ -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", ) @@ -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", )