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,18 +1,7 @@
1
1
  import logging
2
2
  from abc import ABC, abstractmethod
3
3
  from functools import reduce
4
- from typing import (
5
- Any,
6
- Dict,
7
- List,
8
- Optional,
9
- Set,
10
- Text,
11
- Tuple,
12
- Type,
13
- Union,
14
- cast,
15
- )
4
+ from typing import Any, Dict, List, Optional, Set, Text, Tuple, Type, Union, cast
16
5
 
17
6
  import importlib_resources
18
7
 
@@ -178,7 +167,6 @@ class TrainingDataImporter(ABC):
178
167
  domain_path: Optional[Text] = None,
179
168
  training_data_paths: Optional[List[Text]] = None,
180
169
  args: Optional[Dict[Text, Any]] = None,
181
- expand_env_vars: bool = True,
182
170
  ) -> "TrainingDataImporter":
183
171
  """Loads a `TrainingDataImporter` instance from a dictionary."""
184
172
  from rasa.shared.importers.rasa import RasaFileImporter
@@ -194,12 +182,7 @@ class TrainingDataImporter(ABC):
194
182
  importers = [importer for importer in importers if importer]
195
183
  if not importers:
196
184
  importers = [
197
- RasaFileImporter(
198
- config_path,
199
- domain_path,
200
- training_data_paths,
201
- expand_env_vars=expand_env_vars,
202
- )
185
+ RasaFileImporter(config_path, domain_path, training_data_paths)
203
186
  ]
204
187
 
205
188
  return E2EImporter(
@@ -29,9 +29,7 @@ class RasaFileImporter(TrainingDataImporter):
29
29
  config_file: Optional[Text] = None,
30
30
  domain_path: Optional[Text] = None,
31
31
  training_data_paths: Optional[Union[List[Text], Text]] = None,
32
- expand_env_vars: bool = True,
33
32
  ):
34
- self.expand_env_vars = expand_env_vars
35
33
  self._domain_path = domain_path
36
34
 
