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.

Files changed (217) 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 +5 -7
  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/channel.py +0 -20
  31. rasa/core/channels/development_inspector.py +2 -8
  32. rasa/core/channels/inspector/dist/assets/{arc-bc141fb2.js → arc-6852c607.js} +1 -1
  33. rasa/core/channels/inspector/dist/assets/{c4Diagram-d0fbc5ce-be2db283.js → c4Diagram-d0fbc5ce-acc952b2.js} +1 -1
  34. rasa/core/channels/inspector/dist/assets/{classDiagram-936ed81e-55366915.js → classDiagram-936ed81e-848a7597.js} +1 -1
  35. rasa/core/channels/inspector/dist/assets/{classDiagram-v2-c3cb15f1-bb529518.js → classDiagram-v2-c3cb15f1-a73d3e68.js} +1 -1
  36. rasa/core/channels/inspector/dist/assets/{createText-62fc7601-b0ec81d6.js → createText-62fc7601-e5ee049d.js} +1 -1
  37. rasa/core/channels/inspector/dist/assets/{edges-f2ad444c-6166330c.js → edges-f2ad444c-771e517e.js} +1 -1
  38. rasa/core/channels/inspector/dist/assets/{erDiagram-9d236eb7-5ccc6a8e.js → erDiagram-9d236eb7-aa347178.js} +1 -1
  39. rasa/core/channels/inspector/dist/assets/{flowDb-1972c806-fca3bfe4.js → flowDb-1972c806-651fc57d.js} +1 -1
  40. rasa/core/channels/inspector/dist/assets/{flowDiagram-7ea5b25a-4739080f.js → flowDiagram-7ea5b25a-ca67804f.js} +1 -1
  41. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-855bc5b3-587d82d8.js +1 -0
  42. rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-abe16c3d-7c1b0e0f.js → flowchart-elk-definition-abe16c3d-2dbc568d.js} +1 -1
  43. rasa/core/channels/inspector/dist/assets/{ganttDiagram-9b5ea136-772fd050.js → ganttDiagram-9b5ea136-25a65bd8.js} +1 -1
  44. rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-99d0ae7c-8eae1dc9.js → gitGraphDiagram-99d0ae7c-fdc7378d.js} +1 -1
  45. rasa/core/channels/inspector/dist/assets/{index-2c4b9a3b-f55afcdf.js → index-2c4b9a3b-6f1fd606.js} +1 -1
  46. rasa/core/channels/inspector/dist/assets/{index-e7cef9de.js → index-efdd30c1.js} +68 -68
  47. rasa/core/channels/inspector/dist/assets/{infoDiagram-736b4530-124d4a14.js → infoDiagram-736b4530-cb1a041a.js} +1 -1
  48. rasa/core/channels/inspector/dist/assets/{journeyDiagram-df861f2b-7c4fae44.js → journeyDiagram-df861f2b-14609879.js} +1 -1
  49. rasa/core/channels/inspector/dist/assets/{layout-b9885fb6.js → layout-2490f52b.js} +1 -1
  50. rasa/core/channels/inspector/dist/assets/{line-7c59abb6.js → line-40186f1f.js} +1 -1
  51. rasa/core/channels/inspector/dist/assets/{linear-4776f780.js → linear-08814e93.js} +1 -1
  52. rasa/core/channels/inspector/dist/assets/{mindmap-definition-beec6740-2332c46c.js → mindmap-definition-beec6740-1a534584.js} +1 -1
  53. rasa/core/channels/inspector/dist/assets/{pieDiagram-dbbf0591-8fb39303.js → pieDiagram-dbbf0591-72397b61.js} +1 -1
  54. rasa/core/channels/inspector/dist/assets/{quadrantDiagram-4d7f4fd6-3c7180a2.js → quadrantDiagram-4d7f4fd6-3bb0b6a3.js} +1 -1
  55. rasa/core/channels/inspector/dist/assets/{requirementDiagram-6fc4c22a-e910bcb8.js → requirementDiagram-6fc4c22a-57334f61.js} +1 -1
  56. rasa/core/channels/inspector/dist/assets/{sankeyDiagram-8f13d901-ead16c89.js → sankeyDiagram-8f13d901-111e1297.js} +1 -1
  57. rasa/core/channels/inspector/dist/assets/{sequenceDiagram-b655622a-29a02a19.js → sequenceDiagram-b655622a-10bcfe62.js} +1 -1
  58. rasa/core/channels/inspector/dist/assets/{stateDiagram-59f0c015-042b3137.js → stateDiagram-59f0c015-acaf7513.js} +1 -1
  59. rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-2b26beab-2178c0f3.js → stateDiagram-v2-2b26beab-3ec2a235.js} +1 -1
  60. rasa/core/channels/inspector/dist/assets/{styles-080da4f6-23ffa4fc.js → styles-080da4f6-62730289.js} +1 -1
  61. rasa/core/channels/inspector/dist/assets/{styles-3dcbcfbf-94f59763.js → styles-3dcbcfbf-5284ee76.js} +1 -1
  62. rasa/core/channels/inspector/dist/assets/{styles-9c745c82-78a6bebc.js → styles-9c745c82-642435e3.js} +1 -1
  63. rasa/core/channels/inspector/dist/assets/{svgDrawCommon-4835440b-eae2a6f6.js → svgDrawCommon-4835440b-b250a350.js} +1 -1
  64. rasa/core/channels/inspector/dist/assets/{timeline-definition-5b62e21b-5c968d92.js → timeline-definition-5b62e21b-c2b147ed.js} +1 -1
  65. rasa/core/channels/inspector/dist/assets/{xychartDiagram-2b33534f-fd3db0d5.js → xychartDiagram-2b33534f-f92cfea9.js} +1 -1
  66. rasa/core/channels/inspector/dist/index.html +1 -1
  67. rasa/core/channels/inspector/src/App.tsx +1 -1
  68. rasa/core/channels/inspector/src/helpers/audiostream.ts +16 -77
  69. rasa/core/channels/socketio.py +2 -7
  70. rasa/core/channels/telegram.py +1 -1
  71. rasa/core/channels/twilio.py +1 -1
  72. rasa/core/channels/voice_ready/audiocodes.py +4 -15
  73. rasa/core/channels/voice_ready/jambonz.py +4 -15
  74. rasa/core/channels/voice_ready/twilio_voice.py +21 -6
  75. rasa/core/channels/voice_ready/utils.py +5 -6
  76. rasa/core/channels/voice_stream/asr/asr_engine.py +1 -19
  77. rasa/core/channels/voice_stream/asr/asr_event.py +0 -5
  78. rasa/core/channels/voice_stream/asr/deepgram.py +15 -28
  79. rasa/core/channels/voice_stream/audio_bytes.py +0 -1
  80. rasa/core/channels/voice_stream/browser_audio.py +9 -32
  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 +5 -32
  98. rasa/core/training/interactive.py +35 -34
  99. rasa/core/utils.py +22 -58
  100. rasa/dialogue_understanding/coexistence/llm_based_router.py +12 -39
  101. rasa/dialogue_understanding/commands/__init__.py +0 -4
  102. rasa/dialogue_understanding/commands/change_flow_command.py +0 -6
  103. rasa/dialogue_understanding/commands/utils.py +0 -5
  104. rasa/dialogue_understanding/generator/constants.py +0 -2
  105. rasa/dialogue_understanding/generator/flow_retrieval.py +4 -49
  106. rasa/dialogue_understanding/generator/llm_based_command_generator.py +23 -37
  107. rasa/dialogue_understanding/generator/multi_step/multi_step_llm_command_generator.py +10 -57
  108. rasa/dialogue_understanding/generator/nlu_command_adapter.py +1 -19
  109. rasa/dialogue_understanding/generator/single_step/command_prompt_template.jinja2 +0 -3
  110. rasa/dialogue_understanding/generator/single_step/single_step_llm_command_generator.py +10 -90
  111. rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +0 -53
  112. rasa/dialogue_understanding/processor/command_processor.py +1 -21
  113. rasa/e2e_test/assertions.py +16 -133
  114. rasa/e2e_test/assertions_schema.yml +0 -23
  115. rasa/e2e_test/e2e_test_case.py +6 -85
  116. rasa/e2e_test/e2e_test_runner.py +4 -6
  117. rasa/e2e_test/utils/io.py +1 -3
  118. rasa/engine/loader.py +0 -12
  119. rasa/engine/validation.py +11 -541
  120. rasa/keys +1 -0
  121. rasa/llm_fine_tuning/notebooks/unsloth_finetuning.ipynb +407 -0
  122. rasa/model_training.py +7 -29
  123. rasa/nlu/classifiers/diet_classifier.py +25 -38
  124. rasa/nlu/classifiers/logistic_regression_classifier.py +9 -22
  125. rasa/nlu/classifiers/sklearn_intent_classifier.py +16 -37
  126. rasa/nlu/extractors/crf_entity_extractor.py +50 -93
  127. rasa/nlu/featurizers/sparse_featurizer/count_vectors_featurizer.py +16 -45
  128. rasa/nlu/featurizers/sparse_featurizer/lexical_syntactic_featurizer.py +17 -52
  129. rasa/nlu/featurizers/sparse_featurizer/regex_featurizer.py +3 -5
  130. rasa/nlu/tokenizers/whitespace_tokenizer.py +14 -3
  131. rasa/server.py +1 -3
  132. rasa/shared/constants.py +0 -61
  133. rasa/shared/core/constants.py +0 -9
  134. rasa/shared/core/domain.py +5 -8
  135. rasa/shared/core/flows/flow.py +0 -5
  136. rasa/shared/core/flows/flows_list.py +1 -5
  137. rasa/shared/core/flows/flows_yaml_schema.json +0 -10
  138. rasa/shared/core/flows/validation.py +0 -96
  139. rasa/shared/core/flows/yaml_flows_io.py +4 -13
  140. rasa/shared/core/slots.py +0 -5
  141. rasa/shared/importers/importer.py +2 -19
  142. rasa/shared/importers/rasa.py +1 -5
  143. rasa/shared/nlu/training_data/features.py +2 -120
  144. rasa/shared/nlu/training_data/formats/rasa_yaml.py +3 -18
  145. rasa/shared/providers/_configs/azure_openai_client_config.py +3 -5
  146. rasa/shared/providers/_configs/openai_client_config.py +1 -1
  147. rasa/shared/providers/_configs/self_hosted_llm_client_config.py +0 -1
  148. rasa/shared/providers/_configs/utils.py +0 -16
  149. rasa/shared/providers/embedding/_base_litellm_embedding_client.py +29 -18
  150. rasa/shared/providers/embedding/azure_openai_embedding_client.py +21 -54
  151. rasa/shared/providers/embedding/default_litellm_embedding_client.py +0 -24
  152. rasa/shared/providers/llm/_base_litellm_client.py +31 -63
  153. rasa/shared/providers/llm/azure_openai_llm_client.py +29 -50
  154. rasa/shared/providers/llm/default_litellm_llm_client.py +0 -24
  155. rasa/shared/providers/llm/self_hosted_llm_client.py +29 -17
  156. rasa/shared/providers/mappings.py +0 -19
  157. rasa/shared/utils/common.py +2 -37
  158. rasa/shared/utils/io.py +6 -28
  159. rasa/shared/utils/llm.py +46 -353
  160. rasa/shared/utils/yaml.py +82 -181
  161. rasa/studio/auth.py +5 -3
  162. rasa/studio/config.py +4 -13
  163. rasa/studio/constants.py +0 -1
  164. rasa/studio/data_handler.py +4 -13
  165. rasa/studio/upload.py +80 -175
  166. rasa/telemetry.py +17 -94
  167. rasa/tracing/config.py +1 -3
  168. rasa/tracing/instrumentation/attribute_extractors.py +17 -94
  169. rasa/tracing/instrumentation/instrumentation.py +0 -121
  170. rasa/utils/common.py +0 -5
  171. rasa/utils/endpoints.py +1 -27
  172. rasa/utils/io.py +81 -7
  173. rasa/utils/log_utils.py +2 -9
  174. rasa/utils/tensorflow/model_data.py +193 -2
  175. rasa/validator.py +4 -110
  176. rasa/version.py +1 -1
  177. rasa_pro-3.11.0a2.dist-info/METADATA +576 -0
  178. {rasa_pro-3.11.0.dist-info → rasa_pro-3.11.0a2.dist-info}/RECORD +181 -213
  179. rasa/core/actions/action_repeat_bot_messages.py +0 -89
  180. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-855bc5b3-736177bf.js +0 -1
  181. rasa/core/channels/voice_stream/asr/azure.py +0 -129
  182. rasa/core/channels/voice_stream/call_state.py +0 -23
  183. rasa/dialogue_understanding/commands/repeat_bot_messages_command.py +0 -60
  184. rasa/dialogue_understanding/commands/user_silence_command.py +0 -59
  185. rasa/dialogue_understanding/patterns/repeat.py +0 -37
  186. rasa/dialogue_understanding/patterns/user_silence.py +0 -37
  187. rasa/model_manager/__init__.py +0 -0
  188. rasa/model_manager/config.py +0 -40
  189. rasa/model_manager/model_api.py +0 -559
  190. rasa/model_manager/runner_service.py +0 -286
  191. rasa/model_manager/socket_bridge.py +0 -146
  192. rasa/model_manager/studio_jwt_auth.py +0 -86
  193. rasa/model_manager/trainer_service.py +0 -325
  194. rasa/model_manager/utils.py +0 -87
  195. rasa/model_manager/warm_rasa_process.py +0 -187
  196. rasa/model_service.py +0 -112
  197. rasa/shared/core/flows/utils.py +0 -39
  198. rasa/shared/providers/_configs/litellm_router_client_config.py +0 -220
  199. rasa/shared/providers/_configs/model_group_config.py +0 -167
  200. rasa/shared/providers/_configs/rasa_llm_client_config.py +0 -73
  201. rasa/shared/providers/_utils.py +0 -79
  202. rasa/shared/providers/embedding/litellm_router_embedding_client.py +0 -135
  203. rasa/shared/providers/llm/litellm_router_llm_client.py +0 -182
  204. rasa/shared/providers/llm/rasa_llm_client.py +0 -112
  205. rasa/shared/providers/router/__init__.py +0 -0
  206. rasa/shared/providers/router/_base_litellm_router_client.py +0 -183
  207. rasa/shared/providers/router/router_client.py +0 -73
  208. rasa/shared/utils/health_check/__init__.py +0 -0
  209. rasa/shared/utils/health_check/embeddings_health_check_mixin.py +0 -31
  210. rasa/shared/utils/health_check/health_check.py +0 -258
  211. rasa/shared/utils/health_check/llm_health_check_mixin.py +0 -31
  212. rasa/utils/sanic_error_handler.py +0 -32
  213. rasa/utils/tensorflow/feature_array.py +0 -366
  214. rasa_pro-3.11.0.dist-info/METADATA +0 -198
  215. {rasa_pro-3.11.0.dist-info → rasa_pro-3.11.0a2.dist-info}/NOTICE +0 -0
  216. {rasa_pro-3.11.0.dist-info → rasa_pro-3.11.0a2.dist-info}/WHEEL +0 -0
  217. {rasa_pro-3.11.0.dist-info → rasa_pro-3.11.0a2.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,
@@ -792,28 +789,6 @@ class MessageProcessor:
792
789
  )
