rasa-pro 3.10.7__py3-none-any.whl → 3.10.7.dev1__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 (67) hide show
  1. rasa/api.py +8 -2
  2. rasa/cli/arguments/default_arguments.py +23 -2
  3. rasa/cli/arguments/run.py +2 -0
  4. rasa/cli/e2e_test.py +10 -8
  5. rasa/cli/inspect.py +5 -2
  6. rasa/cli/run.py +7 -0
  7. rasa/cli/studio/studio.py +1 -21
  8. rasa/cli/train.py +9 -4
  9. rasa/cli/utils.py +3 -3
  10. rasa/core/agent.py +2 -2
  11. rasa/core/brokers/kafka.py +3 -1
  12. rasa/core/brokers/pika.py +3 -1
  13. rasa/core/channels/voice_aware/utils.py +6 -5
  14. rasa/core/nlg/contextual_response_rephraser.py +11 -2
  15. rasa/{nlu → core}/persistor.py +1 -1
  16. rasa/core/policies/enterprise_search_policy.py +11 -2
  17. rasa/core/policies/intentless_policy.py +9 -2
  18. rasa/core/run.py +2 -1
  19. rasa/core/secrets_manager/constants.py +4 -0
  20. rasa/core/secrets_manager/factory.py +8 -0
  21. rasa/core/secrets_manager/vault.py +11 -1
  22. rasa/core/utils.py +30 -19
  23. rasa/dialogue_understanding/coexistence/llm_based_router.py +9 -2
  24. rasa/dialogue_understanding/commands/set_slot_command.py +1 -5
  25. rasa/dialogue_understanding/generator/llm_based_command_generator.py +11 -2
  26. rasa/dialogue_understanding/generator/llm_command_generator.py +1 -1
  27. rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +15 -15
  28. rasa/e2e_test/e2e_test_runner.py +1 -1
  29. rasa/engine/graph.py +0 -1
  30. rasa/engine/recipes/config_files/default_config.yml +0 -3
  31. rasa/engine/recipes/default_recipe.py +0 -1
  32. rasa/engine/recipes/graph_recipe.py +0 -1
  33. rasa/engine/storage/local_model_storage.py +0 -1
  34. rasa/engine/storage/storage.py +1 -5
  35. rasa/model_manager/__init__.py +0 -0
  36. rasa/model_manager/config.py +7 -0
  37. rasa/model_manager/model_api.py +424 -0
  38. rasa/model_manager/runner_service.py +185 -0
  39. rasa/model_manager/socket_bridge.py +44 -0
  40. rasa/model_manager/trainer_service.py +240 -0
  41. rasa/model_manager/utils.py +27 -0
  42. rasa/model_service.py +43 -0
  43. rasa/model_training.py +11 -6
  44. rasa/server.py +1 -1
  45. rasa/shared/constants.py +2 -0
  46. rasa/shared/core/domain.py +101 -47
  47. rasa/shared/core/flows/flows_list.py +19 -6
  48. rasa/shared/core/flows/validation.py +25 -0
  49. rasa/shared/core/flows/yaml_flows_io.py +3 -24
  50. rasa/shared/importers/importer.py +32 -32
  51. rasa/shared/importers/multi_project.py +23 -11
  52. rasa/shared/importers/rasa.py +7 -2
  53. rasa/shared/importers/remote_importer.py +2 -2
  54. rasa/shared/importers/utils.py +3 -1
  55. rasa/shared/nlu/training_data/training_data.py +18 -19
  56. rasa/shared/utils/common.py +3 -22
  57. rasa/shared/utils/llm.py +28 -2
  58. rasa/shared/utils/schemas/model_config.yml +0 -10
  59. rasa/studio/auth.py +0 -4
  60. rasa/tracing/instrumentation/attribute_extractors.py +1 -1
  61. rasa/validator.py +2 -5
  62. rasa/version.py +1 -1
  63. {rasa_pro-3.10.7.dist-info → rasa_pro-3.10.7.dev1.dist-info}/METADATA +4 -4
  64. {rasa_pro-3.10.7.dist-info → rasa_pro-3.10.7.dev1.dist-info}/RECORD +67 -59
  65. {rasa_pro-3.10.7.dist-info → rasa_pro-3.10.7.dev1.dist-info}/NOTICE +0 -0
  66. {rasa_pro-3.10.7.dist-info → rasa_pro-3.10.7.dev1.dist-info}/WHEEL +0 -0
  67. {rasa_pro-3.10.7.dist-info → rasa_pro-3.10.7.dev1.dist-info}/entry_points.txt +0 -0
