rasa-pro 3.8.17__py3-none-any.whl → 3.9.14__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rasa-pro might be problematic. Click here for more details.
- README.md +5 -5
- rasa/__main__.py +14 -9
- rasa/anonymization/anonymization_pipeline.py +0 -1
- rasa/anonymization/anonymization_rule_executor.py +3 -3
- rasa/anonymization/utils.py +4 -3
- rasa/api.py +2 -2
- rasa/cli/arguments/default_arguments.py +1 -1
- rasa/cli/arguments/run.py +2 -2
- rasa/cli/arguments/test.py +1 -1
- rasa/cli/arguments/train.py +10 -10
- rasa/cli/e2e_test.py +27 -7
- rasa/cli/export.py +0 -1
- rasa/cli/license.py +3 -3
- rasa/cli/project_templates/calm/actions/action_template.py +1 -1
- rasa/cli/project_templates/calm/config.yml +1 -1
- rasa/cli/project_templates/calm/credentials.yml +1 -1
- rasa/cli/project_templates/calm/data/flows/add_contact.yml +1 -1
- rasa/cli/project_templates/calm/data/flows/remove_contact.yml +1 -1
- rasa/cli/project_templates/calm/domain/add_contact.yml +8 -2
- rasa/cli/project_templates/calm/domain/list_contacts.yml +3 -0
- rasa/cli/project_templates/calm/domain/remove_contact.yml +9 -2
- rasa/cli/project_templates/calm/domain/shared.yml +5 -0
- rasa/cli/project_templates/calm/endpoints.yml +4 -4
- rasa/cli/project_templates/default/actions/actions.py +1 -1
- rasa/cli/project_templates/default/config.yml +5 -5
- rasa/cli/project_templates/default/credentials.yml +1 -1
- rasa/cli/project_templates/default/endpoints.yml +4 -4
- rasa/cli/project_templates/default/tests/test_stories.yml +1 -1
- rasa/cli/project_templates/tutorial/config.yml +1 -1
- rasa/cli/project_templates/tutorial/credentials.yml +1 -1
- rasa/cli/project_templates/tutorial/data/patterns.yml +6 -0
- rasa/cli/project_templates/tutorial/domain.yml +4 -0
- rasa/cli/project_templates/tutorial/endpoints.yml +6 -6
- rasa/cli/run.py +0 -1
- rasa/cli/scaffold.py +3 -2
- rasa/cli/studio/download.py +11 -0
- rasa/cli/studio/studio.py +180 -24
- rasa/cli/studio/upload.py +0 -8
- rasa/cli/telemetry.py +18 -6
- rasa/cli/utils.py +21 -10
- rasa/cli/x.py +3 -2
- rasa/core/actions/action.py +90 -315
- rasa/core/actions/action_exceptions.py +24 -0
- rasa/core/actions/constants.py +3 -0
- rasa/core/actions/custom_action_executor.py +188 -0
- rasa/core/actions/forms.py +11 -7
- rasa/core/actions/grpc_custom_action_executor.py +251 -0
- rasa/core/actions/http_custom_action_executor.py +140 -0
- rasa/core/actions/loops.py +3 -0
- rasa/core/actions/two_stage_fallback.py +1 -1
- rasa/core/agent.py +2 -4
- rasa/core/brokers/pika.py +1 -2
- rasa/core/channels/audiocodes.py +1 -1
- rasa/core/channels/botframework.py +0 -1
- rasa/core/channels/callback.py +0 -1
- rasa/core/channels/console.py +6 -8
- rasa/core/channels/development_inspector.py +1 -1
- rasa/core/channels/facebook.py +0 -3
- rasa/core/channels/hangouts.py +0 -6
- rasa/core/channels/inspector/dist/assets/{arc-5623b6dc.js → arc-b6e548fe.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-d0fbc5ce-685c106a.js → c4Diagram-d0fbc5ce-fa03ac9e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-936ed81e-8cbed007.js → classDiagram-936ed81e-ee67392a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-v2-c3cb15f1-5889cf12.js → classDiagram-v2-c3cb15f1-9b283fae.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{createText-62fc7601-24c249d7.js → createText-62fc7601-8b6fcc2a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{edges-f2ad444c-7dd06a75.js → edges-f2ad444c-22e77f4f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-9d236eb7-62c1e54c.js → erDiagram-9d236eb7-60ffc87f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDb-1972c806-ce49b86f.js → flowDb-1972c806-9dd802e4.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDiagram-7ea5b25a-4067e48f.js → flowDiagram-7ea5b25a-5fa1912f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-855bc5b3-1844e5a5.js +1 -0
- rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-abe16c3d-59fe4051.js → flowchart-elk-definition-abe16c3d-622a1fd2.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-9b5ea136-47e3a43b.js → ganttDiagram-9b5ea136-e285a63a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-99d0ae7c-5a2ac0d9.js → gitGraphDiagram-99d0ae7c-f237bdca.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-2c4b9a3b-dfb8efc4.js → index-2c4b9a3b-4b03d70e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-268a75c0.js → index-a5d3e69d.js} +4 -4
- rasa/core/channels/inspector/dist/assets/{infoDiagram-736b4530-b0c470f2.js → infoDiagram-736b4530-72a0fa5f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-df861f2b-2edb829a.js → journeyDiagram-df861f2b-82218c41.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-b6873d69.js → layout-78cff630.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{line-1efc5781.js → line-5038b469.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-661e9b94.js → linear-c4fc4098.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-beec6740-2d2e727f.js → mindmap-definition-beec6740-c33c8ea6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{pieDiagram-dbbf0591-9d3ea93d.js → pieDiagram-dbbf0591-a8d03059.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-4d7f4fd6-06a178a2.js → quadrantDiagram-4d7f4fd6-6a0e56b2.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-6fc4c22a-0bfedffc.js → requirementDiagram-6fc4c22a-2dc7c7bd.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-8f13d901-d76d0a04.js → sankeyDiagram-8f13d901-2360fe39.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-b655622a-37bb4341.js → sequenceDiagram-b655622a-41b9f9ad.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-59f0c015-f52f7f57.js → stateDiagram-59f0c015-0aad326f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-2b26beab-4a986a20.js → stateDiagram-v2-2b26beab-9847d984.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-080da4f6-7dd9ae12.js → styles-080da4f6-564d890e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-3dcbcfbf-46e1ca14.js → styles-3dcbcfbf-38957613.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-9c745c82-4a97439a.js → styles-9c745c82-f0fc6921.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{svgDrawCommon-4835440b-823917a3.js → svgDrawCommon-4835440b-ef3c5a77.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{timeline-definition-5b62e21b-9ea72896.js → timeline-definition-5b62e21b-bf3e91c1.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-2b33534f-b631a8b6.js → xychartDiagram-2b33534f-4d4026c0.js} +1 -1
- rasa/core/channels/inspector/dist/index.html +1 -1
- rasa/core/channels/inspector/src/components/DiagramFlow.tsx +10 -0
- rasa/core/channels/inspector/src/helpers/formatters.test.ts +4 -7
- rasa/core/channels/inspector/src/helpers/formatters.ts +3 -2
- rasa/core/channels/rest.py +36 -21
- rasa/core/channels/rocketchat.py +0 -1
- rasa/core/channels/socketio.py +1 -1
- rasa/core/channels/telegram.py +3 -3
- rasa/core/channels/webexteams.py +0 -1
- rasa/core/concurrent_lock_store.py +1 -1
- rasa/core/evaluation/marker_base.py +1 -3
- rasa/core/evaluation/marker_stats.py +1 -2
- rasa/core/featurizers/single_state_featurizer.py +2 -4
- rasa/core/featurizers/tracker_featurizers.py +0 -7
- rasa/core/information_retrieval/__init__.py +7 -0
- rasa/core/information_retrieval/faiss.py +9 -4
- rasa/core/information_retrieval/information_retrieval.py +64 -7
- rasa/core/information_retrieval/milvus.py +7 -14
- rasa/core/information_retrieval/qdrant.py +8 -15
- rasa/core/lock_store.py +0 -1
- rasa/core/migrate.py +1 -2
- rasa/core/nlg/callback.py +3 -4
- rasa/core/policies/enterprise_search_policy.py +86 -22
- rasa/core/policies/enterprise_search_prompt_template.jinja2 +4 -41
- rasa/core/policies/enterprise_search_prompt_with_citation_template.jinja2 +60 -0
- rasa/core/policies/flows/flow_executor.py +104 -2
- rasa/core/policies/intentless_policy.py +7 -9
- rasa/core/policies/memoization.py +3 -3
- rasa/core/policies/policy.py +18 -9
- rasa/core/policies/rule_policy.py +8 -11
- rasa/core/policies/ted_policy.py +28 -30
- rasa/core/policies/unexpected_intent_policy.py +1 -2
- rasa/core/processor.py +136 -47
- rasa/core/run.py +41 -25
- rasa/core/secrets_manager/endpoints.py +2 -2
- rasa/core/secrets_manager/vault.py +6 -8
- rasa/core/test.py +3 -5
- rasa/core/tracker_store.py +49 -14
- rasa/core/train.py +1 -3
- rasa/core/training/interactive.py +9 -6
- rasa/core/utils.py +5 -10
- rasa/dialogue_understanding/coexistence/intent_based_router.py +11 -4
- rasa/dialogue_understanding/coexistence/llm_based_router.py +2 -3
- rasa/dialogue_understanding/commands/__init__.py +4 -0
- rasa/dialogue_understanding/commands/can_not_handle_command.py +9 -0
- rasa/dialogue_understanding/commands/cancel_flow_command.py +9 -0
- rasa/dialogue_understanding/commands/change_flow_command.py +38 -0
- rasa/dialogue_understanding/commands/chit_chat_answer_command.py +9 -0
- rasa/dialogue_understanding/commands/clarify_command.py +9 -0
- rasa/dialogue_understanding/commands/correct_slots_command.py +9 -0
- rasa/dialogue_understanding/commands/error_command.py +12 -0
- rasa/dialogue_understanding/commands/handle_code_change_command.py +9 -0
- rasa/dialogue_understanding/commands/human_handoff_command.py +9 -0
- rasa/dialogue_understanding/commands/knowledge_answer_command.py +9 -0
- rasa/dialogue_understanding/commands/noop_command.py +9 -0
- rasa/dialogue_understanding/commands/set_slot_command.py +34 -3
- rasa/dialogue_understanding/commands/skip_question_command.py +9 -0
- rasa/dialogue_understanding/commands/start_flow_command.py +9 -0
- rasa/dialogue_understanding/generator/__init__.py +16 -1
- rasa/dialogue_understanding/generator/command_generator.py +92 -6
- rasa/dialogue_understanding/generator/constants.py +18 -0
- rasa/dialogue_understanding/generator/flow_retrieval.py +7 -5
- rasa/dialogue_understanding/generator/llm_based_command_generator.py +467 -0
- rasa/dialogue_understanding/generator/llm_command_generator.py +39 -609
- rasa/dialogue_understanding/generator/multi_step/__init__.py +0 -0
- rasa/dialogue_understanding/generator/multi_step/fill_slots_prompt.jinja2 +62 -0
- rasa/dialogue_understanding/generator/multi_step/handle_flows_prompt.jinja2 +38 -0
- rasa/dialogue_understanding/generator/multi_step/multi_step_llm_command_generator.py +827 -0
- rasa/dialogue_understanding/generator/nlu_command_adapter.py +69 -8
- rasa/dialogue_understanding/generator/single_step/__init__.py +0 -0
- rasa/dialogue_understanding/generator/single_step/single_step_llm_command_generator.py +345 -0
- rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +44 -39
- rasa/dialogue_understanding/processor/command_processor.py +111 -3
- rasa/e2e_test/constants.py +1 -0
- rasa/e2e_test/e2e_test_case.py +44 -0
- rasa/e2e_test/e2e_test_runner.py +114 -11
- rasa/e2e_test/e2e_test_schema.yml +18 -0
- rasa/engine/caching.py +0 -1
- rasa/engine/graph.py +18 -6
- rasa/engine/recipes/config_files/default_config.yml +3 -3
- rasa/engine/recipes/default_components.py +1 -1
- rasa/engine/recipes/default_recipe.py +4 -5
- rasa/engine/recipes/recipe.py +1 -1
- rasa/engine/runner/dask.py +3 -9
- rasa/engine/storage/local_model_storage.py +0 -2
- rasa/engine/validation.py +179 -145
- rasa/exceptions.py +2 -2
- rasa/graph_components/validators/default_recipe_validator.py +3 -5
- rasa/hooks.py +0 -1
- rasa/model.py +1 -1
- rasa/model_training.py +1 -0
- rasa/nlu/classifiers/diet_classifier.py +8 -14
- rasa/nlu/extractors/crf_entity_extractor.py +4 -4
- rasa/nlu/extractors/duckling_entity_extractor.py +1 -1
- rasa/nlu/featurizers/dense_featurizer/convert_featurizer.py +1 -5
- rasa/nlu/featurizers/dense_featurizer/lm_featurizer.py +0 -4
- rasa/nlu/featurizers/featurizer.py +1 -1
- rasa/nlu/featurizers/sparse_featurizer/count_vectors_featurizer.py +2 -4
- rasa/nlu/featurizers/sparse_featurizer/lexical_syntactic_featurizer.py +9 -12
- rasa/nlu/persistor.py +68 -26
- rasa/nlu/selectors/response_selector.py +7 -10
- rasa/nlu/test.py +0 -3
- rasa/nlu/utils/hugging_face/registry.py +1 -1
- rasa/nlu/utils/spacy_utils.py +1 -3
- rasa/server.py +22 -7
- rasa/shared/constants.py +12 -1
- rasa/shared/core/command_payload_reader.py +109 -0
- rasa/shared/core/constants.py +4 -5
- rasa/shared/core/domain.py +57 -56
- rasa/shared/core/events.py +4 -7
- rasa/shared/core/flows/flow.py +9 -0
- rasa/shared/core/flows/flows_list.py +12 -0
- rasa/shared/core/flows/steps/action.py +7 -2
- rasa/shared/core/generator.py +12 -11
- rasa/shared/core/slot_mappings.py +315 -24
- rasa/shared/core/slots.py +4 -2
- rasa/shared/core/trackers.py +32 -14
- rasa/shared/core/training_data/loading.py +0 -1
- rasa/shared/core/training_data/story_reader/story_reader.py +3 -3
- rasa/shared/core/training_data/story_reader/yaml_story_reader.py +11 -11
- rasa/shared/core/training_data/story_writer/yaml_story_writer.py +5 -3
- rasa/shared/core/training_data/structures.py +1 -1
- rasa/shared/core/training_data/visualization.py +1 -1
- rasa/shared/data.py +58 -1
- rasa/shared/exceptions.py +36 -2
- rasa/shared/importers/importer.py +1 -2
- rasa/shared/importers/rasa.py +0 -1
- rasa/shared/nlu/constants.py +2 -0
- rasa/shared/nlu/training_data/entities_parser.py +1 -2
- rasa/shared/nlu/training_data/formats/dialogflow.py +3 -2
- rasa/shared/nlu/training_data/formats/rasa_yaml.py +3 -5
- rasa/shared/nlu/training_data/formats/readerwriter.py +0 -1
- rasa/shared/nlu/training_data/message.py +13 -0
- rasa/shared/nlu/training_data/training_data.py +0 -2
- rasa/shared/providers/openai/session_handler.py +2 -2
- rasa/shared/utils/constants.py +3 -0
- rasa/shared/utils/io.py +11 -0
- rasa/shared/utils/llm.py +1 -2
- rasa/shared/utils/pykwalify_extensions.py +1 -0
- rasa/shared/utils/schemas/domain.yml +3 -0
- rasa/shared/utils/yaml.py +44 -35
- rasa/studio/auth.py +26 -10
- rasa/studio/constants.py +2 -0
- rasa/studio/data_handler.py +114 -107
- rasa/studio/download.py +160 -27
- rasa/studio/results_logger.py +137 -0
- rasa/studio/train.py +6 -7
- rasa/studio/upload.py +159 -134
- rasa/telemetry.py +188 -34
- rasa/tracing/config.py +18 -3
- rasa/tracing/constants.py +26 -2
- rasa/tracing/instrumentation/attribute_extractors.py +50 -41
- rasa/tracing/instrumentation/instrumentation.py +290 -44
- rasa/tracing/instrumentation/intentless_policy_instrumentation.py +7 -5
- rasa/tracing/instrumentation/metrics.py +109 -21
- rasa/tracing/metric_instrument_provider.py +83 -3
- rasa/utils/cli.py +2 -1
- rasa/utils/common.py +1 -1
- rasa/utils/endpoints.py +1 -2
- rasa/utils/io.py +6 -6
- rasa/utils/licensing.py +246 -31
- rasa/utils/ml_utils.py +1 -1
- rasa/utils/tensorflow/data_generator.py +1 -1
- rasa/utils/tensorflow/environment.py +1 -1
- rasa/utils/tensorflow/model_data.py +9 -11
- rasa/utils/tensorflow/model_data_utils.py +499 -500
- rasa/utils/tensorflow/models.py +5 -6
- rasa/utils/tensorflow/rasa_layers.py +15 -15
- rasa/utils/train_utils.py +1 -1
- rasa/utils/url_tools.py +53 -0
- rasa/validator.py +305 -3
- rasa/version.py +1 -1
- {rasa_pro-3.8.17.dist-info → rasa_pro-3.9.14.dist-info}/METADATA +22 -22
- {rasa_pro-3.8.17.dist-info → rasa_pro-3.9.14.dist-info}/RECORD +271 -253
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-855bc5b3-85583a23.js +0 -1
- /rasa/dialogue_understanding/generator/{command_prompt_template.jinja2 → single_step/command_prompt_template.jinja2} +0 -0
- {rasa_pro-3.8.17.dist-info → rasa_pro-3.9.14.dist-info}/NOTICE +0 -0
- {rasa_pro-3.8.17.dist-info → rasa_pro-3.9.14.dist-info}/WHEEL +0 -0
- {rasa_pro-3.8.17.dist-info → rasa_pro-3.9.14.dist-info}/entry_points.txt +0 -0
rasa/core/actions/action.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import copy
|
|
2
|
-
import json
|
|
3
2
|
import logging
|
|
4
3
|
from typing import (
|
|
5
4
|
List,
|
|
@@ -13,14 +12,15 @@ from typing import (
|
|
|
13
12
|
cast,
|
|
14
13
|
)
|
|
15
14
|
|
|
16
|
-
import aiohttp
|
|
17
15
|
import rasa.core
|
|
18
|
-
|
|
19
|
-
from rasa.core.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
import rasa.shared.utils.io
|
|
17
|
+
from rasa.core.actions.custom_action_executor import (
|
|
18
|
+
CustomActionExecutor,
|
|
19
|
+
RetryCustomActionExecutor,
|
|
20
|
+
NoEndpointCustomActionExecutor,
|
|
23
21
|
)
|
|
22
|
+
from rasa.core.actions.grpc_custom_action_executor import GRPCCustomActionExecutor
|
|
23
|
+
from rasa.core.actions.http_custom_action_executor import HTTPCustomActionExecutor
|
|
24
24
|
from rasa.core.policies.policy import PolicyPrediction
|
|
25
25
|
from rasa.nlu.constants import (
|
|
26
26
|
RESPONSE_SELECTOR_DEFAULT_INTENT,
|
|
@@ -52,8 +52,6 @@ from rasa.shared.core.constants import (
|
|
|
52
52
|
REQUESTED_SLOT,
|
|
53
53
|
ACTION_EXTRACT_SLOTS,
|
|
54
54
|
DEFAULT_SLOT_NAMES,
|
|
55
|
-
MAPPING_CONDITIONS,
|
|
56
|
-
ACTIVE_LOOP,
|
|
57
55
|
ACTION_VALIDATE_SLOT_MAPPINGS,
|
|
58
56
|
MAPPING_TYPE,
|
|
59
57
|
SlotMappingType,
|
|
@@ -72,21 +70,20 @@ from rasa.shared.core.events import (
|
|
|
72
70
|
Restarted,
|
|
73
71
|
SessionStarted,
|
|
74
72
|
)
|
|
75
|
-
from rasa.shared.core.
|
|
76
|
-
from rasa.shared.core.
|
|
73
|
+
from rasa.shared.core.flows import FlowsList
|
|
74
|
+
from rasa.shared.core.slot_mappings import (
|
|
75
|
+
SlotFillingManager,
|
|
76
|
+
extract_slot_value,
|
|
77
|
+
)
|
|
77
78
|
from rasa.shared.core.trackers import DialogueStateTracker
|
|
78
79
|
from rasa.shared.exceptions import RasaException
|
|
79
80
|
from rasa.shared.nlu.constants import (
|
|
80
81
|
INTENT_NAME_KEY,
|
|
81
82
|
INTENT_RANKING_KEY,
|
|
82
|
-
ENTITY_ATTRIBUTE_TYPE,
|
|
83
|
-
ENTITY_ATTRIBUTE_ROLE,
|
|
84
|
-
ENTITY_ATTRIBUTE_GROUP,
|
|
85
83
|
)
|
|
86
84
|
from rasa.shared.utils.schemas.events import EVENTS_SCHEMA
|
|
87
|
-
import rasa.shared.utils.io
|
|
88
|
-
from rasa.utils.common import get_bool_env_variable
|
|
89
85
|
from rasa.utils.endpoints import EndpointConfig, ClientResponseError
|
|
86
|
+
from rasa.utils.url_tools import get_url_schema, UrlSchema
|
|
90
87
|
|
|
91
88
|
if TYPE_CHECKING:
|
|
92
89
|
from rasa.core.nlg import NaturalLanguageGenerator
|
|
@@ -345,8 +342,9 @@ class ActionBotResponse(Action):
|
|
|
345
342
|
if message is None:
|
|
346
343
|
if not self.silent_fail:
|
|
347
344
|
logger.error(
|
|
348
|
-
"Couldn't create message for response '{}'."
|
|
349
|
-
|
|
345
|
+
"Couldn't create message for response '{}'.".format(
|
|
346
|
+
self.utter_action
|
|
347
|
+
)
|
|
350
348
|
)
|
|
351
349
|
return []
|
|
352
350
|
message["utter_action"] = self.utter_action
|
|
@@ -492,8 +490,9 @@ class ActionRetrieveResponse(ActionBotResponse):
|
|
|
492
490
|
else:
|
|
493
491
|
if not self.silent_fail:
|
|
494
492
|
logger.error(
|
|
495
|
-
"Couldn't create message for response action '{}'."
|
|
496
|
-
|
|
493
|
+
"Couldn't create message for response action '{}'.".format(
|
|
494
|
+
self.action_name
|
|
495
|
+
)
|
|
497
496
|
)
|
|
498
497
|
return []
|
|
499
498
|
|
|
@@ -702,41 +701,46 @@ class ActionDeactivateLoop(Action):
|
|
|
702
701
|
|
|
703
702
|
|
|
704
703
|
class RemoteAction(Action):
|
|
705
|
-
def __init__(
|
|
706
|
-
|
|
704
|
+
def __init__(
|
|
705
|
+
self, name: Text, action_endpoint: Optional[EndpointConfig] = None
|
|
706
|
+
) -> None:
|
|
707
707
|
self._name = name
|
|
708
708
|
self.action_endpoint = action_endpoint
|
|
709
|
+
self.executor = self._create_executor()
|
|
709
710
|
|
|
710
|
-
def
|
|
711
|
-
|
|
712
|
-
tracker: "DialogueStateTracker",
|
|
713
|
-
domain: "Domain",
|
|
714
|
-
) -> Dict[Text, Any]:
|
|
715
|
-
"""Create the request json send to the action server."""
|
|
716
|
-
from rasa.shared.core.trackers import EventVerbosity
|
|
711
|
+
def _create_executor(self) -> CustomActionExecutor:
|
|
712
|
+
"""Creates an executor based on the action endpoint configuration.
|
|
717
713
|
|
|
718
|
-
|
|
714
|
+
Returns:
|
|
715
|
+
An instance of CustomActionExecutor.
|
|
719
716
|
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
"tracker": tracker_state,
|
|
724
|
-
"version": rasa.__version__,
|
|
725
|
-
}
|
|
717
|
+
Raises:
|
|
718
|
+
RasaException: If no valid action endpoint is configured.
|
|
719
|
+
"""
|
|
726
720
|
|
|
727
|
-
if
|
|
728
|
-
|
|
729
|
-
or domain.does_custom_action_explicitly_need_domain(self.name())
|
|
730
|
-
):
|
|
731
|
-
result["domain"] = domain.as_dict()
|
|
721
|
+
if not self.action_endpoint:
|
|
722
|
+
return NoEndpointCustomActionExecutor(self.name())
|
|
732
723
|
|
|
733
|
-
|
|
724
|
+
url_schema = get_url_schema(self.action_endpoint.url)
|
|
734
725
|
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
726
|
+
if url_schema == UrlSchema.GRPC:
|
|
727
|
+
return RetryCustomActionExecutor(
|
|
728
|
+
GRPCCustomActionExecutor(self.name(), self.action_endpoint)
|
|
729
|
+
)
|
|
730
|
+
elif (
|
|
731
|
+
url_schema == UrlSchema.HTTP
|
|
732
|
+
or url_schema == UrlSchema.HTTPS
|
|
733
|
+
or url_schema == UrlSchema.NOT_SPECIFIED
|
|
734
|
+
):
|
|
735
|
+
return RetryCustomActionExecutor(
|
|
736
|
+
HTTPCustomActionExecutor(self.name(), self.action_endpoint)
|
|
737
|
+
)
|
|
738
|
+
raise RasaException(
|
|
739
|
+
f"Failed to create a custom action executor. "
|
|
740
|
+
f"Please make sure to include an action endpoint configuration in your "
|
|
741
|
+
f"endpoints configuration file. Make sure that for grpc, http and https "
|
|
742
|
+
f"an url schema is set. "
|
|
743
|
+
f"Found url '{self.action_endpoint.url}'."
|
|
740
744
|
)
|
|
741
745
|
|
|
742
746
|
@staticmethod
|
|
@@ -813,102 +817,22 @@ class RemoteAction(Action):
|
|
|
813
817
|
metadata: Optional[Dict[Text, Any]] = None,
|
|
814
818
|
) -> List[Event]:
|
|
815
819
|
"""Runs action. Please see parent class for the full docstring."""
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
raise RasaException(
|
|
819
|
-
f"Failed to execute custom action '{self.name()}' "
|
|
820
|
-
f"because no endpoint is configured to run this "
|
|
821
|
-
f"custom action. Please take a look at "
|
|
822
|
-
f"the docs and set an endpoint configuration via the "
|
|
823
|
-
f"--endpoints flag. "
|
|
824
|
-
f"{DOCS_BASE_URL}/custom-actions"
|
|
825
|
-
)
|
|
826
|
-
|
|
827
|
-
try:
|
|
828
|
-
logger.debug(
|
|
829
|
-
"Calling action endpoint to run action '{}'.".format(self.name())
|
|
830
|
-
)
|
|
831
|
-
|
|
832
|
-
should_compress = get_bool_env_variable(
|
|
833
|
-
COMPRESS_ACTION_SERVER_REQUEST_ENV_NAME,
|
|
834
|
-
DEFAULT_COMPRESS_ACTION_SERVER_REQUEST,
|
|
835
|
-
)
|
|
820
|
+
response = await self.executor.run(tracker=tracker, domain=domain)
|
|
821
|
+
self._validate_action_result(response)
|
|
836
822
|
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
)
|
|
843
|
-
self._validate_action_result(response)
|
|
844
|
-
|
|
845
|
-
events_json = response.get("events", [])
|
|
846
|
-
responses = response.get("responses", [])
|
|
847
|
-
bot_messages = await self._utter_responses(
|
|
848
|
-
responses, output_channel, nlg, tracker
|
|
849
|
-
)
|
|
850
|
-
|
|
851
|
-
events = rasa.shared.core.events.deserialise_events(events_json)
|
|
852
|
-
return cast(List[Event], bot_messages) + events
|
|
853
|
-
|
|
854
|
-
except ClientResponseError as e:
|
|
855
|
-
if e.status == 400:
|
|
856
|
-
response_data = json.loads(e.text)
|
|
857
|
-
exception = ActionExecutionRejection(
|
|
858
|
-
response_data["action_name"], response_data.get("error")
|
|
859
|
-
)
|
|
860
|
-
logger.error(exception.message)
|
|
861
|
-
raise exception
|
|
862
|
-
else:
|
|
863
|
-
raise RasaException(
|
|
864
|
-
f"Failed to execute custom action '{self.name()}'"
|
|
865
|
-
) from e
|
|
866
|
-
|
|
867
|
-
except aiohttp.ClientConnectionError as e:
|
|
868
|
-
logger.error(
|
|
869
|
-
f"Failed to run custom action '{self.name()}'. Couldn't connect "
|
|
870
|
-
f"to the server at '{self.action_endpoint.url}'. "
|
|
871
|
-
f"Is the server running? "
|
|
872
|
-
f"Error: {e}"
|
|
873
|
-
)
|
|
874
|
-
raise RasaException(
|
|
875
|
-
f"Failed to execute custom action '{self.name()}'. Couldn't connect "
|
|
876
|
-
f"to the server at '{self.action_endpoint.url}."
|
|
877
|
-
)
|
|
823
|
+
events_json = response.get("events", [])
|
|
824
|
+
responses = response.get("responses", [])
|
|
825
|
+
bot_messages = await self._utter_responses(
|
|
826
|
+
responses, output_channel, nlg, tracker
|
|
827
|
+
)
|
|
878
828
|
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
# helpful to log if they got it
|
|
882
|
-
|
|
883
|
-
# noinspection PyUnresolvedReferences
|
|
884
|
-
status = getattr(e, "status", None)
|
|
885
|
-
raise RasaException(
|
|
886
|
-
"Failed to run custom action '{}'. Action server "
|
|
887
|
-
"responded with a non 200 status code of {}. "
|
|
888
|
-
"Make sure your action server properly runs actions "
|
|
889
|
-
"and returns a 200 once the action is executed. "
|
|
890
|
-
"Error: {}".format(self.name(), status, e)
|
|
891
|
-
)
|
|
829
|
+
events = rasa.shared.core.events.deserialise_events(events_json)
|
|
830
|
+
return cast(List[Event], bot_messages) + events
|
|
892
831
|
|
|
893
832
|
def name(self) -> Text:
|
|
894
833
|
return self._name
|
|
895
834
|
|
|
896
835
|
|
|
897
|
-
class ActionExecutionRejection(RasaException):
|
|
898
|
-
"""Raising this exception allows other policies to predict a different action."""
|
|
899
|
-
|
|
900
|
-
def __init__(self, action_name: Text, message: Optional[Text] = None) -> None:
|
|
901
|
-
"""Create a new ActionExecutionRejection exception."""
|
|
902
|
-
self.action_name = action_name
|
|
903
|
-
self.message = message or "Custom action '{}' rejected to run".format(
|
|
904
|
-
action_name
|
|
905
|
-
)
|
|
906
|
-
super(ActionExecutionRejection, self).__init__()
|
|
907
|
-
|
|
908
|
-
def __str__(self) -> Text:
|
|
909
|
-
return self.message
|
|
910
|
-
|
|
911
|
-
|
|
912
836
|
class ActionRevertFallbackEvents(Action):
|
|
913
837
|
"""Reverts events which were done during the `TwoStageFallbackPolicy`.
|
|
914
838
|
|
|
@@ -987,7 +911,7 @@ def _revert_affirmation_events(tracker: "DialogueStateTracker") -> List[Event]:
|
|
|
987
911
|
last_user_event = copy.deepcopy(last_user_event)
|
|
988
912
|
# FIXME: better type annotation for `parse_data` would require
|
|
989
913
|
# a larger refactoring (e.g. switch to dataclass)
|
|
990
|
-
last_user_event.parse_data["intent"]["confidence"] = 1.0 # type: ignore[typeddict-item]
|
|
914
|
+
last_user_event.parse_data["intent"]["confidence"] = 1.0 # type: ignore[typeddict-item]
|
|
991
915
|
|
|
992
916
|
return revert_events + [last_user_event]
|
|
993
917
|
|
|
@@ -1061,7 +985,7 @@ class ActionDefaultAskAffirmation(Action):
|
|
|
1061
985
|
intent_to_affirm == DEFAULT_NLU_FALLBACK_INTENT_NAME
|
|
1062
986
|
and len(intent_ranking) > 1
|
|
1063
987
|
):
|
|
1064
|
-
intent_to_affirm = intent_ranking[1][INTENT_NAME_KEY] # type: ignore[literal-required]
|
|
988
|
+
intent_to_affirm = intent_ranking[1][INTENT_NAME_KEY] # type: ignore[literal-required]
|
|
1065
989
|
|
|
1066
990
|
affirmation_message = f"Did you mean '{intent_to_affirm}'?"
|
|
1067
991
|
|
|
@@ -1127,51 +1051,6 @@ class ActionExtractSlots(Action):
|
|
|
1127
1051
|
"""Returns action_extract_slots name."""
|
|
1128
1052
|
return ACTION_EXTRACT_SLOTS
|
|
1129
1053
|
|
|
1130
|
-
@staticmethod
|
|
1131
|
-
def _matches_mapping_conditions(
|
|
1132
|
-
mapping: Dict[Text, Any], tracker: "DialogueStateTracker", slot_name: Text
|
|
1133
|
-
) -> bool:
|
|
1134
|
-
slot_mapping_conditions = mapping.get(MAPPING_CONDITIONS)
|
|
1135
|
-
|
|
1136
|
-
if not slot_mapping_conditions:
|
|
1137
|
-
return True
|
|
1138
|
-
|
|
1139
|
-
if (
|
|
1140
|
-
tracker.is_active_loop_rejected
|
|
1141
|
-
and tracker.get_slot(REQUESTED_SLOT) == slot_name
|
|
1142
|
-
):
|
|
1143
|
-
return False
|
|
1144
|
-
|
|
1145
|
-
# check if found mapping conditions matches form
|
|
1146
|
-
for condition in slot_mapping_conditions:
|
|
1147
|
-
active_loop = condition.get(ACTIVE_LOOP)
|
|
1148
|
-
|
|
1149
|
-
if active_loop and active_loop == tracker.active_loop_name:
|
|
1150
|
-
condition_requested_slot = condition.get(REQUESTED_SLOT)
|
|
1151
|
-
if not condition_requested_slot:
|
|
1152
|
-
return True
|
|
1153
|
-
if condition_requested_slot == tracker.get_slot(REQUESTED_SLOT):
|
|
1154
|
-
return True
|
|
1155
|
-
|
|
1156
|
-
if active_loop is None and tracker.active_loop_name is None:
|
|
1157
|
-
return True
|
|
1158
|
-
|
|
1159
|
-
return False
|
|
1160
|
-
|
|
1161
|
-
@staticmethod
|
|
1162
|
-
def _verify_mapping_conditions(
|
|
1163
|
-
mapping: Dict[Text, Any], tracker: "DialogueStateTracker", slot_name: Text
|
|
1164
|
-
) -> bool:
|
|
1165
|
-
if mapping.get(MAPPING_CONDITIONS) and mapping[MAPPING_TYPE] != str(
|
|
1166
|
-
SlotMappingType.FROM_TRIGGER_INTENT
|
|
1167
|
-
):
|
|
1168
|
-
if not ActionExtractSlots._matches_mapping_conditions(
|
|
1169
|
-
mapping, tracker, slot_name
|
|
1170
|
-
):
|
|
1171
|
-
return False
|
|
1172
|
-
|
|
1173
|
-
return True
|
|
1174
|
-
|
|
1175
1054
|
async def _run_custom_action(
|
|
1176
1055
|
self,
|
|
1177
1056
|
custom_action: Text,
|
|
@@ -1221,12 +1100,19 @@ class ActionExtractSlots(Action):
|
|
|
1221
1100
|
nlg: "NaturalLanguageGenerator",
|
|
1222
1101
|
tracker: "DialogueStateTracker",
|
|
1223
1102
|
domain: "Domain",
|
|
1103
|
+
calm_custom_action_names: Optional[Set[str]] = None,
|
|
1224
1104
|
) -> Tuple[List[Event], Set[Text]]:
|
|
1225
1105
|
custom_action = mapping.get("action")
|
|
1226
1106
|
|
|
1227
1107
|
if not custom_action or custom_action in executed_custom_actions:
|
|
1228
1108
|
return [], executed_custom_actions
|
|
1229
1109
|
|
|
1110
|
+
if (
|
|
1111
|
+
calm_custom_action_names is not None
|
|
1112
|
+
and custom_action in calm_custom_action_names
|
|
1113
|
+
):
|
|
1114
|
+
return [], executed_custom_actions
|
|
1115
|
+
|
|
1230
1116
|
slot_events = await self._run_custom_action(
|
|
1231
1117
|
custom_action, output_channel, nlg, tracker, domain
|
|
1232
1118
|
)
|
|
@@ -1272,36 +1158,6 @@ class ActionExtractSlots(Action):
|
|
|
1272
1158
|
event for event in slot_events if event.key not in validated_slot_names
|
|
1273
1159
|
]
|
|
1274
1160
|
|
|
1275
|
-
def _fails_unique_entity_mapping_check(
|
|
1276
|
-
self,
|
|
1277
|
-
slot_name: Text,
|
|
1278
|
-
mapping: Dict[Text, Any],
|
|
1279
|
-
tracker: "DialogueStateTracker",
|
|
1280
|
-
domain: "Domain",
|
|
1281
|
-
) -> bool:
|
|
1282
|
-
from rasa.core.actions.forms import FormAction
|
|
1283
|
-
|
|
1284
|
-
if mapping[MAPPING_TYPE] != str(SlotMappingType.FROM_ENTITY):
|
|
1285
|
-
return False
|
|
1286
|
-
|
|
1287
|
-
form_name = tracker.active_loop_name
|
|
1288
|
-
|
|
1289
|
-
if not form_name:
|
|
1290
|
-
return False
|
|
1291
|
-
|
|
1292
|
-
if tracker.get_slot(REQUESTED_SLOT) == slot_name:
|
|
1293
|
-
return False
|
|
1294
|
-
|
|
1295
|
-
form = FormAction(form_name, self._action_endpoint)
|
|
1296
|
-
|
|
1297
|
-
if slot_name not in form.required_slots(domain):
|
|
1298
|
-
return False
|
|
1299
|
-
|
|
1300
|
-
if form.entity_mapping_is_unique(mapping, domain):
|
|
1301
|
-
return False
|
|
1302
|
-
|
|
1303
|
-
return True
|
|
1304
|
-
|
|
1305
1161
|
async def run(
|
|
1306
1162
|
self,
|
|
1307
1163
|
output_channel: "OutputChannel",
|
|
@@ -1320,50 +1176,32 @@ class ActionExtractSlots(Action):
|
|
|
1320
1176
|
if slot.name not in DEFAULT_SLOT_NAMES | KNOWLEDGE_BASE_SLOT_NAMES
|
|
1321
1177
|
]
|
|
1322
1178
|
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
if not SlotMapping.check_mapping_validity(
|
|
1328
|
-
slot_name=slot.name,
|
|
1329
|
-
mapping_type=mapping_type,
|
|
1330
|
-
mapping=mapping,
|
|
1331
|
-
domain=domain,
|
|
1332
|
-
):
|
|
1333
|
-
continue
|
|
1334
|
-
|
|
1335
|
-
intent_is_desired = SlotMapping.intent_is_desired(
|
|
1336
|
-
mapping, tracker, domain
|
|
1337
|
-
)
|
|
1338
|
-
|
|
1339
|
-
if not intent_is_desired:
|
|
1340
|
-
continue
|
|
1179
|
+
calm_slot_names = set()
|
|
1180
|
+
calm_custom_action_names = None
|
|
1181
|
+
flows = None
|
|
1341
1182
|
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
):
|
|
1345
|
-
continue
|
|
1183
|
+
if metadata is not None:
|
|
1184
|
+
flows = metadata.get("all_flows")
|
|
1346
1185
|
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1186
|
+
if flows is not None:
|
|
1187
|
+
flows = FlowsList.from_json(flows)
|
|
1188
|
+
calm_slot_names = flows.available_slot_names()
|
|
1189
|
+
calm_custom_action_names = flows.available_custom_actions()
|
|
1351
1190
|
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
)
|
|
1356
|
-
else:
|
|
1357
|
-
value = None
|
|
1191
|
+
slot_filling_manager = SlotFillingManager(
|
|
1192
|
+
domain, tracker, action_endpoint=self._action_endpoint
|
|
1193
|
+
)
|
|
1358
1194
|
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1195
|
+
for slot in user_slots:
|
|
1196
|
+
if slot.name in calm_slot_names:
|
|
1197
|
+
continue
|
|
1362
1198
|
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1199
|
+
slot_value, is_extracted = extract_slot_value(slot, slot_filling_manager)
|
|
1200
|
+
if is_extracted:
|
|
1201
|
+
slot_events.append(SlotSet(slot.name, slot_value))
|
|
1366
1202
|
|
|
1203
|
+
for mapping in slot.mappings:
|
|
1204
|
+
mapping_type = SlotMappingType(mapping.get(MAPPING_TYPE))
|
|
1367
1205
|
should_fill_custom_slot = mapping_type == SlotMappingType.CUSTOM
|
|
1368
1206
|
|
|
1369
1207
|
if should_fill_custom_slot:
|
|
@@ -1377,6 +1215,7 @@ class ActionExtractSlots(Action):
|
|
|
1377
1215
|
nlg,
|
|
1378
1216
|
tracker,
|
|
1379
1217
|
domain,
|
|
1218
|
+
calm_custom_action_names,
|
|
1380
1219
|
)
|
|
1381
1220
|
slot_events.extend(custom_evts)
|
|
1382
1221
|
|
|
@@ -1384,67 +1223,3 @@ class ActionExtractSlots(Action):
|
|
|
1384
1223
|
slot_events, output_channel, nlg, tracker, domain
|
|
1385
1224
|
)
|
|
1386
1225
|
return validated_events
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
def extract_slot_value_from_predefined_mapping(
|
|
1390
|
-
mapping_type: SlotMappingType,
|
|
1391
|
-
mapping: Dict[Text, Any],
|
|
1392
|
-
tracker: "DialogueStateTracker",
|
|
1393
|
-
) -> List[Any]:
|
|
1394
|
-
"""Extracts slot value if slot has an applicable predefined mapping."""
|
|
1395
|
-
if tracker.has_bot_message_after_latest_user_message():
|
|
1396
|
-
# TODO: this needs further validation - not sure if this breaks something!!!
|
|
1397
|
-
|
|
1398
|
-
# If the bot sent a message after the user sent a message, we can't
|
|
1399
|
-
# extract any slots from the user message. We assume that the user
|
|
1400
|
-
# message was already processed by the bot and the slot value was
|
|
1401
|
-
# already extracted (e.g. for a prior form slot).
|
|
1402
|
-
return []
|
|
1403
|
-
|
|
1404
|
-
should_fill_entity_slot = (
|
|
1405
|
-
mapping_type == SlotMappingType.FROM_ENTITY
|
|
1406
|
-
and SlotMapping.entity_is_desired(mapping, tracker)
|
|
1407
|
-
)
|
|
1408
|
-
|
|
1409
|
-
should_fill_intent_slot = mapping_type == SlotMappingType.FROM_INTENT
|
|
1410
|
-
|
|
1411
|
-
should_fill_text_slot = mapping_type == SlotMappingType.FROM_TEXT
|
|
1412
|
-
|
|
1413
|
-
active_loops_in_mapping_conditions = [
|
|
1414
|
-
active_loop.get(ACTIVE_LOOP)
|
|
1415
|
-
for active_loop in mapping.get(MAPPING_CONDITIONS, [])
|
|
1416
|
-
]
|
|
1417
|
-
|
|
1418
|
-
trigger_mapping_condition_met = True
|
|
1419
|
-
|
|
1420
|
-
if tracker.active_loop_name is None:
|
|
1421
|
-
trigger_mapping_condition_met = False
|
|
1422
|
-
elif (
|
|
1423
|
-
active_loops_in_mapping_conditions
|
|
1424
|
-
and tracker.active_loop_name is not None
|
|
1425
|
-
and (tracker.active_loop_name not in active_loops_in_mapping_conditions)
|
|
1426
|
-
):
|
|
1427
|
-
trigger_mapping_condition_met = False
|
|
1428
|
-
|
|
1429
|
-
should_fill_trigger_slot = (
|
|
1430
|
-
mapping_type == SlotMappingType.FROM_TRIGGER_INTENT
|
|
1431
|
-
and trigger_mapping_condition_met
|
|
1432
|
-
)
|
|
1433
|
-
|
|
1434
|
-
value: List[Any] = []
|
|
1435
|
-
if should_fill_entity_slot:
|
|
1436
|
-
value = list(
|
|
1437
|
-
tracker.get_latest_entity_values(
|
|
1438
|
-
mapping.get(ENTITY_ATTRIBUTE_TYPE),
|
|
1439
|
-
mapping.get(ENTITY_ATTRIBUTE_ROLE),
|
|
1440
|
-
mapping.get(ENTITY_ATTRIBUTE_GROUP),
|
|
1441
|
-
)
|
|
1442
|
-
)
|
|
1443
|
-
elif should_fill_intent_slot or should_fill_trigger_slot:
|
|
1444
|
-
value = [mapping.get("value")]
|
|
1445
|
-
elif should_fill_text_slot:
|
|
1446
|
-
value = [
|
|
1447
|
-
tracker.latest_message.text if tracker.latest_message is not None else None
|
|
1448
|
-
]
|
|
1449
|
-
|
|
1450
|
-
return value
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from rasa.shared.exceptions import RasaException
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ActionExecutionRejection(RasaException):
|
|
7
|
+
"""Raising this exception allows other policies to predict a different action."""
|
|
8
|
+
|
|
9
|
+
def __init__(self, action_name: str, message: Optional[str] = None) -> None:
|
|
10
|
+
"""Create a new ActionExecutionRejection exception."""
|
|
11
|
+
self.action_name = action_name
|
|
12
|
+
self.message = message or "Custom action '{}' rejected to run".format(
|
|
13
|
+
action_name
|
|
14
|
+
)
|
|
15
|
+
super(ActionExecutionRejection, self).__init__()
|
|
16
|
+
|
|
17
|
+
def __str__(self) -> str:
|
|
18
|
+
return self.message
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class DomainNotFound(Exception):
|
|
22
|
+
"""Exception raised when domain is not found."""
|
|
23
|
+
|
|
24
|
+
pass
|