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.
- README.md +396 -17
- rasa/__main__.py +15 -31
- rasa/api.py +1 -5
- rasa/cli/arguments/default_arguments.py +2 -1
- rasa/cli/arguments/shell.py +1 -5
- rasa/cli/arguments/train.py +0 -14
- rasa/cli/e2e_test.py +1 -1
- rasa/cli/evaluate.py +8 -8
- rasa/cli/inspect.py +7 -15
- rasa/cli/interactive.py +0 -1
- rasa/cli/llm_fine_tuning.py +1 -1
- rasa/cli/project_templates/calm/config.yml +7 -5
- rasa/cli/project_templates/calm/endpoints.yml +2 -15
- rasa/cli/project_templates/tutorial/config.yml +5 -8
- rasa/cli/project_templates/tutorial/data/flows.yml +1 -1
- rasa/cli/project_templates/tutorial/data/patterns.yml +0 -5
- rasa/cli/project_templates/tutorial/domain.yml +0 -14
- rasa/cli/project_templates/tutorial/endpoints.yml +0 -5
- rasa/cli/run.py +1 -1
- rasa/cli/scaffold.py +2 -4
- rasa/cli/studio/studio.py +8 -18
- rasa/cli/studio/upload.py +15 -0
- rasa/cli/train.py +0 -3
- rasa/cli/utils.py +1 -6
- rasa/cli/x.py +8 -8
- rasa/constants.py +1 -3
- rasa/core/actions/action.py +33 -75
- rasa/core/actions/e2e_stub_custom_action_executor.py +1 -5
- rasa/core/actions/http_custom_action_executor.py +0 -4
- rasa/core/channels/__init__.py +0 -2
- rasa/core/channels/channel.py +0 -20
- rasa/core/channels/development_inspector.py +3 -10
- rasa/core/channels/inspector/dist/assets/{arc-bc141fb2.js → arc-86942a71.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-d0fbc5ce-be2db283.js → c4Diagram-d0fbc5ce-b0290676.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-936ed81e-55366915.js → classDiagram-936ed81e-f6405f6e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-v2-c3cb15f1-bb529518.js → classDiagram-v2-c3cb15f1-ef61ac77.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{createText-62fc7601-b0ec81d6.js → createText-62fc7601-f0411e58.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{edges-f2ad444c-6166330c.js → edges-f2ad444c-7dcc4f3b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-9d236eb7-5ccc6a8e.js → erDiagram-9d236eb7-e0c092d7.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDb-1972c806-fca3bfe4.js → flowDb-1972c806-fba2e3ce.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDiagram-7ea5b25a-4739080f.js → flowDiagram-7ea5b25a-7a70b71a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-855bc5b3-24a5f41a.js +1 -0
- rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-abe16c3d-7c1b0e0f.js → flowchart-elk-definition-abe16c3d-00a59b68.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-9b5ea136-772fd050.js → ganttDiagram-9b5ea136-293c91fa.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-99d0ae7c-8eae1dc9.js → gitGraphDiagram-99d0ae7c-07b2d68c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-2c4b9a3b-f55afcdf.js → index-2c4b9a3b-bc959fbd.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-e7cef9de.js → index-3a8a5a28.js} +143 -143
- rasa/core/channels/inspector/dist/assets/{infoDiagram-736b4530-124d4a14.js → infoDiagram-736b4530-4a350f72.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-df861f2b-7c4fae44.js → journeyDiagram-df861f2b-af464fb7.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-b9885fb6.js → layout-0071f036.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{line-7c59abb6.js → line-2f73cc83.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-4776f780.js → linear-f014b4cc.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-beec6740-2332c46c.js → mindmap-definition-beec6740-d2426fb6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{pieDiagram-dbbf0591-8fb39303.js → pieDiagram-dbbf0591-776f01a2.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-4d7f4fd6-3c7180a2.js → quadrantDiagram-4d7f4fd6-82e00b57.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-6fc4c22a-e910bcb8.js → requirementDiagram-6fc4c22a-ea13c6bb.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-8f13d901-ead16c89.js → sankeyDiagram-8f13d901-1feca7e9.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-b655622a-29a02a19.js → sequenceDiagram-b655622a-070c61d2.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-59f0c015-042b3137.js → stateDiagram-59f0c015-24f46263.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-2b26beab-2178c0f3.js → stateDiagram-v2-2b26beab-c9056051.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-080da4f6-23ffa4fc.js → styles-080da4f6-08abc34a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-3dcbcfbf-94f59763.js → styles-3dcbcfbf-bc74c25a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-9c745c82-78a6bebc.js → styles-9c745c82-4e5d66de.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{svgDrawCommon-4835440b-eae2a6f6.js → svgDrawCommon-4835440b-849c4517.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{timeline-definition-5b62e21b-5c968d92.js → timeline-definition-5b62e21b-d0fb1598.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-2b33534f-fd3db0d5.js → xychartDiagram-2b33534f-04d115e2.js} +1 -1
- rasa/core/channels/inspector/dist/index.html +1 -1
- rasa/core/channels/inspector/src/App.tsx +1 -1
- rasa/core/channels/inspector/src/components/LoadingSpinner.tsx +3 -6
- rasa/core/channels/socketio.py +2 -7
- rasa/core/channels/telegram.py +1 -1
- rasa/core/channels/twilio.py +1 -1
- rasa/core/channels/voice_ready/audiocodes.py +4 -15
- rasa/core/channels/voice_ready/jambonz.py +4 -15
- rasa/core/channels/voice_ready/twilio_voice.py +21 -6
- rasa/core/channels/voice_ready/utils.py +5 -6
- rasa/core/channels/voice_stream/asr/asr_engine.py +1 -19
- rasa/core/channels/voice_stream/asr/asr_event.py +0 -5
- rasa/core/channels/voice_stream/asr/deepgram.py +15 -28
- rasa/core/channels/voice_stream/audio_bytes.py +0 -1
- rasa/core/channels/voice_stream/tts/azure.py +3 -9
- rasa/core/channels/voice_stream/tts/cartesia.py +8 -12
- rasa/core/channels/voice_stream/tts/tts_engine.py +1 -11
- rasa/core/channels/voice_stream/twilio_media_streams.py +19 -28
- rasa/core/channels/voice_stream/util.py +4 -4
- rasa/core/channels/voice_stream/voice_channel.py +42 -222
- rasa/core/featurizers/single_state_featurizer.py +1 -22
- rasa/core/featurizers/tracker_featurizers.py +18 -115
- rasa/core/information_retrieval/qdrant.py +0 -1
- rasa/core/nlg/contextual_response_rephraser.py +25 -44
- rasa/core/persistor.py +34 -191
- rasa/core/policies/enterprise_search_policy.py +60 -119
- rasa/core/policies/flows/flow_executor.py +4 -7
- rasa/core/policies/intentless_policy.py +22 -82
- rasa/core/policies/ted_policy.py +33 -58
- rasa/core/policies/unexpected_intent_policy.py +7 -15
- rasa/core/processor.py +13 -89
- rasa/core/run.py +2 -2
- rasa/core/training/interactive.py +35 -34
- rasa/core/utils.py +22 -58
- rasa/dialogue_understanding/coexistence/llm_based_router.py +12 -39
- rasa/dialogue_understanding/commands/__init__.py +0 -4
- rasa/dialogue_understanding/commands/change_flow_command.py +0 -6
- rasa/dialogue_understanding/commands/utils.py +0 -5
- rasa/dialogue_understanding/generator/constants.py +0 -2
- rasa/dialogue_understanding/generator/flow_retrieval.py +4 -49
- rasa/dialogue_understanding/generator/llm_based_command_generator.py +23 -37
- rasa/dialogue_understanding/generator/multi_step/multi_step_llm_command_generator.py +10 -57
- rasa/dialogue_understanding/generator/nlu_command_adapter.py +1 -19
- rasa/dialogue_understanding/generator/single_step/command_prompt_template.jinja2 +0 -3
- rasa/dialogue_understanding/generator/single_step/single_step_llm_command_generator.py +10 -90
- rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +0 -53
- rasa/dialogue_understanding/processor/command_processor.py +1 -21
- rasa/e2e_test/assertions.py +16 -133
- rasa/e2e_test/assertions_schema.yml +0 -23
- rasa/e2e_test/e2e_test_case.py +6 -85
- rasa/e2e_test/e2e_test_runner.py +4 -6
- rasa/e2e_test/utils/io.py +1 -3
- rasa/engine/loader.py +0 -12
- rasa/engine/validation.py +11 -541
- rasa/keys +1 -0
- rasa/llm_fine_tuning/notebooks/unsloth_finetuning.ipynb +407 -0
- rasa/model_training.py +7 -29
- rasa/nlu/classifiers/diet_classifier.py +25 -38
- rasa/nlu/classifiers/logistic_regression_classifier.py +9 -22
- rasa/nlu/classifiers/sklearn_intent_classifier.py +16 -37
- rasa/nlu/extractors/crf_entity_extractor.py +50 -93
- rasa/nlu/featurizers/sparse_featurizer/count_vectors_featurizer.py +16 -45
- rasa/nlu/featurizers/sparse_featurizer/lexical_syntactic_featurizer.py +17 -52
- rasa/nlu/featurizers/sparse_featurizer/regex_featurizer.py +3 -5
- rasa/nlu/tokenizers/whitespace_tokenizer.py +14 -3
- rasa/server.py +1 -3
- rasa/shared/constants.py +0 -61
- rasa/shared/core/constants.py +0 -9
- rasa/shared/core/domain.py +5 -8
- rasa/shared/core/flows/flow.py +0 -5
- rasa/shared/core/flows/flows_list.py +1 -5
- rasa/shared/core/flows/flows_yaml_schema.json +0 -10
- rasa/shared/core/flows/validation.py +0 -96
- rasa/shared/core/flows/yaml_flows_io.py +4 -13
- rasa/shared/core/slots.py +0 -5
- rasa/shared/importers/importer.py +2 -19
- rasa/shared/importers/rasa.py +1 -5
- rasa/shared/nlu/training_data/features.py +2 -120
- rasa/shared/nlu/training_data/formats/rasa_yaml.py +3 -18
- rasa/shared/providers/_configs/azure_openai_client_config.py +3 -5
- rasa/shared/providers/_configs/openai_client_config.py +1 -1
- rasa/shared/providers/_configs/self_hosted_llm_client_config.py +0 -1
- rasa/shared/providers/_configs/utils.py +0 -16
- rasa/shared/providers/embedding/_base_litellm_embedding_client.py +29 -18
- rasa/shared/providers/embedding/azure_openai_embedding_client.py +21 -54
- rasa/shared/providers/embedding/default_litellm_embedding_client.py +0 -24
- rasa/shared/providers/llm/_base_litellm_client.py +31 -63
- rasa/shared/providers/llm/azure_openai_llm_client.py +29 -50
- rasa/shared/providers/llm/default_litellm_llm_client.py +0 -24
- rasa/shared/providers/llm/self_hosted_llm_client.py +29 -17
- rasa/shared/providers/mappings.py +0 -19
- rasa/shared/utils/common.py +2 -37
- rasa/shared/utils/io.py +6 -28
- rasa/shared/utils/llm.py +46 -353
- rasa/shared/utils/yaml.py +82 -181
- rasa/studio/auth.py +5 -3
- rasa/studio/config.py +4 -13
- rasa/studio/constants.py +0 -1
- rasa/studio/data_handler.py +4 -13
- rasa/studio/upload.py +80 -175
- rasa/telemetry.py +17 -94
- rasa/tracing/config.py +1 -3
- rasa/tracing/instrumentation/attribute_extractors.py +17 -94
- rasa/tracing/instrumentation/instrumentation.py +0 -121
- rasa/utils/common.py +0 -5
- rasa/utils/endpoints.py +1 -27
- rasa/utils/io.py +81 -7
- rasa/utils/log_utils.py +2 -9
- rasa/utils/tensorflow/model_data.py +193 -2
- rasa/validator.py +4 -110
- rasa/version.py +1 -1
- rasa_pro-3.11.0a1.dist-info/METADATA +576 -0
- {rasa_pro-3.11.0.dist-info → rasa_pro-3.11.0a1.dist-info}/RECORD +182 -216
- rasa/core/actions/action_repeat_bot_messages.py +0 -89
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-855bc5b3-736177bf.js +0 -1
- rasa/core/channels/inspector/src/helpers/audiostream.ts +0 -165
- rasa/core/channels/voice_stream/asr/azure.py +0 -129
- rasa/core/channels/voice_stream/browser_audio.py +0 -107
- rasa/core/channels/voice_stream/call_state.py +0 -23
- rasa/dialogue_understanding/commands/repeat_bot_messages_command.py +0 -60
- rasa/dialogue_understanding/commands/user_silence_command.py +0 -59
- rasa/dialogue_understanding/patterns/repeat.py +0 -37
- rasa/dialogue_understanding/patterns/user_silence.py +0 -37
- rasa/model_manager/__init__.py +0 -0
- rasa/model_manager/config.py +0 -40
- rasa/model_manager/model_api.py +0 -559
- rasa/model_manager/runner_service.py +0 -286
- rasa/model_manager/socket_bridge.py +0 -146
- rasa/model_manager/studio_jwt_auth.py +0 -86
- rasa/model_manager/trainer_service.py +0 -325
- rasa/model_manager/utils.py +0 -87
- rasa/model_manager/warm_rasa_process.py +0 -187
- rasa/model_service.py +0 -112
- rasa/shared/core/flows/utils.py +0 -39
- rasa/shared/providers/_configs/litellm_router_client_config.py +0 -220
- rasa/shared/providers/_configs/model_group_config.py +0 -167
- rasa/shared/providers/_configs/rasa_llm_client_config.py +0 -73
- rasa/shared/providers/_utils.py +0 -79
- rasa/shared/providers/embedding/litellm_router_embedding_client.py +0 -135
- rasa/shared/providers/llm/litellm_router_llm_client.py +0 -182
- rasa/shared/providers/llm/rasa_llm_client.py +0 -112
- rasa/shared/providers/router/__init__.py +0 -0
- rasa/shared/providers/router/_base_litellm_router_client.py +0 -183
- rasa/shared/providers/router/router_client.py +0 -73
- rasa/shared/utils/health_check/__init__.py +0 -0
- rasa/shared/utils/health_check/embeddings_health_check_mixin.py +0 -31
- rasa/shared/utils/health_check/health_check.py +0 -258
- rasa/shared/utils/health_check/llm_health_check_mixin.py +0 -31
- rasa/utils/sanic_error_handler.py +0 -32
- rasa/utils/tensorflow/feature_array.py +0 -366
- rasa_pro-3.11.0.dist-info/METADATA +0 -198
- {rasa_pro-3.11.0.dist-info → rasa_pro-3.11.0a1.dist-info}/NOTICE +0 -0
- {rasa_pro-3.11.0.dist-info → rasa_pro-3.11.0a1.dist-info}/WHEEL +0 -0
- {rasa_pro-3.11.0.dist-info → rasa_pro-3.11.0a1.dist-info}/entry_points.txt +0 -0
rasa/studio/data_handler.py
CHANGED
|
@@ -76,9 +76,7 @@ class StudioDataHandler:
|
|
|
76
76
|
|
|
77
77
|
return request
|
|
78
78
|
|
|
79
|
-
def _make_request(
|
|
80
|
-
self, GQL_req: Dict[Any, Any], verify: bool = True
|
|
81
|
-
) -> Dict[Any, Any]:
|
|
79
|
+
def _make_request(self, GQL_req: Dict[Any, Any]) -> Dict[Any, Any]:
|
|
82
80
|
token = KeycloakTokenReader().get_token()
|
|
83
81
|
if token.is_expired():
|
|
84
82
|
token = self.refresh_token(token)
|
|
@@ -95,7 +93,6 @@ class StudioDataHandler:
|
|
|
95
93
|
"Authorization": f"{token.token_type} {token.access_token}",
|
|
96
94
|
"Content-Type": "application/json",
|
|
97
95
|
},
|
|
98
|
-
verify=verify,
|
|
99
96
|
)
|
|
100
97
|
|
|
101
98
|
if res.status_code != 200:
|
|
@@ -131,9 +128,7 @@ class StudioDataHandler:
|
|
|
131
128
|
The data from Rasa Studio.
|
|
132
129
|
"""
|
|
133
130
|
GQL_req = self._build_request()
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
response = self._make_request(GQL_req, verify=verify)
|
|
131
|
+
response = self._make_request(GQL_req)
|
|
137
132
|
self._extract_data(response)
|
|
138
133
|
|
|
139
134
|
def request_data(
|
|
@@ -150,9 +145,7 @@ class StudioDataHandler:
|
|
|
150
145
|
The data from Rasa Studio.
|
|
151
146
|
"""
|
|
152
147
|
GQL_req = self._build_request(intent_names, entity_names)
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
response = self._make_request(GQL_req, verify=verify)
|
|
148
|
+
response = self._make_request(GQL_req)
|
|
156
149
|
self._extract_data(response)
|
|
157
150
|
|
|
158
151
|
def get_config(self) -> Optional[str]:
|
|
@@ -360,9 +353,7 @@ def import_data_from_studio(
|
|
|
360
353
|
studio_domain.persist(domain_file)
|
|
361
354
|
|
|
362
355
|
data_from_studio = TrainingDataImporter.load_from_dict(
|
|
363
|
-
domain_path=str(domain_file),
|
|
364
|
-
training_data_paths=data_paths,
|
|
365
|
-
expand_env_vars=False,
|
|
356
|
+
domain_path=str(domain_file), training_data_paths=data_paths
|
|
366
357
|
)
|
|
367
358
|
|
|
368
359
|
return data_from_studio, data_original
|
rasa/studio/upload.py
CHANGED
|
@@ -15,18 +15,11 @@ from rasa.shared.constants import (
|
|
|
15
15
|
DEFAULT_DOMAIN_PATHS,
|
|
16
16
|
DEFAULT_CONFIG_PATH,
|
|
17
17
|
)
|
|
18
|
-
from rasa.shared.core.
|
|
19
|
-
from rasa.shared.core.flows.yaml_flows_io import YAMLFlowsReader, YamlFlowsWriter
|
|
18
|
+
from rasa.shared.core.flows.yaml_flows_io import YamlFlowsWriter
|
|
20
19
|
from rasa.shared.exceptions import RasaException
|
|
21
20
|
from rasa.shared.importers.importer import TrainingDataImporter, FlowSyncImporter
|
|
22
|
-
from rasa.shared.nlu.training_data.formats.rasa_yaml import
|
|
23
|
-
|
|
24
|
-
RasaYAMLWriter,
|
|
25
|
-
)
|
|
26
|
-
from rasa.shared.utils.yaml import (
|
|
27
|
-
dump_obj_as_yaml_to_string,
|
|
28
|
-
read_yaml_file,
|
|
29
|
-
)
|
|
21
|
+
from rasa.shared.nlu.training_data.formats.rasa_yaml import RasaYAMLWriter
|
|
22
|
+
from rasa.shared.utils.yaml import dump_obj_as_yaml_to_string, read_yaml_file
|
|
30
23
|
from rasa.studio import results_logger
|
|
31
24
|
from rasa.studio.auth import KeycloakTokenReader
|
|
32
25
|
from rasa.studio.config import StudioConfig
|
|
@@ -34,27 +27,6 @@ from rasa.studio.results_logger import StudioResult, with_studio_error_handler
|
|
|
34
27
|
|
|
35
28
|
structlogger = structlog.get_logger()
|
|
36
29
|
|
|
37
|
-
CONFIG_KEYS = [
|
|
38
|
-
"recipe",
|
|
39
|
-
"language",
|
|
40
|
-
"pipeline",
|
|
41
|
-
"llm",
|
|
42
|
-
"policies",
|
|
43
|
-
"model_name",
|
|
44
|
-
"assistant_id",
|
|
45
|
-
]
|
|
46
|
-
|
|
47
|
-
DOMAIN_KEYS = [
|
|
48
|
-
"version",
|
|
49
|
-
"actions",
|
|
50
|
-
"responses",
|
|
51
|
-
"slots",
|
|
52
|
-
"intents",
|
|
53
|
-
"entities",
|
|
54
|
-
"forms",
|
|
55
|
-
"session_config",
|
|
56
|
-
]
|
|
57
|
-
|
|
58
30
|
|
|
59
31
|
def _get_selected_entities_and_intents(
|
|
60
32
|
args: argparse.Namespace,
|
|
@@ -82,81 +54,42 @@ def _get_selected_entities_and_intents(
|
|
|
82
54
|
return list(entities), list(intents)
|
|
83
55
|
|
|
84
56
|
|
|
85
|
-
def run_validation(args: argparse.Namespace) -> None:
|
|
86
|
-
"""Run the validation before uploading to Studio.
|
|
87
|
-
|
|
88
|
-
This is to avoid uploading invalid assistant data
|
|
89
|
-
that would raise errors during Rasa Pro training in Studio.
|
|
90
|
-
|
|
91
|
-
The validation checks that were selected to be run before uploading
|
|
92
|
-
maintain parity with the features that are supported in Studio.
|
|
93
|
-
"""
|
|
94
|
-
from rasa.validator import Validator
|
|
95
|
-
|
|
96
|
-
training_data_importer = TrainingDataImporter.load_from_dict(
|
|
97
|
-
domain_path=args.domain,
|
|
98
|
-
training_data_paths=args.data,
|
|
99
|
-
config_path=args.config,
|
|
100
|
-
expand_env_vars=False,
|
|
101
|
-
)
|
|
102
|
-
|
|
103
|
-
structlogger.info(
|
|
104
|
-
"rasa.studio.upload.validating_data",
|
|
105
|
-
event_info="Validating domain and training data...",
|
|
106
|
-
)
|
|
107
|
-
|
|
108
|
-
validator = Validator.from_importer(training_data_importer)
|
|
109
|
-
|
|
110
|
-
if not validator.verify_studio_supported_validations():
|
|
111
|
-
structlogger.error(
|
|
112
|
-
"rasa.studio.upload.validate_files.project_validation_error",
|
|
113
|
-
event_info="Project validation completed with errors.",
|
|
114
|
-
)
|
|
115
|
-
sys.exit(1)
|
|
116
|
-
|
|
117
|
-
structlogger.info(
|
|
118
|
-
"rasa.studio.upload.validate_files.success",
|
|
119
|
-
event_info="Project validation completed successfully.",
|
|
120
|
-
)
|
|
121
|
-
|
|
122
|
-
|
|
123
57
|
def handle_upload(args: argparse.Namespace) -> None:
|
|
124
58
|
"""Uploads primitives to rasa studio."""
|
|
125
|
-
|
|
126
|
-
endpoint = studio_config.studio_url
|
|
127
|
-
verify = not studio_config.disable_verify
|
|
128
|
-
|
|
59
|
+
endpoint = StudioConfig.read_config().studio_url
|
|
129
60
|
if not endpoint:
|
|
130
61
|
rasa.shared.utils.cli.print_error_and_exit(
|
|
131
62
|
"No GraphQL endpoint found in config. Please run `rasa studio config`."
|
|
132
63
|
)
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
rasa.shared.utils.cli.print_error_and_exit(
|
|
137
|
-
"Authentication is invalid or expired. Please run `rasa studio login`."
|
|
64
|
+
else:
|
|
65
|
+
structlogger.info(
|
|
66
|
+
"rasa.studio.upload.loading_data", event_info="Loading data..."
|
|
138
67
|
)
|
|
139
|
-
return
|
|
140
68
|
|
|
141
|
-
|
|
69
|
+
args.domain = rasa.cli.utils.get_validated_path(
|
|
70
|
+
args.domain, "domain", DEFAULT_DOMAIN_PATHS
|
|
71
|
+
)
|
|
142
72
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
73
|
+
args.config = rasa.cli.utils.get_validated_path(
|
|
74
|
+
args.config, "config", DEFAULT_CONFIG_PATH
|
|
75
|
+
)
|
|
146
76
|
|
|
147
|
-
|
|
148
|
-
args
|
|
149
|
-
|
|
77
|
+
# check safely if args.calm is set and not fail if not
|
|
78
|
+
if hasattr(args, "calm") and args.calm:
|
|
79
|
+
upload_calm_assistant(args, endpoint)
|
|
80
|
+
else:
|
|
81
|
+
upload_nlu_assistant(args, endpoint)
|
|
150
82
|
|
|
151
|
-
Domain.expand_env_vars = False
|
|
152
|
-
RasaYAMLReader.expand_env_vars = False
|
|
153
|
-
YAMLFlowsReader.expand_env_vars = False
|
|
154
83
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
84
|
+
config_keys = [
|
|
85
|
+
"recipe",
|
|
86
|
+
"language",
|
|
87
|
+
"pipeline",
|
|
88
|
+
"llm",
|
|
89
|
+
"policies",
|
|
90
|
+
"model_name",
|
|
91
|
+
"assistant_id",
|
|
92
|
+
]
|
|
160
93
|
|
|
161
94
|
|
|
162
95
|
def extract_values(data: Dict, keys: List[Text]) -> Dict:
|
|
@@ -188,19 +121,13 @@ def _get_assistant_name(config: Dict[Text, Any]) -> str:
|
|
|
188
121
|
),
|
|
189
122
|
)
|
|
190
123
|
|
|
191
|
-
structlogger.info(
|
|
192
|
-
"rasa.studio.upload.name_selected",
|
|
193
|
-
event_info=f"Uploading assistant with the name '{assistant_name}'.",
|
|
194
|
-
assistant_name=assistant_name,
|
|
195
|
-
)
|
|
124
|
+
structlogger.info(f"Uploading assistant with the name '{assistant_name}'.")
|
|
196
125
|
return assistant_name
|
|
197
126
|
|
|
198
127
|
|
|
199
128
|
@with_studio_error_handler
|
|
200
|
-
def upload_calm_assistant(
|
|
201
|
-
|
|
202
|
-
) -> StudioResult:
|
|
203
|
-
"""Validates and uploads the CALM assistant data to Rasa Studio.
|
|
129
|
+
def upload_calm_assistant(args: argparse.Namespace, endpoint: str) -> StudioResult:
|
|
130
|
+
"""Uploads the CALM assistant data to Rasa Studio.
|
|
204
131
|
|
|
205
132
|
Args:
|
|
206
133
|
args: The command line arguments
|
|
@@ -213,8 +140,6 @@ def upload_calm_assistant(
|
|
|
213
140
|
Returns:
|
|
214
141
|
None
|
|
215
142
|
"""
|
|
216
|
-
run_validation(args)
|
|
217
|
-
|
|
218
143
|
structlogger.info(
|
|
219
144
|
"rasa.studio.upload.loading_data", event_info="Parsing CALM assistant data..."
|
|
220
145
|
)
|
|
@@ -222,36 +147,63 @@ def upload_calm_assistant(
|
|
|
222
147
|
importer = TrainingDataImporter.load_from_dict(
|
|
223
148
|
domain_path=args.domain,
|
|
224
149
|
config_path=args.config,
|
|
225
|
-
expand_env_vars=False,
|
|
226
150
|
)
|
|
227
151
|
|
|
228
152
|
# Prepare config and domain
|
|
229
153
|
config = importer.get_config()
|
|
230
154
|
domain_from_files = importer.get_user_domain().as_dict()
|
|
231
|
-
endpoints_from_files = read_yaml_file(args.endpoints
|
|
232
|
-
config_from_files = read_yaml_file(args.config
|
|
155
|
+
endpoints_from_files = read_yaml_file(args.endpoints)
|
|
156
|
+
config_from_files = read_yaml_file(args.config)
|
|
233
157
|
|
|
234
158
|
# Extract domain and config values
|
|
235
|
-
|
|
159
|
+
domain_keys = [
|
|
160
|
+
"version",
|
|
161
|
+
"actions",
|
|
162
|
+
"responses",
|
|
163
|
+
"slots",
|
|
164
|
+
"intents",
|
|
165
|
+
"entities",
|
|
166
|
+
"forms",
|
|
167
|
+
"session_config",
|
|
168
|
+
]
|
|
169
|
+
|
|
170
|
+
domain = extract_values(domain_from_files, domain_keys)
|
|
171
|
+
|
|
172
|
+
assistant_name = _get_assistant_name(config)
|
|
173
|
+
|
|
174
|
+
training_data_paths = args.data
|
|
175
|
+
|
|
176
|
+
if isinstance(training_data_paths, list):
|
|
177
|
+
training_data_paths.append(args.flows)
|
|
178
|
+
elif isinstance(training_data_paths, str):
|
|
179
|
+
if isinstance(args.flows, list):
|
|
180
|
+
training_data_paths = [training_data_paths] + args.flows
|
|
181
|
+
elif isinstance(args.flows, str):
|
|
182
|
+
training_data_paths = [training_data_paths, args.flows]
|
|
183
|
+
else:
|
|
184
|
+
raise RasaException("Invalid flows path")
|
|
236
185
|
|
|
237
186
|
# Prepare flows
|
|
238
187
|
flow_importer = FlowSyncImporter.load_from_dict(
|
|
239
|
-
training_data_paths=
|
|
188
|
+
training_data_paths=training_data_paths
|
|
240
189
|
)
|
|
190
|
+
|
|
241
191
|
flows = list(flow_importer.get_user_flows())
|
|
242
192
|
|
|
243
193
|
# We instantiate the TrainingDataImporter again on purpose to avoid
|
|
244
194
|
# adding patterns to domain's actions. More info https://t.ly/W8uuc
|
|
245
195
|
nlu_importer = TrainingDataImporter.load_from_dict(
|
|
246
|
-
|
|
196
|
+
domain_path=args.domain, training_data_paths=args.data
|
|
247
197
|
)
|
|
248
198
|
nlu_data = nlu_importer.get_nlu_data()
|
|
199
|
+
|
|
200
|
+
intents_from_files = nlu_data.intents
|
|
201
|
+
|
|
249
202
|
nlu_examples = nlu_data.filter_training_examples(
|
|
250
|
-
lambda ex: ex.get("intent") in
|
|
203
|
+
lambda ex: ex.get("intent") in intents_from_files
|
|
251
204
|
)
|
|
252
|
-
nlu_examples_yaml = RasaYAMLWriter().dumps(nlu_examples)
|
|
253
205
|
|
|
254
|
-
|
|
206
|
+
nlu_examples_yaml = RasaYAMLWriter().dumps(nlu_examples)
|
|
255
207
|
|
|
256
208
|
# Build GraphQL request
|
|
257
209
|
graphql_req = build_import_request(
|
|
@@ -263,16 +215,12 @@ def upload_calm_assistant(
|
|
|
263
215
|
nlu_yaml=nlu_examples_yaml,
|
|
264
216
|
)
|
|
265
217
|
|
|
266
|
-
structlogger.info(
|
|
267
|
-
|
|
268
|
-
)
|
|
269
|
-
return make_request(endpoint, graphql_req, verify)
|
|
218
|
+
structlogger.info("Uploading to Rasa Studio...")
|
|
219
|
+
return make_request(endpoint, graphql_req)
|
|
270
220
|
|
|
271
221
|
|
|
272
222
|
@with_studio_error_handler
|
|
273
|
-
def upload_nlu_assistant(
|
|
274
|
-
args: argparse.Namespace, endpoint: str, verify: bool = True
|
|
275
|
-
) -> StudioResult:
|
|
223
|
+
def upload_nlu_assistant(args: argparse.Namespace, endpoint: str) -> StudioResult:
|
|
276
224
|
"""Uploads the classic (dm1) assistant data to Rasa Studio.
|
|
277
225
|
|
|
278
226
|
Args:
|
|
@@ -282,37 +230,27 @@ def upload_nlu_assistant(
|
|
|
282
230
|
- intents: The intents to upload
|
|
283
231
|
- entities: The entities to upload
|
|
284
232
|
endpoint: The studio endpoint
|
|
285
|
-
verify: Whether to verify SSL
|
|
286
233
|
Returns:
|
|
287
234
|
None
|
|
288
235
|
"""
|
|
289
|
-
structlogger.info(
|
|
290
|
-
"rasa.studio.upload.nlu_data_read",
|
|
291
|
-
event_info="Found DM1 assistant data, parsing...",
|
|
292
|
-
)
|
|
236
|
+
structlogger.info("Found DM1 assistant data, parsing...")
|
|
293
237
|
importer = TrainingDataImporter.load_from_dict(
|
|
294
|
-
domain_path=args.domain,
|
|
295
|
-
training_data_paths=args.data,
|
|
296
|
-
config_path=args.config,
|
|
297
|
-
expand_env_vars=False,
|
|
238
|
+
domain_path=args.domain, training_data_paths=args.data, config_path=args.config
|
|
298
239
|
)
|
|
299
240
|
|
|
300
241
|
intents_from_files = importer.get_nlu_data().intents
|
|
242
|
+
entities_from_files = importer.get_domain().entities
|
|
301
243
|
|
|
302
|
-
domain_from_files = importer.get_domain()
|
|
303
|
-
entities_from_files = domain_from_files.entities
|
|
304
244
|
entities, intents = _get_selected_entities_and_intents(
|
|
305
245
|
args, intents_from_files, entities_from_files
|
|
306
246
|
)
|
|
307
247
|
|
|
308
248
|
config_from_files = importer.get_config()
|
|
309
|
-
config = extract_values(config_from_files,
|
|
249
|
+
config = extract_values(config_from_files, config_keys)
|
|
310
250
|
|
|
311
251
|
assistant_name = _get_assistant_name(config)
|
|
312
252
|
|
|
313
|
-
structlogger.info(
|
|
314
|
-
"rasa.studio.upload.nlu_data_validate", event_info="Validating data..."
|
|
315
|
-
)
|
|
253
|
+
structlogger.info("Validating data...")
|
|
316
254
|
_check_for_missing_primitives(
|
|
317
255
|
intents, entities, intents_from_files, entities_from_files
|
|
318
256
|
)
|
|
@@ -324,46 +262,21 @@ def upload_nlu_assistant(
|
|
|
324
262
|
all_entities = _add_missing_entities(nlu_examples.entities, entities)
|
|
325
263
|
nlu_examples_yaml = RasaYAMLWriter().dumps(nlu_examples)
|
|
326
264
|
|
|
327
|
-
domain = _filter_domain(all_entities, intents,
|
|
265
|
+
domain = _filter_domain(all_entities, intents, importer.get_domain().as_dict())
|
|
328
266
|
domain_yaml = dump_obj_as_yaml_to_string(domain)
|
|
329
267
|
|
|
330
268
|
graphql_req = build_request(assistant_name, nlu_examples_yaml, domain_yaml)
|
|
331
269
|
|
|
332
|
-
structlogger.info(
|
|
333
|
-
|
|
334
|
-
)
|
|
335
|
-
return make_request(endpoint, graphql_req, verify)
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
def is_auth_working(endpoint: str, verify: bool = True) -> bool:
|
|
339
|
-
"""Send a test request to Studio to check if auth is working."""
|
|
340
|
-
result = make_request(
|
|
341
|
-
endpoint,
|
|
342
|
-
{
|
|
343
|
-
"operationName": "LicenseDetails",
|
|
344
|
-
"query": (
|
|
345
|
-
"query LicenseDetails {\n"
|
|
346
|
-
" licenseDetails {\n"
|
|
347
|
-
" valid\n"
|
|
348
|
-
" scopes\n"
|
|
349
|
-
" __typename\n"
|
|
350
|
-
" }\n"
|
|
351
|
-
"}"
|
|
352
|
-
),
|
|
353
|
-
"variables": {},
|
|
354
|
-
},
|
|
355
|
-
verify,
|
|
356
|
-
)
|
|
357
|
-
return result.was_successful
|
|
270
|
+
structlogger.info("Uploading to Rasa Studio...")
|
|
271
|
+
return make_request(endpoint, graphql_req)
|
|
358
272
|
|
|
359
273
|
|
|
360
|
-
def make_request(endpoint: str, graphql_req: Dict
|
|
274
|
+
def make_request(endpoint: str, graphql_req: Dict) -> StudioResult:
|
|
361
275
|
"""Makes a request to the studio endpoint to upload data.
|
|
362
276
|
|
|
363
277
|
Args:
|
|
364
278
|
endpoint: The studio endpoint
|
|
365
279
|
graphql_req: The graphql request
|
|
366
|
-
verify: Whether to verify SSL
|
|
367
280
|
"""
|
|
368
281
|
token = KeycloakTokenReader().get_token()
|
|
369
282
|
res = requests.post(
|
|
@@ -373,7 +286,6 @@ def make_request(endpoint: str, graphql_req: Dict, verify: bool = True) -> Studi
|
|
|
373
286
|
"Authorization": f"{token.token_type} {token.access_token}",
|
|
374
287
|
"Content-Type": "application/json",
|
|
375
288
|
},
|
|
376
|
-
verify=verify,
|
|
377
289
|
)
|
|
378
290
|
|
|
379
291
|
if results_logger.response_has_errors(res.json()):
|
|
@@ -389,12 +301,7 @@ def _add_missing_entities(
|
|
|
389
301
|
for entity in entities_from_intents:
|
|
390
302
|
if entity not in entities:
|
|
391
303
|
structlogger.warning(
|
|
392
|
-
"
|
|
393
|
-
event_info=(
|
|
394
|
-
f"Adding entity '{entity}' to upload "
|
|
395
|
-
"since it is used in an intent."
|
|
396
|
-
),
|
|
397
|
-
entity=entity,
|
|
304
|
+
f"Adding entity '{entity}' to upload since it is used in an intent."
|
|
398
305
|
)
|
|
399
306
|
all_entities.append(entity)
|
|
400
307
|
return all_entities
|
|
@@ -462,9 +369,7 @@ def build_request(
|
|
|
462
369
|
|
|
463
370
|
|
|
464
371
|
def _filter_domain(
|
|
465
|
-
entities: List[Union[str, Dict]],
|
|
466
|
-
intents: List[str],
|
|
467
|
-
domain_from_files: Dict[str, Any],
|
|
372
|
+
entities: List[Union[str, Dict]], intents: List[str], domain_from_files: Dict
|
|
468
373
|
) -> Dict:
|
|
469
374
|
"""Filters the domain to only include the selected entities and intents."""
|
|
470
375
|
selected_entities = _remove_not_selected_entities(
|