37
35
  self._nlu_files = rasa.shared.data.get_data_files(
@@ -56,9 +54,7 @@ class RasaFileImporter(TrainingDataImporter):
56
54
  logger.debug("No configuration file was provided to the RasaFileImporter.")
57
55
  return {}
58
56
 
59
- config = read_model_configuration(
60
- self.config_file, expand_env_vars=self.expand_env_vars
61
- )
57
+ config = read_model_configuration(self.config_file)
62
58
  return config
63
59
 
64
60
  def get_config_file_for_auto_config(self) -> Optional[Text]:
@@ -1,133 +1,15 @@
1
1
  from __future__ import annotations
2
-
3
- import itertools
4
- from dataclasses import dataclass
5
2
  from typing import Iterable, Union, Text, Optional, List, Any, Tuple, Dict, Set
3
+ import itertools
6
4
 
7
5
  import numpy as np
8
6
  import scipy.sparse
9
- from safetensors.numpy import save_file, load_file
10
7
 
11
- import rasa.shared.nlu.training_data.util
12
8
  import rasa.shared.utils.io
9
+ import rasa.shared.nlu.training_data.util
13
10
  from rasa.shared.nlu.constants import FEATURE_TYPE_SEQUENCE, FEATURE_TYPE_SENTENCE
14
11
 
15
12
 
16
- @dataclass
17
- class FeatureMetadata:
18
- data_type: str
19
- attribute: str
20
- origin: Union[str, List[str]]
21
- is_sparse: bool
22
- shape: tuple
23
- safetensors_key: str
24
-
25
-
26
- def save_features(
27
- features_dict: Dict[Text, List[Features]], file_name: str
28
- ) -> Dict[str, Any]:
29
- """Save a dictionary of Features lists to disk using safetensors.
30
-
31
- Args:
32
- features_dict: Dictionary mapping strings to lists of Features objects
33
- file_name: File to save the features to
34
-
35
- Returns:
36
- The metadata to reconstruct the features.
37
- """
38
- # All tensors are stored in a single safetensors file
39
- tensors_to_save = {}
40
- # Metadata will be stored separately
41
- metadata = {}
42
-
43
- for key, features_list in features_dict.items():
44
- feature_metadata_list = []
45
-
46
- for idx, feature in enumerate(features_list):
47
- # Create a unique key for this tensor in the safetensors file
48
- safetensors_key = f"{key}_{idx}"
49
-
50
- # Convert sparse matrices to dense if needed
51
- if feature.is_sparse():
52
- # For sparse matrices, use the COO format
53
- coo = feature.features.tocoo() # type:ignore[union-attr]
54
- # Save data, row indices and col indices separately
55
- tensors_to_save[f"{safetensors_key}_data"] = coo.data
56
- tensors_to_save[f"{safetensors_key}_row"] = coo.row
57
- tensors_to_save[f"{safetensors_key}_col"] = coo.col
58
- else:
59
- tensors_to_save[safetensors_key] = feature.features
60
-
61
- # Store metadata
62
- metadata_item = FeatureMetadata(
63
- data_type=feature.type,
64
- attribute=feature.attribute,
65
- origin=feature.origin,
66
- is_sparse=feature.is_sparse(),
67
- shape=feature.features.shape,
68
- safetensors_key=safetensors_key,
69
- )
70
- feature_metadata_list.append(vars(metadata_item))
71
-
72
- metadata[key] = feature_metadata_list
73
-
74
- # Save tensors
75
- save_file(tensors_to_save, file_name)
76
-
77
- return metadata
78
-
79
-
80
- def load_features(
81
- filename: str, metadata: Dict[str, Any]
82
- ) -> Dict[Text, List[Features]]:
83
- """Load Features dictionary from disk.
84
-
85
- Args:
86
- filename: File name of the safetensors file.
87
- metadata: Metadata to reconstruct the features.
88
-
89
- Returns:
90
- Dictionary mapping strings to lists of Features objects
91
- """
92
- # Load tensors
93
- tensors = load_file(filename)
94
-
95
- # Reconstruct the features dictionary
96
- features_dict: Dict[Text, List[Features]] = {}
97
-
98
- for key, feature_metadata_list in metadata.items():
99
- features_list = []
100
-
101
- for meta in feature_metadata_list:
102
- safetensors_key = meta["safetensors_key"]
103
-
104
- if meta["is_sparse"]:
105
- # Reconstruct sparse matrix from COO format
106
- data = tensors[f"{safetensors_key}_data"]
107
- row = tensors[f"{safetensors_key}_row"]
108
- col = tensors[f"{safetensors_key}_col"]
109
-
110
- features_matrix = scipy.sparse.coo_matrix(
111
- (data, (row, col)), shape=tuple(meta["shape"])
112
- ).tocsr() # Convert back to CSR format
113
- else:
114
- features_matrix = tensors[safetensors_key]
115
-
116
- # Reconstruct Features object
117
- features = Features(
118
- features=features_matrix,
119
- feature_type=meta["data_type"],
120
- attribute=meta["attribute"],
121
- origin=meta["origin"],
122
- )
123
-
124
- features_list.append(features)
125
-
126
- features_dict[key] = features_list
127
-
128
- return features_dict
129
-
130
-
131
13
  class Features:
132
14
  """Stores the features produced by any featurizer."""
133
15
 
@@ -1,18 +1,7 @@
1
1
  import logging
2
2
  from collections import OrderedDict
3
3
  from pathlib import Path
4
- from typing import (
5
- ClassVar,
6
- Text,
7
- Any,
8
- List,
9
- Dict,
10
- Tuple,
11
- Union,
12
- Iterator,
13
- Optional,
14
- Callable,
15
- )
4
+ from typing import Text, Any, List, Dict, Tuple, Union, Iterator, Optional, Callable
16
5
 
17
6
  import rasa.shared.data
18
7
  from rasa.shared.core.domain import Domain
@@ -66,8 +55,6 @@ STRIP_SYMBOLS = "\n\r "
66
55
  class RasaYAMLReader(TrainingDataReader):
67
56
  """Reads YAML training data and creates a TrainingData object."""
68
57
 
69
- expand_env_vars: ClassVar[bool] = True
70
-
71
58
  def __init__(self) -> None:
72
59
  super().__init__()
73
60
  self.training_examples: List[Message] = []
@@ -82,9 +69,7 @@ class RasaYAMLReader(TrainingDataReader):
82
69
  If the string is not in the right format, an exception will be raised.
83
70
  """
84
71
  try:
85
- validate_raw_yaml_using_schema_file_with_responses(
86
- string, NLU_SCHEMA_FILE, expand_env_vars=self.expand_env_vars
87
- )
72
+ validate_raw_yaml_using_schema_file_with_responses(string, NLU_SCHEMA_FILE)
88
73
  except YamlException as e:
89
74
  e.filename = self.filename
90
75
  raise e
@@ -103,7 +88,7 @@ class RasaYAMLReader(TrainingDataReader):
103
88
  """
104
89
  self.validate(string)
105
90
 
106
- yaml_content = read_yaml(string, expand_env_vars=self.expand_env_vars)
91
+ yaml_content = read_yaml(string)
107
92
 
108
93
  if not validate_training_data_format_version(yaml_content, self.filename):
109
94
  return TrainingData()
@@ -107,7 +107,8 @@ class AzureOpenAIClientConfig:
107
107
 
108
108
  @classmethod
109
109
  def from_dict(cls, config: dict) -> "AzureOpenAIClientConfig":
110
- """Initializes a dataclass from the passed config.
110
+ """
111
+ Initializes a dataclass from the passed config.
111
112
 
112
113
  Args:
113
114
  config: (dict) The config from which to initialize.
@@ -174,10 +175,7 @@ def is_azure_openai_config(config: dict) -> bool:
174
175
 
175
176
  # Case: Configuration contains `deployment` key
176
177
  # (specific to Azure OpenAI configuration)
177
- if (
178
- config.get(DEPLOYMENT_CONFIG_KEY) is not None
179
- and config.get(PROVIDER_CONFIG_KEY) is None
180
- ):
178
+ if config.get(DEPLOYMENT_CONFIG_KEY) is not None:
181
179
  return True
182
180
 
183
181
  return False
@@ -19,8 +19,8 @@ from rasa.shared.constants import (
19
19
  REQUEST_TIMEOUT_CONFIG_KEY,
20
20
  TIMEOUT_CONFIG_KEY,
21
21
  PROVIDER_CONFIG_KEY,
22
- OPENAI_API_TYPE,
23
22
  OPENAI_PROVIDER,
23
+ OPENAI_API_TYPE,
24
24
  )
25
25
  from rasa.shared.providers._configs.utils import (
26
26
  resolve_aliases,
@@ -23,7 +23,6 @@ from rasa.shared.constants import (
23
23
  SELF_HOSTED_PROVIDER,
24
24
  USE_CHAT_COMPLETIONS_ENDPOINT_CONFIG_KEY,
25
25
  )
26
-
27
26
  from rasa.shared.providers._configs.utils import (
28
27
  raise_deprecation_warnings,
29
28
  resolve_aliases,
@@ -99,19 +99,3 @@ def validate_forbidden_keys(config: dict, forbidden_keys: list) -> None:
99
99
  config=config,
100
100
  )
101
101
  raise ValueError(message)
102
-
103
-
104
- def get_provider_prefixed_model_name(provider: str, model: str) -> str:
105
- """
106
- Returns the model name with the provider prefixed.
107
-
108
- Args:
109
- provider: The provider of the model.
110
- model: The model name.
111
-
112
- Returns:
113
- The model name with the provider prefixed.
114
- """
115
- if model and f"{provider}/" not in model:
116
- return f"{provider}/{model}"
117
- return model
@@ -1,12 +1,10 @@
1
- import logging
2
1
  from abc import abstractmethod
3
2
  from typing import Any, Dict, List
4
3
 
5
4
  import litellm
5
+ import logging
6
6
  import structlog
7
7
  from litellm import aembedding, embedding, validate_environment
8
-
9
- from rasa.shared.constants import API_BASE_CONFIG_KEY, API_KEY
10
8
  from rasa.shared.exceptions import (
11
9
  ProviderClientAPIException,
12
10
  ProviderClientValidationError,
@@ -19,7 +17,7 @@ from rasa.shared.providers.embedding.embedding_response import (
19
17
  EmbeddingResponse,
20
18
  EmbeddingUsage,
21
19
  )
22
- from rasa.shared.utils.io import suppress_logs, resolve_environment_variables
20
+ from rasa.shared.utils.io import suppress_logs
23
21
 
24
22
  structlogger = structlog.get_logger()
25
23
 
@@ -27,7 +25,8 @@ _VALIDATE_ENVIRONMENT_MISSING_KEYS_KEY = "missing_keys"
27
25
 
28
26
 
29
27
  class _BaseLiteLLMEmbeddingClient:
30
- """An abstract base class for LiteLLM embedding clients.
28
+ """
29
+ An abstract base class for LiteLLM embedding clients.
31
30
 
32
31
  This class defines the interface and common functionality for all clients
33
32
  based on LiteLLM.
@@ -82,14 +81,11 @@ class _BaseLiteLLMEmbeddingClient:
82
81
  ProviderClientValidationError if validation fails.
83
82
  """
84
83
  self._validate_environment_variables()
84
+ self._validate_api_key_not_in_config()
85
85
 
86
86
  def _validate_environment_variables(self) -> None:
87
87
  """Validate that the required environment variables are set."""
88
- validation_info = validate_environment(
89
- self._litellm_model_name,
90
- api_key=self._litellm_extra_parameters.get(API_KEY),
91
- api_base=self._litellm_extra_parameters.get(API_BASE_CONFIG_KEY),
92
- )
88
+ validation_info = validate_environment(self._litellm_model_name)
93
89
  if missing_environment_variables := validation_info.get(
94
90
  _VALIDATE_ENVIRONMENT_MISSING_KEYS_KEY
95
91
  ):
@@ -104,8 +100,21 @@ class _BaseLiteLLMEmbeddingClient:
104
100
  )
105
101
  raise ProviderClientValidationError(event_info)
106
102
 
103
+ def _validate_api_key_not_in_config(self) -> None:
104
+ if "api_key" in self._litellm_extra_parameters:
105
+ event_info = (
106
+ "API Key is set through `api_key` extra parameter."
107
+ "Set API keys through environment variables."
108
+ )
109
+ structlogger.error(
110
+ "base_litellm_client.validate_api_key_not_in_config",
111
+ event_info=event_info,
112
+ )
113
+ raise ProviderClientValidationError(event_info)
114
+
107
115
  def validate_documents(self, documents: List[str]) -> None:
108
- """Validates a list of documents to ensure they are suitable for embedding.
116
+ """
117
+ Validates a list of documents to ensure they are suitable for embedding.
109
118
 
110
119
  Args:
111
120
  documents: List of documents to be validated.
@@ -121,7 +130,8 @@ class _BaseLiteLLMEmbeddingClient:
121
130
 
122
131
  @suppress_logs(log_level=logging.WARNING)
123
132
  def embed(self, documents: List[str]) -> EmbeddingResponse:
124
- """Embeds a list of documents synchronously.
133
+ """
134
+ Embeds a list of documents synchronously.
125
135
 
126
136
  Args:
127
137
  documents: List of documents to be embedded.
@@ -134,8 +144,7 @@ class _BaseLiteLLMEmbeddingClient:
134
144
  """
135
145
  self.validate_documents(documents)
136
146
  try:
137
- arguments = resolve_environment_variables(self._embedding_fn_args)
138
- response = embedding(input=documents, **arguments)
147
+ response = embedding(input=documents, **self._embedding_fn_args)
139
148
  return self._format_response(response)
140
149
  except Exception as e:
141
150
  raise ProviderClientAPIException(
@@ -144,7 +153,8 @@ class _BaseLiteLLMEmbeddingClient:
144
153
 
145
154
  @suppress_logs(log_level=logging.WARNING)
146
155
  async def aembed(self, documents: List[str]) -> EmbeddingResponse:
147
- """Embeds a list of documents asynchronously.
156
+ """
157
+ Embeds a list of documents asynchronously.
148
158
 
149
159
  Args:
150
160
  documents: List of documents to be embedded.
@@ -157,8 +167,7 @@ class _BaseLiteLLMEmbeddingClient:
157
167
  """
158
168
  self.validate_documents(documents)
159
169
  try:
160
- arguments = resolve_environment_variables(self._embedding_fn_args)
161
- response = await aembedding(input=documents, **arguments)
170
+ response = await aembedding(input=documents, **self._embedding_fn_args)
162
171
  return self._format_response(response)
163
172
  except Exception as e:
164
173
  raise ProviderClientAPIException(
@@ -173,6 +182,7 @@ class _BaseLiteLLMEmbeddingClient:
173
182
  Raises:
174
183
  ValueError: If any response data is None.
175
184
  """
185
+
176
186
  # If data is not available (None), raise a ValueError
177
187
  if response.data is None:
178
188
  message = (
@@ -229,7 +239,8 @@ class _BaseLiteLLMEmbeddingClient:
229
239
 
230
240
  @staticmethod
231
241
  def _ensure_certificates() -> None:
232
- """Configures SSL certificates for LiteLLM. This method is invoked during
242
+ """
243
+ Configures SSL certificates for LiteLLM. This method is invoked during
233
244
  client initialization.
234
245
 
235
246
  LiteLLM may utilize `openai` clients or other providers that require
@@ -1,6 +1,5 @@
1
- import os
2
1
  from typing import Any, Dict, List, Optional
3
-
2
+ import os
4
3
  import structlog
5
4
 
6
5
  from rasa.shared.constants import (
@@ -43,7 +42,6 @@ class AzureOpenAIEmbeddingClient(_BaseLiteLLMEmbeddingClient):
43
42
  If not provided, it will be set via environment variable.
44
43
  kwargs (Optional[Dict[str, Any]]): Optional configuration parameters specific
45
44
  to the embedding model deployment.
46
-
47
45
  Raises:
48
46
  ProviderClientValidationError: If validation of the client setup fails.
49
47
  DeprecationWarning: If deprecated environment variables are used for
@@ -62,7 +60,6 @@ class AzureOpenAIEmbeddingClient(_BaseLiteLLMEmbeddingClient):
62
60
  super().__init__() # type: ignore
63
61
  self._deployment = deployment
64
62
  self._model = model
65
- self._extra_parameters = kwargs or {}
66
63
 
67
64
  # Set api_base with the following priority:
68
65
  # parameter -> Azure Env Var -> (deprecated) OpenAI Env Var
@@ -84,55 +81,17 @@ class AzureOpenAIEmbeddingClient(_BaseLiteLLMEmbeddingClient):
84
81
  # Litellm does not support use of OPENAI_API_KEY, so we need to map it
85
82
  # because of backward compatibility. However, we're first looking at
86
83
  # AZURE_API_KEY.
87
- self._api_key_env_var = self._resolve_api_key_env_var()
84
+ self._api_key = os.environ.get(AZURE_API_KEY_ENV_VAR) or os.environ.get(
85
+ OPENAI_API_KEY_ENV_VAR
86
+ )
88
87
 
88
+ self._extra_parameters = kwargs or {}
89
89
  self.validate_client_setup()
90
90
 
91
- def _resolve_api_key_env_var(self) -> str:
92
- """Resolves the environment variable to use for the API key.
93
-
94
- Returns:
95
- str: The env variable in dollar syntax format to use for the API key.
96
- """
97
- if API_KEY in self._extra_parameters:
98
- # API key is set to an env var in the config itself
99
- # in case the model is defined in the endpoints.yml
100
- return self._extra_parameters[API_KEY]
101
-
102
- if os.getenv(AZURE_API_KEY_ENV_VAR) is not None:
103
- return "${AZURE_API_KEY}"
104
-
105
- if os.getenv(OPENAI_API_KEY_ENV_VAR) is not None:
106
- # API key can be set through OPENAI_API_KEY too,
107
- # because of the backward compatibility
108
- raise_deprecation_warning(
109
- message=(
110
- f"Usage of '{OPENAI_API_KEY_ENV_VAR}' environment variable "
111
- "for setting the API key of "
112
- "Azure OpenAI client is deprecated and will "
113
- "be removed in 4.0.0. Please "
114
- f"use '{AZURE_API_KEY_ENV_VAR}' instead."
115
- )
116
- )
117
- return "${OPENAI_API_KEY}"
118
-
119
- structlogger.error(
120
- "azure_openai_embedding_client.api_key_not_set",
121
- event_info=(
122
- "API key not set, it is required for API calls. "
123
- f"Set it either via the environment variable "
124
- f"'{AZURE_API_KEY_ENV_VAR}' or directly"
125
- f"via the config key '{API_KEY}'."
126
- ),
127
- )
128
- raise ProviderClientValidationError(
129
- f"Missing required environment variable/config key '{API_KEY}' for "
130
- f"API calls."
131
- )
132
-
133
91
  @classmethod
134
92
  def from_config(cls, config: Dict[str, Any]) -> "AzureOpenAIEmbeddingClient":
135
- """Initializes the client from given configuration.
93
+ """
94
+ Initializes the client from given configuration.
136
95
 
137
96
  Args:
138
97
  config (Dict[str, Any]): Configuration.
@@ -183,7 +142,8 @@ class AzureOpenAIEmbeddingClient(_BaseLiteLLMEmbeddingClient):
183
142
 
184
143
  @property
185
144
  def model(self) -> Optional[str]:
186
- """Returns the name of the model deployed on Azure. If model name is not
145
+ """
146
+ Returns the name of the model deployed on Azure. If model name is not
187
147
  provided, returns "N/A".
188
148
  """
189
149
  return self._model
@@ -210,7 +170,8 @@ class AzureOpenAIEmbeddingClient(_BaseLiteLLMEmbeddingClient):
210
170
 
211
171
  @property
212
172
  def _litellm_extra_parameters(self) -> Dict[str, Any]:
213
- """Returns the model parameters for the azure openai embedding client.
173
+ """
174
+ Returns the model parameters for the azure openai embedding client.
214
175
 
215
176
  Returns:
216
177
  Dictionary containing the model parameters.
@@ -225,7 +186,7 @@ class AzureOpenAIEmbeddingClient(_BaseLiteLLMEmbeddingClient):
225
186
  "api_base": self.api_base,
226
187
  "api_type": self.api_type,
227
188
  "api_version": self.api_version,
228
- "api_key": self._api_key_env_var,
189
+ "api_key": self._api_key,
229
190
  }
230
191
 
231
192
  @property
@@ -236,9 +197,8 @@ class AzureOpenAIEmbeddingClient(_BaseLiteLLMEmbeddingClient):
236
197
  return self.deployment
237
198
 
238
199
  def validate_client_setup(self) -> None:
239
- """Perform client validation.
240
-
241
- By default, only environment variables are validated.
200
+ """Perform client validation. By default only environment variables
201
+ are validated.
242
202
 
243
203
  Raises:
244
204
  ProviderClientValidationError if validation fails.
@@ -254,6 +214,13 @@ class AzureOpenAIEmbeddingClient(_BaseLiteLLMEmbeddingClient):
254
214
  "current_value": self.api_base,
255
215
  "new_env_key": AZURE_API_BASE_ENV_VAR,
256
216
  },
217
+ {
218
+ "param_name": "API key",
219
+ "config_key": API_KEY,
220
+ "deprecated_env_key": OPENAI_API_KEY_ENV_VAR,
221
+ "current_value": self._api_key,
222
+ "new_env_key": AZURE_API_KEY_ENV_VAR,
223
+ },
257
224
  {
258
225
  "param_name": "API version",
259
226
  "config_key": API_VERSION_CONFIG_KEY,
@@ -1,13 +1,8 @@
1
1
  from typing import Any, Dict
2
2
 
3
- from rasa.shared.constants import (
4
- AWS_BEDROCK_PROVIDER,
5
- AWS_SAGEMAKER_PROVIDER,
6
- )
7
3
  from rasa.shared.providers._configs.default_litellm_client_config import (
8
4
  DefaultLiteLLMClientConfig,
9
5
  )
10
- from rasa.shared.providers._utils import validate_aws_setup_for_litellm_clients
11
6
  from rasa.shared.providers.embedding._base_litellm_embedding_client import (
12
7
  _BaseLiteLLMEmbeddingClient,
13
8
  )
@@ -105,22 +100,3 @@ class DefaultLiteLLMEmbeddingClient(_BaseLiteLLMEmbeddingClient):
105
100
  "model": self._litellm_model_name,
106
101
  **self._litellm_extra_parameters,
107
102
  }
108
-
109
- def validate_client_setup(self) -> None:
110
- # TODO: Temporarily disable environment variable validation for AWS setup
111
- # (Bedrock and SageMaker) until resolved by either:
112
- # 1. An update from the LiteLLM package addressing the issue.
113
- # 2. The implementation of a Bedrock client on our end.
114
- # ---
115
- # This fix ensures a consistent user experience for Bedrock (and
116
- # SageMaker) in Rasa by allowing AWS secrets to be provided as extra
117
- # parameters without triggering validation errors due to missing AWS
118
- # environment variables.
119
- if self.provider.lower() in [AWS_BEDROCK_PROVIDER, AWS_SAGEMAKER_PROVIDER]:
120
- validate_aws_setup_for_litellm_clients(
121
- self._litellm_model_name,
122
- self._litellm_extra_parameters,
123
- "default_litellm_embedding_client",
124
- )
125
- else:
126
- super().validate_client_setup()