rasa/core/utils.py CHANGED
@@ -1,3 +1,4 @@
1
+ import structlog
1
2
  import logging
2
3
  import os
3
4
  from pathlib import Path
@@ -26,7 +27,7 @@ if TYPE_CHECKING:
26
27
  from rasa.core.nlg import NaturalLanguageGenerator
27
28
  from rasa.shared.core.domain import Domain
28
29
 
29
- logger = logging.getLogger(__name__)
30
+ structlogger = structlog.get_logger()
30
31
 
31
32
 
32
33
  def configure_file_logging(
@@ -124,15 +125,17 @@ def list_routes(app: Sanic) -> Dict[Text, Text]:
124
125
  for arg in route._params:
125
126
  options[arg] = f"[{arg}]"
126
127
 
127
- handlers = [(next(iter(route.methods)), route.name.replace("rasa_server.", ""))]
128
+ name = route.name.replace("rasa_server.", "")
129
+ methods = ",".join(route.methods)
128
130
 
129
- for method, name in handlers:
130
- full_endpoint = "/" + "/".join(endpoint)
131
- line = unquote(f"{full_endpoint:50s} {method:30s} {name}")
132
- output[name] = line
131
+ full_endpoint = "/" + "/".join(endpoint)
132
+ line = unquote(f"{full_endpoint:50s} {methods:30s} {name}")
133
+ output[name] = line
133
134
 
134
135
  url_table = "\n".join(output[url] for url in sorted(output))
135
- logger.debug(f"Available web server routes: \n{url_table}")
136
+ structlogger.debug(
137
+ "server.routes", event_info=f"Available web server routes: \n{url_table}"
138
+ )
136
139
 
137
140
  return output
138
141
 
@@ -263,17 +266,22 @@ def number_of_sanic_workers(lock_store: Union[EndpointConfig, LockStore, None])
263
266
  """
264
267
 
265
268
  def _log_and_get_default_number_of_workers() -> int:
266
- logger.debug(
267
- f"Using the default number of Sanic workers ({DEFAULT_SANIC_WORKERS})."
269
+ structlogger.debug(
270
+ "server.worker.set_count",
271
+ number_of_workers=DEFAULT_SANIC_WORKERS,
272
+ event_info=f"Using the default number of Sanic workers "
273
+ f"({DEFAULT_SANIC_WORKERS}).",
268
274
  )
269
275
  return DEFAULT_SANIC_WORKERS
270
276
 
271
277
  try:
272
278
  env_value = int(os.environ.get(ENV_SANIC_WORKERS, DEFAULT_SANIC_WORKERS))
273
279
  except ValueError:
274
- logger.error(
275
- f"Cannot convert environment variable `{ENV_SANIC_WORKERS}` "
276
- f"to int ('{os.environ[ENV_SANIC_WORKERS]}')."
280
+ structlogger.error(
281
+ "server.worker.set_count.error",
282
+ number_of_workers=os.environ[ENV_SANIC_WORKERS],
283
+ event_info=f"Cannot convert environment variable `{ENV_SANIC_WORKERS}` "
284
+ f"to int ('{os.environ[ENV_SANIC_WORKERS]}').",
277
285
  )
278
286
  return _log_and_get_default_number_of_workers()
279
287
 
@@ -281,20 +289,23 @@ def number_of_sanic_workers(lock_store: Union[EndpointConfig, LockStore, None])
281
289
  return _log_and_get_default_number_of_workers()
282
290
 
283
291
  if env_value < 1:
284
- logger.debug(
285
- f"Cannot set number of Sanic workers to the desired value "
286
- f"({env_value}). The number of workers must be at least 1."
292
+ structlogger.debug(
293
+ "server.worker.set_count.error_less_than_one",
294
+ number_of_workers=env_value,
295
+ event_info=f"Cannot set number of Sanic workers to the desired value "
296
+ f"({env_value}). The number of workers must be at least 1.",
287
297
  )
288
298
  return _log_and_get_default_number_of_workers()
289
299
 
290
300
  if _lock_store_is_multi_worker_compatible(lock_store):
291
- logger.debug(f"Using {env_value} Sanic workers.")
301
+ structlogger.debug(f"Using {env_value} Sanic workers.")
292
302
  return env_value
293
303
 
294
- logger.debug(
295
- f"Unable to assign desired number of Sanic workers ({env_value}) as "
304
+ structlogger.debug(
305
+ "server.worker.set_count.error_no_lock_store",
306
+ event_info=f"Unable to assign desired number of Sanic workers ({env_value}) as "
296
307
  f"no `RedisLockStore` or custom `LockStore` endpoint "
297
- f"configuration has been found."
308
+ f"configuration has been found.",
298
309
  )
299
310
  return _log_and_get_default_number_of_workers()
300
311
 
@@ -1,6 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import importlib
4
+ import os
4
5
  from typing import Any, Dict, List, Optional
5
6
 
6
7
  import structlog
@@ -21,6 +22,7 @@ from rasa.engine.recipes.default_recipe import DefaultV1Recipe
21
22
  from rasa.engine.storage.resource import Resource
22
23
  from rasa.engine.storage.storage import ModelStorage
23
24
  from rasa.shared.constants import (
25
+ LLM_API_HEALTH_CHECK_ENV_VAR,
24
26
  ROUTE_TO_CALM_SLOT,
25
27
  PROMPT_CONFIG_KEY,
26
28
  PROVIDER_CONFIG_KEY,
@@ -36,6 +38,7 @@ from rasa.shared.nlu.training_data.training_data import TrainingData
36
38
  from rasa.shared.utils.llm import (
37
39
  DEFAULT_OPENAI_CHAT_MODEL_NAME,
38
40
  get_prompt_template,
41
+ llm_api_health_check,
39
42
  llm_factory,
40
43
  try_instantiate_llm_client,
41
44
  )
@@ -130,12 +133,16 @@ class LLMBasedRouter(GraphComponent):
130
133
  def train(self, training_data: TrainingData) -> Resource:
131
134
  """Train the intent classifier on a data set."""
132
135
  # Validate llm configuration
133
- try_instantiate_llm_client(
136
+ llm_client = try_instantiate_llm_client(
134
137
  self.config.get(LLM_CONFIG_KEY),
135
138
  DEFAULT_LLM_CONFIG,
136
139
  "llm_based_router.train",
137
- "LLMBasedRouter",
140
+ LLMBasedRouter.__name__,
138
141
  )
142
+ if os.getenv(LLM_API_HEALTH_CHECK_ENV_VAR, "true").lower() == "true":
143
+ llm_api_health_check(
144
+ llm_client, "llm_based_router.train", LLMBasedRouter.__name__
145
+ )
139
146
 
140
147
  self.persist()
141
148
  return self._resource
@@ -127,11 +127,7 @@ class SetSlotCommand(Command):
127
127
  if (
128
128
  self.name not in slots_of_active_flow
129
129
  and self.name != ROUTE_TO_CALM_SLOT
130
- and self.extractor
131
- in {
132
- SetSlotExtractor.LLM.value,
133
- SetSlotExtractor.COMMAND_PAYLOAD_READER.value,
134
- }
130
+ and self.extractor == SetSlotExtractor.LLM.value
135
131
  ):
136
132
  # Get the other predicted flows from the most recent message on the tracker.
137
133
  predicted_flows = get_flows_predicted_to_start_from_tracker(tracker)
@@ -2,6 +2,7 @@ from abc import ABC, abstractmethod
2
2
  from functools import lru_cache
3
3
  from typing import Dict, Any, List, Optional, Tuple, Union, Text
4
4
 
5
+ import os
5
6
  import structlog
6
7
  from jinja2 import Template
7
8
 
@@ -22,6 +23,7 @@ from rasa.engine.graph import GraphComponent, ExecutionContext
22
23
  from rasa.engine.recipes.default_recipe import DefaultV1Recipe
23
24
  from rasa.engine.storage.resource import Resource
24
25
  from rasa.engine.storage.storage import ModelStorage
26
+ from rasa.shared.constants import LLM_API_HEALTH_CHECK_ENV_VAR
25
27
  from rasa.shared.core.domain import Domain
26
28
  from rasa.shared.core.flows import FlowStep, Flow, FlowsList
27
29
  from rasa.shared.core.flows.steps.collect import CollectInformationFlowStep
@@ -33,6 +35,7 @@ from rasa.shared.nlu.training_data.message import Message
33
35
  from rasa.shared.nlu.training_data.training_data import TrainingData
34
36
  from rasa.shared.utils.llm import (
35
37
  allowed_values_for_slot,
38
+ llm_api_health_check,
36
39
  llm_factory,
37
40
  try_instantiate_llm_client,
38
41
  )
@@ -169,12 +172,18 @@ class LLMBasedCommandGenerator(GraphComponent, CommandGenerator, ABC):
169
172
  store.
170
173
  """
171
174
  # Validate llm configuration
172
- try_instantiate_llm_client(
175
+ llm_client = try_instantiate_llm_client(
173
176
  self.config.get(LLM_CONFIG_KEY),
174
177
  DEFAULT_LLM_CONFIG,
175
178
  "llm_based_command_generator.train",
176
- "LLMBasedCommandGenerator",
179
+ LLMBasedCommandGenerator.__name__,
177
180
  )
181
+ if os.getenv(LLM_API_HEALTH_CHECK_ENV_VAR, "true").lower() == "true":
182
+ llm_api_health_check(
183
+ llm_client,
184
+ "llm_based_command_generator.train",
185
+ LLMBasedCommandGenerator.__name__,
186
+ )
178
187
 
179
188
  # flow retrieval is populated with only user-defined flows
180
189
  try:
@@ -1,4 +1,4 @@
1
- from typing import Dict, Any, Optional, Text
1
+ from typing import Any, Dict, Optional, Text
2
2
 
3
3
  import structlog
4
4
  from deprecated import deprecated # type: ignore[import]
@@ -55,7 +55,7 @@ responses:
55
55
  template: jinja
56
56
 
57
57
  utter_free_chitchat_response:
58
- - text: "Sorry, I'm not able to answer that right now."
58
+ - text: placeholder_this_utterance_needs_the_rephraser
59
59
  metadata:
60
60
  rephrase: True
61
61
  rephrase_prompt: |
@@ -160,9 +160,9 @@ flows:
160
160
  action: action_run_slot_rejections
161
161
  - action: validate_{{context.collect}}
162
162
  next:
163
- - if: "slots.{{context.collect}} is not null"
164
- then: END
165
- - else: ask_collect
163
+ - if: "slots.{{context.collect}} is not null"
164
+ then: END
165
+ - else: ask_collect
166
166
  - id: ask_collect
167
167
  action: "{{context.utter}}"
168
168
  - action: "{{context.collect_action}}"
@@ -205,17 +205,17 @@ flows:
205
205
  steps:
206
206
  - noop: true
207
207
  next:
208
- - if: "'{{context.error_type}}' = 'rasa_internal_error_user_input_too_long'"
209
- then:
210
- - action: utter_user_input_too_long_error_rasa
211
- next: END
212
- - if: "'{{context.error_type}}' = 'rasa_internal_error_user_input_empty'"
213
- then:
214
- - action: utter_user_input_empty_error_rasa
215
- next: END
216
- - else:
217
- - action: utter_internal_error_rasa
218
- next: END
208
+ - if: "'{{context.error_type}}' = 'rasa_internal_error_user_input_too_long'"
209
+ then:
210
+ - action: utter_user_input_too_long_error_rasa
211
+ next: END
212
+ - if: "'{{context.error_type}}' = 'rasa_internal_error_user_input_empty'"
213
+ then:
214
+ - action: utter_user_input_empty_error_rasa
215
+ next: END
216
+ - else:
217
+ - action: utter_internal_error_rasa
218
+ next: END
219
219
 
220
220
 
221
221
  pattern_restart:
@@ -16,6 +16,7 @@ import rasa.shared.utils.io
16
16
  from rasa.core.channels import CollectingOutputChannel, UserMessage
17
17
  from rasa.core.constants import ACTIVE_FLOW_METADATA_KEY, STEP_ID_METADATA_KEY
18
18
  from rasa.core.exceptions import AgentNotReady
19
+ from rasa.core.persistor import StorageType
19
20
  from rasa.core.utils import AvailableEndpoints
20
21
  from rasa.e2e_test.constants import TEST_CASE_NAME, TEST_FILE_NAME
21
22
  from rasa.e2e_test.e2e_config import create_llm_judge_config
@@ -34,7 +35,6 @@ from rasa.e2e_test.e2e_test_result import (
34
35
  TestResult,
35
36
  )
36
37
  from rasa.llm_fine_tuning.conversations import Conversation
37
- from rasa.nlu.persistor import StorageType
38
38
  from rasa.shared.constants import RASA_DEFAULT_FLOW_PATTERN_PREFIX
39
39
  from rasa.shared.core.events import (
40
40
  ActionExecuted,
rasa/engine/graph.py CHANGED
@@ -634,4 +634,3 @@ class GraphModelConfiguration:
634
634
  language: Optional[Text]
635
635
  core_target: Optional[Text]
636
636
  nlu_target: Optional[Text]
637
- spaces: Optional[Dict[Text, Text]] = None
@@ -35,9 +35,6 @@ pipeline:
35
35
  policies:
36
36
  - name: MemoizationPolicy
37
37
  - name: RulePolicy
38
- - name: UnexpecTEDIntentPolicy
39
- max_history: 5
40
- epochs: 100
41
38
  - name: TEDPolicy
42
39
  max_history: 5
43
40
  epochs: 100
@@ -233,7 +233,6 @@ class DefaultV1Recipe(Recipe):
233
233
  training_type=training_type,
234
234
  assistant_id=config.get(ASSISTANT_ID_KEY),
235
235
  language=config.get("language"),
236
- spaces=config.get("spaces"),
237
236
  core_target=core_target,
238
237
  nlu_target=f"run_{RegexMessageHandler.__name__}",
239
238
  )
@@ -73,7 +73,6 @@ class GraphV1Recipe(Recipe):
73
73
  training_type=training_type,
74
74
  assistant_id=config.get(ASSISTANT_ID_KEY),
75
75
  language=config.get("language"),
76
- spaces=config.get("spaces"),
77
76
  core_target=core_target,
78
77
  nlu_target=nlu_target,
79
78
  )
@@ -238,7 +238,6 @@ class LocalModelStorage(ModelStorage):
238
238
  predict_schema=model_configuration.predict_schema,
239
239
  training_type=model_configuration.training_type,
240
240
  project_fingerprint=rasa.model.project_fingerprint(),
241
- spaces=model_configuration.spaces,
242
241
  language=model_configuration.language,
243
242
  core_target=model_configuration.core_target,
244
243
  nlu_target=model_configuration.nlu_target,
@@ -6,7 +6,7 @@ from contextlib import contextmanager
6
6
  from dataclasses import dataclass
7
7
  from datetime import datetime
8
8
  from pathlib import Path
9
- from typing import List, Tuple, Union, Text, Generator, Dict, Any, Optional
9
+ from typing import Tuple, Union, Text, Generator, Dict, Any, Optional
10
10
  from packaging import version
11
11
 
12
12
  from rasa.constants import MINIMUM_COMPATIBLE_VERSION
@@ -140,7 +140,6 @@ class ModelMetadata:
140
140
  core_target: Optional[Text]
141
141
  nlu_target: Text
142
142
  language: Optional[Text]
143
- spaces: Optional[List[Dict[Text, Any]]] = None
144
143
  training_type: TrainingType = TrainingType.BOTH
145
144
 
146
145
  def __post_init__(self) -> None:
@@ -170,7 +169,6 @@ class ModelMetadata:
170
169
  "core_target": self.core_target,
171
170
  "nlu_target": self.nlu_target,
172
171
  "language": self.language,
173
- "spaces": self.spaces,
174
172
  }
175
173
 
176
174
  @classmethod
@@ -198,6 +196,4 @@ class ModelMetadata:
198
196
  core_target=serialized["core_target"],
199
197
  nlu_target=serialized["nlu_target"],
200
198
  language=serialized["language"],
201
- # optional, since introduced later
202
- spaces=serialized.get("spaces"),
203
199
  )
File without changes
@@ -0,0 +1,7 @@
1
+ import sys
2
+
3
+ SERVER_BASE_WORKING_DIRECTORY = "working-data"
4
+
5
+ # The path to the python executable that is running this script
6
+ # we will use the same python to run training / bots
7
+ RASA_PYTHON_PATH = sys.executable