rasa-pro 3.11.0__py3-none-any.whl → 3.11.0a1__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.

Files changed (220) hide show
  1. README.md +396 -17
  2. rasa/__main__.py +15 -31
  3. rasa/api.py +1 -5
  4. rasa/cli/arguments/default_arguments.py +2 -1
  5. rasa/cli/arguments/shell.py +1 -5
  6. rasa/cli/arguments/train.py +0 -14
  7. rasa/cli/e2e_test.py +1 -1
  8. rasa/cli/evaluate.py +8 -8
  9. rasa/cli/inspect.py +7 -15
  10. rasa/cli/interactive.py +0 -1
  11. rasa/cli/llm_fine_tuning.py +1 -1
  12. rasa/cli/project_templates/calm/config.yml +7 -5
  13. rasa/cli/project_templates/calm/endpoints.yml +2 -15
  14. rasa/cli/project_templates/tutorial/config.yml +5 -8
  15. rasa/cli/project_templates/tutorial/data/flows.yml +1 -1
  16. rasa/cli/project_templates/tutorial/data/patterns.yml +0 -5
  17. rasa/cli/project_templates/tutorial/domain.yml +0 -14
  18. rasa/cli/project_templates/tutorial/endpoints.yml +0 -5
  19. rasa/cli/run.py +1 -1
  20. rasa/cli/scaffold.py +2 -4
  21. rasa/cli/studio/studio.py +8 -18
  22. rasa/cli/studio/upload.py +15 -0
  23. rasa/cli/train.py +0 -3
  24. rasa/cli/utils.py +1 -6
  25. rasa/cli/x.py +8 -8
  26. rasa/constants.py +1 -3
  27. rasa/core/actions/action.py +33 -75
  28. rasa/core/actions/e2e_stub_custom_action_executor.py +1 -5
  29. rasa/core/actions/http_custom_action_executor.py +0 -4
  30. rasa/core/channels/__init__.py +0 -2
  31. rasa/core/channels/channel.py +0 -20
  32. rasa/core/channels/development_inspector.py +3 -10
  33. rasa/core/channels/inspector/dist/assets/{arc-bc141fb2.js → arc-86942a71.js} +1 -1
  34. rasa/core/channels/inspector/dist/assets/{c4Diagram-d0fbc5ce-be2db283.js → c4Diagram-d0fbc5ce-b0290676.js} +1 -1
  35. rasa/core/channels/inspector/dist/assets/{classDiagram-936ed81e-55366915.js → classDiagram-936ed81e-f6405f6e.js} +1 -1
  36. rasa/core/channels/inspector/dist/assets/{classDiagram-v2-c3cb15f1-bb529518.js → classDiagram-v2-c3cb15f1-ef61ac77.js} +1 -1
  37. rasa/core/channels/inspector/dist/assets/{createText-62fc7601-b0ec81d6.js → createText-62fc7601-f0411e58.js} +1 -1
  38. rasa/core/channels/inspector/dist/assets/{edges-f2ad444c-6166330c.js → edges-f2ad444c-7dcc4f3b.js} +1 -1
  39. rasa/core/channels/inspector/dist/assets/{erDiagram-9d236eb7-5ccc6a8e.js → erDiagram-9d236eb7-e0c092d7.js} +1 -1
  40. rasa/core/channels/inspector/dist/assets/{flowDb-1972c806-fca3bfe4.js → flowDb-1972c806-fba2e3ce.js} +1 -1
  41. rasa/core/channels/inspector/dist/assets/{flowDiagram-7ea5b25a-4739080f.js → flowDiagram-7ea5b25a-7a70b71a.js} +1 -1
  42. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-855bc5b3-24a5f41a.js +1 -0
  43. rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-abe16c3d-7c1b0e0f.js → flowchart-elk-definition-abe16c3d-00a59b68.js} +1 -1
  44. rasa/core/channels/inspector/dist/assets/{ganttDiagram-9b5ea136-772fd050.js → ganttDiagram-9b5ea136-293c91fa.js} +1 -1
  45. rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-99d0ae7c-8eae1dc9.js → gitGraphDiagram-99d0ae7c-07b2d68c.js} +1 -1
  46. rasa/core/channels/inspector/dist/assets/{index-2c4b9a3b-f55afcdf.js → index-2c4b9a3b-bc959fbd.js} +1 -1
  47. rasa/core/channels/inspector/dist/assets/{index-e7cef9de.js → index-3a8a5a28.js} +143 -143
  48. rasa/core/channels/inspector/dist/assets/{infoDiagram-736b4530-124d4a14.js → infoDiagram-736b4530-4a350f72.js} +1 -1
  49. rasa/core/channels/inspector/dist/assets/{journeyDiagram-df861f2b-7c4fae44.js → journeyDiagram-df861f2b-af464fb7.js} +1 -1
  50. rasa/core/channels/inspector/dist/assets/{layout-b9885fb6.js → layout-0071f036.js} +1 -1
  51. rasa/core/channels/inspector/dist/assets/{line-7c59abb6.js → line-2f73cc83.js} +1 -1
  52. rasa/core/channels/inspector/dist/assets/{linear-4776f780.js → linear-f014b4cc.js} +1 -1
  53. rasa/core/channels/inspector/dist/assets/{mindmap-definition-beec6740-2332c46c.js → mindmap-definition-beec6740-d2426fb6.js} +1 -1
  54. rasa/core/channels/inspector/dist/assets/{pieDiagram-dbbf0591-8fb39303.js → pieDiagram-dbbf0591-776f01a2.js} +1 -1
  55. rasa/core/channels/inspector/dist/assets/{quadrantDiagram-4d7f4fd6-3c7180a2.js → quadrantDiagram-4d7f4fd6-82e00b57.js} +1 -1
  56. rasa/core/channels/inspector/dist/assets/{requirementDiagram-6fc4c22a-e910bcb8.js → requirementDiagram-6fc4c22a-ea13c6bb.js} +1 -1
  57. rasa/core/channels/inspector/dist/assets/{sankeyDiagram-8f13d901-ead16c89.js → sankeyDiagram-8f13d901-1feca7e9.js} +1 -1
  58. rasa/core/channels/inspector/dist/assets/{sequenceDiagram-b655622a-29a02a19.js → sequenceDiagram-b655622a-070c61d2.js} +1 -1
  59. rasa/core/channels/inspector/dist/assets/{stateDiagram-59f0c015-042b3137.js → stateDiagram-59f0c015-24f46263.js} +1 -1
  60. rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-2b26beab-2178c0f3.js → stateDiagram-v2-2b26beab-c9056051.js} +1 -1
  61. rasa/core/channels/inspector/dist/assets/{styles-080da4f6-23ffa4fc.js → styles-080da4f6-08abc34a.js} +1 -1
  62. rasa/core/channels/inspector/dist/assets/{styles-3dcbcfbf-94f59763.js → styles-3dcbcfbf-bc74c25a.js} +1 -1
  63. rasa/core/channels/inspector/dist/assets/{styles-9c745c82-78a6bebc.js → styles-9c745c82-4e5d66de.js} +1 -1
  64. rasa/core/channels/inspector/dist/assets/{svgDrawCommon-4835440b-eae2a6f6.js → svgDrawCommon-4835440b-849c4517.js} +1 -1
  65. rasa/core/channels/inspector/dist/assets/{timeline-definition-5b62e21b-5c968d92.js → timeline-definition-5b62e21b-d0fb1598.js} +1 -1
  66. rasa/core/channels/inspector/dist/assets/{xychartDiagram-2b33534f-fd3db0d5.js → xychartDiagram-2b33534f-04d115e2.js} +1 -1
  67. rasa/core/channels/inspector/dist/index.html +1 -1
  68. rasa/core/channels/inspector/src/App.tsx +1 -1
  69. rasa/core/channels/inspector/src/components/LoadingSpinner.tsx +3 -6
  70. rasa/core/channels/socketio.py +2 -7
  71. rasa/core/channels/telegram.py +1 -1
  72. rasa/core/channels/twilio.py +1 -1
  73. rasa/core/channels/voice_ready/audiocodes.py +4 -15
  74. rasa/core/channels/voice_ready/jambonz.py +4 -15
  75. rasa/core/channels/voice_ready/twilio_voice.py +21 -6
  76. rasa/core/channels/voice_ready/utils.py +5 -6
  77. rasa/core/channels/voice_stream/asr/asr_engine.py +1 -19
  78. rasa/core/channels/voice_stream/asr/asr_event.py +0 -5
  79. rasa/core/channels/voice_stream/asr/deepgram.py +15 -28
  80. rasa/core/channels/voice_stream/audio_bytes.py +0 -1
  81. rasa/core/channels/voice_stream/tts/azure.py +3 -9
  82. rasa/core/channels/voice_stream/tts/cartesia.py +8 -12
  83. rasa/core/channels/voice_stream/tts/tts_engine.py +1 -11
  84. rasa/core/channels/voice_stream/twilio_media_streams.py +19 -28
  85. rasa/core/channels/voice_stream/util.py +4 -4
  86. rasa/core/channels/voice_stream/voice_channel.py +42 -222
  87. rasa/core/featurizers/single_state_featurizer.py +1 -22
  88. rasa/core/featurizers/tracker_featurizers.py +18 -115
  89. rasa/core/information_retrieval/qdrant.py +0 -1
  90. rasa/core/nlg/contextual_response_rephraser.py +25 -44
  91. rasa/core/persistor.py +34 -191
  92. rasa/core/policies/enterprise_search_policy.py +60 -119
  93. rasa/core/policies/flows/flow_executor.py +4 -7
  94. rasa/core/policies/intentless_policy.py +22 -82
  95. rasa/core/policies/ted_policy.py +33 -58
  96. rasa/core/policies/unexpected_intent_policy.py +7 -15
  97. rasa/core/processor.py +13 -89
  98. rasa/core/run.py +2 -2
  99. rasa/core/training/interactive.py +35 -34
  100. rasa/core/utils.py +22 -58
  101. rasa/dialogue_understanding/coexistence/llm_based_router.py +12 -39
  102. rasa/dialogue_understanding/commands/__init__.py +0 -4
  103. rasa/dialogue_understanding/commands/change_flow_command.py +0 -6
  104. rasa/dialogue_understanding/commands/utils.py +0 -5
  105. rasa/dialogue_understanding/generator/constants.py +0 -2
  106. rasa/dialogue_understanding/generator/flow_retrieval.py +4 -49
  107. rasa/dialogue_understanding/generator/llm_based_command_generator.py +23 -37
  108. rasa/dialogue_understanding/generator/multi_step/multi_step_llm_command_generator.py +10 -57
  109. rasa/dialogue_understanding/generator/nlu_command_adapter.py +1 -19
  110. rasa/dialogue_understanding/generator/single_step/command_prompt_template.jinja2 +0 -3
  111. rasa/dialogue_understanding/generator/single_step/single_step_llm_command_generator.py +10 -90
  112. rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +0 -53
  113. rasa/dialogue_understanding/processor/command_processor.py +1 -21
  114. rasa/e2e_test/assertions.py +16 -133
  115. rasa/e2e_test/assertions_schema.yml +0 -23
  116. rasa/e2e_test/e2e_test_case.py +6 -85
  117. rasa/e2e_test/e2e_test_runner.py +4 -6
  118. rasa/e2e_test/utils/io.py +1 -3
  119. rasa/engine/loader.py +0 -12
  120. rasa/engine/validation.py +11 -541
  121. rasa/keys +1 -0
  122. rasa/llm_fine_tuning/notebooks/unsloth_finetuning.ipynb +407 -0
  123. rasa/model_training.py +7 -29
  124. rasa/nlu/classifiers/diet_classifier.py +25 -38
  125. rasa/nlu/classifiers/logistic_regression_classifier.py +9 -22
  126. rasa/nlu/classifiers/sklearn_intent_classifier.py +16 -37
  127. rasa/nlu/extractors/crf_entity_extractor.py +50 -93
  128. rasa/nlu/featurizers/sparse_featurizer/count_vectors_featurizer.py +16 -45
  129. rasa/nlu/featurizers/sparse_featurizer/lexical_syntactic_featurizer.py +17 -52
  130. rasa/nlu/featurizers/sparse_featurizer/regex_featurizer.py +3 -5
  131. rasa/nlu/tokenizers/whitespace_tokenizer.py +14 -3
  132. rasa/server.py +1 -3
  133. rasa/shared/constants.py +0 -61
  134. rasa/shared/core/constants.py +0 -9
  135. rasa/shared/core/domain.py +5 -8
  136. rasa/shared/core/flows/flow.py +0 -5
  137. rasa/shared/core/flows/flows_list.py +1 -5
  138. rasa/shared/core/flows/flows_yaml_schema.json +0 -10
  139. rasa/shared/core/flows/validation.py +0 -96
  140. rasa/shared/core/flows/yaml_flows_io.py +4 -13
  141. rasa/shared/core/slots.py +0 -5
  142. rasa/shared/importers/importer.py +2 -19
  143. rasa/shared/importers/rasa.py +1 -5
  144. rasa/shared/nlu/training_data/features.py +2 -120
  145. rasa/shared/nlu/training_data/formats/rasa_yaml.py +3 -18
  146. rasa/shared/providers/_configs/azure_openai_client_config.py +3 -5
  147. rasa/shared/providers/_configs/openai_client_config.py +1 -1
  148. rasa/shared/providers/_configs/self_hosted_llm_client_config.py +0 -1
  149. rasa/shared/providers/_configs/utils.py +0 -16
  150. rasa/shared/providers/embedding/_base_litellm_embedding_client.py +29 -18
  151. rasa/shared/providers/embedding/azure_openai_embedding_client.py +21 -54
  152. rasa/shared/providers/embedding/default_litellm_embedding_client.py +0 -24
  153. rasa/shared/providers/llm/_base_litellm_client.py +31 -63
  154. rasa/shared/providers/llm/azure_openai_llm_client.py +29 -50
  155. rasa/shared/providers/llm/default_litellm_llm_client.py +0 -24
  156. rasa/shared/providers/llm/self_hosted_llm_client.py +29 -17
  157. rasa/shared/providers/mappings.py +0 -19
  158. rasa/shared/utils/common.py +2 -37
  159. rasa/shared/utils/io.py +6 -28
  160. rasa/shared/utils/llm.py +46 -353
  161. rasa/shared/utils/yaml.py +82 -181
  162. rasa/studio/auth.py +5 -3
  163. rasa/studio/config.py +4 -13
  164. rasa/studio/constants.py +0 -1
  165. rasa/studio/data_handler.py +4 -13
  166. rasa/studio/upload.py +80 -175
  167. rasa/telemetry.py +17 -94
  168. rasa/tracing/config.py +1 -3
  169. rasa/tracing/instrumentation/attribute_extractors.py +17 -94
  170. rasa/tracing/instrumentation/instrumentation.py +0 -121
  171. rasa/utils/common.py +0 -5
  172. rasa/utils/endpoints.py +1 -27
  173. rasa/utils/io.py +81 -7
  174. rasa/utils/log_utils.py +2 -9
  175. rasa/utils/tensorflow/model_data.py +193 -2
  176. rasa/validator.py +4 -110
  177. rasa/version.py +1 -1
  178. rasa_pro-3.11.0a1.dist-info/METADATA +576 -0
  179. {rasa_pro-3.11.0.dist-info → rasa_pro-3.11.0a1.dist-info}/RECORD +182 -216
  180. rasa/core/actions/action_repeat_bot_messages.py +0 -89
  181. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-855bc5b3-736177bf.js +0 -1
  182. rasa/core/channels/inspector/src/helpers/audiostream.ts +0 -165
  183. rasa/core/channels/voice_stream/asr/azure.py +0 -129
  184. rasa/core/channels/voice_stream/browser_audio.py +0 -107
  185. rasa/core/channels/voice_stream/call_state.py +0 -23
  186. rasa/dialogue_understanding/commands/repeat_bot_messages_command.py +0 -60
  187. rasa/dialogue_understanding/commands/user_silence_command.py +0 -59
  188. rasa/dialogue_understanding/patterns/repeat.py +0 -37
  189. rasa/dialogue_understanding/patterns/user_silence.py +0 -37
  190. rasa/model_manager/__init__.py +0 -0
  191. rasa/model_manager/config.py +0 -40
  192. rasa/model_manager/model_api.py +0 -559
  193. rasa/model_manager/runner_service.py +0 -286
  194. rasa/model_manager/socket_bridge.py +0 -146
  195. rasa/model_manager/studio_jwt_auth.py +0 -86
  196. rasa/model_manager/trainer_service.py +0 -325
  197. rasa/model_manager/utils.py +0 -87
  198. rasa/model_manager/warm_rasa_process.py +0 -187
  199. rasa/model_service.py +0 -112
  200. rasa/shared/core/flows/utils.py +0 -39
  201. rasa/shared/providers/_configs/litellm_router_client_config.py +0 -220
  202. rasa/shared/providers/_configs/model_group_config.py +0 -167
  203. rasa/shared/providers/_configs/rasa_llm_client_config.py +0 -73
  204. rasa/shared/providers/_utils.py +0 -79
  205. rasa/shared/providers/embedding/litellm_router_embedding_client.py +0 -135
  206. rasa/shared/providers/llm/litellm_router_llm_client.py +0 -182
  207. rasa/shared/providers/llm/rasa_llm_client.py +0 -112
  208. rasa/shared/providers/router/__init__.py +0 -0
  209. rasa/shared/providers/router/_base_litellm_router_client.py +0 -183
  210. rasa/shared/providers/router/router_client.py +0 -73
  211. rasa/shared/utils/health_check/__init__.py +0 -0
  212. rasa/shared/utils/health_check/embeddings_health_check_mixin.py +0 -31
  213. rasa/shared/utils/health_check/health_check.py +0 -258
  214. rasa/shared/utils/health_check/llm_health_check_mixin.py +0 -31
  215. rasa/utils/sanic_error_handler.py +0 -32
  216. rasa/utils/tensorflow/feature_array.py +0 -366
  217. rasa_pro-3.11.0.dist-info/METADATA +0 -198
  218. {rasa_pro-3.11.0.dist-info → rasa_pro-3.11.0a1.dist-info}/NOTICE +0 -0
  219. {rasa_pro-3.11.0.dist-info → rasa_pro-3.11.0a1.dist-info}/WHEEL +0 -0
  220. {rasa_pro-3.11.0.dist-info → rasa_pro-3.11.0a1.dist-info}/entry_points.txt +0 -0
