rasa-pro 3.9.17__py3-none-any.whl → 3.10.3__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 (187) hide show
  1. README.md +5 -37
  2. rasa/__init__.py +1 -2
  3. rasa/__main__.py +5 -0
  4. rasa/anonymization/anonymization_rule_executor.py +2 -2
  5. rasa/api.py +26 -22
  6. rasa/cli/arguments/data.py +27 -2
  7. rasa/cli/arguments/default_arguments.py +25 -3
  8. rasa/cli/arguments/run.py +9 -9
  9. rasa/cli/arguments/train.py +2 -0
  10. rasa/cli/data.py +70 -8
  11. rasa/cli/e2e_test.py +108 -433
  12. rasa/cli/interactive.py +1 -0
  13. rasa/cli/llm_fine_tuning.py +395 -0
  14. rasa/cli/project_templates/calm/endpoints.yml +1 -1
  15. rasa/cli/project_templates/tutorial/endpoints.yml +1 -1
  16. rasa/cli/run.py +14 -13
  17. rasa/cli/scaffold.py +10 -8
  18. rasa/cli/train.py +8 -7
  19. rasa/cli/utils.py +15 -0
  20. rasa/constants.py +7 -1
  21. rasa/core/actions/action.py +98 -49
  22. rasa/core/actions/action_run_slot_rejections.py +4 -1
  23. rasa/core/actions/custom_action_executor.py +9 -6
  24. rasa/core/actions/direct_custom_actions_executor.py +80 -0
  25. rasa/core/actions/e2e_stub_custom_action_executor.py +68 -0
  26. rasa/core/actions/grpc_custom_action_executor.py +2 -2
  27. rasa/core/actions/http_custom_action_executor.py +6 -5
  28. rasa/core/agent.py +21 -17
  29. rasa/core/channels/__init__.py +2 -0
  30. rasa/core/channels/audiocodes.py +1 -16
  31. rasa/core/channels/voice_aware/__init__.py +0 -0
  32. rasa/core/channels/voice_aware/jambonz.py +103 -0
  33. rasa/core/channels/voice_aware/jambonz_protocol.py +344 -0
  34. rasa/core/channels/voice_aware/utils.py +20 -0
  35. rasa/core/channels/voice_native/__init__.py +0 -0
  36. rasa/core/constants.py +6 -1
  37. rasa/core/featurizers/single_state_featurizer.py +1 -22
  38. rasa/core/featurizers/tracker_featurizers.py +18 -115
  39. rasa/core/information_retrieval/faiss.py +7 -4
  40. rasa/core/information_retrieval/information_retrieval.py +8 -0
  41. rasa/core/information_retrieval/milvus.py +9 -2
  42. rasa/core/information_retrieval/qdrant.py +1 -1
  43. rasa/core/nlg/contextual_response_rephraser.py +32 -10
  44. rasa/core/nlg/summarize.py +4 -3
  45. rasa/core/policies/enterprise_search_policy.py +100 -44
  46. rasa/core/policies/flows/flow_executor.py +155 -98
  47. rasa/core/policies/intentless_policy.py +52 -28
  48. rasa/core/policies/ted_policy.py +33 -58
  49. rasa/core/policies/unexpected_intent_policy.py +7 -15
  50. rasa/core/processor.py +15 -46
  51. rasa/core/run.py +5 -4
  52. rasa/core/tracker_store.py +8 -4
  53. rasa/core/utils.py +45 -56
  54. rasa/dialogue_understanding/coexistence/llm_based_router.py +45 -12
  55. rasa/dialogue_understanding/commands/__init__.py +4 -0
  56. rasa/dialogue_understanding/commands/change_flow_command.py +0 -6
  57. rasa/dialogue_understanding/commands/session_start_command.py +59 -0
  58. rasa/dialogue_understanding/commands/set_slot_command.py +1 -5
  59. rasa/dialogue_understanding/commands/utils.py +38 -0
  60. rasa/dialogue_understanding/generator/constants.py +10 -3
  61. rasa/dialogue_understanding/generator/flow_retrieval.py +14 -5
  62. rasa/dialogue_understanding/generator/llm_based_command_generator.py +12 -2
  63. rasa/dialogue_understanding/generator/multi_step/multi_step_llm_command_generator.py +106 -87
  64. rasa/dialogue_understanding/generator/nlu_command_adapter.py +28 -6
  65. rasa/dialogue_understanding/generator/single_step/single_step_llm_command_generator.py +90 -37
  66. rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +15 -15
  67. rasa/dialogue_understanding/patterns/session_start.py +37 -0
  68. rasa/dialogue_understanding/processor/command_processor.py +13 -14
  69. rasa/e2e_test/aggregate_test_stats_calculator.py +124 -0
  70. rasa/e2e_test/assertions.py +1181 -0
  71. rasa/e2e_test/assertions_schema.yml +106 -0
  72. rasa/e2e_test/constants.py +20 -0
  73. rasa/e2e_test/e2e_config.py +220 -0
  74. rasa/e2e_test/e2e_config_schema.yml +26 -0
  75. rasa/e2e_test/e2e_test_case.py +131 -8
  76. rasa/e2e_test/e2e_test_converter.py +363 -0
  77. rasa/e2e_test/e2e_test_converter_prompt.jinja2 +70 -0
  78. rasa/e2e_test/e2e_test_coverage_report.py +364 -0
  79. rasa/e2e_test/e2e_test_result.py +26 -6
  80. rasa/e2e_test/e2e_test_runner.py +498 -73
  81. rasa/e2e_test/e2e_test_schema.yml +96 -0
  82. rasa/e2e_test/pykwalify_extensions.py +39 -0
  83. rasa/e2e_test/stub_custom_action.py +70 -0
  84. rasa/e2e_test/utils/__init__.py +0 -0
  85. rasa/e2e_test/utils/e2e_yaml_utils.py +55 -0
  86. rasa/e2e_test/utils/io.py +596 -0
  87. rasa/e2e_test/utils/validation.py +80 -0
  88. rasa/engine/recipes/default_components.py +0 -2
  89. rasa/engine/storage/local_model_storage.py +0 -1
  90. rasa/env.py +9 -0
  91. rasa/llm_fine_tuning/__init__.py +0 -0
  92. rasa/llm_fine_tuning/annotation_module.py +241 -0
  93. rasa/llm_fine_tuning/conversations.py +144 -0
  94. rasa/llm_fine_tuning/llm_data_preparation_module.py +178 -0
  95. rasa/llm_fine_tuning/notebooks/unsloth_finetuning.ipynb +407 -0
  96. rasa/llm_fine_tuning/paraphrasing/__init__.py +0 -0
  97. rasa/llm_fine_tuning/paraphrasing/conversation_rephraser.py +281 -0
  98. rasa/llm_fine_tuning/paraphrasing/default_rephrase_prompt_template.jina2 +44 -0
  99. rasa/llm_fine_tuning/paraphrasing/rephrase_validator.py +121 -0
  100. rasa/llm_fine_tuning/paraphrasing/rephrased_user_message.py +10 -0
  101. rasa/llm_fine_tuning/paraphrasing_module.py +128 -0
  102. rasa/llm_fine_tuning/storage.py +174 -0
  103. rasa/llm_fine_tuning/train_test_split_module.py +441 -0
  104. rasa/model_training.py +48 -16
  105. rasa/nlu/classifiers/diet_classifier.py +25 -38
  106. rasa/nlu/classifiers/logistic_regression_classifier.py +9 -44
  107. rasa/nlu/classifiers/sklearn_intent_classifier.py +16 -37
  108. rasa/nlu/extractors/crf_entity_extractor.py +50 -93
  109. rasa/nlu/featurizers/sparse_featurizer/count_vectors_featurizer.py +45 -78
  110. rasa/nlu/featurizers/sparse_featurizer/lexical_syntactic_featurizer.py +17 -52
  111. rasa/nlu/featurizers/sparse_featurizer/regex_featurizer.py +3 -5
  112. rasa/nlu/persistor.py +129 -32
  113. rasa/server.py +45 -10
  114. rasa/shared/constants.py +63 -15
  115. rasa/shared/core/domain.py +15 -12
  116. rasa/shared/core/events.py +28 -2
  117. rasa/shared/core/flows/flow.py +208 -13
  118. rasa/shared/core/flows/flow_path.py +84 -0
  119. rasa/shared/core/flows/flows_list.py +28 -10
  120. rasa/shared/core/flows/flows_yaml_schema.json +269 -193
  121. rasa/shared/core/flows/validation.py +112 -25
  122. rasa/shared/core/flows/yaml_flows_io.py +149 -10
  123. rasa/shared/core/trackers.py +6 -0
  124. rasa/shared/core/training_data/visualization.html +2 -2
  125. rasa/shared/exceptions.py +4 -0
  126. rasa/shared/importers/importer.py +60 -11
  127. rasa/shared/importers/remote_importer.py +196 -0
  128. rasa/shared/nlu/constants.py +2 -0
  129. rasa/shared/nlu/training_data/features.py +2 -120
  130. rasa/shared/providers/_configs/__init__.py +0 -0
  131. rasa/shared/providers/_configs/azure_openai_client_config.py +181 -0
  132. rasa/shared/providers/_configs/client_config.py +57 -0
  133. rasa/shared/providers/_configs/default_litellm_client_config.py +130 -0
  134. rasa/shared/providers/_configs/huggingface_local_embedding_client_config.py +234 -0
  135. rasa/shared/providers/_configs/openai_client_config.py +175 -0
  136. rasa/shared/providers/_configs/self_hosted_llm_client_config.py +171 -0
  137. rasa/shared/providers/_configs/utils.py +101 -0
  138. rasa/shared/providers/_ssl_verification_utils.py +124 -0
  139. rasa/shared/providers/embedding/__init__.py +0 -0
  140. rasa/shared/providers/embedding/_base_litellm_embedding_client.py +254 -0
  141. rasa/shared/providers/embedding/_langchain_embedding_client_adapter.py +74 -0
  142. rasa/shared/providers/embedding/azure_openai_embedding_client.py +277 -0
  143. rasa/shared/providers/embedding/default_litellm_embedding_client.py +102 -0
  144. rasa/shared/providers/embedding/embedding_client.py +90 -0
  145. rasa/shared/providers/embedding/embedding_response.py +41 -0
  146. rasa/shared/providers/embedding/huggingface_local_embedding_client.py +191 -0
  147. rasa/shared/providers/embedding/openai_embedding_client.py +172 -0
  148. rasa/shared/providers/llm/__init__.py +0 -0
  149. rasa/shared/providers/llm/_base_litellm_client.py +227 -0
  150. rasa/shared/providers/llm/azure_openai_llm_client.py +338 -0
  151. rasa/shared/providers/llm/default_litellm_llm_client.py +84 -0
  152. rasa/shared/providers/llm/llm_client.py +76 -0
  153. rasa/shared/providers/llm/llm_response.py +50 -0
  154. rasa/shared/providers/llm/openai_llm_client.py +155 -0
  155. rasa/shared/providers/llm/self_hosted_llm_client.py +169 -0
  156. rasa/shared/providers/mappings.py +75 -0
  157. rasa/shared/utils/cli.py +30 -0
  158. rasa/shared/utils/io.py +65 -3
  159. rasa/shared/utils/llm.py +223 -200
  160. rasa/shared/utils/yaml.py +122 -7
  161. rasa/studio/download.py +19 -13
  162. rasa/studio/train.py +2 -3
  163. rasa/studio/upload.py +2 -3
  164. rasa/telemetry.py +113 -58
  165. rasa/tracing/config.py +2 -3
  166. rasa/tracing/instrumentation/attribute_extractors.py +29 -17
  167. rasa/tracing/instrumentation/instrumentation.py +4 -47
  168. rasa/utils/common.py +18 -19
  169. rasa/utils/endpoints.py +7 -4
  170. rasa/utils/io.py +66 -0
  171. rasa/utils/json_utils.py +60 -0
  172. rasa/utils/licensing.py +9 -1
  173. rasa/utils/ml_utils.py +4 -2
  174. rasa/utils/tensorflow/model_data.py +193 -2
  175. rasa/validator.py +195 -1
  176. rasa/version.py +1 -1
  177. {rasa_pro-3.9.17.dist-info → rasa_pro-3.10.3.dist-info}/METADATA +25 -51
  178. {rasa_pro-3.9.17.dist-info → rasa_pro-3.10.3.dist-info}/RECORD +183 -119
  179. rasa/nlu/classifiers/llm_intent_classifier.py +0 -519
  180. rasa/shared/providers/openai/clients.py +0 -43
  181. rasa/shared/providers/openai/session_handler.py +0 -110
  182. rasa/utils/tensorflow/feature_array.py +0 -366
  183. /rasa/{shared/providers/openai → cli/project_templates/tutorial/actions}/__init__.py +0 -0
  184. /rasa/cli/project_templates/tutorial/{actions.py → actions/actions.py} +0 -0
  185. {rasa_pro-3.9.17.dist-info → rasa_pro-3.10.3.dist-info}/NOTICE +0 -0
  186. {rasa_pro-3.9.17.dist-info → rasa_pro-3.10.3.dist-info}/WHEEL +0 -0
  187. {rasa_pro-3.9.17.dist-info → rasa_pro-3.10.3.dist-info}/entry_points.txt +0 -0
