rasa-pro 3.8.18__py3-none-any.whl → 3.9.15__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 +6 -42
- 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/constants.py +1 -1
- 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 +3 -26
- rasa/core/featurizers/tracker_featurizers.py +18 -122
- 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 +61 -88
- rasa/core/policies/unexpected_intent_policy.py +8 -17
- 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 +38 -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 +36 -31
- rasa/dialogue_understanding/processor/command_processor.py +112 -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 +33 -52
- rasa/nlu/classifiers/logistic_regression_classifier.py +9 -22
- rasa/nlu/classifiers/sklearn_intent_classifier.py +16 -37
- rasa/nlu/extractors/crf_entity_extractor.py +54 -97
- 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 +18 -49
- rasa/nlu/featurizers/sparse_featurizer/lexical_syntactic_featurizer.py +26 -64
- rasa/nlu/featurizers/sparse_featurizer/regex_featurizer.py +3 -5
- 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/features.py +2 -120
- 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 -1
- 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 +72 -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 +201 -12
- 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.18.dist-info → rasa_pro-3.9.15.dist-info}/METADATA +25 -61
- {rasa_pro-3.8.18.dist-info → rasa_pro-3.9.15.dist-info}/RECORD +276 -259
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-855bc5b3-85583a23.js +0 -1
- rasa/utils/tensorflow/feature_array.py +0 -370
- /rasa/dialogue_understanding/generator/{command_prompt_template.jinja2 → single_step/command_prompt_template.jinja2} +0 -0
- {rasa_pro-3.8.18.dist-info → rasa_pro-3.9.15.dist-info}/NOTICE +0 -0
- {rasa_pro-3.8.18.dist-info → rasa_pro-3.9.15.dist-info}/WHEEL +0 -0
- {rasa_pro-3.8.18.dist-info → rasa_pro-3.9.15.dist-info}/entry_points.txt +0 -0
|
@@ -5,7 +5,6 @@ from typing import Any, List, Optional, Text, Dict, Type, Union
|
|
|
5
5
|
|
|
6
6
|
import numpy as np
|
|
7
7
|
import tensorflow as tf
|
|
8
|
-
|
|
9
8
|
import rasa.utils.common
|
|
10
9
|
from rasa.engine.graph import ExecutionContext
|
|
11
10
|
from rasa.engine.recipes.default_recipe import DefaultV1Recipe
|
|
@@ -17,7 +16,6 @@ from rasa.shared.core.domain import Domain
|
|
|
17
16
|
from rasa.shared.core.trackers import DialogueStateTracker
|
|
18
17
|
from rasa.shared.core.constants import SLOTS, ACTIVE_LOOP, ACTION_UNLIKELY_INTENT_NAME
|
|
19
18
|
from rasa.shared.core.events import UserUttered, ActionExecuted
|
|
20
|
-
import rasa.shared.utils.io
|
|
21
19
|
from rasa.shared.nlu.constants import (
|
|
22
20
|
INTENT,
|
|
23
21
|
TEXT,
|
|
@@ -105,6 +103,8 @@ from rasa.utils.tensorflow.constants import (
|
|
|
105
103
|
)
|
|
106
104
|
from rasa.utils.tensorflow import layers
|
|
107
105
|
from rasa.utils.tensorflow.model_data import RasaModelData, FeatureArray, Data
|
|
106
|
+
|
|
107
|
+
import rasa.utils.io as io_utils
|
|
108
108
|
from rasa.core.exceptions import RasaCoreException
|
|
109
109
|
from rasa.shared.utils import common
|
|
110
110
|
|
|
@@ -794,7 +794,6 @@ class UnexpecTEDIntentPolicy(TEDPolicy):
|
|
|
794
794
|
}
|
|
795
795
|
|
|
796
796
|
for index, all_pos_labels in enumerate(label_ids):
|
|
797
|
-
|
|
798
797
|
for candidate_label_id in unique_label_ids:
|
|
799
798
|
if candidate_label_id in all_pos_labels:
|
|
800
799
|
label_id_scores[candidate_label_id][POSITIVE_SCORES_KEY].append(
|
|
@@ -809,7 +808,7 @@ class UnexpecTEDIntentPolicy(TEDPolicy):
|
|
|
809
808
|
|
|
810
809
|
@staticmethod
|
|
811
810
|
def _compute_label_quantiles(
|
|
812
|
-
label_id_scores: Dict[int, Dict[Text, List[float]]]
|
|
811
|
+
label_id_scores: Dict[int, Dict[Text, List[float]]],
|
|
813
812
|
) -> Dict[int, List[float]]:
|
|
814
813
|
"""Computes multiple quantiles for each label id.
|
|
815
814
|
|
|
@@ -882,12 +881,9 @@ class UnexpecTEDIntentPolicy(TEDPolicy):
|
|
|
882
881
|
model_path: Path where model is to be persisted
|
|
883
882
|
"""
|
|
884
883
|
super().persist_model_utilities(model_path)
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
save_file(
|
|
889
|
-
{str(k): np.array(v) for k, v in self.label_quantiles.items()},
|
|
890
|
-
model_path / f"{self._metadata_filename()}.label_quantiles.st",
|
|
884
|
+
io_utils.pickle_dump(
|
|
885
|
+
model_path / f"{self._metadata_filename()}.label_quantiles.pkl",
|
|
886
|
+
self.label_quantiles,
|
|
891
887
|
)
|
|
892
888
|
|
|
893
889
|
@classmethod
|
|
@@ -898,14 +894,9 @@ class UnexpecTEDIntentPolicy(TEDPolicy):
|
|
|
898
894
|
model_path: Path where model is to be persisted.
|
|
899
895
|
"""
|
|
900
896
|
model_utilties = super()._load_model_utilities(model_path)
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
loaded_label_quantiles = load_file(
|
|
905
|
-
model_path / f"{cls._metadata_filename()}.label_quantiles.st"
|
|
897
|
+
label_quantiles = io_utils.pickle_load(
|
|
898
|
+
model_path / f"{cls._metadata_filename()}.label_quantiles.pkl"
|
|
906
899
|
)
|
|
907
|
-
label_quantiles = {int(k): list(v) for k, v in loaded_label_quantiles.items()}
|
|
908
|
-
|
|
909
900
|
model_utilties.update({"label_quantiles": label_quantiles})
|
|
910
901
|
return model_utilties
|
|
911
902
|
|
rasa/core/processor.py
CHANGED
|
@@ -3,15 +3,21 @@ import copy
|
|
|
3
3
|
import logging
|
|
4
4
|
import structlog
|
|
5
5
|
import os
|
|
6
|
-
import re
|
|
7
6
|
from pathlib import Path
|
|
8
7
|
import tarfile
|
|
9
8
|
import time
|
|
10
9
|
from types import LambdaType
|
|
11
10
|
from typing import Any, Dict, List, Optional, TYPE_CHECKING, Text, Tuple, Union
|
|
12
11
|
|
|
12
|
+
from rasa.core.actions.action_exceptions import ActionExecutionRejection
|
|
13
|
+
from rasa.core.actions.forms import FormAction
|
|
13
14
|
from rasa.core.http_interpreter import RasaNLUHttpInterpreter
|
|
14
|
-
from rasa.dialogue_understanding.commands import
|
|
15
|
+
from rasa.dialogue_understanding.commands import (
|
|
16
|
+
Command,
|
|
17
|
+
NoopCommand,
|
|
18
|
+
SetSlotCommand,
|
|
19
|
+
CannotHandleCommand,
|
|
20
|
+
)
|
|
15
21
|
from rasa.engine import loader
|
|
16
22
|
from rasa.engine.constants import (
|
|
17
23
|
PLACEHOLDER_MESSAGE,
|
|
@@ -24,7 +30,7 @@ from rasa.engine.storage.storage import ModelMetadata
|
|
|
24
30
|
from rasa.model import get_latest_model
|
|
25
31
|
from rasa.plugin import plugin_manager
|
|
26
32
|
from rasa.shared.core.flows import FlowsList
|
|
27
|
-
from rasa.shared.data import TrainingType
|
|
33
|
+
from rasa.shared.data import TrainingType, create_regex_pattern_reader
|
|
28
34
|
import rasa.shared.utils.io
|
|
29
35
|
import rasa.core.actions.action
|
|
30
36
|
from rasa.core import jobs
|
|
@@ -73,9 +79,6 @@ import rasa.core.tracker_store
|
|
|
73
79
|
import rasa.core.actions.action
|
|
74
80
|
import rasa.shared.core.trackers
|
|
75
81
|
from rasa.shared.core.trackers import DialogueStateTracker, EventVerbosity
|
|
76
|
-
from rasa.shared.core.training_data.story_reader.yaml_story_reader import (
|
|
77
|
-
YAMLStoryReader,
|
|
78
|
-
)
|
|
79
82
|
from rasa.shared.nlu.constants import (
|
|
80
83
|
COMMANDS,
|
|
81
84
|
ENTITIES,
|
|
@@ -143,7 +146,7 @@ class MessageProcessor:
|
|
|
143
146
|
|
|
144
147
|
@staticmethod
|
|
145
148
|
def _load_model(
|
|
146
|
-
model_path: Union[Text, Path]
|
|
149
|
+
model_path: Union[Text, Path],
|
|
147
150
|
) -> Tuple[Text, ModelMetadata, GraphRunner]:
|
|
148
151
|
"""Unpacks a model from a given path using the graph model loader."""
|
|
149
152
|
try:
|
|
@@ -185,7 +188,10 @@ class MessageProcessor:
|
|
|
185
188
|
)
|
|
186
189
|
return None
|
|
187
190
|
|
|
188
|
-
|
|
191
|
+
if not self.message_contains_commands(tracker.latest_message):
|
|
192
|
+
tracker = await self.run_action_extract_slots(
|
|
193
|
+
message.output_channel, tracker
|
|
194
|
+
)
|
|
189
195
|
|
|
190
196
|
await self._run_prediction_loop(message.output_channel, tracker)
|
|
191
197
|
|
|
@@ -213,8 +219,10 @@ class MessageProcessor:
|
|
|
213
219
|
action_extract_slots = rasa.core.actions.action.action_for_name_or_text(
|
|
214
220
|
ACTION_EXTRACT_SLOTS, self.domain, self.action_endpoint
|
|
215
221
|
)
|
|
222
|
+
metadata = await self._add_flows_to_metadata()
|
|
223
|
+
|
|
216
224
|
extraction_events = await action_extract_slots.run(
|
|
217
|
-
output_channel, self.nlg, tracker, self.domain
|
|
225
|
+
output_channel, self.nlg, tracker, self.domain, metadata
|
|
218
226
|
)
|
|
219
227
|
|
|
220
228
|
await self._send_bot_messages(extraction_events, tracker, output_channel)
|
|
@@ -735,28 +743,37 @@ class MessageProcessor:
|
|
|
735
743
|
if self.http_interpreter:
|
|
736
744
|
parse_data = await self.http_interpreter.parse(message)
|
|
737
745
|
else:
|
|
738
|
-
|
|
739
|
-
message=Message({TEXT: message.text}), domain=self.domain
|
|
740
|
-
)
|
|
746
|
+
regex_reader = create_regex_pattern_reader(message, self.domain)
|
|
741
747
|
|
|
742
|
-
|
|
743
|
-
|
|
748
|
+
processed_message = Message({TEXT: message.text})
|
|
749
|
+
if regex_reader:
|
|
750
|
+
processed_message = regex_reader.unpack_regex_message(
|
|
751
|
+
message=processed_message, domain=self.domain
|
|
752
|
+
)
|
|
753
|
+
|
|
754
|
+
# Invalid use of slash syntax
|
|
744
755
|
if (
|
|
745
|
-
|
|
746
|
-
and
|
|
756
|
+
processed_message.starts_with_slash_syntax()
|
|
757
|
+
and not processed_message.has_intent()
|
|
758
|
+
and not processed_message.has_commands()
|
|
747
759
|
):
|
|
748
|
-
|
|
760
|
+
parse_data = self._parse_invalid_use_of_slash_syntax(
|
|
761
|
+
processed_message, tracker, only_output_properties
|
|
762
|
+
)
|
|
749
763
|
|
|
750
|
-
#
|
|
751
|
-
|
|
764
|
+
# Intent or commands are not explicitly present. Pass message to graph.
|
|
765
|
+
elif not (
|
|
766
|
+
processed_message.has_intent() or processed_message.has_commands()
|
|
767
|
+
):
|
|
752
768
|
parse_data = await self._parse_message_with_graph(
|
|
753
769
|
message, tracker, only_output_properties
|
|
754
770
|
)
|
|
755
771
|
|
|
756
|
-
#
|
|
772
|
+
# Intents or commands are presents. Bypasses the standard parsing
|
|
773
|
+
# pipeline.
|
|
757
774
|
else:
|
|
758
|
-
parse_data = await self.
|
|
759
|
-
|
|
775
|
+
parse_data = await self._parse_message_with_commands_and_intents(
|
|
776
|
+
processed_message, tracker, only_output_properties
|
|
760
777
|
)
|
|
761
778
|
|
|
762
779
|
self._update_full_retrieval_intent(parse_data)
|
|
@@ -771,36 +788,68 @@ class MessageProcessor:
|
|
|
771
788
|
|
|
772
789
|
return parse_data
|
|
773
790
|
|
|
774
|
-
def
|
|
775
|
-
"""Sanitize user message by removing prepended slashes before the
|
|
776
|
-
actual content.
|
|
777
|
-
"""
|
|
778
|
-
# Regex pattern to match leading slashes and any whitespace before
|
|
779
|
-
# actual content
|
|
780
|
-
pattern = r"^[/\s]+"
|
|
781
|
-
# Remove the matched pattern from the beginning of the message
|
|
782
|
-
message.text = re.sub(pattern, "", message.text).strip()
|
|
783
|
-
return message
|
|
784
|
-
|
|
785
|
-
async def _parse_message_with_intent_trigger(
|
|
791
|
+
def _parse_invalid_use_of_slash_syntax(
|
|
786
792
|
self,
|
|
787
793
|
message: Message,
|
|
788
794
|
tracker: Optional[DialogueStateTracker] = None,
|
|
789
795
|
only_output_properties: bool = True,
|
|
790
796
|
) -> Dict[Text, Any]:
|
|
791
|
-
|
|
797
|
+
structlogger.warning(
|
|
798
|
+
"processor.message.parse.invalid_use_of_slash_syntax",
|
|
799
|
+
event_info=(
|
|
800
|
+
"Message starts with '/', but no intents or commands are"
|
|
801
|
+
"passed. Returning CannotHandleCommand() as a fallback."
|
|
802
|
+
),
|
|
803
|
+
message=message.get(TEXT),
|
|
804
|
+
)
|
|
792
805
|
parse_data: Dict[Text, Any] = {
|
|
793
806
|
TEXT: "",
|
|
794
807
|
INTENT: {INTENT_NAME_KEY: None, PREDICTED_CONFIDENCE_KEY: 0.0},
|
|
795
808
|
ENTITIES: [],
|
|
796
|
-
COMMANDS: [],
|
|
797
809
|
}
|
|
798
810
|
parse_data.update(
|
|
799
811
|
message.as_dict(only_output_properties=only_output_properties)
|
|
800
812
|
)
|
|
813
|
+
commands = parse_data.get(COMMANDS, [])
|
|
814
|
+
commands += [
|
|
815
|
+
CannotHandleCommand(RASA_PATTERN_CANNOT_HANDLE_INVALID_INTENT).as_dict()
|
|
816
|
+
]
|
|
817
|
+
|
|
818
|
+
if (
|
|
819
|
+
tracker is not None
|
|
820
|
+
and tracker.has_coexistence_routing_slot
|
|
821
|
+
and tracker.get_slot(ROUTE_TO_CALM_SLOT) is None
|
|
822
|
+
):
|
|
823
|
+
# if we are currently not routing to either CALM or dm1
|
|
824
|
+
# we make a sticky routing to CALM
|
|
825
|
+
commands += [SetSlotCommand(ROUTE_TO_CALM_SLOT, True).as_dict()]
|
|
826
|
+
|
|
827
|
+
parse_data[COMMANDS] = commands
|
|
828
|
+
return parse_data
|
|
829
|
+
|
|
830
|
+
async def _parse_message_with_commands_and_intents(
|
|
831
|
+
self,
|
|
832
|
+
message: Message,
|
|
833
|
+
tracker: Optional[DialogueStateTracker] = None,
|
|
834
|
+
only_output_properties: bool = True,
|
|
835
|
+
) -> Dict[Text, Any]:
|
|
836
|
+
"""Parses the message to handle commands or intent trigger."""
|
|
837
|
+
parse_data: Dict[Text, Any] = {
|
|
838
|
+
TEXT: "",
|
|
839
|
+
INTENT: {INTENT_NAME_KEY: None, PREDICTED_CONFIDENCE_KEY: 0.0},
|
|
840
|
+
ENTITIES: [],
|
|
841
|
+
}
|
|
842
|
+
parse_data.update(
|
|
843
|
+
message.as_dict(only_output_properties=only_output_properties)
|
|
844
|
+
)
|
|
845
|
+
|
|
846
|
+
commands = parse_data.get(COMMANDS, [])
|
|
847
|
+
|
|
848
|
+
# add commands from intent payloads
|
|
849
|
+
if tracker and not commands:
|
|
850
|
+
nlu_adapted_commands = await self._nlu_to_commands(parse_data, tracker)
|
|
851
|
+
commands += nlu_adapted_commands
|
|
801
852
|
|
|
802
|
-
if tracker:
|
|
803
|
-
commands = await self._nlu_to_commands(parse_data, tracker)
|
|
804
853
|
if (
|
|
805
854
|
tracker.has_coexistence_routing_slot
|
|
806
855
|
and tracker.get_slot(ROUTE_TO_CALM_SLOT) is None
|
|
@@ -809,11 +858,13 @@ class MessageProcessor:
|
|
|
809
858
|
# we make a sticky routing to CALM if there are any commands
|
|
810
859
|
# from the trigger intent parsing
|
|
811
860
|
# or a sticky routing to dm1 if there are no commands
|
|
812
|
-
commands
|
|
813
|
-
SetSlotCommand(
|
|
814
|
-
|
|
815
|
-
|
|
861
|
+
commands += [
|
|
862
|
+
SetSlotCommand(
|
|
863
|
+
ROUTE_TO_CALM_SLOT, len(nlu_adapted_commands) > 0
|
|
864
|
+
).as_dict()
|
|
865
|
+
]
|
|
816
866
|
|
|
867
|
+
parse_data[COMMANDS] = commands
|
|
817
868
|
return parse_data
|
|
818
869
|
|
|
819
870
|
def _update_full_retrieval_intent(self, parse_data: Dict[Text, Any]) -> None:
|
|
@@ -847,7 +898,7 @@ class MessageProcessor:
|
|
|
847
898
|
)
|
|
848
899
|
|
|
849
900
|
commands = NLUCommandAdapter.convert_nlu_to_commands(
|
|
850
|
-
Message(parse_data), tracker, await self.get_flows()
|
|
901
|
+
Message(parse_data), tracker, await self.get_flows(), self.domain
|
|
851
902
|
)
|
|
852
903
|
|
|
853
904
|
# if there are no converted commands and parsed data contains invalid intent
|
|
@@ -912,7 +963,6 @@ class MessageProcessor:
|
|
|
912
963
|
async def _handle_message_with_tracker(
|
|
913
964
|
self, message: UserMessage, tracker: DialogueStateTracker
|
|
914
965
|
) -> None:
|
|
915
|
-
|
|
916
966
|
if message.parse_data:
|
|
917
967
|
parse_data = message.parse_data
|
|
918
968
|
else:
|
|
@@ -1154,6 +1204,17 @@ class MessageProcessor:
|
|
|
1154
1204
|
results = await self.graph_runner.run(inputs={}, targets=[target])
|
|
1155
1205
|
return results[target]
|
|
1156
1206
|
|
|
1207
|
+
async def _add_flows_to_metadata(self) -> Dict[Text, Any]:
|
|
1208
|
+
"""Convert the flows to metadata."""
|
|
1209
|
+
flows = await self.get_flows()
|
|
1210
|
+
flows_metadata = {}
|
|
1211
|
+
for flow in flows.underlying_flows:
|
|
1212
|
+
flow_as_json = flow.as_json()
|
|
1213
|
+
flow_as_json.pop("id")
|
|
1214
|
+
flows_metadata[flow.id] = flow_as_json
|
|
1215
|
+
|
|
1216
|
+
return {"all_flows": flows_metadata}
|
|
1217
|
+
|
|
1157
1218
|
async def _run_action(
|
|
1158
1219
|
self,
|
|
1159
1220
|
action: rasa.core.actions.action.Action,
|
|
@@ -1172,18 +1233,25 @@ class MessageProcessor:
|
|
|
1172
1233
|
|
|
1173
1234
|
run_args = inspect.getfullargspec(action.run).args
|
|
1174
1235
|
if "metadata" in run_args:
|
|
1236
|
+
metadata: Optional[Dict] = prediction.action_metadata
|
|
1237
|
+
|
|
1238
|
+
if isinstance(action, FormAction):
|
|
1239
|
+
flows_metadata = await self._add_flows_to_metadata()
|
|
1240
|
+
metadata = prediction.action_metadata or {}
|
|
1241
|
+
metadata.update(flows_metadata)
|
|
1242
|
+
|
|
1175
1243
|
events = await action.run(
|
|
1176
1244
|
output_channel,
|
|
1177
1245
|
nlg,
|
|
1178
1246
|
temporary_tracker,
|
|
1179
1247
|
self.domain,
|
|
1180
|
-
metadata=
|
|
1248
|
+
metadata=metadata,
|
|
1181
1249
|
)
|
|
1182
1250
|
else:
|
|
1183
1251
|
events = await action.run(
|
|
1184
1252
|
output_channel, nlg, temporary_tracker, self.domain
|
|
1185
1253
|
)
|
|
1186
|
-
except
|
|
1254
|
+
except ActionExecutionRejection:
|
|
1187
1255
|
events = [
|
|
1188
1256
|
ActionExecutionRejected(
|
|
1189
1257
|
action.name(), prediction.policy_name, prediction.max_confidence
|
|
@@ -1312,7 +1380,7 @@ class MessageProcessor:
|
|
|
1312
1380
|
|
|
1313
1381
|
logger.error(
|
|
1314
1382
|
f"Trying to run unknown follow-up action '{followup_action}'. "
|
|
1315
|
-
"Instead of running that, Rasa
|
|
1383
|
+
"Instead of running that, Rasa Pro will ignore the action "
|
|
1316
1384
|
"and predict the next action."
|
|
1317
1385
|
)
|
|
1318
1386
|
|
|
@@ -1329,3 +1397,24 @@ class MessageProcessor:
|
|
|
1329
1397
|
)
|
|
1330
1398
|
policy_prediction = results[target]
|
|
1331
1399
|
return policy_prediction
|
|
1400
|
+
|
|
1401
|
+
@staticmethod
|
|
1402
|
+
def message_contains_commands(latest_message: Optional[UserUttered]) -> bool:
|
|
1403
|
+
"""Check if the latest message contains commands."""
|
|
1404
|
+
if latest_message is None:
|
|
1405
|
+
return False
|
|
1406
|
+
|
|
1407
|
+
commands = [
|
|
1408
|
+
Command.command_from_json(command) for command in latest_message.commands
|
|
1409
|
+
]
|
|
1410
|
+
filtered_commands = [
|
|
1411
|
+
command
|
|
1412
|
+
for command in commands
|
|
1413
|
+
if not (
|
|
1414
|
+
isinstance(command, SetSlotCommand)
|
|
1415
|
+
and command.name == ROUTE_TO_CALM_SLOT
|
|
1416
|
+
)
|
|
1417
|
+
and not isinstance(command, NoopCommand)
|
|
1418
|
+
]
|
|
1419
|
+
|
|
1420
|
+
return len(filtered_commands) > 0
|
rasa/core/run.py
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import logging
|
|
3
|
-
import uuid
|
|
4
|
-
import platform
|
|
5
3
|
import os
|
|
4
|
+
import platform
|
|
5
|
+
import uuid
|
|
6
|
+
import warnings
|
|
7
|
+
from asyncio import AbstractEventLoop
|
|
6
8
|
from functools import partial
|
|
7
9
|
from typing import (
|
|
8
10
|
Any,
|
|
@@ -15,11 +17,14 @@ from typing import (
|
|
|
15
17
|
Dict,
|
|
16
18
|
)
|
|
17
19
|
|
|
20
|
+
from sanic import Sanic
|
|
21
|
+
from sanic.worker.loader import AppLoader
|
|
22
|
+
|
|
18
23
|
import rasa.core.utils
|
|
19
|
-
from rasa.plugin import plugin_manager
|
|
20
|
-
from rasa.shared.exceptions import RasaException
|
|
21
24
|
import rasa.shared.utils.common
|
|
25
|
+
import rasa.shared.utils.io
|
|
22
26
|
import rasa.utils
|
|
27
|
+
from rasa.utils import licensing
|
|
23
28
|
import rasa.utils.common
|
|
24
29
|
import rasa.utils.io
|
|
25
30
|
from rasa import server, telemetry
|
|
@@ -29,10 +34,8 @@ from rasa.core.agent import Agent
|
|
|
29
34
|
from rasa.core.channels import console
|
|
30
35
|
from rasa.core.channels.channel import InputChannel
|
|
31
36
|
from rasa.core.utils import AvailableEndpoints
|
|
32
|
-
|
|
33
|
-
from
|
|
34
|
-
from asyncio import AbstractEventLoop
|
|
35
|
-
|
|
37
|
+
from rasa.plugin import plugin_manager
|
|
38
|
+
from rasa.shared.exceptions import RasaException
|
|
36
39
|
from rasa.shared.utils.yaml import read_config_file
|
|
37
40
|
|
|
38
41
|
logger = logging.getLogger() # get the root logger
|
|
@@ -84,6 +87,10 @@ def _create_single_channel(channel: Text, credentials: Dict[Text, Any]) -> Any:
|
|
|
84
87
|
|
|
85
88
|
def _create_app_without_api(cors: Optional[Union[Text, List[Text]]] = None) -> Sanic:
|
|
86
89
|
app = Sanic("rasa_core_no_api", configure_logging=False)
|
|
90
|
+
|
|
91
|
+
# Reset Sanic warnings filter that allows the triggering of Sanic warnings
|
|
92
|
+
warnings.filterwarnings("ignore", category=DeprecationWarning, module=r"sanic.*")
|
|
93
|
+
|
|
87
94
|
server.add_root_route(app)
|
|
88
95
|
server.configure_cors(app, cors)
|
|
89
96
|
return app
|
|
@@ -126,19 +133,24 @@ def configure_app(
|
|
|
126
133
|
)
|
|
127
134
|
|
|
128
135
|
if enable_api:
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
136
|
+
loader = AppLoader(
|
|
137
|
+
factory=partial(
|
|
138
|
+
server.create_app,
|
|
139
|
+
cors_origins=cors,
|
|
140
|
+
auth_token=auth_token,
|
|
141
|
+
response_timeout=response_timeout,
|
|
142
|
+
jwt_secret=jwt_secret,
|
|
143
|
+
jwt_private_key=jwt_private_key,
|
|
144
|
+
jwt_method=jwt_method,
|
|
145
|
+
endpoints=endpoints,
|
|
146
|
+
)
|
|
137
147
|
)
|
|
138
148
|
else:
|
|
139
|
-
|
|
149
|
+
loader = AppLoader(factory=partial(_create_app_without_api, cors))
|
|
140
150
|
|
|
151
|
+
app = loader.load()
|
|
141
152
|
app.config.KEEP_ALIVE_TIMEOUT = keep_alive_timeout
|
|
153
|
+
|
|
142
154
|
if _is_apple_silicon_system() or not use_uvloop:
|
|
143
155
|
app.config.USE_UVLOOP = False
|
|
144
156
|
# some library still sets the loop to uvloop, even if disabled for sanic
|
|
@@ -154,18 +166,16 @@ def configure_app(
|
|
|
154
166
|
if logger.isEnabledFor(logging.DEBUG):
|
|
155
167
|
rasa.core.utils.list_routes(app)
|
|
156
168
|
|
|
157
|
-
|
|
169
|
+
@app.main_process_start
|
|
170
|
+
async def configure_async_logging(running_app: Sanic) -> None:
|
|
158
171
|
if logger.isEnabledFor(logging.DEBUG):
|
|
159
172
|
rasa.utils.io.enable_async_loop_debugging(asyncio.get_event_loop())
|
|
160
173
|
|
|
161
|
-
app.add_task(configure_async_logging)
|
|
162
|
-
|
|
163
174
|
if "cmdline" in {c.name() for c in input_channels}:
|
|
164
175
|
|
|
176
|
+
@app.after_server_start
|
|
165
177
|
async def run_cmdline_io(running_app: Sanic) -> None:
|
|
166
178
|
"""Small wrapper to shut down the server once cmd io is done."""
|
|
167
|
-
await asyncio.sleep(1) # allow server to start
|
|
168
|
-
|
|
169
179
|
await console.record_messages(
|
|
170
180
|
server_url=constants.DEFAULT_SERVER_FORMAT.format("http", port),
|
|
171
181
|
sender_id=conversation_id,
|
|
@@ -174,12 +184,13 @@ def configure_app(
|
|
|
174
184
|
|
|
175
185
|
logger.info("Killing Sanic server now.")
|
|
176
186
|
running_app.stop() # kill the sanic server
|
|
177
|
-
plugin_manager().hook.after_server_stop()
|
|
178
187
|
|
|
179
|
-
|
|
188
|
+
@app.after_server_stop
|
|
189
|
+
async def after_server_stop(running_app: Sanic) -> None:
|
|
190
|
+
plugin_manager().hook.after_server_stop()
|
|
180
191
|
|
|
181
192
|
if server_listeners:
|
|
182
|
-
for
|
|
193
|
+
for listener, event in server_listeners:
|
|
183
194
|
app.register_listener(listener, event)
|
|
184
195
|
|
|
185
196
|
return app
|
|
@@ -252,6 +263,10 @@ def serve_application(
|
|
|
252
263
|
"before_server_start",
|
|
253
264
|
)
|
|
254
265
|
|
|
266
|
+
app.register_listener(
|
|
267
|
+
licensing.validate_limited_server_license, "after_server_start"
|
|
268
|
+
)
|
|
269
|
+
|
|
255
270
|
app.register_listener(close_resources, "after_server_stop")
|
|
256
271
|
|
|
257
272
|
number_of_workers = rasa.core.utils.number_of_sanic_workers(
|
|
@@ -272,6 +287,7 @@ def serve_application(
|
|
|
272
287
|
ssl=ssl_context,
|
|
273
288
|
backlog=int(os.environ.get(ENV_SANIC_BACKLOG, "100")),
|
|
274
289
|
workers=number_of_workers,
|
|
290
|
+
legacy=True,
|
|
275
291
|
)
|
|
276
292
|
|
|
277
293
|
|
|
@@ -47,7 +47,7 @@ class CredentialsLocation:
|
|
|
47
47
|
|
|
48
48
|
@staticmethod
|
|
49
49
|
def is_credentials_location_instance(
|
|
50
|
-
value: Union[Text, "CredentialsLocation"]
|
|
50
|
+
value: Union[Text, "CredentialsLocation"],
|
|
51
51
|
) -> bool:
|
|
52
52
|
"""Check if the value is a CredentialsLocation.
|
|
53
53
|
|
|
@@ -85,7 +85,7 @@ class CredentialsLocation:
|
|
|
85
85
|
|
|
86
86
|
@staticmethod
|
|
87
87
|
def is_credentials_location_valid(
|
|
88
|
-
raw_credentials_location: Dict[Text, Text]
|
|
88
|
+
raw_credentials_location: Dict[Text, Text],
|
|
89
89
|
) -> bool:
|
|
90
90
|
"""Check if the configuration is a secret manager configuration.
|
|
91
91
|
|
|
@@ -124,7 +124,6 @@ class VaultEndpointConfigReader:
|
|
|
124
124
|
credentials_location.get_secret_manager_name()
|
|
125
125
|
== VAULT_SECRET_MANAGER_NAME
|
|
126
126
|
):
|
|
127
|
-
|
|
128
127
|
return VaultCredentialsLocation.from_credentials_location(
|
|
129
128
|
credentials_location=credentials_location
|
|
130
129
|
)
|
|
@@ -161,11 +160,10 @@ class VaultEndpointConfigReader:
|
|
|
161
160
|
credentials_location
|
|
162
161
|
)
|
|
163
162
|
):
|
|
164
|
-
|
|
165
163
|
if credentials_location.transit_key:
|
|
166
|
-
transit_keys[
|
|
167
|
-
credentials_location.
|
|
168
|
-
|
|
164
|
+
transit_keys[credentials_location.secret_key] = (
|
|
165
|
+
credentials_location.transit_key
|
|
166
|
+
)
|
|
169
167
|
|
|
170
168
|
return transit_keys if transit_keys else None
|
|
171
169
|
|
|
@@ -357,9 +355,9 @@ class VaultTokenManager:
|
|
|
357
355
|
|
|
358
356
|
def start(self) -> None:
|
|
359
357
|
"""Start refreshing the token if it is expiring."""
|
|
360
|
-
renew_response: Dict[
|
|
361
|
-
|
|
362
|
-
|
|
358
|
+
renew_response: Dict[Text, Dict[Text, Any]] = (
|
|
359
|
+
self.client.auth.token.lookup_self()
|
|
360
|
+
)
|
|
363
361
|
is_token_expiring = renew_response["data"]["renewable"]
|
|
364
362
|
if is_token_expiring:
|
|
365
363
|
refresh_interval_in_seconds = renew_response["data"]["creation_ttl"]
|
rasa/core/test.py
CHANGED
|
@@ -300,14 +300,14 @@ class EvaluationStore:
|
|
|
300
300
|
filter(
|
|
301
301
|
lambda x: x.get(ENTITY_ATTRIBUTE_TEXT) == text, self.entity_targets
|
|
302
302
|
),
|
|
303
|
-
key=lambda x: x[ENTITY_ATTRIBUTE_START], # type: ignore[literal-required]
|
|
303
|
+
key=lambda x: x[ENTITY_ATTRIBUTE_START], # type: ignore[literal-required]
|
|
304
304
|
)
|
|
305
305
|
entity_predictions = sorted(
|
|
306
306
|
filter(
|
|
307
307
|
lambda x: x.get(ENTITY_ATTRIBUTE_TEXT) == text,
|
|
308
308
|
self.entity_predictions,
|
|
309
309
|
),
|
|
310
|
-
key=lambda x: x[ENTITY_ATTRIBUTE_START], # type: ignore[literal-required]
|
|
310
|
+
key=lambda x: x[ENTITY_ATTRIBUTE_START], # type: ignore[literal-required]
|
|
311
311
|
)
|
|
312
312
|
|
|
313
313
|
i_pred, i_target = 0, 0
|
|
@@ -461,7 +461,7 @@ def _clean_entity_results(
|
|
|
461
461
|
cleaned_entities = []
|
|
462
462
|
|
|
463
463
|
for r in tuple(entity_results):
|
|
464
|
-
cleaned_entity: EntityPrediction = {ENTITY_ATTRIBUTE_TEXT: text} # type: ignore[misc]
|
|
464
|
+
cleaned_entity: EntityPrediction = {ENTITY_ATTRIBUTE_TEXT: text} # type: ignore[misc]
|
|
465
465
|
for k in (
|
|
466
466
|
ENTITY_ATTRIBUTE_START,
|
|
467
467
|
ENTITY_ATTRIBUTE_END,
|
|
@@ -706,7 +706,6 @@ async def _collect_action_executed_predictions(
|
|
|
706
706
|
event: ActionExecuted,
|
|
707
707
|
fail_on_prediction_errors: bool,
|
|
708
708
|
) -> Tuple[EvaluationStore, PolicyPrediction, Optional[EntityEvaluationResult]]:
|
|
709
|
-
|
|
710
709
|
action_executed_eval_store = EvaluationStore()
|
|
711
710
|
|
|
712
711
|
expected_action_name = event.action_name
|
|
@@ -825,7 +824,6 @@ async def _predict_tracker_actions(
|
|
|
825
824
|
List[Dict[Text, Any]],
|
|
826
825
|
List[EntityEvaluationResult],
|
|
827
826
|
]:
|
|
828
|
-
|
|
829
827
|
processor = agent.processor
|
|
830
828
|
if agent.processor is not None:
|
|
831
829
|
processor = agent.processor
|