@@ -1,15 +1,15 @@
1
1
  from __future__ import annotations
2
-
3
2
  import logging
3
+
4
+ from rasa.engine.recipes.default_recipe import DefaultV1Recipe
4
5
  from pathlib import Path
5
6
  from collections import defaultdict
6
7
  import contextlib
7
- from typing import Any, List, Optional, Text, Dict, Tuple, Union, Type
8
8
 
9
9
  import numpy as np
10
10
  import tensorflow as tf
11
+ from typing import Any, List, Optional, Text, Dict, Tuple, Union, Type
11
12
 
12
- from rasa.engine.recipes.default_recipe import DefaultV1Recipe
13
13
  from rasa.engine.graph import ExecutionContext
14
14
  from rasa.engine.storage.resource import Resource
15
15
  from rasa.engine.storage.storage import ModelStorage
@@ -49,22 +49,18 @@ from rasa.shared.core.generator import TrackerWithCachedStates
49
49
  from rasa.shared.core.events import EntitiesAdded, Event
50
50
  from rasa.shared.core.domain import Domain
51
51
  from rasa.shared.nlu.training_data.message import Message
52
- from rasa.shared.nlu.training_data.features import (
53
- Features,
54
- save_features,
55
- load_features,
56
- )
52
+ from rasa.shared.nlu.training_data.features import Features
57
53
  import rasa.shared.utils.io
