rasa-pro 3.10.10__py3-none-any.whl → 3.10.12__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 (38) hide show
  1. README.md +17 -396
  2. rasa/cli/arguments/train.py +9 -3
  3. rasa/cli/train.py +40 -2
  4. rasa/cli/utils.py +7 -5
  5. rasa/constants.py +1 -1
  6. rasa/core/featurizers/single_state_featurizer.py +22 -1
  7. rasa/core/featurizers/tracker_featurizers.py +115 -18
  8. rasa/core/policies/ted_policy.py +58 -33
  9. rasa/core/policies/unexpected_intent_policy.py +15 -7
  10. rasa/dialogue_understanding/commands/change_flow_command.py +6 -0
  11. rasa/dialogue_understanding/generator/multi_step/multi_step_llm_command_generator.py +20 -3
  12. rasa/dialogue_understanding/generator/single_step/single_step_llm_command_generator.py +29 -4
  13. rasa/e2e_test/e2e_test_runner.py +2 -2
  14. rasa/engine/storage/local_model_storage.py +41 -12
  15. rasa/model_training.py +10 -3
  16. rasa/nlu/classifiers/diet_classifier.py +38 -25
  17. rasa/nlu/classifiers/logistic_regression_classifier.py +22 -9
  18. rasa/nlu/classifiers/sklearn_intent_classifier.py +37 -16
  19. rasa/nlu/extractors/crf_entity_extractor.py +93 -50
  20. rasa/nlu/featurizers/sparse_featurizer/count_vectors_featurizer.py +45 -16
  21. rasa/nlu/featurizers/sparse_featurizer/lexical_syntactic_featurizer.py +52 -17
  22. rasa/nlu/featurizers/sparse_featurizer/regex_featurizer.py +5 -3
  23. rasa/nlu/persistor.py +37 -15
  24. rasa/shared/constants.py +4 -1
  25. rasa/shared/importers/importer.py +7 -8
  26. rasa/shared/nlu/training_data/features.py +120 -2
  27. rasa/shared/utils/io.py +1 -0
  28. rasa/utils/io.py +0 -66
  29. rasa/utils/tensorflow/feature_array.py +366 -0
  30. rasa/utils/tensorflow/model_data.py +2 -193
  31. rasa/version.py +1 -1
  32. rasa_pro-3.10.12.dist-info/METADATA +196 -0
  33. {rasa_pro-3.10.10.dist-info → rasa_pro-3.10.12.dist-info}/RECORD +36 -36
  34. rasa/shared/importers/remote_importer.py +0 -196
  35. rasa_pro-3.10.10.dist-info/METADATA +0 -575
  36. {rasa_pro-3.10.10.dist-info → rasa_pro-3.10.12.dist-info}/NOTICE +0 -0
  37. {rasa_pro-3.10.10.dist-info → rasa_pro-3.10.12.dist-info}/WHEEL +0 -0
  38. {rasa_pro-3.10.10.dist-info → rasa_pro-3.10.12.dist-info}/entry_points.txt +0 -0
