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,9 +1,11 @@
1
1
  from __future__ import annotations
2
-
3
- import logging
4
- from abc import abstractmethod
5
- from collections import defaultdict
6
2
  from pathlib import Path
3
+ from collections import defaultdict
4
+ from abc import abstractmethod
5
+ import jsonpickle
6
+ import logging
7
+
8
+ from tqdm import tqdm
7
9
  from typing import (
8
10
  Tuple,
9
11
  List,
@@ -16,30 +18,25 @@ from typing import (
16
18
  Set,
17
19
  DefaultDict,
18
20
  cast,
19
- Type,
20
- Callable,
21
- ClassVar,
22
21
  )
23
-
24
22
  import numpy as np
25
- from tqdm import tqdm
26
23
 
24
+ from rasa.core.featurizers.single_state_featurizer import SingleStateFeaturizer
25
+ from rasa.core.featurizers.precomputation import MessageContainerForCoreFeaturization
26
+ from rasa.core.exceptions import InvalidTrackerFeaturizerUsageError
27
27
  import rasa.shared.core.trackers
28
28
  import rasa.shared.utils.io
29
- from rasa.core.exceptions import InvalidTrackerFeaturizerUsageError
30
- from rasa.core.featurizers.precomputation import MessageContainerForCoreFeaturization
31
- from rasa.core.featurizers.single_state_featurizer import SingleStateFeaturizer
29
+ from rasa.shared.nlu.constants import TEXT, INTENT, ENTITIES, ACTION_NAME
30
+ from rasa.shared.nlu.training_data.features import Features
31
+ from rasa.shared.core.trackers import DialogueStateTracker
32
+ from rasa.shared.core.domain import State, Domain
33
+ from rasa.shared.core.events import Event, ActionExecuted, UserUttered
32
34
  from rasa.shared.core.constants import (
33
35
  USER,
34
36
  ACTION_UNLIKELY_INTENT_NAME,
35
37
  PREVIOUS_ACTION,
36
38
  )
37
- from rasa.shared.core.domain import State, Domain
38
- from rasa.shared.core.events import Event, ActionExecuted, UserUttered
39
- from rasa.shared.core.trackers import DialogueStateTracker
40
39
  from rasa.shared.exceptions import RasaException
41
- from rasa.shared.nlu.constants import TEXT, INTENT, ENTITIES, ACTION_NAME
42
- from rasa.shared.nlu.training_data.features import Features
43
40
  from rasa.utils.tensorflow.constants import LABEL_PAD_ID
44
41
  from rasa.utils.tensorflow.model_data import ragged_array_to_ndarray
45
42
 
@@ -67,10 +64,6 @@ class InvalidStory(RasaException):
67
64
  class TrackerFeaturizer:
68
65
  """Base class for actual tracker featurizers."""
69
66
 
70
- # Class registry to store all subclasses
71
- _registry: ClassVar[Dict[str, Type["TrackerFeaturizer"]]] = {}
72
- _featurizer_type: str = "TrackerFeaturizer"
73
-
74
67
  def __init__(
75
68
  self, state_featurizer: Optional[SingleStateFeaturizer] = None
76
69
  ) -> None:
@@ -81,36 +74,6 @@ class TrackerFeaturizer:
81
74
  """
82
75
  self.state_featurizer = state_featurizer
83
76
 
84
- @classmethod
85
- def register(cls, featurizer_type: str) -> Callable:
86
- """Decorator to register featurizer subclasses."""
87
-
88
- def wrapper(subclass: Type["TrackerFeaturizer"]) -> Type["TrackerFeaturizer"]:
89
- cls._registry[featurizer_type] = subclass
90
- # Store the type identifier in the class for serialization
91
- subclass._featurizer_type = featurizer_type
92
- return subclass
93
-
94
- return wrapper
95
-
96
- @classmethod
97
- def from_dict(cls, data: Dict[str, Any]) -> "TrackerFeaturizer":
98
- """Create featurizer instance from dictionary."""
99
- featurizer_type = data.pop("type")
100
-
101
- if featurizer_type not in cls._registry:
102
- raise ValueError(f"Unknown featurizer type: {featurizer_type}")
103
-
104
- # Get the correct subclass and instantiate it
105
- subclass = cls._registry[featurizer_type]
106
- return subclass.create_from_dict(data)
107
-
108
- @classmethod
109
- @abstractmethod
110
- def create_from_dict(cls, data: Dict[str, Any]) -> "TrackerFeaturizer":
111
- """Each subclass must implement its own creation from dict method."""
112
- pass
113
-
114
77
  @staticmethod
115
78
  def _create_states(
116
79
  tracker: DialogueStateTracker,
@@ -502,7 +465,9 @@ class TrackerFeaturizer:
502
465
  self.state_featurizer.entity_tag_specs = []
503
466
 
504
467
  # noinspection PyTypeChecker
505
- rasa.shared.utils.io.dump_obj_as_json_to_file(featurizer_file, self.to_dict())
468
+ rasa.shared.utils.io.write_text_file(
469
+ str(jsonpickle.encode(self)), featurizer_file
470
+ )
506
471
 
507
472
  @staticmethod
508
473
  def load(path: Union[Text, Path]) -> Optional[TrackerFeaturizer]:
@@ -516,17 +481,7 @@ class TrackerFeaturizer:
516
481
  """
517
482
  featurizer_file = Path(path) / FEATURIZER_FILE
518
483
  if featurizer_file.is_file():
519
- data = rasa.shared.utils.io.read_json_file(featurizer_file)
520
-
521
- if "type" not in data:
522
- logger.error(
523
- f"Couldn't load featurizer for policy. "
524
- f"File '{featurizer_file}' does not contain all "
525
- f"necessary information. 'type' is missing."
526
- )
527
- return None
528
-
529
- return TrackerFeaturizer.from_dict(data)
484
+ return jsonpickle.decode(rasa.shared.utils.io.read_file(featurizer_file))
530
485
 
531
486
  logger.error(
532
487
  f"Couldn't load featurizer for policy. "
@@ -553,16 +508,7 @@ class TrackerFeaturizer:
553
508
  )
554
509
  ]