58
54
  import rasa.utils.io
59
55
  from rasa.utils import train_utils
60
- from rasa.utils.tensorflow.feature_array import (
61
- FeatureArray,
62
- serialize_nested_feature_arrays,
63
- deserialize_nested_feature_arrays,
64
- )
65
56
  from rasa.utils.tensorflow.models import RasaModel, TransformerRasaModel
66
57
  from rasa.utils.tensorflow import rasa_layers
67
- from rasa.utils.tensorflow.model_data import RasaModelData, FeatureSignature, Data
58
+ from rasa.utils.tensorflow.model_data import (
59
+ RasaModelData,
60
+ FeatureSignature,
61
+ FeatureArray,
62
+ Data,
63
+ )
68
64
  from rasa.utils.tensorflow.model_data_utils import convert_to_data_format
69
65
  from rasa.utils.tensorflow.constants import (
70
66
  LABEL,
@@ -965,32 +961,22 @@ class TEDPolicy(Policy):
965
961
  model_path: Path where model is to be persisted
966
962
  """
967
963
  model_filename = self._metadata_filename()
968
- rasa.shared.utils.io.dump_obj_as_json_to_file(
969
- model_path / f"{model_filename}.priority.json", self.priority
970
- )
971
- rasa.shared.utils.io.dump_obj_as_json_to_file(
972
- model_path / f"{model_filename}.meta.json", self.config
964
+ rasa.utils.io.json_pickle(
965
+ model_path / f"{model_filename}.priority.pkl", self.priority
973
966
  )
974
- # save data example
975
- serialize_nested_feature_arrays(
976
- self.data_example,
977
- str(model_path / f"{model_filename}.data_example.st"),
978
- str(model_path / f"{model_filename}.data_example_metadata.json"),
967
+ rasa.utils.io.pickle_dump(
968
+ model_path / f"{model_filename}.meta.pkl", self.config
979
969
  )
980
- # save label data
981
- serialize_nested_feature_arrays(
982
- dict(self._label_data.data) if self._label_data is not None else {},
983
- str(model_path / f"{model_filename}.label_data.st"),
984
- str(model_path / f"{model_filename}.label_data_metadata.json"),
970
+ rasa.utils.io.pickle_dump(
971
+ model_path / f"{model_filename}.data_example.pkl", self.data_example
985
972
  )
986
- # save fake features
987
- metadata = save_features(
988
- self.fake_features, str(model_path / f"{model_filename}.fake_features.st")
973
+ rasa.utils.io.pickle_dump(
974
+ model_path / f"{model_filename}.fake_features.pkl", self.fake_features
989
975
  )
990
- rasa.shared.utils.io.dump_obj_as_json_to_file(
991
- model_path / f"{model_filename}.fake_features_metadata.json", metadata
976
+ rasa.utils.io.pickle_dump(
977
+ model_path / f"{model_filename}.label_data.pkl",
978
+ dict(self._label_data.data) if self._label_data is not None else {},
992
979
  )
993
-
994
980
  entity_tag_specs = (
995
981
  [tag_spec._asdict() for tag_spec in self._entity_tag_specs]
996
982
  if self._entity_tag_specs
@@ -1008,29 +994,18 @@ class TEDPolicy(Policy):
1008
994
  model_path: Path where model is to be persisted.
1009
995
  """
1010
996
  tf_model_file = model_path / f"{cls._metadata_filename()}.tf_model"
1011
-
1012
- # load data example
1013
- loaded_data = deserialize_nested_feature_arrays(
1014
- str(model_path / f"{cls._metadata_filename()}.data_example.st"),
1015
- str(model_path / f"{cls._metadata_filename()}.data_example_metadata.json"),
997
+ loaded_data = rasa.utils.io.pickle_load(
998
+ model_path / f"{cls._metadata_filename()}.data_example.pkl"
1016
999
  )
1017
- # load label data
1018
- loaded_label_data = deserialize_nested_feature_arrays(
1019
- str(model_path / f"{cls._metadata_filename()}.label_data.st"),
1020
- str(model_path / f"{cls._metadata_filename()}.label_data_metadata.json"),
1000
+ label_data = rasa.utils.io.pickle_load(
1001
+ model_path / f"{cls._metadata_filename()}.label_data.pkl"
1021
1002
  )
1022
- label_data = RasaModelData(data=loaded_label_data)
1023
-
1024
- # load fake features
1025
- metadata = rasa.shared.utils.io.read_json_file(
1026
- model_path / f"{cls._metadata_filename()}.fake_features_metadata.json"
1003
+ fake_features = rasa.utils.io.pickle_load(
1004
+ model_path / f"{cls._metadata_filename()}.fake_features.pkl"
1027
1005
  )
1028
- fake_features = load_features(
1029
- str(model_path / f"{cls._metadata_filename()}.fake_features.st"), metadata
1030
- )
1031
-
1032
- priority = rasa.shared.utils.io.read_json_file(
1033
- model_path / f"{cls._metadata_filename()}.priority.json"
1006
+ label_data = RasaModelData(data=label_data)
1007
+ priority = rasa.utils.io.json_unpickle(
1008
+ model_path / f"{cls._metadata_filename()}.priority.pkl"
1034
1009
  )
1035
1010
  entity_tag_specs = rasa.shared.utils.io.read_json_file(
1036
1011
  model_path / f"{cls._metadata_filename()}.entity_tag_specs.json"
@@ -1048,8 +1023,8 @@ class TEDPolicy(Policy):
1048
1023
  )
1049
1024
  for tag_spec in entity_tag_specs
1050
1025
  ]
1051
- model_config = rasa.shared.utils.io.read_json_file(
1052
- model_path / f"{cls._metadata_filename()}.meta.json"
1026
+ model_config = rasa.utils.io.pickle_load(
1027
+ model_path / f"{cls._metadata_filename()}.meta.pkl"
1053
1028
  )
1054
1029
 
1055
1030
  return {
@@ -1095,7 +1070,7 @@ class TEDPolicy(Policy):
1095
1070
  ) -> TEDPolicy:
1096
1071
  featurizer = TrackerFeaturizer.load(model_path)
1097
1072
 
1098
- if not (model_path / f"{cls._metadata_filename()}.data_example.st").is_file():
1073
+ if not (model_path / f"{cls._metadata_filename()}.data_example.pkl").is_file():
1099
1074
  return cls(
1100
1075
  config,
1101
1076
  model_storage,
@@ -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
 
@@ -881,12 +881,9 @@ class UnexpecTEDIntentPolicy(TEDPolicy):
881
881
  model_path: Path where model is to be persisted
882
882
  """
883
883
  super().persist_model_utilities(model_path)
884
-
885
- from safetensors.numpy import save_file
886
-
887
- save_file(
888
- {str(k): np.array(v) for k, v in self.label_quantiles.items()},
889
- 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,
890
887
  )
891
888
 
892
889
  @classmethod
@@ -897,14 +894,9 @@ class UnexpecTEDIntentPolicy(TEDPolicy):
897
894
  model_path: Path where model is to be persisted.
898
895
  """
899
896
  model_utilties = super()._load_model_utilities(model_path)
900
-
901
- from safetensors.numpy import load_file
902
-
903
- loaded_label_quantiles = load_file(
904
- 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"
905
899
  )
906
- label_quantiles = {int(k): list(v) for k, v in loaded_label_quantiles.items()}
907
-
908
900
  model_utilties.update({"label_quantiles": label_quantiles})
909
901
  return model_utilties
910
902
 
rasa/core/processor.py CHANGED
@@ -46,15 +46,12 @@ from rasa.engine.runner.interface import GraphRunner
46
46
  from rasa.exceptions import ActionLimitReached, ModelNotFound
47
47
  from rasa.shared.core.constants import (
48
48
  ACTION_CORRECT_FLOW_SLOT,
49
- SLOT_CONSECUTIVE_SILENCE_TIMEOUTS,
50
- SLOT_SILENCE_TIMEOUT,
51
49
  USER_INTENT_RESTART,
52
50
  ACTION_LISTEN_NAME,
53
51
  ACTION_SESSION_START_NAME,
54
52
  FOLLOWUP_ACTION,
55
53
  SESSION_START_METADATA_SLOT,
56
54
  ACTION_EXTRACT_SLOTS,
57
- USER_INTENT_SILENCE_TIMEOUT,
58
55
  )
59
56
  from rasa.shared.core.events import (
60
57
  ActionExecutionRejected,
@@ -104,9 +101,6 @@ logger = logging.getLogger(__name__)
104
101
  structlogger = structlog.get_logger()
105
102
 
106
103
  MAX_NUMBER_OF_PREDICTIONS = int(os.environ.get("MAX_NUMBER_OF_PREDICTIONS", "10"))
107
- MAX_NUMBER_OF_PREDICTIONS_CALM = int(
108
- os.environ.get("MAX_NUMBER_OF_PREDICTIONS_CALM", "1000")
109
- )
110
104
 
111
105
 
112
106
  class MessageProcessor:
@@ -120,7 +114,6 @@ class MessageProcessor:
120
114
  generator: NaturalLanguageGenerator,
121
115
  action_endpoint: Optional[EndpointConfig] = None,
122
116
  max_number_of_predictions: int = MAX_NUMBER_OF_PREDICTIONS,
123
- max_number_of_predictions_calm: int = MAX_NUMBER_OF_PREDICTIONS_CALM,
124
117
  on_circuit_break: Optional[LambdaType] = None,
125
118
  http_interpreter: Optional[RasaNLUHttpInterpreter] = None,
126
119
  endpoints: Optional["AvailableEndpoints"] = None,
@@ -129,6 +122,7 @@ class MessageProcessor:
129
122
  self.nlg = generator
130
123
  self.tracker_store = tracker_store
131
124
  self.lock_store = lock_store
125
+ self.max_number_of_predictions = max_number_of_predictions
132
126
  self.on_circuit_break = on_circuit_break
133
127
  self.action_endpoint = action_endpoint
134
128
  self.model_filename, self.model_metadata, self.graph_runner = self._load_model(
@@ -136,10 +130,6 @@ class MessageProcessor:
136
130
  )
137
131
  self.endpoints = endpoints
138
132
 
139
- self.max_number_of_predictions = max_number_of_predictions
140
- self.max_number_of_predictions_calm = max_number_of_predictions_calm
141
- self.is_calm_assistant = self._is_calm_assistant()
142
-
143
133
  if self.model_metadata.assistant_id is None:
144
134
  rasa.shared.utils.io.raise_warning(
145
135
  f"The model metadata does not contain a value for the "
@@ -792,28 +782,6 @@ class MessageProcessor:
792
782
  )
793
783
 
794
784
  self._check_for_unseen_features(parse_data)
795
- # resetting timeouts variables whenever something that is not a timeout occurs
796
- if (
797
- parse_data.get(INTENT, {}).get(INTENT_NAME_KEY)
798
- != USER_INTENT_SILENCE_TIMEOUT
799
- and tracker
800
- ):
801
- if (
802
- SLOT_CONSECUTIVE_SILENCE_TIMEOUTS in tracker.slots
803
- and tracker.slots[SLOT_CONSECUTIVE_SILENCE_TIMEOUTS].value != 0.0
804
- ):
805
- tracker.update(SlotSet(SLOT_CONSECUTIVE_SILENCE_TIMEOUTS, 0.0))
806
- if (
807
- SLOT_SILENCE_TIMEOUT in tracker.slots
808
- and tracker.slots[SLOT_SILENCE_TIMEOUT].value
809
- != tracker.slots[SLOT_SILENCE_TIMEOUT].initial_value
810
- ):
811
- tracker.update(
812
- SlotSet(
813
- SLOT_SILENCE_TIMEOUT,
814
- tracker.slots[SLOT_SILENCE_TIMEOUT].initial_value,
815
- )
816
- )
817
785
 
818
786
  return parse_data
819
787
 
@@ -1004,15 +972,11 @@ class MessageProcessor:
1004
972
  ) -> int:
1005
973
  """Select the action limit based on the tracker state.
1006
974
 
1007
- This function determines the maximum number of predictions that should be
1008
- made during a dialogue conversation. Typically, the number of predictions
1009
- is limited to the number of actions executed so far in the conversation.
1010
- However, in certain states (e.g., when the user is correcting the
1011
- conversation flow), more predictions may be allowed as the system traverses
1012
- through a long dialogue flow.
1013
-
1014
- Additionally, if the `ROUTE_TO_CALM_SLOT` is present in the tracker slots,
1015
- the action limit is adjusted to a separate limit for CALM-based flows.
975
+ Usually, we want to limit the number of predictions to the number of actions
976
+ that have been executed in the conversation so far. However, if the
977
+ conversation is currently in a state where the user is correcting the flow
978
+ we want to allow for more predictions to be made as we might be traversing
979
+ through a long flow.
1016
980
 
1017
981
  Args:
1018
982
  tracker: instance of DialogueStateTracker.
@@ -1020,18 +984,6 @@ class MessageProcessor:
1020
984
  Returns:
1021
985
  The maximum number of predictions to make.
1022
986
  """
1023
- # Check if it is a CALM assistant and if so, that the `ROUTE_TO_CALM_SLOT`
1024
- # is either not present or set to `True`.
1025
- # If it does, use the specific prediction limit for CALM assistants.
1026
- # Otherwise, use the default prediction limit.
1027
- if self.is_calm_assistant and (
1028
- not tracker.has_coexistence_routing_slot
1029
- or tracker.get_slot(ROUTE_TO_CALM_SLOT)
1030
- ):
1031
- max_number_of_predictions = self.max_number_of_predictions_calm
1032
- else:
1033
- max_number_of_predictions = self.max_number_of_predictions
1034
-
1035
987
  reversed_events = list(tracker.events)[::-1]
1036
988
  is_conversation_in_flow_correction = False
1037
989
  for e in reversed_events:
@@ -1046,10 +998,8 @@ class MessageProcessor:
1046
998
  # allow for more predictions to be made as we might be traversing through
1047
999
  # a long flow. We multiply the number of predictions by 10 to allow for
1048
1000
  # more predictions to be made - the factor is a best guess.
1049
- return max_number_of_predictions * 5
1050
-
1051
- # Return the default
1052
- return max_number_of_predictions
1001
+ return self.max_number_of_predictions * 5
1002
+ return self.max_number_of_predictions
1053
1003
 
1054
1004
  def is_action_limit_reached(
1055
1005
  self, tracker: DialogueStateTracker, should_predict_another_action: bool
@@ -1279,13 +1229,11 @@ class MessageProcessor:
1279
1229
  tracker.update(events[0])
1280
1230
  return self.should_predict_another_action(action.name())
1281
1231
  except Exception:
1282
- structlogger.exception(
1283
- "rasa.core.processor.run_action.exception",
1284
- event_info=f"Encountered an exception while "
1285
- f"running action '{action.name()}'."
1286
- f"Bot will continue, but the actions events are lost. "
1287
- f"Please check the logs of your action server for "
1288
- f"more information.",
1232
+ logger.exception(
1233
+ f"Encountered an exception while running action '{action.name()}'."
1234
+ "Bot will continue, but the actions events are lost. "
1235
+ "Please check the logs of your action server for "
1236
+ "more information."
1289
1237
  )
1290
1238
  events = []
1291
1239
 
@@ -1439,27 +1387,3 @@ class MessageProcessor:
1439
1387
  ]
1440
1388
 
1441
1389
  return len(filtered_commands) > 0
1442
-
1443
- def _is_calm_assistant(self) -> bool:
1444
- """Inspects the nodes of the graph schema to determine whether
1445
- any node is associated with the `FlowPolicy`, which is indicative of a
1446
- CALM assistant setup.
1447
-
1448
- Returns:
1449
- bool: True if any node in the graph schema uses `FlowPolicy`.
1450
- """
1451
- # Get the graph schema's nodes from the graph runner.
1452
- nodes: dict[str, Any] = self.graph_runner._graph_schema.nodes # type: ignore[attr-defined]
1453
-
1454
- flow_policy_class_path = "rasa.core.policies.flow_policy.FlowPolicy"
1455
- # Iterate over the nodes and check if any node uses `FlowPolicy`.
1456
- for node_name, schema_node in nodes.items():
1457
- if (
1458
- schema_node.uses is not None
1459
- and f"{schema_node.uses.__module__}.{schema_node.uses.__name__}"
1460
- == flow_policy_class_path
1461
- ):
1462
- return True
1463
-
1464
- # Return False if no node is found using `FlowPolicy`.
1465
- return False
rasa/core/run.py CHANGED
@@ -51,6 +51,7 @@ def create_http_input_channels(
51
51
  all_credentials = read_config_file(credentials_file)
52
52
  else:
53
53
  all_credentials = {}
54
+
54
55
  if channel:
55
56
  if len(all_credentials) > 1:
56
57
  logger.info(
@@ -225,7 +226,6 @@ def serve_application(
225
226
  request_timeout: Optional[int] = None,
226
227
  server_listeners: Optional[List[Tuple[Callable, Text]]] = None,
227
228
  inspect: Optional[bool] = False,
228
- voice: Optional[bool] = False,
229
229
  ) -> None:
230
230
  """Run the API entrypoint."""
231
231
  if not channel and not credentials:
@@ -235,7 +235,7 @@ def serve_application(
235
235
 
236
236
  if inspect:
237
237
  logger.info("Starting development inspector.")
238
- input_channels = [DevelopmentInspectProxy(ic, voice) for ic in input_channels]
238
+ input_channels = [DevelopmentInspectProxy(ic) for ic in input_channels]
239
239
 
240
240
  # the inspector needs the api to retrieve slots and flows
241
241
  enable_api = True
@@ -20,41 +20,25 @@ from typing import (
20
20
  cast,
21
21
  )
22
22
 
23
- import numpy as np
24
- import questionary
25
- import terminaltables.width_and_alignment
26
- from aiohttp import ClientError
27
- from colorclass import Color
28
- from questionary import Choice, Form, Question
29
23
  from sanic import Sanic, response
30
24
  from sanic.exceptions import NotFound
31
25
  from sanic.request import Request
32
26
  from sanic.response import HTTPResponse
33
27
  from terminaltables import AsciiTable, SingleTable
28
+ import terminaltables.width_and_alignment
29
+ import numpy as np
30
+ from aiohttp import ClientError
31
+ from colorclass import Color
32
+ import questionary
33
+ from questionary import Choice, Form, Question
34
34
 
35
- import rasa.cli.utils
36
- import rasa.core.train
37
- import rasa.shared.core.events
38
- import rasa.shared.data
35
+ from rasa import telemetry
39
36
  import rasa.shared.utils.cli
40
37
  import rasa.shared.utils.io
41
-
42
- # WARNING: This command line UI is using an external library
43
- # communicating with the shell - these functions are hard to test
44
- # automatically. If you change anything in here, please make sure to
45
- # run the interactive learning and check if your part of the "ui"
46
- # still works.
47
- import rasa.utils.io as io_utils
48
- from rasa import telemetry
49
- from rasa.core import run, utils
50
- from rasa.core.constants import DEFAULT_SERVER_FORMAT, DEFAULT_SERVER_PORT
51
- from rasa.core.utils import AvailableEndpoints
52
- from rasa.shared.constants import (
53
- INTENT_MESSAGE_PREFIX,
54
- DEFAULT_SENDER_ID,
55
- UTTER_PREFIX,
56
- DOCS_URL_NLU_BASED_POLICIES,
57
- )
38
+ import rasa.cli.utils
39
+ import rasa.shared.data
40
+ from rasa.shared.nlu.constants import TEXT, INTENT_NAME_KEY
41
+ from rasa.shared.nlu.training_data.loading import RASA, RASA_YAML
58
42
  from rasa.shared.core.constants import (
59
43
  USER_INTENT_RESTART,
60
44
  ACTION_LISTEN_NAME,
@@ -65,6 +49,9 @@ from rasa.shared.core.constants import (
65
49
  LOOP_INTERRUPTED,
66
50
  ACTION_UNLIKELY_INTENT_NAME,
67
51
  )
52
+ from rasa.core import run, utils
53
+ import rasa.core.train
54
+ from rasa.core.constants import DEFAULT_SERVER_FORMAT, DEFAULT_SERVER_PORT
68
55
  from rasa.shared.core.domain import (
69
56
  Domain,
70
57
  KEY_INTENTS,
@@ -73,6 +60,7 @@ from rasa.shared.core.domain import (
73
60
  KEY_ACTIONS,
74
61
  KEY_RESPONSES_TEXT,
75
62
  )
63
+ import rasa.shared.core.events
76
64
  from rasa.shared.core.events import (
77
65
  ActionExecuted,
78
66
  ActionReverted,
@@ -82,23 +70,36 @@ from rasa.shared.core.events import (
82
70
  UserUttered,
83
71
  UserUtteranceReverted,
84
72
  )
85
- from rasa.shared.core.generator import TrackerWithCachedStates
73
+ from rasa.shared.constants import (
74
+ INTENT_MESSAGE_PREFIX,
75
+ DEFAULT_SENDER_ID,
76
+ UTTER_PREFIX,
77
+ DOCS_URL_NLU_BASED_POLICIES,
78
+ )
86
79
  from rasa.shared.core.trackers import EventVerbosity, DialogueStateTracker
87
80
  from rasa.shared.core.training_data import visualization
88
81
  from rasa.shared.core.training_data.visualization import (
89
82
  VISUALIZATION_TEMPLATE_PATH,
90
83
  visualize_neighborhood,
91
84
  )
92
- from rasa.shared.exceptions import InvalidConfigException
85
+ from rasa.core.utils import AvailableEndpoints
93
86
  from rasa.shared.importers.rasa import TrainingDataImporter
94
- from rasa.shared.nlu.constants import TEXT, INTENT_NAME_KEY
87
+ from rasa.utils.common import update_sanic_log_level
88
+ from rasa.utils.endpoints import EndpointConfig
89
+ from rasa.shared.exceptions import InvalidConfigException
95
90
 
96
91
  # noinspection PyProtectedMember
97
92
  from rasa.shared.nlu.training_data import loading
98
- from rasa.shared.nlu.training_data.loading import RASA, RASA_YAML
99
93
  from rasa.shared.nlu.training_data.message import Message
100
- from rasa.utils.common import update_sanic_log_level
101
- from rasa.utils.endpoints import EndpointConfig
94
+
95
+ # WARNING: This command line UI is using an external library
96
+ # communicating with the shell - these functions are hard to test
97
+ # automatically. If you change anything in here, please make sure to
98
+ # run the interactive learning and check if your part of the "ui"
99
+ # still works.
100
+ import rasa.utils.io as io_utils
101
+
102
+ from rasa.shared.core.generator import TrackerWithCachedStates
102
103
 
103
104
  logger = logging.getLogger(__name__)
104
105
 
@@ -1687,7 +1688,7 @@ def run_interactive_learning(
1687
1688
  p = None
1688
1689
 
1689
1690
  app = run.configure_app(port=port, conversation_id="default", enable_api=True)
1690
- endpoints = AvailableEndpoints.get_instance(server_args.get("endpoints"))
1691
+ endpoints = AvailableEndpoints.read_endpoints(server_args.get("endpoints"))
1691
1692
 
1692
1693
  # before_server_start handlers make sure the agent is loaded before the
1693
1694
  # interactive learning IO starts