@@ -1,196 +0,0 @@
1
- import os
2
- from typing import Dict, List, Optional, Text, Union
3
-
4
- import structlog
5
- from tarsafe import TarSafe
6
-
7
- import rasa.shared.core.flows.yaml_flows_io
8
- import rasa.shared.data
9
- import rasa.shared.utils.common
10
- import rasa.shared.utils.io
11
- from rasa.nlu.persistor import StorageType
12
- from rasa.shared.core.domain import Domain, InvalidDomain
13
- from rasa.shared.core.flows import FlowsList
14
- from rasa.shared.core.training_data.story_reader.yaml_story_reader import (
15
- YAMLStoryReader,
16
- )
17
- from rasa.shared.core.training_data.structures import StoryGraph
18
- from rasa.shared.exceptions import RasaException
19
- from rasa.shared.importers import utils
20
- from rasa.shared.importers.importer import TrainingDataImporter
21
- from rasa.shared.nlu.training_data.training_data import TrainingData
22
- from rasa.shared.utils.yaml import read_model_configuration
23
-
24
- structlogger = structlog.get_logger()
25
-
26
- TRAINING_DATA_ARCHIVE = "training_data.tar.gz"
27
-
28
-
29
- class RemoteTrainingDataImporter(TrainingDataImporter):
30
- """Remote `TrainingFileImporter` implementation.
31
-
32
- Fetches training data from a remote storage and extracts it to a local directory.
33
- Extracted training data is then used to load flows, NLU, stories,
34
- domain, and config files.
35
- """
36
-
37
- def __init__(
38
- self,
39
- config_file: Optional[Text] = None,
40
- domain_path: Optional[Text] = None,
41
- training_data_paths: Optional[Union[List[Text], Text]] = None,
42
- project_directory: Optional[Text] = None,
43
- remote_storage: Optional[StorageType] = None,
44
- training_data_path: Optional[Text] = None,
45
- ):
46
- """Initializes `RemoteTrainingDataImporter`.
47
-
48
- Args:
49
- config_file: Path to the model configuration file.
50
- domain_path: Path to the domain file.
51
- training_data_paths: List of paths to the training data files.
52
- project_directory: Path to the project directory.
53
- remote_storage: Storage to use to load the training data.
54
- training_data_path: Path to the training data.
55
- """
56
- self.remote_storage = remote_storage
57
- self.training_data_path = training_data_path
58
-
59
- self.extracted_path = self._fetch_and_extract_training_archive(
60
- TRAINING_DATA_ARCHIVE, self.training_data_path
61
- )
62
-
63
- self._nlu_files = rasa.shared.data.get_data_files(
64
- self.extracted_path, rasa.shared.data.is_nlu_file
65
- )
66
- self._story_files = rasa.shared.data.get_data_files(
67
- self.extracted_path, YAMLStoryReader.is_stories_file
68
- )
69
- self._flow_files = rasa.shared.data.get_data_files(
70
- self.extracted_path, rasa.shared.core.flows.yaml_flows_io.is_flows_file
71
- )
72
- self._conversation_test_files = rasa.shared.data.get_data_files(
73
- self.extracted_path, YAMLStoryReader.is_test_stories_file
74
- )
75
-
76
- self.config_file = config_file
77
-
78
- def _fetch_training_archive(
79
- self, training_file: str, training_data_path: Optional[str] = None
80
- ) -> str:
81
- """Fetches training files from remote storage."""
82
- from rasa.nlu.persistor import get_persistor
83
-
84
- persistor = get_persistor(self.remote_storage)
85
- if persistor is None:
86
- raise RasaException(
87
- f"Could not find a persistor for "
88
- f"the storage type '{self.remote_storage}'."
89
- )
90
-
91
- return persistor.retrieve(training_file, training_data_path)
92
-
93
- def _fetch_and_extract_training_archive(
94
- self, training_file: str, training_data_path: Optional[Text] = None
95
- ) -> Optional[str]:
96
- """Fetches and extracts training files from remote storage.
97
-
98
- If the `training_data_path` is not provided, the training
99
- data is extracted to the current working directory.
100
-
101
- Args:
102
- training_file: Name of the training data archive file.
103
- training_data_path: Path to the training data.
104
-
105
- Returns:
106
- Path to the extracted training data.
107
- """
108
-
109
- if training_data_path is None:
110
- training_data_path = os.path.join(os.getcwd(), "data")
111
-
112
- if os.path.isfile(training_data_path):
113
- raise ValueError(
114
- f"Training data path '{training_data_path}' is a file. "
115
- f"Please provide a directory path."
116
- )
117
-
118
- structlogger.debug(
119
- "rasa.importers.remote_training_data_importer.fetch_training_archive",
120
- training_data_path=training_data_path,
121
- )
122
- training_archive_file_path = self._fetch_training_archive(
123
- training_file, training_data_path
124
- )
125
-
126
- if not os.path.isfile(training_archive_file_path):
127
- raise FileNotFoundError(
128
- f"Training data archive '{training_archive_file_path}' not found. "
129
- f"Please make sure to provide the correct path."
130
- )
131
-
132
- structlogger.debug(
133
- "rasa.importers.remote_training_data_importer.extract_training_archive",
134
- training_archive_file_path=training_archive_file_path,
135
- training_data_path=training_data_path,
136
- )
137
- with TarSafe.open(training_archive_file_path, "r:gz") as tar:
138
- tar.extractall(path=training_data_path)
139
-
140
- structlogger.debug(
141
- "rasa.importers.remote_training_data_importer.remove_downloaded_archive",
142
- training_data_path=training_data_path,
143
- )
144
- os.remove(training_archive_file_path)
145
- return training_data_path
146
-
147
- def get_config(self) -> Dict:
148
- """Retrieves model config (see parent class for full docstring)."""
149
- if not self.config_file or not os.path.exists(self.config_file):
150
- structlogger.debug(
151
- "rasa.importers.remote_training_data_importer.no_config_file",
152
- message="No configuration file was provided to the RasaFileImporter.",
153
- )
154
- return {}
155
-
156
- config = read_model_configuration(self.config_file)
157
- return config
158
-
159
- @rasa.shared.utils.common.cached_method
160
- def get_config_file_for_auto_config(self) -> Optional[Text]:
161
- """Returns config file path for auto-config only if there is a single one."""
162
- return self.config_file
163
-
164
- def get_stories(self, exclusion_percentage: Optional[int] = None) -> StoryGraph:
165
- """Retrieves training stories / rules (see parent class for full docstring)."""
166
- return utils.story_graph_from_paths(
167
- self._story_files, self.get_domain(), exclusion_percentage
168
- )
169
-
170
- def get_flows(self) -> FlowsList:
171
- """Retrieves training stories / rules (see parent class for full docstring)."""
172
- return utils.flows_from_paths(self._flow_files)
173
-
174
- def get_conversation_tests(self) -> StoryGraph:
175
- """Retrieves conversation test stories (see parent class for full docstring)."""
176
- return utils.story_graph_from_paths(
177
- self._conversation_test_files, self.get_domain()
178
- )
179
-
180
- def get_nlu_data(self, language: Optional[Text] = "en") -> TrainingData:
181
- """Retrieves NLU training data (see parent class for full docstring)."""
182
- return utils.training_data_from_paths(self._nlu_files, language)
183
-
184
- def get_domain(self) -> Domain:
185
- """Retrieves model domain (see parent class for full docstring)."""
186
- domain = Domain.empty()
187
- domain_path = f"{self.extracted_path}"
188
- try:
189
- domain = Domain.load(domain_path)
190
- except InvalidDomain as e:
191
- rasa.shared.utils.io.raise_warning(
192
- f"Loading domain from '{domain_path}' failed. Using "
193
- f"empty domain. Error: '{e}'"
194
- )
195
-
196
- return domain