555
510
 
556
- def to_dict(self) -> Dict[str, Any]:
557
- return {
558
- "type": self.__class__._featurizer_type,
559
- "state_featurizer": (
560
- self.state_featurizer.to_dict() if self.state_featurizer else None
561
- ),
562
- }
563
-
564
511
 
565
- @TrackerFeaturizer.register("FullDialogueTrackerFeaturizer")
566
512
  class FullDialogueTrackerFeaturizer(TrackerFeaturizer):
567
513
  """Creates full dialogue training data for time distributed architectures.
568
514
 
@@ -700,20 +646,7 @@ class FullDialogueTrackerFeaturizer(TrackerFeaturizer):
700
646
 
701
647
  return trackers_as_states
702
648
 
703
- def to_dict(self) -> Dict[str, Any]:
704
- return super().to_dict()
705
649
 
706
- @classmethod
707
- def create_from_dict(cls, data: Dict[str, Any]) -> "FullDialogueTrackerFeaturizer":
708
- state_featurizer = SingleStateFeaturizer.create_from_dict(
709
- data["state_featurizer"]
710
- )
711
- return cls(
712
- state_featurizer,
713
- )
714
-
715
-
716
- @TrackerFeaturizer.register("MaxHistoryTrackerFeaturizer")
717
650
  class MaxHistoryTrackerFeaturizer(TrackerFeaturizer):
718
651
  """Truncates the tracker history into `max_history` long sequences.
719
652
 
@@ -951,25 +884,7 @@ class MaxHistoryTrackerFeaturizer(TrackerFeaturizer):
951
884
 
952
885
  return trackers_as_states
953
886
 
954
- def to_dict(self) -> Dict[str, Any]:
955
- data = super().to_dict()
956
- data.update(
957
- {
958
- "remove_duplicates": self.remove_duplicates,
959
- "max_history": self.max_history,
960
- }
961
- )
962
- return data
963
-
964
- @classmethod
965
- def create_from_dict(cls, data: Dict[str, Any]) -> "MaxHistoryTrackerFeaturizer":
966
- state_featurizer = SingleStateFeaturizer.create_from_dict(
967
- data["state_featurizer"]
968
- )
969
- return cls(state_featurizer, data["max_history"], data["remove_duplicates"])
970
887
 
971
-
972
- @TrackerFeaturizer.register("IntentMaxHistoryTrackerFeaturizer")
973
888
  class IntentMaxHistoryTrackerFeaturizer(MaxHistoryTrackerFeaturizer):
