rasa-pro 3.8.18__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 +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 +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 +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.14.dist-info}/METADATA +25 -61
- {rasa_pro-3.8.18.dist-info → rasa_pro-3.9.14.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.14.dist-info}/NOTICE +0 -0
- {rasa_pro-3.8.18.dist-info → rasa_pro-3.9.14.dist-info}/WHEEL +0 -0
- {rasa_pro-3.8.18.dist-info → rasa_pro-3.9.14.dist-info}/entry_points.txt +0 -0
rasa/utils/tensorflow/models.py
CHANGED
|
@@ -239,7 +239,7 @@ class RasaModel(Model):
|
|
|
239
239
|
|
|
240
240
|
@staticmethod
|
|
241
241
|
def _dynamic_signature(
|
|
242
|
-
batch_in: Union[Tuple[tf.Tensor, ...], Tuple[np.ndarray, ...]]
|
|
242
|
+
batch_in: Union[Tuple[tf.Tensor, ...], Tuple[np.ndarray, ...]],
|
|
243
243
|
) -> List[List[tf.TensorSpec]]:
|
|
244
244
|
element_spec = []
|
|
245
245
|
for tensor in batch_in:
|
|
@@ -326,9 +326,9 @@ class RasaModel(Model):
|
|
|
326
326
|
# We only need input, since output is always None and not
|
|
327
327
|
# consumed by our TF graphs.
|
|
328
328
|
batch_in = next(data_iterator)[0]
|
|
329
|
-
batch_out: Dict[
|
|
330
|
-
|
|
331
|
-
|
|
329
|
+
batch_out: Dict[Text, Union[np.ndarray, Dict[Text, Any]]] = (
|
|
330
|
+
self._rasa_predict(batch_in)
|
|
331
|
+
)
|
|
332
332
|
if output_keys_expected:
|
|
333
333
|
batch_out = {
|
|
334
334
|
key: output
|
|
@@ -379,7 +379,7 @@ class RasaModel(Model):
|
|
|
379
379
|
"""Recursively replaces empty list or np array with None in a dictionary."""
|
|
380
380
|
|
|
381
381
|
def _recurse(
|
|
382
|
-
x: Union[Dict[Text, Any], List[Any], np.ndarray]
|
|
382
|
+
x: Union[Dict[Text, Any], List[Any], np.ndarray],
|
|
383
383
|
) -> Optional[Union[Dict[Text, Any], List[Any], np.ndarray]]:
|
|
384
384
|
if isinstance(x, dict):
|
|
385
385
|
return {k: _recurse(v) for k, v in x.items()}
|
|
@@ -891,7 +891,6 @@ class TransformerRasaModel(RasaModel):
|
|
|
891
891
|
tag_name: Text,
|
|
892
892
|
entity_tags: Optional[tf.Tensor] = None,
|
|
893
893
|
) -> Tuple[tf.Tensor, tf.Tensor, tf.Tensor]:
|
|
894
|
-
|
|
895
894
|
tag_ids = tf.cast(tag_ids[:, :, 0], tf.int32)
|
|
896
895
|
|
|
897
896
|
if entity_tags is not None:
|
|
@@ -418,7 +418,7 @@ class RasaFeatureCombiningLayer(RasaCustomLayer):
|
|
|
418
418
|
|
|
419
419
|
@staticmethod
|
|
420
420
|
def _get_present_feature_types(
|
|
421
|
-
attribute_signature: Dict[Text, List[FeatureSignature]]
|
|
421
|
+
attribute_signature: Dict[Text, List[FeatureSignature]],
|
|
422
422
|
) -> Dict[Text, bool]:
|
|
423
423
|
"""Determines feature types that are present.
|
|
424
424
|
|
|
@@ -444,13 +444,13 @@ class RasaFeatureCombiningLayer(RasaCustomLayer):
|
|
|
444
444
|
for feature_type, present in self._feature_types_present.items():
|
|
445
445
|
if not present:
|
|
446
446
|
continue
|
|
447
|
-
self._tf_layers[
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
447
|
+
self._tf_layers[f"sparse_dense.{feature_type}"] = (
|
|
448
|
+
ConcatenateSparseDenseFeatures(
|
|
449
|
+
attribute=attribute,
|
|
450
|
+
feature_type=feature_type,
|
|
451
|
+
feature_type_signature=attribute_signature[feature_type],
|
|
452
|
+
config=config,
|
|
453
|
+
)
|
|
454
454
|
)
|
|
455
455
|
|
|
456
456
|
def _prepare_sequence_sentence_concat(
|
|
@@ -853,13 +853,13 @@ class RasaSequenceLayer(RasaCustomLayer):
|
|
|
853
853
|
[not signature.is_sparse for signature in attribute_signature[SEQUENCE]]
|
|
854
854
|
)
|
|
855
855
|
if not expect_dense_seq_features:
|
|
856
|
-
self._tf_layers[
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
856
|
+
self._tf_layers[self.SPARSE_TO_DENSE_FOR_TOKEN_IDS] = (
|
|
857
|
+
layers.DenseForSparse(
|
|
858
|
+
units=2,
|
|
859
|
+
use_bias=False,
|
|
860
|
+
trainable=False,
|
|
861
|
+
name=f"{self.SPARSE_TO_DENSE_FOR_TOKEN_IDS}.{attribute}",
|
|
862
|
+
)
|
|
863
863
|
)
|
|
864
864
|
|
|
865
865
|
def _calculate_output_units(
|
rasa/utils/train_utils.py
CHANGED
|
@@ -453,7 +453,7 @@ def _check_evaluation_setting(component_config: Dict[Text, Any]) -> None:
|
|
|
453
453
|
f"No checkpoint model will be saved."
|
|
454
454
|
)
|
|
455
455
|
rasa.shared.utils.io.raise_warning(warning)
|
|
456
|
-
if
|
|
456
|
+
if component_config.get(CHECKPOINT_MODEL):
|
|
457
457
|
if (
|
|
458
458
|
component_config[EVAL_NUM_EPOCHS] != -1
|
|
459
459
|
and component_config[EVAL_NUM_EPOCHS] < 1
|
rasa/utils/url_tools.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
import enum
|
|
3
|
+
from typing import Dict
|
|
4
|
+
|
|
5
|
+
from urllib.parse import urlparse
|
|
6
|
+
|
|
7
|
+
import structlog
|
|
8
|
+
|
|
9
|
+
structlogger = structlog.get_logger()
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class UrlSchema(enum.Enum):
|
|
13
|
+
HTTP = "http"
|
|
14
|
+
HTTPS = "https"
|
|
15
|
+
FILE = "file"
|
|
16
|
+
FTP = "ftp"
|
|
17
|
+
SFTP = "sftp"
|
|
18
|
+
GRPC = "grpc"
|
|
19
|
+
UNKNOWN = "unknown"
|
|
20
|
+
NOT_SPECIFIED = "not_specified"
|
|
21
|
+
|
|
22
|
+
@property
|
|
23
|
+
def available_schemas(self) -> Dict[str, UrlSchema]:
|
|
24
|
+
"""Get all available URL schemas except for the unknown schema."""
|
|
25
|
+
return {
|
|
26
|
+
schema.value: schema for schema in UrlSchema if schema != UrlSchema.UNKNOWN
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def get_url_schema(url: str) -> UrlSchema:
|
|
31
|
+
"""Get the schema of a URL.
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
url: The URL to parse.
|
|
35
|
+
|
|
36
|
+
Returns:
|
|
37
|
+
The schema of the URL.
|
|
38
|
+
"""
|
|
39
|
+
parsed_url = urlparse(url)
|
|
40
|
+
|
|
41
|
+
if parsed_url.scheme == "":
|
|
42
|
+
return UrlSchema.NOT_SPECIFIED
|
|
43
|
+
|
|
44
|
+
try:
|
|
45
|
+
return UrlSchema(parsed_url.scheme)
|
|
46
|
+
except ValueError:
|
|
47
|
+
structlogger.warn(
|
|
48
|
+
"rasa.utils.url_tools.get_url_schema.unknown_schema",
|
|
49
|
+
event_info=f"Unknown URL schema '{parsed_url.scheme}'. "
|
|
50
|
+
f"Returning 'unknown'.",
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
return UrlSchema.UNKNOWN
|
rasa/validator.py
CHANGED
|
@@ -9,7 +9,12 @@ from jinja2 import Template
|
|
|
9
9
|
from pypred import Predicate
|
|
10
10
|
|
|
11
11
|
import rasa.core.training.story_conflict
|
|
12
|
+
from rasa.core.channels import UserMessage
|
|
12
13
|
from rasa.dialogue_understanding.stack.frames import PatternFlowStackFrame
|
|
14
|
+
from rasa.shared.core.command_payload_reader import (
|
|
15
|
+
CommandPayloadReader,
|
|
16
|
+
MAX_NUMBER_OF_SLOTS,
|
|
17
|
+
)
|
|
13
18
|
from rasa.shared.core.flows.flow_step_links import IfFlowStepLink
|
|
14
19
|
from rasa.shared.core.flows.steps.set_slots import SetSlotsFlowStep
|
|
15
20
|
from rasa.shared.core.flows.steps.collect import CollectInformationFlowStep
|
|
@@ -21,8 +26,10 @@ from rasa.shared.constants import (
|
|
|
21
26
|
ASSISTANT_ID_DEFAULT_VALUE,
|
|
22
27
|
ASSISTANT_ID_KEY,
|
|
23
28
|
CONFIG_MANDATORY_KEYS,
|
|
29
|
+
DOCS_URL_DOMAIN,
|
|
24
30
|
DOCS_URL_DOMAINS,
|
|
25
31
|
DOCS_URL_FORMS,
|
|
32
|
+
DOCS_URL_RESPONSES,
|
|
26
33
|
UTTER_PREFIX,
|
|
27
34
|
DOCS_URL_ACTIONS,
|
|
28
35
|
REQUIRED_SLOTS_KEY,
|
|
@@ -38,8 +45,14 @@ from rasa.shared.core.domain import (
|
|
|
38
45
|
from rasa.shared.core.generator import TrainingDataGenerator
|
|
39
46
|
from rasa.shared.core.constants import SlotMappingType, MAPPING_TYPE
|
|
40
47
|
from rasa.shared.core.slots import ListSlot, Slot
|
|
48
|
+
from rasa.shared.core.training_data.story_reader.yaml_story_reader import (
|
|
49
|
+
YAMLStoryReader,
|
|
50
|
+
)
|
|
41
51
|
from rasa.shared.core.training_data.structures import StoryGraph
|
|
52
|
+
from rasa.shared.data import create_regex_pattern_reader
|
|
42
53
|
from rasa.shared.importers.importer import TrainingDataImporter
|
|
54
|
+
from rasa.shared.nlu.constants import COMMANDS
|
|
55
|
+
from rasa.shared.nlu.training_data.message import Message
|
|
43
56
|
from rasa.shared.nlu.training_data.training_data import TrainingData
|
|
44
57
|
import rasa.shared.utils.cli
|
|
45
58
|
import rasa.shared.utils.io
|
|
@@ -326,7 +339,7 @@ class Validator:
|
|
|
326
339
|
continue
|
|
327
340
|
|
|
328
341
|
if event.name not in self.domain.action_names_or_texts:
|
|
329
|
-
structlogger.
|
|
342
|
+
structlogger.error(
|
|
330
343
|
"validator.verify_forms_in_stories_rules.not_in_domain",
|
|
331
344
|
form=event.name,
|
|
332
345
|
block=story.block_name,
|
|
@@ -365,7 +378,7 @@ class Validator:
|
|
|
365
378
|
continue
|
|
366
379
|
|
|
367
380
|
if event.action_name not in self.domain.action_names_or_texts:
|
|
368
|
-
structlogger.
|
|
381
|
+
structlogger.error(
|
|
369
382
|
"validator.verify_actions_in_stories_rules.not_in_domain",
|
|
370
383
|
action=event.action_name,
|
|
371
384
|
block=story.block_name,
|
|
@@ -786,7 +799,7 @@ class Validator:
|
|
|
786
799
|
|
|
787
800
|
for flow in self.flows.underlying_flows:
|
|
788
801
|
flow_description = flow.description
|
|
789
|
-
cleaned_description = flow_description.translate(punctuation_table) # type: ignore[union-attr]
|
|
802
|
+
cleaned_description = flow_description.translate(punctuation_table) # type: ignore[union-attr]
|
|
790
803
|
if cleaned_description in flow_descriptions:
|
|
791
804
|
structlogger.error(
|
|
792
805
|
"validator.verify_unique_flows.duplicate_description",
|
|
@@ -1033,3 +1046,292 @@ class Validator:
|
|
|
1033
1046
|
structlogger.info("validation.flows.ended")
|
|
1034
1047
|
|
|
1035
1048
|
return all_good
|
|
1049
|
+
|
|
1050
|
+
def validate_button_payloads(self) -> bool:
|
|
1051
|
+
"""Check if the response button payloads are valid."""
|
|
1052
|
+
all_good = True
|
|
1053
|
+
for utter_name, response in self.domain.responses.items():
|
|
1054
|
+
for variation in response:
|
|
1055
|
+
for button in variation.get("buttons", []):
|
|
1056
|
+
payload = button.get("payload")
|
|
1057
|
+
if payload is None:
|
|
1058
|
+
structlogger.error(
|
|
1059
|
+
"validator.validate_button_payloads.missing_payload",
|
|
1060
|
+
event_info=(
|
|
1061
|
+
f"The button '{button.get('title')}' in response "
|
|
1062
|
+
f"'{utter_name}' does not have a payload. "
|
|
1063
|
+
f"Please add a payload to the button."
|
|
1064
|
+
),
|
|
1065
|
+
)
|
|
1066
|
+
all_good = False
|
|
1067
|
+
continue
|
|
1068
|
+
|
|
1069
|
+
if not payload.strip():
|
|
1070
|
+
structlogger.error(
|
|
1071
|
+
"validator.validate_button_payloads.empty_payload",
|
|
1072
|
+
event_info=(
|
|
1073
|
+
f"The button '{button.get('title')}' in response "
|
|
1074
|
+
f"'{utter_name}' has an empty payload. "
|
|
1075
|
+
f"Please add a payload to the button."
|
|
1076
|
+
),
|
|
1077
|
+
)
|
|
1078
|
+
all_good = False
|
|
1079
|
+
continue
|
|
1080
|
+
|
|
1081
|
+
regex_reader = create_regex_pattern_reader(
|
|
1082
|
+
UserMessage(text=payload), self.domain
|
|
1083
|
+
)
|
|
1084
|
+
|
|
1085
|
+
if regex_reader is None:
|
|
1086
|
+
structlogger.warning(
|
|
1087
|
+
"validator.validate_button_payloads.free_form_string",
|
|
1088
|
+
event_info=(
|
|
1089
|
+
"Using a free form string in payload of a button "
|
|
1090
|
+
"implies that the string will be sent to the NLU "
|
|
1091
|
+
"interpreter for parsing. To avoid the need for "
|
|
1092
|
+
"parsing at runtime, it is recommended to use one "
|
|
1093
|
+
"of the documented formats "
|
|
1094
|
+
"(https://rasa.com/docs/rasa-pro/concepts/responses#buttons)"
|
|
1095
|
+
),
|
|
1096
|
+
)
|
|
1097
|
+
continue
|
|
1098
|
+
|
|
1099
|
+
if isinstance(
|
|
1100
|
+
regex_reader, CommandPayloadReader
|
|
1101
|
+
) and regex_reader.is_above_slot_limit(payload):
|
|
1102
|
+
structlogger.error(
|
|
1103
|
+
"validator.validate_button_payloads.slot_limit_exceeded",
|
|
1104
|
+
event_info=(
|
|
1105
|
+
f"The button '{button.get('title')}' in response "
|
|
1106
|
+
f"'{utter_name}' has a payload that sets more than "
|
|
1107
|
+
f"{MAX_NUMBER_OF_SLOTS} slots. "
|
|
1108
|
+
f"Please make sure that the number of slots set by "
|
|
1109
|
+
f"the button payload does not exceed the limit."
|
|
1110
|
+
),
|
|
1111
|
+
)
|
|
1112
|
+
all_good = False
|
|
1113
|
+
continue
|
|
1114
|
+
|
|
1115
|
+
if isinstance(regex_reader, YAMLStoryReader):
|
|
1116
|
+
# the payload could contain double curly braces
|
|
1117
|
+
# we need to remove 1 set of curly braces
|
|
1118
|
+
payload = payload.replace("{{", "{").replace("}}", "}")
|
|
1119
|
+
|
|
1120
|
+
resulting_message = regex_reader.unpack_regex_message(
|
|
1121
|
+
message=Message(data={"text": payload}), domain=self.domain
|
|
1122
|
+
)
|
|
1123
|
+
|
|
1124
|
+
if not (
|
|
1125
|
+
resulting_message.has_intent()
|
|
1126
|
+
or resulting_message.has_commands()
|
|
1127
|
+
):
|
|
1128
|
+
structlogger.error(
|
|
1129
|
+
"validator.validate_button_payloads.invalid_payload_format",
|
|
1130
|
+
event_info=(
|
|
1131
|
+
f"The button '{button.get('title')}' in response "
|
|
1132
|
+
f"'{utter_name}' does not follow valid payload formats "
|
|
1133
|
+
f"for triggering a specific intent and entities or for "
|
|
1134
|
+
f"triggering a SetSlot command."
|
|
1135
|
+
),
|
|
1136
|
+
calm_docs_link=DOCS_URL_RESPONSES + "#payload-syntax",
|
|
1137
|
+
nlu_docs_link=DOCS_URL_RESPONSES
|
|
1138
|
+
+ "#triggering-intents-or-passing-entities",
|
|
1139
|
+
)
|
|
1140
|
+
all_good = False
|
|
1141
|
+
|
|
1142
|
+
if resulting_message.has_commands():
|
|
1143
|
+
# validate that slot names are unique
|
|
1144
|
+
slot_names = set()
|
|
1145
|
+
for command in resulting_message.get(COMMANDS, []):
|
|
1146
|
+
slot_name = command.get("name")
|
|
1147
|
+
if slot_name and slot_name in slot_names:
|
|
1148
|
+
structlogger.error(
|
|
1149
|
+
"validator.validate_button_payloads.duplicate_slot_name",
|
|
1150
|
+
event_info=(
|
|
1151
|
+
f"The button '{button.get('title')}' "
|
|
1152
|
+
f"in response '{utter_name}' has a "
|
|
1153
|
+
f"command to set the slot "
|
|
1154
|
+
f"'{slot_name}' multiple times. "
|
|
1155
|
+
f"Please make sure that each slot "
|
|
1156
|
+
f"is set only once."
|
|
1157
|
+
),
|
|
1158
|
+
)
|
|
1159
|
+
all_good = False
|
|
1160
|
+
slot_names.add(slot_name)
|
|
1161
|
+
|
|
1162
|
+
return all_good
|
|
1163
|
+
|
|
1164
|
+
def validate_CALM_slot_mappings(self) -> bool:
|
|
1165
|
+
"""Check if the usage of slot mappings in a CALM assistant is valid."""
|
|
1166
|
+
all_good = True
|
|
1167
|
+
|
|
1168
|
+
for slot in self.domain._user_slots:
|
|
1169
|
+
nlu_mappings = any(
|
|
1170
|
+
[
|
|
1171
|
+
SlotMappingType(
|
|
1172
|
+
mapping.get("type", SlotMappingType.FROM_LLM.value)
|
|
1173
|
+
).is_predefined_type()
|
|
1174
|
+
for mapping in slot.mappings
|
|
1175
|
+
]
|
|
1176
|
+
)
|
|
1177
|
+
llm_mappings = any(
|
|
1178
|
+
[
|
|
1179
|
+
SlotMappingType(mapping.get("type", SlotMappingType.FROM_LLM.value))
|
|
1180
|
+
== SlotMappingType.FROM_LLM
|
|
1181
|
+
for mapping in slot.mappings
|
|
1182
|
+
]
|
|
1183
|
+
)
|
|
1184
|
+
custom_mappings = any(
|
|
1185
|
+
[
|
|
1186
|
+
SlotMappingType(mapping.get("type", SlotMappingType.FROM_LLM.value))
|
|
1187
|
+
== SlotMappingType.CUSTOM
|
|
1188
|
+
for mapping in slot.mappings
|
|
1189
|
+
]
|
|
1190
|
+
)
|
|
1191
|
+
|
|
1192
|
+
all_good = self._slot_contains_all_mappings_types(
|
|
1193
|
+
llm_mappings, nlu_mappings, custom_mappings, slot.name, all_good
|
|
1194
|
+
)
|
|
1195
|
+
|
|
1196
|
+
all_good = self._custom_action_name_is_defined_in_the_domain(
|
|
1197
|
+
custom_mappings, slot, all_good
|
|
1198
|
+
)
|
|
1199
|
+
|
|
1200
|
+
all_good = self._config_contains_nlu_command_adapter(
|
|
1201
|
+
nlu_mappings, slot.name, all_good
|
|
1202
|
+
)
|
|
1203
|
+
|
|
1204
|
+
all_good = self._uses_from_llm_mappings_in_a_NLU_based_assistant(
|
|
1205
|
+
llm_mappings, slot.name, all_good
|
|
1206
|
+
)
|
|
1207
|
+
|
|
1208
|
+
return all_good
|
|
1209
|
+
|
|
1210
|
+
@staticmethod
|
|
1211
|
+
def _slot_contains_all_mappings_types(
|
|
1212
|
+
llm_mappings: bool,
|
|
1213
|
+
nlu_mappings: bool,
|
|
1214
|
+
custom_mappings: bool,
|
|
1215
|
+
slot_name: str,
|
|
1216
|
+
all_good: bool,
|
|
1217
|
+
) -> bool:
|
|
1218
|
+
if llm_mappings and (nlu_mappings or custom_mappings):
|
|
1219
|
+
structlogger.error(
|
|
1220
|
+
"validator.validate_slot_mappings_in_CALM.llm_and_nlu_mappings",
|
|
1221
|
+
slot_name=slot_name,
|
|
1222
|
+
event_info=(
|
|
1223
|
+
f"The slot '{slot_name}' has both LLM and "
|
|
1224
|
+
f"NLU or custom slot mappings. "
|
|
1225
|
+
f"Please make sure that the slot has only one type of mapping."
|
|
1226
|
+
),
|
|
1227
|
+
docs_link=DOCS_URL_DOMAIN + "#calm-slot-mappings",
|
|
1228
|
+
)
|
|
1229
|
+
all_good = False
|
|
1230
|
+
|
|
1231
|
+
return all_good
|
|
1232
|
+
|
|
1233
|
+
def _custom_action_name_is_defined_in_the_domain(
|
|
1234
|
+
self,
|
|
1235
|
+
custom_mappings: bool,
|
|
1236
|
+
slot: Slot,
|
|
1237
|
+
all_good: bool,
|
|
1238
|
+
) -> bool:
|
|
1239
|
+
if not custom_mappings:
|
|
1240
|
+
return all_good
|
|
1241
|
+
|
|
1242
|
+
if not self.flows:
|
|
1243
|
+
return all_good
|
|
1244
|
+
|
|
1245
|
+
is_custom_action_defined = any(
|
|
1246
|
+
[
|
|
1247
|
+
mapping.get("action") is not None
|
|
1248
|
+
and mapping.get("action") in self.domain.action_names_or_texts
|
|
1249
|
+
for mapping in slot.mappings
|
|
1250
|
+
]
|
|
1251
|
+
)
|
|
1252
|
+
|
|
1253
|
+
if is_custom_action_defined:
|
|
1254
|
+
return all_good
|
|
1255
|
+
|
|
1256
|
+
slot_collected_by_flows = any(
|
|
1257
|
+
[
|
|
1258
|
+
step.collect == slot.name
|
|
1259
|
+
for flow in self.flows.underlying_flows
|
|
1260
|
+
for step in flow.steps
|
|
1261
|
+
if isinstance(step, CollectInformationFlowStep)
|
|
1262
|
+
]
|
|
1263
|
+
)
|
|
1264
|
+
|
|
1265
|
+
if not slot_collected_by_flows:
|
|
1266
|
+
# if the slot is not collected by any flow,
|
|
1267
|
+
# it could be a DM1 custom slot
|
|
1268
|
+
return all_good
|
|
1269
|
+
|
|
1270
|
+
custom_action_ask_name = f"action_ask_{slot.name}"
|
|
1271
|
+
if custom_action_ask_name not in self.domain.action_names_or_texts:
|
|
1272
|
+
structlogger.error(
|
|
1273
|
+
"validator.validate_slot_mappings_in_CALM.custom_action_not_in_domain",
|
|
1274
|
+
slot_name=slot.name,
|
|
1275
|
+
event_info=(
|
|
1276
|
+
f"The slot '{slot.name}' has a custom slot mapping, but "
|
|
1277
|
+
f"neither the action '{custom_action_ask_name}' nor "
|
|
1278
|
+
f"another custom action are defined in the domain file. "
|
|
1279
|
+
f"Please add one of the actions to your domain file."
|
|
1280
|
+
),
|
|
1281
|
+
docs_link=DOCS_URL_DOMAIN + "#custom-slot-mappings",
|
|
1282
|
+
)
|
|
1283
|
+
all_good = False
|
|
1284
|
+
|
|
1285
|
+
return all_good
|
|
1286
|
+
|
|
1287
|
+
def _config_contains_nlu_command_adapter(
|
|
1288
|
+
self, nlu_mappings: bool, slot_name: str, all_good: bool
|
|
1289
|
+
) -> bool:
|
|
1290
|
+
if not nlu_mappings:
|
|
1291
|
+
return all_good
|
|
1292
|
+
|
|
1293
|
+
if not self.flows:
|
|
1294
|
+
return all_good
|
|
1295
|
+
|
|
1296
|
+
contains_nlu_command_adapter = any(
|
|
1297
|
+
[
|
|
1298
|
+
component.get("name") == "NLUCommandAdapter"
|
|
1299
|
+
for component in self.config.get("pipeline", [])
|
|
1300
|
+
]
|
|
1301
|
+
)
|
|
1302
|
+
|
|
1303
|
+
if not contains_nlu_command_adapter:
|
|
1304
|
+
structlogger.error(
|
|
1305
|
+
"validator.validate_slot_mappings_in_CALM.nlu_mappings_without_adapter",
|
|
1306
|
+
slot_name=slot_name,
|
|
1307
|
+
event_info=(
|
|
1308
|
+
f"The slot '{slot_name}' has NLU slot mappings, "
|
|
1309
|
+
f"but the NLUCommandAdapter is not present in the "
|
|
1310
|
+
f"pipeline. Please add the NLUCommandAdapter to the "
|
|
1311
|
+
f"pipeline in the config file."
|
|
1312
|
+
),
|
|
1313
|
+
docs_link=DOCS_URL_DOMAIN + "#nlu-based-predefined-slot-mappings",
|
|
1314
|
+
)
|
|
1315
|
+
all_good = False
|
|
1316
|
+
|
|
1317
|
+
return all_good
|
|
1318
|
+
|
|
1319
|
+
def _uses_from_llm_mappings_in_a_NLU_based_assistant(
|
|
1320
|
+
self, llm_mappings: bool, slot_name: str, all_good: bool
|
|
1321
|
+
) -> bool:
|
|
1322
|
+
if not llm_mappings:
|
|
1323
|
+
return all_good
|
|
1324
|
+
|
|
1325
|
+
if self.flows:
|
|
1326
|
+
return all_good
|
|
1327
|
+
|
|
1328
|
+
structlogger.error(
|
|
1329
|
+
"validator.validate_slot_mappings_in_CALM.llm_mappings_without_flows",
|
|
1330
|
+
slot_name=slot_name,
|
|
1331
|
+
event_info=(
|
|
1332
|
+
f"The slot '{slot_name}' has LLM slot mappings, "
|
|
1333
|
+
f"but no flows are present in the training data files. "
|
|
1334
|
+
f"Please add flows to the training data files."
|
|
1335
|
+
),
|
|
1336
|
+
)
|
|
1337
|
+
return False
|
rasa/version.py
CHANGED