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.
- rasa/api.py +8 -2
- rasa/cli/arguments/default_arguments.py +23 -2
- rasa/cli/arguments/run.py +2 -0
- rasa/cli/e2e_test.py +10 -8
- rasa/cli/inspect.py +5 -2
- rasa/cli/run.py +7 -0
- rasa/cli/studio/studio.py +1 -21
- rasa/cli/train.py +9 -4
- rasa/cli/utils.py +3 -3
- rasa/core/agent.py +2 -2
- rasa/core/brokers/kafka.py +3 -1
- rasa/core/brokers/pika.py +3 -1
- rasa/core/channels/voice_aware/utils.py +6 -5
- rasa/core/nlg/contextual_response_rephraser.py +11 -2
- rasa/{nlu → core}/persistor.py +1 -1
- rasa/core/policies/enterprise_search_policy.py +11 -2
- rasa/core/policies/intentless_policy.py +9 -2
- rasa/core/run.py +2 -1
- rasa/core/secrets_manager/constants.py +4 -0
- rasa/core/secrets_manager/factory.py +8 -0
- rasa/core/secrets_manager/vault.py +11 -1
- rasa/core/utils.py +30 -19
- rasa/dialogue_understanding/coexistence/llm_based_router.py +9 -2
- rasa/dialogue_understanding/commands/set_slot_command.py +1 -5
- rasa/dialogue_understanding/generator/llm_based_command_generator.py +11 -2
- rasa/dialogue_understanding/generator/llm_command_generator.py +1 -1
- rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +15 -15
- rasa/e2e_test/e2e_test_runner.py +1 -1
- rasa/engine/graph.py +0 -1
- rasa/engine/recipes/config_files/default_config.yml +0 -3
- rasa/engine/recipes/default_recipe.py +0 -1
- rasa/engine/recipes/graph_recipe.py +0 -1
- rasa/engine/storage/local_model_storage.py +0 -1
- rasa/engine/storage/storage.py +1 -5
- rasa/model_manager/__init__.py +0 -0
- rasa/model_manager/config.py +7 -0
- rasa/model_manager/model_api.py +424 -0
- rasa/model_manager/runner_service.py +185 -0
- rasa/model_manager/socket_bridge.py +44 -0
- rasa/model_manager/trainer_service.py +240 -0
- rasa/model_manager/utils.py +27 -0
- rasa/model_service.py +43 -0
- rasa/model_training.py +11 -6
- rasa/server.py +1 -1
- rasa/shared/constants.py +2 -0
- rasa/shared/core/domain.py +101 -47
- rasa/shared/core/flows/flows_list.py +19 -6
- rasa/shared/core/flows/validation.py +25 -0
- rasa/shared/core/flows/yaml_flows_io.py +3 -24
- rasa/shared/importers/importer.py +32 -32
- rasa/shared/importers/multi_project.py +23 -11
- rasa/shared/importers/rasa.py +7 -2
- rasa/shared/importers/remote_importer.py +2 -2
- rasa/shared/importers/utils.py +3 -1
- rasa/shared/nlu/training_data/training_data.py +18 -19
- rasa/shared/utils/common.py +3 -22
- rasa/shared/utils/llm.py +28 -2
- rasa/shared/utils/schemas/model_config.yml +0 -10
- rasa/studio/auth.py +0 -4
- rasa/tracing/instrumentation/attribute_extractors.py +1 -1
- rasa/validator.py +2 -5
- rasa/version.py +1 -1
- {rasa_pro-3.10.7.dist-info → rasa_pro-3.10.7.dev1.dist-info}/METADATA +4 -4
- {rasa_pro-3.10.7.dist-info → rasa_pro-3.10.7.dev1.dist-info}/RECORD +67 -59
- {rasa_pro-3.10.7.dist-info → rasa_pro-3.10.7.dev1.dist-info}/NOTICE +0 -0
- {rasa_pro-3.10.7.dist-info → rasa_pro-3.10.7.dev1.dist-info}/WHEEL +0 -0
- {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
|
-
|
|
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
|
-
|
|
128
|
+
name = route.name.replace("rasa_server.", "")
|
|
129
|
+
methods = ",".join(route.methods)
|
|
128
130
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
|
|
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
|
-
|
|
267
|
-
|
|
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
|
-
|
|
275
|
-
|
|
276
|
-
|
|
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
|
-
|
|
285
|
-
|
|
286
|
-
|
|
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
|
-
|
|
301
|
+
structlogger.debug(f"Using {env_value} Sanic workers.")
|
|
292
302
|
return env_value
|
|
293
303
|
|
|
294
|
-
|
|
295
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
@@ -55,7 +55,7 @@ responses:
|
|
|
55
55
|
template: jinja
|
|
56
56
|
|
|
57
57
|
utter_free_chitchat_response:
|
|
58
|
-
- text:
|
|
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
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
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:
|
rasa/e2e_test/e2e_test_runner.py
CHANGED
|
@@ -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
|
@@ -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
|
)
|
|
@@ -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,
|
rasa/engine/storage/storage.py
CHANGED
|
@@ -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
|
|
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
|