974
889
  """Truncates the tracker history into `max_history` long sequences.
975
890
 
@@ -1244,18 +1159,6 @@ class IntentMaxHistoryTrackerFeaturizer(MaxHistoryTrackerFeaturizer):
1244
1159
 
1245
1160
  return trackers_as_states
1246
1161
 
1247
- def to_dict(self) -> Dict[str, Any]:
1248
- return super().to_dict()
1249
-
1250
- @classmethod
1251
- def create_from_dict(
1252
- cls, data: Dict[str, Any]
1253
- ) -> "IntentMaxHistoryTrackerFeaturizer":
1254
- state_featurizer = SingleStateFeaturizer.create_from_dict(
1255
- data["state_featurizer"]
1256
- )
1257
- return cls(state_featurizer, data["max_history"], data["remove_duplicates"])
1258
-
1259
1162
 
1260
1163
  def _is_prev_action_unlikely_intent_in_state(state: State) -> bool:
1261
1164
  prev_action_name = state.get(PREVIOUS_ACTION, {}).get(ACTION_NAME)
@@ -62,7 +62,6 @@ class Qdrant_Store(InformationRetrieval):
62
62
  embeddings=self.embeddings,
63
63
  content_payload_key=params.get("content_payload_key", "text"),
64
64
  metadata_payload_key=params.get("metadata_payload_key", "metadata"),
65
- vector_name=params.get("vector_name", None),
66
65
  )
67
66
 
68
67
  async def search(
@@ -1,11 +1,13 @@
1
1
  from typing import Any, Dict, Optional, Text
2
2
 
3
+ import os
3
4
  import structlog
4
5
  from jinja2 import Template
6
+
5
7
  from rasa import telemetry
6
8
  from rasa.core.nlg.response import TemplatedNaturalLanguageGenerator
7
- from rasa.core.nlg.summarize import summarize_conversation
8
9
  from rasa.shared.constants import (
10
+ LLM_API_HEALTH_CHECK_ENV_VAR,
9
11
  LLM_CONFIG_KEY,
10
12
  MODEL_CONFIG_KEY,
11
13
  MODEL_NAME_CONFIG_KEY,
@@ -13,25 +15,24 @@ from rasa.shared.constants import (
13
15
  PROVIDER_CONFIG_KEY,
14
16
  OPENAI_PROVIDER,
15
17
  TIMEOUT_CONFIG_KEY,
16
- MODEL_GROUP_ID_CONFIG_KEY,
17
18
  )
18
19
  from rasa.shared.core.domain import KEY_RESPONSES_TEXT, Domain
19
20
  from rasa.shared.core.events import BotUttered, UserUttered
20
21
  from rasa.shared.core.trackers import DialogueStateTracker
21
- from rasa.shared.utils.health_check.llm_health_check_mixin import LLMHealthCheckMixin
22
22
  from rasa.shared.utils.llm import (
23
23
  DEFAULT_OPENAI_GENERATE_MODEL_NAME,
24
24
  DEFAULT_OPENAI_MAX_GENERATED_TOKENS,
25
25
  USER,
26
26
  combine_custom_and_default_config,
27
27
  get_prompt_template,
28
+ llm_api_health_check,
28
29
  llm_factory,
29
- resolve_model_client_config,
30
- )
31
- from rasa.shared.utils.llm import (
32
- tracker_as_readable_transcript,
30
+ try_instantiate_llm_client,
33
31
  )
34
32
  from rasa.utils.endpoints import EndpointConfig
33
+
34
+ from rasa.core.nlg.summarize import summarize_conversation
35
+
35
36
  from rasa.utils.log_utils import log_llm
36
37
 
37
38
  structlogger = structlog.get_logger()
@@ -40,11 +41,7 @@ RESPONSE_REPHRASING_KEY = "rephrase"
40
41
 
41
42
  RESPONSE_REPHRASING_TEMPLATE_KEY = "rephrase_prompt"
42
43
 
43
- RESPONSE_SUMMARISE_CONVERSATION_KEY = "summarize_conversation"
44
-
45
44
  DEFAULT_REPHRASE_ALL = False
46
- DEFAULT_SUMMARIZE_HISTORY = True
47
- DEFAULT_MAX_HISTORICAL_TURNS = 5
48
45
 
49
46
  DEFAULT_LLM_CONFIG = {
50
47
  PROVIDER_CONFIG_KEY: OPENAI_PROVIDER,
@@ -69,9 +66,7 @@ Suggested AI Response: {{suggested_response}}
69
66
  Rephrased AI Response:"""
70
67
 
71
68
 
