rasa-pro 3.11.0__py3-none-any.whl → 3.11.0a2__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 +396 -17
- rasa/__main__.py +15 -31
- rasa/api.py +1 -5
- rasa/cli/arguments/default_arguments.py +2 -1
- rasa/cli/arguments/shell.py +1 -5
- rasa/cli/arguments/train.py +0 -14
- rasa/cli/e2e_test.py +1 -1
- rasa/cli/evaluate.py +8 -8
- rasa/cli/inspect.py +5 -7
- rasa/cli/interactive.py +0 -1
- rasa/cli/llm_fine_tuning.py +1 -1
- rasa/cli/project_templates/calm/config.yml +7 -5
- rasa/cli/project_templates/calm/endpoints.yml +2 -15
- rasa/cli/project_templates/tutorial/config.yml +5 -8
- rasa/cli/project_templates/tutorial/data/flows.yml +1 -1
- rasa/cli/project_templates/tutorial/data/patterns.yml +0 -5
- rasa/cli/project_templates/tutorial/domain.yml +0 -14
- rasa/cli/project_templates/tutorial/endpoints.yml +0 -5
- rasa/cli/run.py +1 -1
- rasa/cli/scaffold.py +2 -4
- rasa/cli/studio/studio.py +8 -18
- rasa/cli/studio/upload.py +15 -0
- rasa/cli/train.py +0 -3
- rasa/cli/utils.py +1 -6
- rasa/cli/x.py +8 -8
- rasa/constants.py +1 -3
- rasa/core/actions/action.py +33 -75
- rasa/core/actions/e2e_stub_custom_action_executor.py +1 -5
- rasa/core/actions/http_custom_action_executor.py +0 -4
- rasa/core/channels/channel.py +0 -20
- rasa/core/channels/development_inspector.py +2 -8
- rasa/core/channels/inspector/dist/assets/{arc-bc141fb2.js → arc-6852c607.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-d0fbc5ce-be2db283.js → c4Diagram-d0fbc5ce-acc952b2.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-936ed81e-55366915.js → classDiagram-936ed81e-848a7597.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-v2-c3cb15f1-bb529518.js → classDiagram-v2-c3cb15f1-a73d3e68.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{createText-62fc7601-b0ec81d6.js → createText-62fc7601-e5ee049d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{edges-f2ad444c-6166330c.js → edges-f2ad444c-771e517e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-9d236eb7-5ccc6a8e.js → erDiagram-9d236eb7-aa347178.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDb-1972c806-fca3bfe4.js → flowDb-1972c806-651fc57d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDiagram-7ea5b25a-4739080f.js → flowDiagram-7ea5b25a-ca67804f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-855bc5b3-587d82d8.js +1 -0
- rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-abe16c3d-7c1b0e0f.js → flowchart-elk-definition-abe16c3d-2dbc568d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-9b5ea136-772fd050.js → ganttDiagram-9b5ea136-25a65bd8.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-99d0ae7c-8eae1dc9.js → gitGraphDiagram-99d0ae7c-fdc7378d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-2c4b9a3b-f55afcdf.js → index-2c4b9a3b-6f1fd606.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-e7cef9de.js → index-efdd30c1.js} +68 -68
- rasa/core/channels/inspector/dist/assets/{infoDiagram-736b4530-124d4a14.js → infoDiagram-736b4530-cb1a041a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-df861f2b-7c4fae44.js → journeyDiagram-df861f2b-14609879.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-b9885fb6.js → layout-2490f52b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{line-7c59abb6.js → line-40186f1f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-4776f780.js → linear-08814e93.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-beec6740-2332c46c.js → mindmap-definition-beec6740-1a534584.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{pieDiagram-dbbf0591-8fb39303.js → pieDiagram-dbbf0591-72397b61.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-4d7f4fd6-3c7180a2.js → quadrantDiagram-4d7f4fd6-3bb0b6a3.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-6fc4c22a-e910bcb8.js → requirementDiagram-6fc4c22a-57334f61.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-8f13d901-ead16c89.js → sankeyDiagram-8f13d901-111e1297.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-b655622a-29a02a19.js → sequenceDiagram-b655622a-10bcfe62.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-59f0c015-042b3137.js → stateDiagram-59f0c015-acaf7513.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-2b26beab-2178c0f3.js → stateDiagram-v2-2b26beab-3ec2a235.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-080da4f6-23ffa4fc.js → styles-080da4f6-62730289.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-3dcbcfbf-94f59763.js → styles-3dcbcfbf-5284ee76.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-9c745c82-78a6bebc.js → styles-9c745c82-642435e3.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{svgDrawCommon-4835440b-eae2a6f6.js → svgDrawCommon-4835440b-b250a350.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{timeline-definition-5b62e21b-5c968d92.js → timeline-definition-5b62e21b-c2b147ed.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-2b33534f-fd3db0d5.js → xychartDiagram-2b33534f-f92cfea9.js} +1 -1
- rasa/core/channels/inspector/dist/index.html +1 -1
- rasa/core/channels/inspector/src/App.tsx +1 -1
- rasa/core/channels/inspector/src/helpers/audiostream.ts +16 -77
- rasa/core/channels/socketio.py +2 -7
- rasa/core/channels/telegram.py +1 -1
- rasa/core/channels/twilio.py +1 -1
- rasa/core/channels/voice_ready/audiocodes.py +4 -15
- rasa/core/channels/voice_ready/jambonz.py +4 -15
- rasa/core/channels/voice_ready/twilio_voice.py +21 -6
- rasa/core/channels/voice_ready/utils.py +5 -6
- rasa/core/channels/voice_stream/asr/asr_engine.py +1 -19
- rasa/core/channels/voice_stream/asr/asr_event.py +0 -5
- rasa/core/channels/voice_stream/asr/deepgram.py +15 -28
- rasa/core/channels/voice_stream/audio_bytes.py +0 -1
- rasa/core/channels/voice_stream/browser_audio.py +9 -32
- rasa/core/channels/voice_stream/tts/azure.py +3 -9
- rasa/core/channels/voice_stream/tts/cartesia.py +8 -12
- rasa/core/channels/voice_stream/tts/tts_engine.py +1 -11
- rasa/core/channels/voice_stream/twilio_media_streams.py +19 -28
- rasa/core/channels/voice_stream/util.py +4 -4
- rasa/core/channels/voice_stream/voice_channel.py +42 -222
- rasa/core/featurizers/single_state_featurizer.py +1 -22
- rasa/core/featurizers/tracker_featurizers.py +18 -115
- rasa/core/information_retrieval/qdrant.py +0 -1
- rasa/core/nlg/contextual_response_rephraser.py +25 -44
- rasa/core/persistor.py +34 -191
- rasa/core/policies/enterprise_search_policy.py +60 -119
- rasa/core/policies/flows/flow_executor.py +4 -7
- rasa/core/policies/intentless_policy.py +22 -82
- rasa/core/policies/ted_policy.py +33 -58
- rasa/core/policies/unexpected_intent_policy.py +7 -15
- rasa/core/processor.py +5 -32
- rasa/core/training/interactive.py +35 -34
- rasa/core/utils.py +22 -58
- rasa/dialogue_understanding/coexistence/llm_based_router.py +12 -39
- rasa/dialogue_understanding/commands/__init__.py +0 -4
- rasa/dialogue_understanding/commands/change_flow_command.py +0 -6
- rasa/dialogue_understanding/commands/utils.py +0 -5
- rasa/dialogue_understanding/generator/constants.py +0 -2
- rasa/dialogue_understanding/generator/flow_retrieval.py +4 -49
- rasa/dialogue_understanding/generator/llm_based_command_generator.py +23 -37
- rasa/dialogue_understanding/generator/multi_step/multi_step_llm_command_generator.py +10 -57
- rasa/dialogue_understanding/generator/nlu_command_adapter.py +1 -19
- rasa/dialogue_understanding/generator/single_step/command_prompt_template.jinja2 +0 -3
- rasa/dialogue_understanding/generator/single_step/single_step_llm_command_generator.py +10 -90
- rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +0 -53
- rasa/dialogue_understanding/processor/command_processor.py +1 -21
- rasa/e2e_test/assertions.py +16 -133
- rasa/e2e_test/assertions_schema.yml +0 -23
- rasa/e2e_test/e2e_test_case.py +6 -85
- rasa/e2e_test/e2e_test_runner.py +4 -6
- rasa/e2e_test/utils/io.py +1 -3
- rasa/engine/loader.py +0 -12
- rasa/engine/validation.py +11 -541
- rasa/keys +1 -0
- rasa/llm_fine_tuning/notebooks/unsloth_finetuning.ipynb +407 -0
- rasa/model_training.py +7 -29
- rasa/nlu/classifiers/diet_classifier.py +25 -38
- 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 +50 -93
- rasa/nlu/featurizers/sparse_featurizer/count_vectors_featurizer.py +16 -45
- rasa/nlu/featurizers/sparse_featurizer/lexical_syntactic_featurizer.py +17 -52
- rasa/nlu/featurizers/sparse_featurizer/regex_featurizer.py +3 -5
- rasa/nlu/tokenizers/whitespace_tokenizer.py +14 -3
- rasa/server.py +1 -3
- rasa/shared/constants.py +0 -61
- rasa/shared/core/constants.py +0 -9
- rasa/shared/core/domain.py +5 -8
- rasa/shared/core/flows/flow.py +0 -5
- rasa/shared/core/flows/flows_list.py +1 -5
- rasa/shared/core/flows/flows_yaml_schema.json +0 -10
- rasa/shared/core/flows/validation.py +0 -96
- rasa/shared/core/flows/yaml_flows_io.py +4 -13
- rasa/shared/core/slots.py +0 -5
- rasa/shared/importers/importer.py +2 -19
- rasa/shared/importers/rasa.py +1 -5
- rasa/shared/nlu/training_data/features.py +2 -120
- rasa/shared/nlu/training_data/formats/rasa_yaml.py +3 -18
- rasa/shared/providers/_configs/azure_openai_client_config.py +3 -5
- rasa/shared/providers/_configs/openai_client_config.py +1 -1
- rasa/shared/providers/_configs/self_hosted_llm_client_config.py +0 -1
- rasa/shared/providers/_configs/utils.py +0 -16
- rasa/shared/providers/embedding/_base_litellm_embedding_client.py +29 -18
- rasa/shared/providers/embedding/azure_openai_embedding_client.py +21 -54
- rasa/shared/providers/embedding/default_litellm_embedding_client.py +0 -24
- rasa/shared/providers/llm/_base_litellm_client.py +31 -63
- rasa/shared/providers/llm/azure_openai_llm_client.py +29 -50
- rasa/shared/providers/llm/default_litellm_llm_client.py +0 -24
- rasa/shared/providers/llm/self_hosted_llm_client.py +29 -17
- rasa/shared/providers/mappings.py +0 -19
- rasa/shared/utils/common.py +2 -37
- rasa/shared/utils/io.py +6 -28
- rasa/shared/utils/llm.py +46 -353
- rasa/shared/utils/yaml.py +82 -181
- rasa/studio/auth.py +5 -3
- rasa/studio/config.py +4 -13
- rasa/studio/constants.py +0 -1
- rasa/studio/data_handler.py +4 -13
- rasa/studio/upload.py +80 -175
- rasa/telemetry.py +17 -94
- rasa/tracing/config.py +1 -3
- rasa/tracing/instrumentation/attribute_extractors.py +17 -94
- rasa/tracing/instrumentation/instrumentation.py +0 -121
- rasa/utils/common.py +0 -5
- rasa/utils/endpoints.py +1 -27
- rasa/utils/io.py +81 -7
- rasa/utils/log_utils.py +2 -9
- rasa/utils/tensorflow/model_data.py +193 -2
- rasa/validator.py +4 -110
- rasa/version.py +1 -1
- rasa_pro-3.11.0a2.dist-info/METADATA +576 -0
- {rasa_pro-3.11.0.dist-info → rasa_pro-3.11.0a2.dist-info}/RECORD +181 -213
- rasa/core/actions/action_repeat_bot_messages.py +0 -89
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-855bc5b3-736177bf.js +0 -1
- rasa/core/channels/voice_stream/asr/azure.py +0 -129
- rasa/core/channels/voice_stream/call_state.py +0 -23
- rasa/dialogue_understanding/commands/repeat_bot_messages_command.py +0 -60
- rasa/dialogue_understanding/commands/user_silence_command.py +0 -59
- rasa/dialogue_understanding/patterns/repeat.py +0 -37
- rasa/dialogue_understanding/patterns/user_silence.py +0 -37
- rasa/model_manager/__init__.py +0 -0
- rasa/model_manager/config.py +0 -40
- rasa/model_manager/model_api.py +0 -559
- rasa/model_manager/runner_service.py +0 -286
- rasa/model_manager/socket_bridge.py +0 -146
- rasa/model_manager/studio_jwt_auth.py +0 -86
- rasa/model_manager/trainer_service.py +0 -325
- rasa/model_manager/utils.py +0 -87
- rasa/model_manager/warm_rasa_process.py +0 -187
- rasa/model_service.py +0 -112
- rasa/shared/core/flows/utils.py +0 -39
- rasa/shared/providers/_configs/litellm_router_client_config.py +0 -220
- rasa/shared/providers/_configs/model_group_config.py +0 -167
- rasa/shared/providers/_configs/rasa_llm_client_config.py +0 -73
- rasa/shared/providers/_utils.py +0 -79
- rasa/shared/providers/embedding/litellm_router_embedding_client.py +0 -135
- rasa/shared/providers/llm/litellm_router_llm_client.py +0 -182
- rasa/shared/providers/llm/rasa_llm_client.py +0 -112
- rasa/shared/providers/router/__init__.py +0 -0
- rasa/shared/providers/router/_base_litellm_router_client.py +0 -183
- rasa/shared/providers/router/router_client.py +0 -73
- rasa/shared/utils/health_check/__init__.py +0 -0
- rasa/shared/utils/health_check/embeddings_health_check_mixin.py +0 -31
- rasa/shared/utils/health_check/health_check.py +0 -258
- rasa/shared/utils/health_check/llm_health_check_mixin.py +0 -31
- rasa/utils/sanic_error_handler.py +0 -32
- rasa/utils/tensorflow/feature_array.py +0 -366
- rasa_pro-3.11.0.dist-info/METADATA +0 -198
- {rasa_pro-3.11.0.dist-info → rasa_pro-3.11.0a2.dist-info}/NOTICE +0 -0
- {rasa_pro-3.11.0.dist-info → rasa_pro-3.11.0a2.dist-info}/WHEEL +0 -0
- {rasa_pro-3.11.0.dist-info → rasa_pro-3.11.0a2.dist-info}/entry_points.txt +0 -0
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
-
|
|
3
2
|
import logging
|
|
4
3
|
from collections import OrderedDict
|
|
4
|
+
|
|
5
|
+
import scipy.sparse
|
|
6
|
+
import numpy as np
|
|
5
7
|
from typing import (
|
|
6
8
|
Any,
|
|
7
9
|
Dict,
|
|
@@ -15,34 +17,30 @@ from typing import (
|
|
|
15
17
|
Union,
|
|
16
18
|
)
|
|
17
19
|
|
|
18
|
-
import numpy as np
|
|
19
|
-
import scipy.sparse
|
|
20
|
-
|
|
21
|
-
import rasa.shared.utils.io
|
|
22
|
-
import rasa.utils.io
|
|
23
20
|
from rasa.engine.graph import ExecutionContext, GraphComponent
|
|
24
21
|
from rasa.engine.recipes.default_recipe import DefaultV1Recipe
|
|
25
22
|
from rasa.engine.storage.resource import Resource
|
|
26
23
|
from rasa.engine.storage.storage import ModelStorage
|
|
27
|
-
from rasa.nlu.constants import TOKENS_NAMES
|
|
28
|
-
from rasa.nlu.featurizers.sparse_featurizer.sparse_featurizer import SparseFeaturizer
|
|
29
24
|
from rasa.nlu.tokenizers.spacy_tokenizer import POS_TAG_KEY, SpacyTokenizer
|
|
30
25
|
from rasa.nlu.tokenizers.tokenizer import Token, Tokenizer
|
|
26
|
+
from rasa.nlu.featurizers.sparse_featurizer.sparse_featurizer import SparseFeaturizer
|
|
27
|
+
from rasa.nlu.constants import TOKENS_NAMES
|
|
31
28
|
from rasa.shared.constants import DOCS_URL_COMPONENTS
|
|
32
|
-
from rasa.shared.exceptions import InvalidConfigException
|
|
33
|
-
from rasa.shared.nlu.constants import TEXT
|
|
34
|
-
from rasa.shared.nlu.training_data.message import Message
|
|
35
29
|
from rasa.shared.nlu.training_data.training_data import TrainingData
|
|
30
|
+
from rasa.shared.nlu.training_data.message import Message
|
|
31
|
+
from rasa.shared.nlu.constants import TEXT
|
|
32
|
+
from rasa.shared.exceptions import InvalidConfigException
|
|
33
|
+
import rasa.shared.utils.io
|
|
34
|
+
import rasa.utils.io
|
|
36
35
|
|
|
37
36
|
logger = logging.getLogger(__name__)
|
|
38
37
|
|
|
38
|
+
|
|
39
39
|
END_OF_SENTENCE = "EOS"
|
|
40
40
|
BEGIN_OF_SENTENCE = "BOS"
|
|
41
41
|
|
|
42
42
|
FEATURES = "features"
|
|
43
43
|
|
|
44
|
-
SEPERATOR = "###"
|
|
45
|
-
|
|
46
44
|
|
|
47
45
|
@DefaultV1Recipe.register(
|
|
48
46
|
DefaultV1Recipe.ComponentType.MESSAGE_FEATURIZER, is_trainable=True
|
|
@@ -74,7 +72,7 @@ class LexicalSyntacticFeaturizer(SparseFeaturizer, GraphComponent):
|
|
|
74
72
|
of the token at position `t+1`.
|
|
75
73
|
"""
|
|
76
74
|
|
|
77
|
-
FILENAME_FEATURE_TO_IDX_DICT = "feature_to_idx_dict.
|
|
75
|
+
FILENAME_FEATURE_TO_IDX_DICT = "feature_to_idx_dict.pkl"
|
|
78
76
|
|
|
79
77
|
# NOTE: "suffix5" of the token "is" will be "is". Hence, when combining multiple
|
|
80
78
|
# prefixes, short words will be represented/encoded repeatedly.
|
|
@@ -490,32 +488,6 @@ class LexicalSyntacticFeaturizer(SparseFeaturizer, GraphComponent):
|
|
|
490
488
|
"""Creates a new untrained component (see parent class for full docstring)."""
|
|
491
489
|
return cls(config, model_storage, resource, execution_context)
|
|
492
490
|
|
|
493
|
-
@staticmethod
|
|
494
|
-
def _restructure_feature_to_idx_dict(
|
|
495
|
-
loaded_data: Dict[str, Dict[str, int]],
|
|
496
|
-
) -> Dict[Tuple[int, str], Dict[str, int]]:
|
|
497
|
-
"""Reconstructs the feature to idx dict.
|
|
498
|
-
|
|
499
|
-
When storing the feature_to_idx_dict to disk, we need to convert the tuple (key)
|
|
500
|
-
into a string to be able to store it via json. When loading the data
|
|
501
|
-
we need to reconstruct the tuple from the stored string.
|
|
502
|
-
|
|
503
|
-
Args:
|
|
504
|
-
loaded_data: The loaded feature to idx dict from file.
|
|
505
|
-
|
|
506
|
-
Returns:
|
|
507
|
-
The reconstructed feature_to_idx_dict
|
|
508
|
-
"""
|
|
509
|
-
feature_to_idx_dict = {}
|
|
510
|
-
for tuple_string, feature_value in loaded_data.items():
|
|
511
|
-
# Example of tuple_string: "1###low"
|
|
512
|
-
index, feature_name = tuple_string.split(SEPERATOR)
|
|
513
|
-
|
|
514
|
-
feature_key = (int(index), feature_name)
|
|
515
|
-
feature_to_idx_dict[feature_key] = feature_value
|
|
516
|
-
|
|
517
|
-
return feature_to_idx_dict
|
|
518
|
-
|
|
519
491
|
@classmethod
|
|
520
492
|
def load(
|
|
521
493
|
cls,
|
|
@@ -528,13 +500,10 @@ class LexicalSyntacticFeaturizer(SparseFeaturizer, GraphComponent):
|
|
|
528
500
|
"""Loads trained component (see parent class for full docstring)."""
|
|
529
501
|
try:
|
|
530
502
|
with model_storage.read_from(resource) as model_path:
|
|
531
|
-
|
|
503
|
+
feature_to_idx_dict = rasa.utils.io.json_unpickle(
|
|
532
504
|
model_path / cls.FILENAME_FEATURE_TO_IDX_DICT,
|
|
505
|
+
encode_non_string_keys=True,
|
|
533
506
|
)
|
|
534
|
-
|
|
535
|
-
# convert the key back into tuple
|
|
536
|
-
feature_to_idx_dict = cls._restructure_feature_to_idx_dict(loaded_data)
|
|
537
|
-
|
|
538
507
|
return cls(
|
|
539
508
|
config=config,
|
|
540
509
|
model_storage=model_storage,
|
|
@@ -559,13 +528,9 @@ class LexicalSyntacticFeaturizer(SparseFeaturizer, GraphComponent):
|
|
|
559
528
|
if not self._feature_to_idx_dict:
|
|
560
529
|
return None
|
|
561
530
|
|
|
562
|
-
# as we cannot dump tuples, convert the tuple into a string
|
|
563
|
-
restructured_feature_dict = {
|
|
564
|
-
f"{k[0]}{SEPERATOR}{k[1]}": v for k, v in self._feature_to_idx_dict.items()
|
|
565
|
-
}
|
|
566
|
-
|
|
567
531
|
with self._model_storage.write_to(self._resource) as model_path:
|
|
568
|
-
rasa.
|
|
532
|
+
rasa.utils.io.json_pickle(
|
|
569
533
|
model_path / self.FILENAME_FEATURE_TO_IDX_DICT,
|
|
570
|
-
|
|
534
|
+
self._feature_to_idx_dict,
|
|
535
|
+
encode_non_string_keys=True,
|
|
571
536
|
)
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
-
|
|
3
2
|
import logging
|
|
4
3
|
import re
|
|
5
4
|
from typing import Any, Dict, List, Optional, Text, Tuple, Type
|
|
6
|
-
|
|
7
5
|
import numpy as np
|
|
8
6
|
import scipy.sparse
|
|
9
|
-
|
|
10
7
|
from rasa.nlu.tokenizers.tokenizer import Tokenizer
|
|
8
|
+
|
|
11
9
|
import rasa.shared.utils.io
|
|
12
10
|
import rasa.utils.io
|
|
13
11
|
import rasa.nlu.utils.pattern_utils as pattern_utils
|
|
@@ -242,7 +240,7 @@ class RegexFeaturizer(SparseFeaturizer, GraphComponent):
|
|
|
242
240
|
|
|
243
241
|
try:
|
|
244
242
|
with model_storage.read_from(resource) as model_dir:
|
|
245
|
-
patterns_file_name = model_dir / "patterns.
|
|
243
|
+
patterns_file_name = model_dir / "patterns.pkl"
|
|
246
244
|
known_patterns = rasa.shared.utils.io.read_json_file(patterns_file_name)
|
|
247
245
|
except (ValueError, FileNotFoundError):
|
|
248
246
|
logger.warning(
|
|
@@ -260,7 +258,7 @@ class RegexFeaturizer(SparseFeaturizer, GraphComponent):
|
|
|
260
258
|
|
|
261
259
|
def _persist(self) -> None:
|
|
262
260
|
with self._model_storage.write_to(self._resource) as model_dir:
|
|
263
|
-
regex_file = model_dir / "patterns.
|
|
261
|
+
regex_file = model_dir / "patterns.pkl"
|
|
264
262
|
rasa.shared.utils.io.dump_obj_as_json_to_file(
|
|
265
263
|
regex_file, self.known_patterns
|
|
266
264
|
)
|
|
@@ -43,6 +43,8 @@ class WhitespaceTokenizer(Tokenizer):
|
|
|
43
43
|
def __init__(self, config: Dict[Text, Any]) -> None:
|
|
44
44
|
"""Initialize the tokenizer."""
|
|
45
45
|
super().__init__(config)
|
|
46
|
+
self.emoji_pattern = rasa.utils.io.get_emoji_regex()
|
|
47
|
+
|
|
46
48
|
if "case_sensitive" in self._config:
|
|
47
49
|
rasa.shared.utils.io.raise_warning(
|
|
48
50
|
"The option 'case_sensitive' was moved from the tokenizers to the "
|
|
@@ -62,9 +64,18 @@ class WhitespaceTokenizer(Tokenizer):
|
|
|
62
64
|
# Path to the dictionaries on the local filesystem.
|
|
63
65
|
return cls(config)
|
|
64
66
|
|
|
67
|
+
def remove_emoji(self, text: Text) -> Text:
|
|
68
|
+
"""Remove emoji if the full text, aka token, matches the emoji regex."""
|
|
69
|
+
match = self.emoji_pattern.fullmatch(text)
|
|
70
|
+
|
|
71
|
+
if match is not None:
|
|
72
|
+
return ""
|
|
73
|
+
|
|
74
|
+
return text
|
|
75
|
+
|
|
65
76
|
def tokenize(self, message: Message, attribute: Text) -> List[Token]:
|
|
66
|
-
|
|
67
|
-
|
|
77
|
+
text = message.get(attribute)
|
|
78
|
+
|
|
68
79
|
# we need to use regex instead of re, because of
|
|
69
80
|
# https://stackoverflow.com/questions/12746458/python-unicode-regular-expression-matching-failing-with-some-unicode-characters
|
|
70
81
|
|
|
@@ -83,11 +94,11 @@ class WhitespaceTokenizer(Tokenizer):
|
|
|
83
94
|
text,
|
|
84
95
|
).split()
|
|
85
96
|
|
|
97
|
+
words = [self.remove_emoji(w) for w in words]
|
|
86
98
|
words = [w for w in words if w]
|
|
87
99
|
|
|
88
100
|
# if we removed everything like smiles `:)`, use the whole text as 1 token
|
|
89
101
|
if not words:
|
|
90
|
-
text = original_text
|
|
91
102
|
words = [text]
|
|
92
103
|
|
|
93
104
|
tokens = self._convert_words_to_tokens(words, text)
|
rasa/server.py
CHANGED
|
@@ -78,7 +78,6 @@ from rasa.shared.utils.schemas.events import EVENTS_SCHEMA
|
|
|
78
78
|
from rasa.shared.utils.yaml import validate_training_data
|
|
79
79
|
from rasa.utils.common import TempDirectoryPath, get_temp_dir_name
|
|
80
80
|
from rasa.utils.endpoints import EndpointConfig
|
|
81
|
-
from rasa.utils.sanic_error_handler import register_custom_sanic_error_handler
|
|
82
81
|
|
|
83
82
|
if TYPE_CHECKING:
|
|
84
83
|
from ssl import SSLContext
|
|
@@ -529,7 +528,7 @@ def add_root_route(app: Sanic) -> None:
|
|
|
529
528
|
<p>Hello from Rasa: {rasa.__version__}</p>
|
|
530
529
|
<a href="./webhooks/inspector/inspect.html">Go to the inspector</a>
|
|
531
530
|
<script>
|
|
532
|
-
window.location.replace("./webhooks/
|
|
531
|
+
window.location.replace("./webhooks/inspector/inspect.html");
|
|
533
532
|
</script>
|
|
534
533
|
</body>
|
|
535
534
|
</html>
|
|
@@ -688,7 +687,6 @@ def create_app(
|
|
|
688
687
|
app = Sanic("rasa_server")
|
|
689
688
|
app.config.RESPONSE_TIMEOUT = response_timeout
|
|
690
689
|
configure_cors(app, cors_origins)
|
|
691
|
-
register_custom_sanic_error_handler(app)
|
|
692
690
|
|
|
693
691
|
# Reset Sanic warnings filter that allows the triggering of Sanic warnings
|
|
694
692
|
warnings.filterwarnings("ignore", category=DeprecationWarning, module=r"sanic.*")
|
rasa/shared/constants.py
CHANGED
|
@@ -149,10 +149,6 @@ AZURE_AD_TOKEN_ENV_VAR = "AZURE_AD_TOKEN"
|
|
|
149
149
|
AZURE_API_BASE_ENV_VAR = "AZURE_API_BASE"
|
|
150
150
|
AZURE_API_VERSION_ENV_VAR = "AZURE_API_VERSION"
|
|
151
151
|
AZURE_API_TYPE_ENV_VAR = "AZURE_API_TYPE"
|
|
152
|
-
AZURE_SPEECH_API_KEY_ENV_VAR = "AZURE_SPEECH_API_KEY"
|
|
153
|
-
|
|
154
|
-
DEEPGRAM_API_KEY_ENV_VAR = "DEEPGRAM_API_KEY"
|
|
155
|
-
CARTESIA_API_KEY_ENV_VAR = "CARTESIA_API_KEY"
|
|
156
152
|
|
|
157
153
|
OPENAI_API_KEY_ENV_VAR = "OPENAI_API_KEY"
|
|
158
154
|
OPENAI_API_TYPE_ENV_VAR = "OPENAI_API_TYPE"
|
|
@@ -163,9 +159,6 @@ OPENAI_API_BASE_CONFIG_KEY = "openai_api_base"
|
|
|
163
159
|
OPENAI_API_TYPE_CONFIG_KEY = "openai_api_type"
|
|
164
160
|
OPENAI_API_VERSION_CONFIG_KEY = "openai_api_version"
|
|
165
161
|
|
|
166
|
-
AWS_BEDROCK_PROVIDER = "bedrock"
|
|
167
|
-
AWS_SAGEMAKER_PROVIDER = "sagemaker"
|
|
168
|
-
|
|
169
162
|
API_BASE_CONFIG_KEY = "api_base"
|
|
170
163
|
API_TYPE_CONFIG_KEY = "api_type"
|
|
171
164
|
API_VERSION_CONFIG_KEY = "api_version"
|
|
@@ -190,34 +183,7 @@ STREAM_CONFIG_KEY = "stream"
|
|
|
190
183
|
N_REPHRASES_CONFIG_KEY = "n"
|
|
191
184
|
USE_CHAT_COMPLETIONS_ENDPOINT_CONFIG_KEY = "use_chat_completions_endpoint"
|
|
192
185
|
|
|
193
|
-
ROUTER_CONFIG_KEY = "router"
|
|
194
|
-
ROUTING_STRATEGY_CONFIG_KEY = "routing_strategy"
|
|
195
|
-
REDIS_HOST_CONFIG_KEY = "redis_host"
|
|
196
|
-
ROUTING_STRATEGIES_REQUIRING_REDIS_CACHE = [
|
|
197
|
-
"cost-based-routing",
|
|
198
|
-
"usage-based-routing",
|
|
199
|
-
]
|
|
200
|
-
ROUTING_STRATEGIES_NOT_REQUIRING_CACHE = [
|
|
201
|
-
"latency-based-routing",
|
|
202
|
-
"least-busy",
|
|
203
|
-
"simple-shuffle",
|
|
204
|
-
]
|
|
205
|
-
VALID_ROUTING_STRATEGIES = (
|
|
206
|
-
ROUTING_STRATEGIES_REQUIRING_REDIS_CACHE + ROUTING_STRATEGIES_NOT_REQUIRING_CACHE
|
|
207
|
-
)
|
|
208
|
-
|
|
209
|
-
MODELS_CONFIG_KEY = "models"
|
|
210
|
-
MODEL_GROUPS_CONFIG_KEY = "model_groups"
|
|
211
|
-
MODEL_GROUP_CONFIG_KEY = "model_group"
|
|
212
|
-
MODEL_GROUP_ID_CONFIG_KEY = "id"
|
|
213
|
-
|
|
214
|
-
EXTRA_PARAMETERS_KEY = "extra_parameters"
|
|
215
|
-
MODEL_GROUP_ID_KEY = "model_group_id"
|
|
216
|
-
MODEL_LIST_KEY = "model_list"
|
|
217
|
-
LITELLM_PARAMS_KEY = "litellm_params"
|
|
218
|
-
|
|
219
186
|
LLM_API_HEALTH_CHECK_ENV_VAR = "LLM_API_HEALTH_CHECK"
|
|
220
|
-
LLM_API_HEALTH_CHECK_DEFAULT_VALUE = "false"
|
|
221
187
|
|
|
222
188
|
AZURE_API_KEY_ENV_VAR = "AZURE_API_KEY"
|
|
223
189
|
AZURE_AD_TOKEN_ENV_VAR = "AZURE_AD_TOKEN"
|
|
@@ -225,16 +191,6 @@ AZURE_API_BASE_ENV_VAR = "AZURE_API_BASE"
|
|
|
225
191
|
AZURE_API_VERSION_ENV_VAR = "AZURE_API_VERSION"
|
|
226
192
|
AZURE_API_TYPE_ENV_VAR = "AZURE_API_TYPE"
|
|
227
193
|
|
|
228
|
-
AWS_REGION_NAME_CONFIG_KEY = "aws_region_name"
|
|
229
|
-
AWS_ACCESS_KEY_ID_CONFIG_KEY = "aws_access_key_id"
|
|
230
|
-
AWS_SECRET_ACCESS_KEY_CONFIG_KEY = "aws_secret_access_key"
|
|
231
|
-
AWS_SESSION_TOKEN_CONFIG_KEY = "aws_session_token"
|
|
232
|
-
|
|
233
|
-
AWS_ACCESS_KEY_ID_ENV_VAR = "AWS_ACCESS_KEY_ID"
|
|
234
|
-
AWS_SECRET_ACCESS_KEY_ENV_VAR = "AWS_SECRET_ACCESS_KEY"
|
|
235
|
-
AWS_REGION_NAME_ENV_VAR = "AWS_REGION_NAME"
|
|
236
|
-
AWS_SESSION_TOKEN_ENV_VAR = "AWS_SESSION_TOKEN"
|
|
237
|
-
|
|
238
194
|
HUGGINGFACE_MULTIPROCESS_CONFIG_KEY = "multi_process"
|
|
239
195
|
HUGGINGFACE_CACHE_FOLDER_CONFIG_KEY = "cache_folder"
|
|
240
196
|
HUGGINGFACE_SHOW_PROGRESS_CONFIG_KEY = "show_progress"
|
|
@@ -255,16 +211,6 @@ OPENAI_PROVIDER = "openai"
|
|
|
255
211
|
AZURE_OPENAI_PROVIDER = "azure"
|
|
256
212
|
SELF_HOSTED_PROVIDER = "self-hosted"
|
|
257
213
|
HUGGINGFACE_LOCAL_EMBEDDING_PROVIDER = "huggingface_local"
|
|
258
|
-
RASA_PROVIDER = "rasa"
|
|
259
|
-
|
|
260
|
-
SELF_HOSTED_VLLM_PREFIX = "hosted_vllm"
|
|
261
|
-
SELF_HOSTED_VLLM_API_KEY_ENV_VAR = "HOSTED_VLLM_API_KEY"
|
|
262
|
-
|
|
263
|
-
SELF_HOSTED_VLLM_PREFIX = "hosted_vllm"
|
|
264
|
-
SELF_HOSTED_VLLM_API_KEY_ENV_VAR = "HOSTED_VLLM_API_KEY"
|
|
265
|
-
|
|
266
|
-
SELF_HOSTED_VLLM_PREFIX = "hosted_vllm"
|
|
267
|
-
SELF_HOSTED_VLLM_API_KEY_ENV_VAR = "HOSTED_VLLM_API_KEY"
|
|
268
214
|
|
|
269
215
|
AZURE_API_TYPE = "azure"
|
|
270
216
|
OPENAI_API_TYPE = "openai"
|
|
@@ -295,10 +241,3 @@ RASA_PATTERN_CANNOT_HANDLE_INVALID_INTENT = (
|
|
|
295
241
|
)
|
|
296
242
|
|
|
297
243
|
ROUTE_TO_CALM_SLOT = "route_session_to_calm"
|
|
298
|
-
|
|
299
|
-
SENSITIVE_DATA = [
|
|
300
|
-
API_KEY,
|
|
301
|
-
AWS_ACCESS_KEY_ID_CONFIG_KEY,
|
|
302
|
-
AWS_SECRET_ACCESS_KEY_CONFIG_KEY,
|
|
303
|
-
AWS_SESSION_TOKEN_CONFIG_KEY,
|
|
304
|
-
]
|
rasa/shared/core/constants.py
CHANGED
|
@@ -11,7 +11,6 @@ USER_INTENT_BACK = "back"
|
|
|
11
11
|
USER_INTENT_OUT_OF_SCOPE = "out_of_scope"
|
|
12
12
|
USER_INTENT_SESSION_START = "session_start"
|
|
13
13
|
USER_INTENT_SESSION_END = "session_end"
|
|
14
|
-
USER_INTENT_SILENCE_TIMEOUT = "silence_timeout"
|
|
15
14
|
SESSION_START_METADATA_SLOT = "session_started_metadata"
|
|
16
15
|
|
|
17
16
|
DEFAULT_INTENTS = [
|
|
@@ -20,7 +19,6 @@ DEFAULT_INTENTS = [
|
|
|
20
19
|
USER_INTENT_OUT_OF_SCOPE,
|
|
21
20
|
USER_INTENT_SESSION_START,
|
|
22
21
|
USER_INTENT_SESSION_END,
|
|
23
|
-
USER_INTENT_SILENCE_TIMEOUT,
|
|
24
22
|
constants.DEFAULT_NLU_FALLBACK_INTENT_NAME,
|
|
25
23
|
]
|
|
26
24
|
|
|
@@ -50,7 +48,6 @@ ACTION_TRIGGER_SEARCH = "action_trigger_search"
|
|
|
50
48
|
ACTION_TRIGGER_CHITCHAT = "action_trigger_chitchat"
|
|
51
49
|
ACTION_RESET_ROUTING = "action_reset_routing"
|
|
52
50
|
ACTION_HANGUP = "action_hangup"
|
|
53
|
-
ACTION_REPEAT_BOT_MESSAGES = "action_repeat_bot_messages"
|
|
54
51
|
|
|
55
52
|
|
|
56
53
|
DEFAULT_ACTION_NAMES = [
|
|
@@ -77,7 +74,6 @@ DEFAULT_ACTION_NAMES = [
|
|
|
77
74
|
ACTION_TRIGGER_CHITCHAT,
|
|
78
75
|
ACTION_RESET_ROUTING,
|
|
79
76
|
ACTION_HANGUP,
|
|
80
|
-
ACTION_REPEAT_BOT_MESSAGES,
|
|
81
77
|
]
|
|
82
78
|
|
|
83
79
|
ACTION_SHOULD_SEND_DOMAIN = "send_domain"
|
|
@@ -108,11 +104,6 @@ FLOW_HASHES_SLOT = "flow_hashes"
|
|
|
108
104
|
|
|
109
105
|
FLOW_SLOT_NAMES = [FLOW_HASHES_SLOT]
|
|
110
106
|
|
|
111
|
-
# slots for audio timeout
|
|
112
|
-
SLOT_SILENCE_TIMEOUT = "silence_timeout"
|
|
113
|
-
SLOT_CONSECUTIVE_SILENCE_TIMEOUTS = "consecutive_silence_timeouts"
|
|
114
|
-
SILENCE_TIMEOUT_DEFAULT_VALUE = 6.0
|
|
115
|
-
SILENCE_SLOTS = [SLOT_SILENCE_TIMEOUT, SLOT_CONSECUTIVE_SILENCE_TIMEOUTS]
|
|
116
107
|
# slots for knowledge base
|
|
117
108
|
SLOT_LISTED_ITEMS = "knowledge_base_listed_objects"
|
|
118
109
|
SLOT_LAST_OBJECT = "knowledge_base_last_object"
|
rasa/shared/core/domain.py
CHANGED
|
@@ -196,7 +196,6 @@ class Domain:
|
|
|
196
196
|
"""
|
|
197
197
|
|
|
198
198
|
validate_yaml: ClassVar[bool] = True
|
|
199
|
-
expand_env_vars: ClassVar[bool] = True
|
|
200
199
|
|
|
201
200
|
@classmethod
|
|
202
201
|
def empty(cls) -> Domain:
|
|
@@ -1956,8 +1955,8 @@ class Domain:
|
|
|
1956
1955
|
"""Check whether the domain is empty."""
|
|
1957
1956
|
return self.as_dict() == Domain.empty().as_dict()
|
|
1958
1957
|
|
|
1959
|
-
@
|
|
1960
|
-
def is_domain_file(
|
|
1958
|
+
@staticmethod
|
|
1959
|
+
def is_domain_file(filename: Union[Text, Path]) -> bool:
|
|
1961
1960
|
"""Checks whether the given file path is a Rasa domain file.
|
|
1962
1961
|
|
|
1963
1962
|
Args:
|
|
@@ -1976,7 +1975,7 @@ class Domain:
|
|
|
1976
1975
|
return False
|
|
1977
1976
|
|
|
1978
1977
|
try:
|
|
1979
|
-
content = read_yaml_file(filename
|
|
1978
|
+
content = read_yaml_file(filename)
|
|
1980
1979
|
except (RasaException, YamlSyntaxException):
|
|
1981
1980
|
structlogger.warning(
|
|
1982
1981
|
"domain.cannot_load_domain_file",
|
|
@@ -2105,12 +2104,10 @@ class Domain:
|
|
|
2105
2104
|
"domain.from_yaml.validating",
|
|
2106
2105
|
)
|
|
2107
2106
|
validate_raw_yaml_using_schema_file_with_responses(
|
|
2108
|
-
raw_yaml_content,
|
|
2109
|
-
DOMAIN_SCHEMA_FILE,
|
|
2110
|
-
expand_env_vars=cls.expand_env_vars,
|
|
2107
|
+
raw_yaml_content, DOMAIN_SCHEMA_FILE
|
|
2111
2108
|
)
|
|
2112
2109
|
|
|
2113
|
-
return read_yaml(raw_yaml_content
|
|
2110
|
+
return read_yaml(raw_yaml_content)
|
|
2114
2111
|
|
|
2115
2112
|
|
|
2116
2113
|
def warn_about_duplicates_found_during_domain_merging(
|
rasa/shared/core/flows/flow.py
CHANGED
|
@@ -60,8 +60,6 @@ class Flow:
|
|
|
60
60
|
"""
|
|
61
61
|
file_path: Optional[str] = None
|
|
62
62
|
"""The path to the file where the flow is stored."""
|
|
63
|
-
persisted_slots: List[str] = field(default_factory=list)
|
|
64
|
-
"""The list of slots that should be persisted after the flow ends."""
|
|
65
63
|
|
|
66
64
|
@staticmethod
|
|
67
65
|
def from_json(
|
|
@@ -97,7 +95,6 @@ class Flow:
|
|
|
97
95
|
# If we are reading the flows in after training the file_path is part of
|
|
98
96
|
# data. When the model is trained, take the provided file_path.
|
|
99
97
|
file_path=data.get("file_path") if "file_path" in data else file_path,
|
|
100
|
-
persisted_slots=data.get("persisted_slots", []),
|
|
101
98
|
)
|
|
102
99
|
|
|
103
100
|
def get_full_name(self) -> str:
|
|
@@ -170,8 +167,6 @@ class Flow:
|
|
|
170
167
|
data["nlu_trigger"] = self.nlu_triggers.as_json()
|
|
171
168
|
if self.file_path:
|
|
172
169
|
data["file_path"] = self.file_path
|
|
173
|
-
if self.persisted_slots:
|
|
174
|
-
data["persisted_slots"] = self.persisted_slots
|
|
175
170
|
|
|
176
171
|
return data
|
|
177
172
|
|
|
@@ -234,16 +234,12 @@ class FlowsList:
|
|
|
234
234
|
[f for f in self.underlying_flows if not f.is_startable_only_via_link()]
|
|
235
235
|
)
|
|
236
236
|
|
|
237
|
-
def available_slot_names(
|
|
238
|
-
self, ask_before_filling: Optional[bool] = None
|
|
239
|
-
) -> Set[str]:
|
|
237
|
+
def available_slot_names(self) -> Set[str]:
|
|
240
238
|
"""Get all slot names collected by flows."""
|
|
241
239
|
return {
|
|
242
240
|
step.collect
|
|
243
241
|
for flow in self.underlying_flows
|
|
244
242
|
for step in flow.get_collect_steps()
|
|
245
|
-
if ask_before_filling is None
|
|
246
|
-
or step.ask_before_filling == ask_before_filling
|
|
247
243
|
}
|
|
248
244
|
|
|
249
245
|
def available_custom_actions(self) -> Set[str]:
|
|
@@ -279,9 +279,6 @@
|
|
|
279
279
|
},
|
|
280
280
|
"steps": {
|
|
281
281
|
"$ref": "#/$defs/steps"
|
|
282
|
-
},
|
|
283
|
-
"persisted_slots": {
|
|
284
|
-
"$ref": "#/$defs/persisted_slots"
|
|
285
282
|
}
|
|
286
283
|
}
|
|
287
284
|
},
|
|
@@ -291,13 +288,6 @@
|
|
|
291
288
|
"items": {
|
|
292
289
|
"type": "object"
|
|
293
290
|
}
|
|
294
|
-
},
|
|
295
|
-
"persisted_slots": {
|
|
296
|
-
"type": "array",
|
|
297
|
-
"schema_name": "list of slots",
|
|
298
|
-
"items": {
|
|
299
|
-
"type": "string"
|
|
300
|
-
}
|
|
301
291
|
}
|
|
302
292
|
}
|
|
303
293
|
}
|
|
@@ -3,7 +3,6 @@ from __future__ import annotations
|
|
|
3
3
|
import re
|
|
4
4
|
import typing
|
|
5
5
|
from collections import defaultdict
|
|
6
|
-
from dataclasses import dataclass
|
|
7
6
|
from typing import Optional, Set, Text, List
|
|
8
7
|
|
|
9
8
|
from rasa.shared.constants import (
|
|
@@ -27,12 +26,6 @@ from rasa.shared.core.flows.steps.call import CallFlowStep
|
|
|
27
26
|
from rasa.shared.core.flows.steps.collect import CollectInformationFlowStep
|
|
28
27
|
from rasa.shared.core.flows.steps.constants import CONTINUE_STEP_PREFIX, DEFAULT_STEPS
|
|
29
28
|
from rasa.shared.core.flows.steps.link import LinkFlowStep
|
|
30
|
-
from rasa.shared.core.flows.steps.set_slots import SetSlotsFlowStep
|
|
31
|
-
from rasa.shared.core.flows.utils import (
|
|
32
|
-
warn_deprecated_collect_step_config,
|
|
33
|
-
get_duplicate_slot_persistence_config_error_message,
|
|
34
|
-
get_invalid_slot_persistence_config_error_message,
|
|
35
|
-
)
|
|
36
29
|
from rasa.shared.exceptions import RasaException
|
|
37
30
|
|
|
38
31
|
if typing.TYPE_CHECKING:
|
|
@@ -386,42 +379,6 @@ class FlowIdNamingException(RasaException):
|
|
|
386
379
|
)
|
|
387
380
|
|
|
388
381
|
|
|
389
|
-
class DuplicateSlotPersistConfigException(RasaException):
|
|
390
|
-
"""Raised when a slot persist configuration is duplicated."""
|
|
391
|
-
|
|
392
|
-
def __init__(self, flow_id: str, collect_step: str) -> None:
|
|
393
|
-
"""Initializes the exception."""
|
|
394
|
-
self.flow_id = flow_id
|
|
395
|
-
self.collect_step = collect_step
|
|
396
|
-
|
|
397
|
-
def __str__(self) -> str:
|
|
398
|
-
"""Return a string representation of the exception."""
|
|
399
|
-
return get_duplicate_slot_persistence_config_error_message(
|
|
400
|
-
self.flow_id, self.collect_step
|
|
401
|
-
)
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
class InvalidPersistSlotsException(RasaException):
|
|
405
|
-
"""Raised when a slot persist configuration is duplicated."""
|
|
406
|
-
|
|
407
|
-
def __init__(self, flow_id: str, invalid_slots: Set[str]) -> None:
|
|
408
|
-
"""Initializes the exception."""
|
|
409
|
-
self.flow_id = flow_id
|
|
410
|
-
self.invalid_slots = invalid_slots
|
|
411
|
-
|
|
412
|
-
def __str__(self) -> str:
|
|
413
|
-
"""Return a string representation of the exception."""
|
|
414
|
-
return get_invalid_slot_persistence_config_error_message(
|
|
415
|
-
self.flow_id, self.invalid_slots
|
|
416
|
-
)
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
@dataclass
|
|
420
|
-
class ValidationResult:
|
|
421
|
-
is_valid: bool
|
|
422
|
-
invalid_slots: Set[str]
|
|
423
|
-
|
|
424
|
-
|
|
425
382
|
def validate_flow(flow: Flow) -> None:
|
|
426
383
|
"""Validates the flow configuration.
|
|
427
384
|
|
|
@@ -430,8 +387,6 @@ def validate_flow(flow: Flow) -> None:
|
|
|
430
387
|
- whether all next links point to existing steps
|
|
431
388
|
- whether all steps can be reached from the start step
|
|
432
389
|
"""
|
|
433
|
-
from rasa.cli.utils import is_skip_validation_flag_set
|
|
434
|
-
|
|
435
390
|
validate_flow_not_empty(flow)
|
|
436
391
|
validate_no_empty_step_sequences(flow)
|
|
437
392
|
validate_all_steps_next_property(flow)
|
|
@@ -442,12 +397,6 @@ def validate_flow(flow: Flow) -> None:
|
|
|
442
397
|
validate_slot_names_to_be_collected(flow)
|
|
443
398
|
validate_flow_id(flow)
|
|
444
399
|
|
|
445
|
-
if is_skip_validation_flag_set():
|
|
446
|
-
# we only want to run this validation if the --skip-validation flag is used
|
|
447
|
-
# during training because Flow Validation exceptions are raised one by one
|
|
448
|
-
# as opposed to all at once with the Validator class
|
|
449
|
-
validate_slot_persistence_configuration(flow)
|
|
450
|
-
|
|
451
400
|
|
|
452
401
|
def validate_flow_not_empty(flow: Flow) -> None:
|
|
453
402
|
"""Validate that the flow is not empty."""
|
|
@@ -688,48 +637,3 @@ def validate_flow_id(flow: Flow) -> None:
|
|
|
688
637
|
flow_re = re.compile(FLOW_ID_REGEX)
|
|
689
638
|
if not flow_re.search(flow.id):
|
|
690
639
|
raise FlowIdNamingException(flow.id)
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
def validate_slot_persistence_configuration(flow: Flow) -> None:
|
|
694
|
-
"""Validates that slot persistence configuration is valid.
|
|
695
|
-
|
|
696
|
-
Only slots used in either a collect step or a set_slot step can be persisted
|
|
697
|
-
and the configuration can either be set at the flow level or the collect step level,
|
|
698
|
-
but not both.
|
|
699
|
-
|
|
700
|
-
Args:
|
|
701
|
-
flow: The flow to validate.
|
|
702
|
-
|
|
703
|
-
Raises:
|
|
704
|
-
DuplicateSlotPersistConfigException: If slot persist config is duplicated.
|
|
705
|
-
"""
|
|
706
|
-
|
|
707
|
-
def _is_persist_slots_valid(
|
|
708
|
-
persist_slots: List[str], flow_slots: Set[str]
|
|
709
|
-
) -> ValidationResult:
|
|
710
|
-
"""Validates that the slots that should be persisted are used in the flow."""
|
|
711
|
-
invalid_slots = set(persist_slots) - flow_slots
|
|
712
|
-
is_valid = False if invalid_slots else True
|
|
713
|
-
|
|
714
|
-
return ValidationResult(is_valid, invalid_slots)
|
|
715
|
-
|
|
716
|
-
flow_id = flow.id
|
|
717
|
-
persist_slots = flow.persisted_slots
|
|
718
|
-
has_flow_level_persistence = True if persist_slots else False
|
|
719
|
-
flow_slots = set()
|
|
720
|
-
|
|
721
|
-
for step in flow.steps_with_calls_resolved:
|
|
722
|
-
if isinstance(step, SetSlotsFlowStep):
|
|
723
|
-
flow_slots.update([slot["key"] for slot in step.slots])
|
|
724
|
-
elif isinstance(step, CollectInformationFlowStep):
|
|
725
|
-
flow_slots.add(step.collect)
|
|
726
|
-
if not step.reset_after_flow_ends:
|
|
727
|
-
collect_step = step.collect
|
|
728
|
-
warn_deprecated_collect_step_config(flow_id, collect_step)
|
|
729
|
-
if has_flow_level_persistence:
|
|
730
|
-
raise DuplicateSlotPersistConfigException(flow_id, collect_step)
|
|
731
|
-
|
|
732
|
-
if has_flow_level_persistence:
|
|
733
|
-
result = _is_persist_slots_valid(persist_slots, flow_slots)
|
|
734
|
-
if not result.is_valid:
|
|
735
|
-
raise InvalidPersistSlotsException(flow_id, result.invalid_slots)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
|
-
from typing import Any,
|
|
2
|
+
from typing import Any, Dict, List, Optional, Text, Union
|
|
3
3
|
|
|
4
4
|
import jsonschema
|
|
5
5
|
import ruamel.yaml.nodes as yaml_nodes
|
|
@@ -25,8 +25,6 @@ KEY_FLOWS = "flows"
|
|
|
25
25
|
class YAMLFlowsReader:
|
|
26
26
|
"""Class that reads flows information in YAML format."""
|
|
27
27
|
|
|
28
|
-
expand_env_vars: ClassVar[bool] = True
|
|
29
|
-
|
|
30
28
|
@classmethod
|
|
31
29
|
def read_from_file(
|
|
32
30
|
cls, filename: Union[Text, Path], add_line_numbers: bool = True
|
|
@@ -219,21 +217,14 @@ class YAMLFlowsReader:
|
|
|
219
217
|
`Flow`s read from `string`.
|
|
220
218
|
"""
|
|
221
219
|
validate_yaml_with_jsonschema(
|
|
222
|
-
string,
|
|
223
|
-
FLOWS_SCHEMA_FILE,
|
|
224
|
-
humanize_error=cls.humanize_flow_error,
|
|
225
|
-
expand_env_vars=cls.expand_env_vars,
|
|
220
|
+
string, FLOWS_SCHEMA_FILE, humanize_error=cls.humanize_flow_error
|
|
226
221
|
)
|
|
227
222
|
if add_line_numbers:
|
|
228
|
-
yaml_content = read_yaml(
|
|
229
|
-
string,
|
|
230
|
-
custom_constructor=line_number_constructor,
|
|
231
|
-
expand_env_vars=cls.expand_env_vars,
|
|
232
|
-
)
|
|
223
|
+
yaml_content = read_yaml(string, custom_constructor=line_number_constructor)
|
|
233
224
|
yaml_content = process_yaml_content(yaml_content)
|
|
234
225
|
|
|
235
226
|
else:
|
|
236
|
-
yaml_content = read_yaml(string
|
|
227
|
+
yaml_content = read_yaml(string)
|
|
237
228
|
|
|
238
229
|
return FlowsList.from_json(yaml_content.get(KEY_FLOWS, {}), file_path=file_path)
|
|
239
230
|
|
rasa/shared/core/slots.py
CHANGED
|
@@ -193,11 +193,6 @@ class Slot(ABC):
|
|
|
193
193
|
data.update(self.persistence_info())
|
|
194
194
|
return rasa.shared.utils.io.get_dictionary_fingerprint(data)
|
|
195
195
|
|
|
196
|
-
def __eq__(self, other: Any) -> bool:
|
|
197
|
-
if not isinstance(other, Slot):
|
|
198
|
-
return False
|
|
199
|
-
return self.name == other.name and self.value == other.value
|
|
200
|
-
|
|
201
196
|
|
|
202
197
|
class FloatSlot(Slot):
|
|
203
198
|
"""A slot storing a float value."""
|