793
790
 
794
791
  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
792
 
818
793
  return parse_data
819
794
 
@@ -1279,13 +1254,11 @@ class MessageProcessor:
1279
1254
  tracker.update(events[0])
1280
1255
  return self.should_predict_another_action(action.name())
1281
1256
  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.",
1257
+ logger.exception(
1258
+ f"Encountered an exception while running action '{action.name()}'."
1259
+ "Bot will continue, but the actions events are lost. "
1260
+ "Please check the logs of your action server for "
1261
+ "more information."
1289
1262
  )
1290
1263
  events = []
1291
1264
 
@@ -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
rasa/core/utils.py CHANGED
@@ -1,9 +1,8 @@
1
- import structlog
2
1
  import logging
3
2
  import os
4
3
  from pathlib import Path
5
4
  from socket import SOCK_DGRAM, SOCK_STREAM
6
- from typing import Any, Dict, Optional, List, Set, TYPE_CHECKING, Text, Tuple, Union
5
+ from typing import Any, Dict, Optional, Set, TYPE_CHECKING, Text, Tuple, Union
7
6
 
8
7
  import numpy as np
9
8
  from sanic import Sanic
@@ -20,18 +19,14 @@ from rasa.core.constants import (
20
19
  from rasa.core.lock_store import LockStore, RedisLockStore, InMemoryLockStore
21
20
  from rasa.shared.constants import DEFAULT_ENDPOINTS_PATH, TCP_PROTOCOL
22
21
  from rasa.shared.core.trackers import DialogueStateTracker
23
- from rasa.utils.endpoints import (
24
- EndpointConfig,
25
- read_endpoint_config,
26
- read_property_config_from_endpoints_file,
27
- )
22
+ from rasa.utils.endpoints import EndpointConfig, read_endpoint_config
28
23
  from rasa.utils.io import write_yaml
29
24
 
30
25
  if TYPE_CHECKING:
31
26
  from rasa.core.nlg import NaturalLanguageGenerator
32
27
  from rasa.shared.core.domain import Domain
33
28
 
34
- structlogger = structlog.get_logger()
29
+ logger = logging.getLogger(__name__)
35
30
 
36
31
 
37
32
  def configure_file_logging(
@@ -129,17 +124,15 @@ def list_routes(app: Sanic) -> Dict[Text, Text]:
129
124
  for arg in route._params:
130
125
  options[arg] = f"[{arg}]"
131
126
 
132
- name = route.name.replace("rasa_server.", "")
133
- methods = ",".join(route.methods)
127
+ handlers = [(next(iter(route.methods)), route.name.replace("rasa_server.", ""))]
134
128
 
135
- full_endpoint = "/" + "/".join(endpoint)
136
- line = unquote(f"{full_endpoint:50s} {methods:30s} {name}")
137
- output[name] = line
129
+ for method, name in handlers:
130
+ full_endpoint = "/" + "/".join(endpoint)
131
+ line = unquote(f"{full_endpoint:50s} {method:30s} {name}")
132
+ output[name] = line
138
133
 
139
134
  url_table = "\n".join(output[url] for url in sorted(output))
140
- structlogger.debug(
141
- "server.routes", event_info=f"Available web server routes: \n{url_table}"
142
- )
135
+ logger.debug(f"Available web server routes: \n{url_table}")
143
136
 
144
137
  return output
145
138
 
@@ -178,8 +171,6 @@ def is_limit_reached(num_messages: int, limit: Optional[int]) -> bool:
178
171
  class AvailableEndpoints:
179
172
  """Collection of configured endpoints."""
180
173
 
181
- _instance = None
182
-
183
174
  @classmethod
184
175
  def read_endpoints(cls, endpoint_file: Text) -> "AvailableEndpoints":
185
176
  """Read the different endpoints from a yaml file."""
@@ -193,9 +184,6 @@ class AvailableEndpoints:
193
184
  lock_store = read_endpoint_config(endpoint_file, endpoint_type="lock_store")
194
185
  event_broker = read_endpoint_config(endpoint_file, endpoint_type="event_broker")
195
186
  vector_store = read_endpoint_config(endpoint_file, endpoint_type="vector_store")
196
- model_groups = read_property_config_from_endpoints_file(
197
- endpoint_file, property_name="model_groups"
198
- )
199
187
 
200
188
  return cls(
201
189
  nlg,
@@ -206,7 +194,6 @@ class AvailableEndpoints:
206
194
  lock_store,
207
195
  event_broker,
208
196
  vector_store,
209
- model_groups,
210
197
  )
211
198
 
212
199
  def __init__(
@@ -219,7 +206,6 @@ class AvailableEndpoints:
219
206
  lock_store: Optional[EndpointConfig] = None,
220
207
  event_broker: Optional[EndpointConfig] = None,
221
208
  vector_store: Optional[EndpointConfig] = None,
222
- model_groups: Optional[List[Dict[str, Any]]] = None,
223
209
  ) -> None:
224
210
  """Create an `AvailableEndpoints` object."""
225
211
  self.model = model
@@ -230,15 +216,6 @@ class AvailableEndpoints:
230
216
  self.lock_store = lock_store
231
217
  self.event_broker = event_broker
232
218
  self.vector_store = vector_store
233
- self.model_groups = model_groups
234
-
235
- @classmethod
236
- def get_instance(cls, endpoint_file: Optional[Text] = None) -> "AvailableEndpoints":
237
- """Get the singleton instance of AvailableEndpoints."""
238
- # Ensure that the instance is initialized only once.
239
- if cls._instance is None:
240
- cls._instance = cls.read_endpoints(endpoint_file)
241
- return cls._instance
242
219
 
243
220
 
244
221
  def read_endpoints_from_path(
@@ -257,7 +234,7 @@ def read_endpoints_from_path(
257
234
  endpoints_config_path = cli_utils.get_validated_path(
258
235
  endpoints_path, "endpoints", DEFAULT_ENDPOINTS_PATH, True
259
236
  )
260
- return AvailableEndpoints.get_instance(endpoints_config_path)
237
+ return AvailableEndpoints.read_endpoints(endpoints_config_path)
261
238
 
262
239
 
263
240
  def _lock_store_is_multi_worker_compatible(
@@ -286,22 +263,17 @@ def number_of_sanic_workers(lock_store: Union[EndpointConfig, LockStore, None])
286
263
  """
287
264
 
288
265
  def _log_and_get_default_number_of_workers() -> int:
289
- structlogger.debug(
290
- "server.worker.set_count",
291
- number_of_workers=DEFAULT_SANIC_WORKERS,
292
- event_info=f"Using the default number of Sanic workers "
293
- f"({DEFAULT_SANIC_WORKERS}).",
266
+ logger.debug(
267
+ f"Using the default number of Sanic workers ({DEFAULT_SANIC_WORKERS})."
294
268
  )
295
269
  return DEFAULT_SANIC_WORKERS
296
270
 
297
271
  try:
298
272
  env_value = int(os.environ.get(ENV_SANIC_WORKERS, DEFAULT_SANIC_WORKERS))
299
273
  except ValueError:
300
- structlogger.error(
301
- "server.worker.set_count.error",
302
- number_of_workers=os.environ[ENV_SANIC_WORKERS],
303
- event_info=f"Cannot convert environment variable `{ENV_SANIC_WORKERS}` "
304
- f"to int ('{os.environ[ENV_SANIC_WORKERS]}').",
274
+ logger.error(
275
+ f"Cannot convert environment variable `{ENV_SANIC_WORKERS}` "
276
+ f"to int ('{os.environ[ENV_SANIC_WORKERS]}')."
305
277
  )
306
278
  return _log_and_get_default_number_of_workers()
307
279
 
@@ -309,28 +281,20 @@ def number_of_sanic_workers(lock_store: Union[EndpointConfig, LockStore, None])
309
281
  return _log_and_get_default_number_of_workers()
310
282
 
311
283
  if env_value < 1:
312
- structlogger.warning(
313
- "server.worker.set_count.error_less_than_one",
314
- number_of_workers=env_value,
315
- event_info=f"Cannot set number of Sanic workers to the desired value "
316
- f"({env_value}). The number of workers must be at least 1.",
284
+ logger.debug(
285
+ f"Cannot set number of Sanic workers to the desired value "
286
+ f"({env_value}). The number of workers must be at least 1."
317
287
  )
318
288
  return _log_and_get_default_number_of_workers()
319
289
 
320
290
  if _lock_store_is_multi_worker_compatible(lock_store):
321
- structlogger.debug(
322
- "server.worker.set_count.success",
323
- event_info=f"Using {env_value} Sanic workers.",
324
- num_workers=env_value,
325
- )
291
+ logger.debug(f"Using {env_value} Sanic workers.")
326
292
  return env_value
327
293
 
328
- structlogger.warning(
329
- "server.worker.set_count.error_no_lock_store",
330
- event_info=f"Unable to assign desired number of Sanic workers ({env_value}) as "
294
+ logger.debug(
295
+ f"Unable to assign desired number of Sanic workers ({env_value}) as "
331
296
  f"no `RedisLockStore` or custom `LockStore` endpoint "
332
- f"configuration has been found.",
333
- num_workers=env_value,
297
+ f"configuration has been found."
334
298
  )
335
299
  return _log_and_get_default_number_of_workers()
336
300