72
- class ContextualResponseRephraser(
73
- LLMHealthCheckMixin, TemplatedNaturalLanguageGenerator
74
- ):
69
+ class ContextualResponseRephraser(TemplatedNaturalLanguageGenerator):
75
70
  """Generates responses based on modified templates.
76
71
 
77
72
  The templates are filled with the entities and slots that are available in the
@@ -105,24 +100,18 @@ class ContextualResponseRephraser(
105
100
  self.trace_prompt_tokens = self.nlg_endpoint.kwargs.get(
106
101
  "trace_prompt_tokens", False
107
102
  )
108
- self.summarize_history = self.nlg_endpoint.kwargs.get(
109
- "summarize_history", DEFAULT_SUMMARIZE_HISTORY
110
- )
111
- self.max_historical_turns = self.nlg_endpoint.kwargs.get(
112
- "max_historical_turns", DEFAULT_MAX_HISTORICAL_TURNS
113
- )
114
-
115
- self.llm_config = resolve_model_client_config(
103
+ llm_client = try_instantiate_llm_client(
116
104
  self.nlg_endpoint.kwargs.get(LLM_CONFIG_KEY),
117
- ContextualResponseRephraser.__name__,
118
- )
119
-
120
- self.perform_llm_health_check(
121
- self.llm_config,
122
105
  DEFAULT_LLM_CONFIG,
123
106
  "contextual_response_rephraser.init",
124
107
  ContextualResponseRephraser.__name__,
125
108
  )
109
+ if os.getenv(LLM_API_HEALTH_CHECK_ENV_VAR, "true").lower() == "true":
110
+ llm_api_health_check(
111
+ llm_client,
112
+ "contextual_response_rephraser.init",
113
+ ContextualResponseRephraser.__name__,
114
+ )
126
115
 
127
116
  def _last_message_if_human(self, tracker: DialogueStateTracker) -> Optional[str]:
128
117
  """Returns the latest message from the tracker.
@@ -151,7 +140,9 @@ class ContextualResponseRephraser(
151
140
  Returns:
152
141
  generated text
153
142
  """
154
- llm = llm_factory(self.llm_config, DEFAULT_LLM_CONFIG)
143
+ llm = llm_factory(
144
+ self.nlg_endpoint.kwargs.get(LLM_CONFIG_KEY), DEFAULT_LLM_CONFIG
145
+ )
155
146
 
156
147
  try:
157
148
  llm_response = await llm.acompletion(prompt)
@@ -165,7 +156,7 @@ class ContextualResponseRephraser(
165
156
  def llm_property(self, prop: str) -> Optional[str]:
166
157
  """Returns a property of the LLM provider."""
167
158
  return combine_custom_and_default_config(
168
- self.llm_config, DEFAULT_LLM_CONFIG
159
+ self.nlg_endpoint.kwargs.get(LLM_CONFIG_KEY), DEFAULT_LLM_CONFIG
169
160
  ).get(prop)
170
161
 
171
162
  def custom_prompt_template(self, prompt_template: str) -> Optional[str]:
@@ -198,7 +189,9 @@ class ContextualResponseRephraser(
198
189
  Returns:
199
190
  The history for the prompt.
200
191
  """
201
- llm = llm_factory(self.llm_config, DEFAULT_LLM_CONFIG)
192
+ llm = llm_factory(
193
+ self.nlg_endpoint.kwargs.get(LLM_CONFIG_KEY), DEFAULT_LLM_CONFIG
194
+ )
202
195
  return await summarize_conversation(tracker, llm, max_turns=5)
203
196
 
204
197
  async def rephrase(
@@ -219,24 +212,13 @@ class ContextualResponseRephraser(
219
212
  if not (response_text := response.get(KEY_RESPONSES_TEXT)):
220
213
  return response
221
214
 
222
- prompt_template_text = self._template_for_response_rephrasing(response)
223
-
224
- # Retrieve inputs for the dynamic prompt
225
215
  latest_message = self._last_message_if_human(tracker)
226
216
  current_input = f"{USER}: {latest_message}" if latest_message else ""
227
217
 
228
- # Only summarise conversation history if flagged
229
- if self.summarize_history:
230
- history = await self._create_history(tracker)
231
- else:
232
- # make sure the transcript/history contains the last user utterance
233
- max_turns = max(self.max_historical_turns, 1)
234
- history = tracker_as_readable_transcript(tracker, max_turns=max_turns)
235
- # the history already contains the current input
236
- current_input = ""
218
+ prompt_template_text = self._template_for_response_rephrasing(response)
237
219
 
238
220
  prompt = Template(prompt_template_text).render(
239
- history=history,
221
+ history=await self._create_history(tracker),
240
222
  suggested_response=response_text,
241
223
  current_input=current_input,
242
224
  slots=tracker.current_slot_values(),
@@ -253,7 +235,6 @@ class ContextualResponseRephraser(
253
235
  llm_type=self.llm_property(PROVIDER_CONFIG_KEY),
254
236
  llm_model=self.llm_property(MODEL_CONFIG_KEY)
255
237
  or self.llm_property(MODEL_NAME_CONFIG_KEY),
256
- llm_model_group_id=self.llm_property(MODEL_GROUP_ID_CONFIG_KEY),
257
238
  )
258
239
  if not (updated_text := await self._generate_llm_response(prompt)):
259
240
  # If the LLM fails to generate a response, we