README.md CHANGED
@@ -236,39 +236,6 @@ To check the types execute
236
236
  make types
237
237
  ```
238
238
 
239
- ### Backporting
240
-
241
- In order to port changes to `main` and across release branches, we use the `backport` workflow located at
242
- the `.github/workflows/backport.yml` path.
243
- This workflow is triggered by the `backport-to-<release-branch>` label applied to a PR, for example `backport-to-3.8.x`.
244
- Current available target branches are `main` and maintained release branches.
245
-
246
- When a PR gets labelled `backport-to-<release-branch>`, a PR is opened by the `backport-github-action` as soon as the
247
- source PR gets closed (by merging). If you want to close the PR without merging changes, make sure to remove the `backport-to-<release-branch>` label.
248
-
249
- The PR author which the action assigns to the backporting PR has to resolve any conflicts before approving and merging.
250
- Release PRs should also be labelled with `backport-to-main` to backport the `CHANGELOG.md` updates to `main`.
251
- Backporting version updates should be accepted to the `main` branch from the latest release branch only.
252
-
253
- Here are some guidelines to follow when backporting changes and resolving conflicts:
254
-
255
- a) for conflicts in `version.py`: accept only the version from the latest release branch. Do not merge version changes
256
- from earlier release branches into `main` because this could cause issues when trying to make the next minor release.
257
-
258
- b) for conflicts in `pyproject.toml`: if related to the `rasa-pro` version, accept only the latest release branch;
259
- if related to other dependencies, accept `main` or whichever is the higher upgrade (main usually has the updated
260
- dependencies because we only do housekeeping on `main`, apart from vulnerability updates). Be mindful of dependencies that
261
- are removed from `main` but still exist in former release branches (for example `langchain`).
262
-
263
- c) for conflicts in `poetry.lock`: accept changes which were already present on the target branch, then run
264
- `poetry lock --no-update` so that the lock file contains your changes from `pyproject.toml` too.
265
-
266
- d) for conflicts in `CHANGELOG.md`: Manually place the changelog in their allocated section (e.g. 3.8.10 will go under the
267
- 3.8 section with the other releases, rather than go at the top of the file)
268
-
269
- If the backporting workflow fails, you are encouraged to cherry-pick the commits manually and create a PR to
270
- the target branch. Alternatively, you can install the backporting CLI tool as described [here](https://github.com/sorenlouv/backport?tab=readme-ov-file#install).
271
-
272
239
  ## Releases
273
240
  Rasa has implemented robust policies governing version naming, as well as release pace for major, minor, and patch releases.
274
241
 
@@ -351,12 +318,9 @@ Releasing a new version is quite simple, as the packages are build and distribut
351
318
  9. If however an error occurs in the build, then we should see a failure message automatically posted in the company's Slack (`dev-tribe` channel) like this [one](https://rasa-hq.slack.com/archives/C01M5TAHDHA/p1701444735622919)
352
319
  (In this case do the following checks):
353
320
  - Check the workflows in [Github Actions](https://github.com/RasaHQ/rasa-private/actions) and make sure that the merged PR of the current release is completed successfully. To easily find your PR you can use the filters `event: push` and `branch: <version number>` (example on release 2.4 you can see [here](https://github.com/RasaHQ/rasa/actions/runs/643344876))
354
- - If the workflow is not completed, then try to re-run the workflow in case that solves the problem
321
+ - If the workflow is not completed, then try to re run the workflow in case that solves the problem
355
322
  - If the problem persists, check also the log files and try to find the root cause of the issue
356
323
  - If you still cannot resolve the error, contact the infrastructure team by providing any helpful information from your investigation
357
- 10. If the release is successful, add the newly created release branch to the backporting configuration in the `.backportrc.json` file to
358
- the `targetBranchesChoices` list. This is necessary for the backporting workflow to work correctly with new release branches.
359
-
360
324
 
361
325
  ### Cutting a Patch release
362
326
 
@@ -405,6 +369,10 @@ steps.
405
369
 
406
370
  Please refer to the [Rasa Product Release and Maintenance Policy](https://rasa.com/rasa-product-release-and-maintenance-policy/) page.
407
371
 
372
+ ### Active workflows on the CI
373
+
374
+ Please refer to the [WORKFLOW_README FILE](https://github.com/RasaHQ/rasa-private/blob/main/WORKFLOW_README.md)
375
+
408
376
  ## Troubleshooting
409
377
 
410
378
  - When running docker commands, if you encounter this error: `OSError No space left on device`, consider running:
rasa/__init__.py CHANGED
@@ -1,7 +1,6 @@
1
1
  import logging
2
2
 
3
- from rasa import version, plugin # noqa: F401
4
- from rasa.api import run, train, test # noqa: F401
3
+ from rasa import version
5
4
 
6
5
  # define the version before the other imports since these need it
7
6
  __version__ = version.__version__
rasa/__main__.py CHANGED
@@ -25,6 +25,7 @@ from rasa.cli import (
25
25
  visualize,
26
26
  x,
27
27
  evaluate,
28
+ llm_fine_tuning,
28
29
  )
29
30
  from rasa.cli.arguments.default_arguments import add_logging_options
30
31
  from rasa.cli.utils import (
@@ -76,6 +77,7 @@ def create_argument_parser() -> argparse.ArgumentParser:
76
77
  export.add_subparser(subparsers, parents=parent_parsers)
77
78
  x.add_subparser(subparsers, parents=parent_parsers)
78
79
  evaluate.add_subparser(subparsers, parents=parent_parsers)
80
+ llm_fine_tuning.add_subparser(subparsers, parent_parsers)
79
81
  plugin_manager().hook.refine_cli(
80
82
  subparsers=subparsers, parent_parsers=parent_parsers
81
83
  )
@@ -85,12 +87,15 @@ def create_argument_parser() -> argparse.ArgumentParser:
85
87
 
86
88
  def print_version() -> None:
87
89
  """Prints version information of rasa tooling and python."""
90
+ from rasa.utils.licensing import get_license_expiration_date
91
+
88
92
  print(f"Rasa Version : {version.__version__}")
89
93
  print(f"Minimum Compatible Version: {MINIMUM_COMPATIBLE_VERSION}")
90
94
  print(f"Rasa SDK Version : {rasa_sdk_version}")
91
95
  print(f"Python Version : {platform.python_version()}")
92
96
  print(f"Operating System : {platform.platform()}")
93
97
  print(f"Python Path : {sys.executable}")
98
+ print(f"License Expires : {get_license_expiration_date()}")
94
99
 
95
100
 
96
101
  def main() -> None:
@@ -123,7 +123,7 @@ class AnonymizationRuleExecutor:
123
123
  else None
124
124
  )
125
125
 
126
- self.anonymizer_engine = AnonymizerEngine()
126
+ self.anonymizer_engine = AnonymizerEngine() # type: ignore
127
127
 
128
128
  @staticmethod
129
129
  def _validate_anonymization_rule_list(
@@ -146,7 +146,7 @@ class AnonymizationRuleExecutor:
146
146
 
147
147
  return True
148
148
 
149
- def run(self, text: Text) -> Text:
149
+ def run(self, text: Text) -> Optional[Text]:
150
150
  """Anonymizes the given text using the given anonymization rule list."""
151
151
  if (
152
152
  self.analyzer is None
rasa/api.py CHANGED
@@ -1,6 +1,8 @@
1
- from typing import Any, Text, Dict, Union, List, Optional, TYPE_CHECKING
2
1
  import asyncio
2
+ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Text, Union
3
+
3
4
  import rasa.shared.constants
5
+ from rasa.nlu.persistor import StorageType
4
6
 
5
7
  # WARNING: Be careful about adding any top level imports at this place!
6
8
  # These functions are imported in `rasa.__init__` and any top level import
@@ -15,11 +17,11 @@ if TYPE_CHECKING:
15
17
 
16
18
 
17
19
  def run(
18
- model: "Text",
19
- endpoints: "Text",
20
- connector: "Optional[Text]" = None,
21
- credentials: "Optional[Text]" = None,
22
- **kwargs: "Dict[Text, Any]",
20
+ model: Text,
21
+ endpoints: Text,
22
+ connector: Optional[Text] = None,
23
+ credentials: Optional[Text] = None,
24
+ **kwargs: Dict[Text, Any],
23
25
  ) -> None:
24
26
  """Runs a Rasa model.
25
27
 
@@ -34,10 +36,10 @@ def run(
34
36
 
35
37
  """
36
38
  import rasa.core.run
37
- from rasa.core.utils import AvailableEndpoints
38
- from rasa.shared.utils.cli import print_warning
39
39
  import rasa.shared.utils.common
40
+ from rasa.core.utils import AvailableEndpoints
40
41
  from rasa.shared.constants import DOCS_BASE_URL
42
+ from rasa.shared.utils.cli import print_warning
41
43
 
42
44
  _endpoints = AvailableEndpoints.read_endpoints(endpoints)
43
45
 
@@ -63,18 +65,19 @@ def run(
63
65
 
64
66
 
65
67
  def train(
66
- domain: "Text",
67
- config: "Text",
68
+ domain: Text,
69
+ config: Text,
68
70
  training_files: "Union[Text, List[Text]]",
69
- output: "Text" = rasa.shared.constants.DEFAULT_MODELS_PATH,
71
+ output: Text = rasa.shared.constants.DEFAULT_MODELS_PATH,
70
72
  dry_run: bool = False,
71
73
  force_training: bool = False,
72
- fixed_model_name: "Optional[Text]" = None,
74
+ fixed_model_name: Optional[Text] = None,
73
75
  persist_nlu_training_data: bool = False,
74
- core_additional_arguments: "Optional[Dict]" = None,
75
- nlu_additional_arguments: "Optional[Dict]" = None,
76
- model_to_finetune: "Optional[Text]" = None,
76
+ core_additional_arguments: Optional[Dict] = None,
77
+ nlu_additional_arguments: Optional[Dict] = None,
78
+ model_to_finetune: Optional[Text] = None,
77
79
  finetuning_epoch_fraction: float = 1.0,
80
+ remote_storage: Optional[StorageType] = None,
78
81
  ) -> "TrainingResult":
79
82
  """Runs Rasa Core and NLU training in `async` loop.
80
83
 
@@ -96,6 +99,7 @@ def train(
96
99
  a directory in case the latest trained model should be used.
97
100
  finetuning_epoch_fraction: The fraction currently specified training epochs
98
101
  in the model configuration which should be used for finetuning.
102
+ remote_storage: Remote storage to use for model storage.
99
103
 
100
104
  Returns:
101
105
  An instance of `TrainingResult`.
@@ -116,16 +120,17 @@ def train(
116
120
  nlu_additional_arguments=nlu_additional_arguments,
117
121
  model_to_finetune=model_to_finetune,
118
122
  finetuning_epoch_fraction=finetuning_epoch_fraction,
123
+ remote_storage=remote_storage,
119
124
  )
120
125
  )
121
126
 
122
127
 
123
128
  def test(
124
- model: "Text",
125
- stories: "Text",
126
- nlu_data: "Text",
127
- output: "Text" = rasa.shared.constants.DEFAULT_RESULTS_PATH,
128
- additional_arguments: "Optional[Dict]" = None,
129
+ model: Text,
130
+ stories: Text,
131
+ nlu_data: Text,
132
+ output: Text = rasa.shared.constants.DEFAULT_RESULTS_PATH,
133
+ additional_arguments: Optional[Dict] = None,
129
134
  ) -> None:
130
135
  """Test a Rasa model against a set of test data.
131
136
 
@@ -136,8 +141,7 @@ def test(
136
141
  output: path to folder where all output will be stored
137
142
  additional_arguments: additional arguments for the test call
138
143
  """
139
- from rasa.model_testing import test_core
140
- from rasa.model_testing import test_nlu
144
+ from rasa.model_testing import test_core, test_nlu
141
145
 
142
146
  if additional_arguments is None:
143
147
  additional_arguments = {}
@@ -10,8 +10,8 @@ from rasa.cli.arguments.default_arguments import (
10
10
  from rasa.shared.constants import DEFAULT_CONVERTED_DATA_PATH
11
11
 
12
12
 
13
- def set_convert_arguments(parser: argparse.ArgumentParser, data_type: Text) -> None:
14
- """Sets convert command arguments."""
13
+ def set_convert_nlu_arguments(parser: argparse.ArgumentParser, data_type: Text) -> None:
14
+ """Sets convert nlu command arguments."""
15
15
  parser.add_argument(
16
16
  "-f",
17
17
  "--format",
@@ -32,6 +32,31 @@ def set_convert_arguments(parser: argparse.ArgumentParser, data_type: Text) -> N
32
32
  parser.add_argument("-l", "--language", default="en", help="Language of data.")
33
33
 
34
34
 
35
+ def set_convert_e2e_arguments(parser: argparse.ArgumentParser) -> None:
36
+ """Sets convert e2e command arguments.
37
+
38
+ Args:
39
+ parser: Parser we are going to attach arguments to.
40
+ """
41
+ parser.add_argument(
42
+ "path",
43
+ type=str,
44
+ help="Path to the input CSV or XLS/XLSX file.",
45
+ )
46
+ parser.add_argument(
47
+ "-o",
48
+ "--output",
49
+ type=str,
50
+ default="e2e_tests",
51
+ help="Output directory to store the tests.",
52
+ )
53
+ parser.add_argument(
54
+ "--sheet-name",
55
+ type=str,
56
+ help="Worksheet name containing relevant data. Mandatory for Excel file input.",
57
+ )
58
+
59
+
35
60
  def set_split_arguments(parser: argparse.ArgumentParser) -> None:
36
61
  add_nlu_data_param(parser, help_text="File or folder containing your NLU data.")
37
62
 
@@ -1,13 +1,14 @@
1
1
  import argparse
2
2
  import logging
3
- from typing import Text, Union, Optional
3
+ from typing import Optional, Text, Union
4
4
 
5
+ from rasa.nlu.persistor import RemoteStorageType, StorageType, parse_remote_storage
5
6
  from rasa.shared.constants import (
6
7
  DEFAULT_CONFIG_PATH,
7
- DEFAULT_DOMAIN_PATH,
8
- DEFAULT_MODELS_PATH,
9
8
  DEFAULT_DATA_PATH,
9
+ DEFAULT_DOMAIN_PATH,
10
10
  DEFAULT_ENDPOINTS_PATH,
11
+ DEFAULT_MODELS_PATH,
11
12
  )
12
13
 
13
14
 
@@ -163,3 +164,24 @@ def add_logging_options(parser: argparse.ArgumentParser) -> None:
163
164
  help="If set, the name of the logging configuration file will be set "
164
165
  "to the given name.",
165
166
  )
167
+
168
+
169
+ def add_remote_storage_param(
170
+ parser: Union[argparse.ArgumentParser, argparse._ActionsContainer],
171
+ required: bool = False,
172
+ ) -> None:
173
+ parser.add_argument(
174
+ "--remote-storage",
175
+ help="Remote storage which should be used to store/load the model."
176
+ f"Supported storages are: {RemoteStorageType.list()}. "
177
+ "You can also provide your own implementation of the `Persistor` interface.",
178
+ required=required,
179
+ type=parse_remote_storage_arg,
180
+ )
181
+
182
+
183
+ def parse_remote_storage_arg(value: str) -> StorageType:
184
+ try:
185
+ return parse_remote_storage(value)
186
+ except ValueError as e:
187
+ raise argparse.ArgumentTypeError(str(e))
rasa/cli/arguments/run.py CHANGED
@@ -1,16 +1,19 @@
1
- import os
2
-
3
1
  import argparse
2
+ import os
4
3
  from typing import Union
5
4
 
6
- from rasa.cli.arguments.default_arguments import add_model_param, add_endpoint_param
5
+ from rasa.cli.arguments.default_arguments import (
6
+ add_endpoint_param,
7
+ add_model_param,
8
+ add_remote_storage_param,
9
+ )
7
10
  from rasa.core import constants
8
11
  from rasa.env import (
12
+ AUTH_TOKEN_ENV,
9
13
  DEFAULT_JWT_METHOD,
10
14
  JWT_METHOD_ENV,
11
- JWT_SECRET_ENV,
12
15
  JWT_PRIVATE_KEY_ENV,
13
- AUTH_TOKEN_ENV,
16
+ JWT_SECRET_ENV,
14
17
  )
15
18
 
16
19
 
@@ -136,10 +139,7 @@ def add_server_settings_arguments(parser: argparse.ArgumentParser) -> None:
136
139
  type=int,
137
140
  help="Maximum time a request can take to process (sec).",
138
141
  )
139
- server_arguments.add_argument(
140
- "--remote-storage",
141
- help="Set the remote location where your Rasa model is stored, e.g. on AWS.",
142
- )
142
+ add_remote_storage_param(server_arguments)
143
143
  server_arguments.add_argument(
144
144
  "--ssl-certificate",
145
145
  help="Set the SSL Certificate to create a TLS secured server.",
@@ -8,6 +8,7 @@ from rasa.cli.arguments.default_arguments import (
8
8
  add_out_param,
9
9
  add_domain_param,
10
10
  add_endpoint_param,
11
+ add_remote_storage_param,
11
12
  )
12
13
  from rasa.graph_components.providers.training_tracker_provider import (
13
14
  TrainingTrackerProvider,
@@ -38,6 +39,7 @@ def set_train_arguments(parser: argparse.ArgumentParser) -> None:
38
39
  add_endpoint_param(
39
40
  parser, help_text="Configuration file for the connectors as a yml file."
40
41
  )
42
+ add_remote_storage_param(parser)
41
43
 
42
44
 
43
45
  def set_train_core_arguments(parser: argparse.ArgumentParser) -> None:
rasa/cli/data.py CHANGED
@@ -3,28 +3,36 @@ import logging
3
3
  import pathlib
4
4
  from typing import List
5
5
 
6
+ import rasa.cli.utils
6
7
  import rasa.shared.core.domain
8
+ import rasa.shared.data
9
+ import rasa.shared.nlu.training_data.loading
10
+ import rasa.shared.nlu.training_data.util
11
+ import rasa.shared.utils.cli
12
+ import rasa.shared.utils.io
13
+ import rasa.utils.common
7
14
  from rasa import telemetry
8
15
  from rasa.cli import SubParsersAction
9
16
  from rasa.cli.arguments import data as arguments
10
17
  from rasa.cli.arguments import default_arguments
11
- import rasa.cli.utils
18
+ from rasa.e2e_test.e2e_config import create_llm_e2e_test_converter_config
19
+ from rasa.e2e_test.e2e_test_converter import E2ETestConverter
20
+ from rasa.e2e_test.utils.e2e_yaml_utils import E2ETestYAMLWriter
12
21
  from rasa.shared.constants import (
13
22
  DEFAULT_DATA_PATH,
14
23
  DEFAULT_CONFIG_PATH,
15
24
  DEFAULT_DOMAIN_PATHS,
16
25
  )
17
- import rasa.shared.data
26
+ from rasa.shared.exceptions import RasaException
18
27
  from rasa.shared.importers.importer import TrainingDataImporter
19
- import rasa.shared.nlu.training_data.loading
20
- import rasa.shared.nlu.training_data.util
21
- import rasa.shared.utils.cli
22
- import rasa.utils.common
23
- import rasa.shared.utils.io
28
+ from rasa.shared.utils.common import minimal_kwargs
24
29
  from rasa.shared.utils.yaml import read_yaml_file, write_yaml
30
+ from rasa.utils.beta import ensure_beta_feature_is_enabled
25
31
 
26
32
  logger = logging.getLogger(__name__)
27
33
 
34
+ RASA_PRO_BETA_E2E_CONVERSION_ENV_VAR_NAME = "RASA_PRO_BETA_E2E_CONVERSION"
35
+
28
36
 
29
37
  def add_subparser(
30
38
  subparsers: SubParsersAction, parents: List[argparse.ArgumentParser]
@@ -71,7 +79,16 @@ def _add_data_convert_parsers(
71
79
  help="Converts NLU data between formats.",
72
80
  )
73
81
  convert_nlu_parser.set_defaults(func=_convert_nlu_data)
74
- arguments.set_convert_arguments(convert_nlu_parser, data_type="Rasa NLU")
82
+ arguments.set_convert_nlu_arguments(convert_nlu_parser, data_type="Rasa NLU")
83
+
84
+ convert_e2e_parser = convert_subparsers.add_parser(
85
+ "e2e",
86
+ formatter_class=argparse.ArgumentDefaultsHelpFormatter,
87
+ parents=parents,
88
+ help="Convert input sample conversations into E2E test cases.",
89
+ )
90
+ convert_e2e_parser.set_defaults(func=convert_data_to_e2e_tests)
91
+ arguments.set_convert_e2e_arguments(convert_e2e_parser)
75
92
 
76
93
 
77
94
  def _add_data_split_parsers(
@@ -290,3 +307,48 @@ def _migrate_domain(args: argparse.Namespace) -> None:
290
307
  import rasa.core.migrate
291
308
 
292
309
  rasa.core.migrate.migrate_domain_format(args.domain, args.out)
310
+
311
+
312
+ def validate_e2e_test_conversion_output_path(output_path: str) -> None:
313
+ """Validates that the provided output path is within the project directory.
314
+
315
+ Args:
316
+ output_path (str): The output path to be validated.
317
+
318
+ Raises:
319
+ RasaException: If the provided output path is an absolute path.
320
+ """
321
+ if pathlib.Path(output_path).is_absolute():
322
+ raise RasaException(
323
+ "Please provide a relative output path within the assistant "
324
+ "project directory in which the command is running."
325
+ )
326
+
327
+
328
+ def convert_data_to_e2e_tests(args: argparse.Namespace) -> None:
329
+ """Converts sample conversation data into E2E test cases
330
+ and stores them in the output YAML file.
331
+
332
+ Args:
333
+ args: The arguments passed in from the CLI.
334
+ """
335
+ try:
336
+ ensure_beta_feature_is_enabled(
337
+ "conversion of sample conversations into end-to-end tests",
338
+ RASA_PRO_BETA_E2E_CONVERSION_ENV_VAR_NAME,
339
+ )
340
+ validate_e2e_test_conversion_output_path(args.output)
341
+
342
+ config_path = pathlib.Path(args.output)
343
+ llm_config = create_llm_e2e_test_converter_config(config_path)
344
+
345
+ kwargs = minimal_kwargs(vars(args), E2ETestConverter)
346
+ converter = E2ETestConverter(llm_config=llm_config, **kwargs)
347
+ yaml_tests_string = converter.run()
348
+
349
+ writer = E2ETestYAMLWriter(output_path=args.output)
350
+ writer.write_to_file(yaml_tests_string)
351
+ except RasaException as exc:
352
+ rasa.shared.utils.cli.print_error_and_exit(
353
+ f"Failed to convert the data into E2E tests. Error: {exc}"
354
+ )