rasa-pro 3.13.0.dev20250612__py3-none-any.whl → 3.13.0.dev20250613__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/__main__.py +0 -3
- rasa/api.py +1 -1
- rasa/cli/dialogue_understanding_test.py +1 -1
- rasa/cli/e2e_test.py +1 -1
- rasa/cli/evaluate.py +1 -1
- rasa/cli/export.py +1 -1
- rasa/cli/llm_fine_tuning.py +12 -11
- rasa/cli/project_templates/defaults.py +133 -0
- rasa/cli/run.py +1 -1
- rasa/cli/studio/link.py +53 -0
- rasa/cli/studio/pull.py +78 -0
- rasa/cli/studio/push.py +78 -0
- rasa/cli/studio/studio.py +12 -0
- rasa/cli/studio/upload.py +8 -0
- rasa/cli/train.py +1 -1
- rasa/cli/utils.py +1 -1
- rasa/cli/x.py +1 -1
- rasa/constants.py +2 -0
- rasa/core/__init__.py +0 -16
- rasa/core/actions/action.py +5 -1
- rasa/core/actions/action_repeat_bot_messages.py +18 -22
- rasa/core/actions/action_run_slot_rejections.py +0 -1
- rasa/core/agent.py +16 -1
- rasa/core/available_endpoints.py +146 -0
- rasa/core/brokers/pika.py +1 -2
- rasa/core/channels/botframework.py +2 -2
- rasa/core/channels/channel.py +2 -2
- rasa/core/channels/hangouts.py +8 -5
- rasa/core/channels/mattermost.py +1 -1
- rasa/core/channels/rasa_chat.py +2 -4
- rasa/core/channels/rest.py +5 -4
- rasa/core/channels/studio_chat.py +3 -2
- rasa/core/channels/vier_cvg.py +1 -2
- rasa/core/channels/voice_ready/audiocodes.py +1 -8
- rasa/core/channels/voice_stream/audiocodes.py +7 -4
- rasa/core/channels/voice_stream/genesys.py +2 -2
- rasa/core/channels/voice_stream/twilio_media_streams.py +10 -5
- rasa/core/channels/voice_stream/voice_channel.py +33 -22
- rasa/core/http_interpreter.py +3 -7
- rasa/core/jobs.py +2 -1
- rasa/core/nlg/contextual_response_rephraser.py +38 -11
- rasa/core/nlg/generator.py +0 -1
- rasa/core/nlg/interpolator.py +2 -3
- rasa/core/nlg/summarize.py +39 -5
- rasa/core/policies/enterprise_search_policy.py +290 -66
- rasa/core/policies/enterprise_search_prompt_with_relevancy_check_and_citation_template.jinja2 +63 -0
- rasa/core/policies/flow_policy.py +1 -1
- rasa/core/policies/flows/flow_executor.py +96 -17
- rasa/core/policies/intentless_policy.py +24 -16
- rasa/core/processor.py +104 -51
- rasa/core/run.py +33 -11
- rasa/core/tracker_stores/tracker_store.py +1 -1
- rasa/core/training/interactive.py +1 -1
- rasa/core/utils.py +24 -97
- rasa/dialogue_understanding/coexistence/intent_based_router.py +2 -1
- rasa/dialogue_understanding/coexistence/llm_based_router.py +8 -3
- rasa/dialogue_understanding/commands/can_not_handle_command.py +2 -0
- rasa/dialogue_understanding/commands/cancel_flow_command.py +2 -0
- rasa/dialogue_understanding/commands/chit_chat_answer_command.py +2 -0
- rasa/dialogue_understanding/commands/clarify_command.py +5 -1
- rasa/dialogue_understanding/commands/command_syntax_manager.py +1 -0
- rasa/dialogue_understanding/commands/human_handoff_command.py +2 -0
- rasa/dialogue_understanding/commands/knowledge_answer_command.py +2 -0
- rasa/dialogue_understanding/commands/repeat_bot_messages_command.py +2 -0
- rasa/dialogue_understanding/commands/set_slot_command.py +11 -1
- rasa/dialogue_understanding/commands/skip_question_command.py +2 -0
- rasa/dialogue_understanding/commands/start_flow_command.py +4 -0
- rasa/dialogue_understanding/commands/utils.py +26 -2
- rasa/dialogue_understanding/generator/__init__.py +7 -1
- rasa/dialogue_understanding/generator/command_generator.py +4 -2
- rasa/dialogue_understanding/generator/command_parser.py +2 -2
- rasa/dialogue_understanding/generator/command_parser_validator.py +63 -0
- rasa/dialogue_understanding/generator/constants.py +2 -2
- rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v3_gpt_4o_2024_11_20_template.jinja2 +78 -0
- rasa/dialogue_understanding/generator/single_step/compact_llm_command_generator.py +28 -463
- rasa/dialogue_understanding/generator/single_step/search_ready_llm_command_generator.py +147 -0
- rasa/dialogue_understanding/generator/single_step/single_step_based_llm_command_generator.py +477 -0
- rasa/dialogue_understanding/generator/single_step/single_step_llm_command_generator.py +8 -58
- rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +37 -25
- rasa/dialogue_understanding/patterns/domain_for_patterns.py +190 -0
- rasa/dialogue_understanding/processor/command_processor.py +3 -3
- rasa/dialogue_understanding/processor/command_processor_component.py +3 -3
- rasa/dialogue_understanding/stack/frames/flow_stack_frame.py +17 -4
- rasa/dialogue_understanding/utils.py +68 -12
- rasa/dialogue_understanding_test/du_test_case.py +1 -1
- rasa/dialogue_understanding_test/du_test_runner.py +4 -22
- rasa/dialogue_understanding_test/test_case_simulation/test_case_tracker_simulator.py +2 -6
- rasa/e2e_test/e2e_test_runner.py +1 -1
- rasa/engine/constants.py +1 -1
- rasa/engine/recipes/default_recipe.py +26 -2
- rasa/engine/validation.py +3 -2
- rasa/hooks.py +0 -28
- rasa/llm_fine_tuning/annotation_module.py +39 -9
- rasa/llm_fine_tuning/conversations.py +3 -0
- rasa/llm_fine_tuning/llm_data_preparation_module.py +66 -49
- rasa/llm_fine_tuning/paraphrasing/conversation_rephraser.py +4 -2
- rasa/llm_fine_tuning/paraphrasing/rephrase_validator.py +52 -44
- rasa/llm_fine_tuning/paraphrasing_module.py +10 -12
- rasa/llm_fine_tuning/storage.py +4 -4
- rasa/llm_fine_tuning/utils.py +63 -1
- rasa/model_manager/model_api.py +88 -0
- rasa/model_manager/trainer_service.py +4 -4
- rasa/plugin.py +1 -11
- rasa/privacy/__init__.py +0 -0
- rasa/privacy/constants.py +83 -0
- rasa/privacy/event_broker_utils.py +77 -0
- rasa/privacy/privacy_config.py +281 -0
- rasa/privacy/privacy_config_schema.json +86 -0
- rasa/privacy/privacy_filter.py +340 -0
- rasa/privacy/privacy_manager.py +576 -0
- rasa/server.py +23 -2
- rasa/shared/constants.py +6 -0
- rasa/shared/core/constants.py +4 -3
- rasa/shared/core/domain.py +7 -0
- rasa/shared/core/events.py +37 -7
- rasa/shared/core/flows/flow.py +1 -2
- rasa/shared/core/flows/flows_yaml_schema.json +3 -0
- rasa/shared/core/flows/steps/collect.py +46 -2
- rasa/shared/core/slots.py +28 -0
- rasa/shared/exceptions.py +4 -0
- rasa/shared/providers/_configs/azure_openai_client_config.py +4 -0
- rasa/shared/providers/_configs/openai_client_config.py +4 -0
- rasa/shared/providers/embedding/_base_litellm_embedding_client.py +3 -0
- rasa/shared/providers/llm/_base_litellm_client.py +5 -2
- rasa/shared/utils/llm.py +161 -6
- rasa/shared/utils/yaml.py +32 -0
- rasa/studio/data_handler.py +3 -3
- rasa/studio/download/download.py +37 -60
- rasa/studio/download/flows.py +23 -31
- rasa/studio/link.py +200 -0
- rasa/studio/pull.py +94 -0
- rasa/studio/push.py +131 -0
- rasa/studio/upload.py +117 -67
- rasa/telemetry.py +82 -25
- rasa/tracing/config.py +3 -4
- rasa/tracing/constants.py +19 -1
- rasa/tracing/instrumentation/attribute_extractors.py +10 -2
- rasa/tracing/instrumentation/instrumentation.py +53 -2
- rasa/tracing/instrumentation/metrics.py +98 -15
- rasa/tracing/metric_instrument_provider.py +75 -3
- rasa/utils/common.py +1 -27
- rasa/utils/log_utils.py +1 -45
- rasa/validator.py +2 -8
- rasa/version.py +1 -1
- {rasa_pro-3.13.0.dev20250612.dist-info → rasa_pro-3.13.0.dev20250613.dist-info}/METADATA +5 -6
- {rasa_pro-3.13.0.dev20250612.dist-info → rasa_pro-3.13.0.dev20250613.dist-info}/RECORD +149 -135
- rasa/anonymization/__init__.py +0 -2
- rasa/anonymization/anonymisation_rule_yaml_reader.py +0 -91
- rasa/anonymization/anonymization_pipeline.py +0 -286
- rasa/anonymization/anonymization_rule_executor.py +0 -266
- rasa/anonymization/anonymization_rule_orchestrator.py +0 -119
- rasa/anonymization/schemas/config.yml +0 -47
- rasa/anonymization/utils.py +0 -118
- {rasa_pro-3.13.0.dev20250612.dist-info → rasa_pro-3.13.0.dev20250613.dist-info}/NOTICE +0 -0
- {rasa_pro-3.13.0.dev20250612.dist-info → rasa_pro-3.13.0.dev20250613.dist-info}/WHEEL +0 -0
- {rasa_pro-3.13.0.dev20250612.dist-info → rasa_pro-3.13.0.dev20250613.dist-info}/entry_points.txt +0 -0
rasa/core/run.py
CHANGED
|
@@ -30,12 +30,11 @@ from rasa import server, telemetry
|
|
|
30
30
|
from rasa.constants import ENV_SANIC_BACKLOG
|
|
31
31
|
from rasa.core import agent, channels, constants
|
|
32
32
|
from rasa.core.agent import Agent
|
|
33
|
+
from rasa.core.available_endpoints import AvailableEndpoints
|
|
33
34
|
from rasa.core.channels import console
|
|
34
35
|
from rasa.core.channels.channel import InputChannel
|
|
35
36
|
from rasa.core.channels.development_inspector import DevelopmentInspectProxy
|
|
36
37
|
from rasa.core.persistor import StorageType
|
|
37
|
-
from rasa.core.utils import AvailableEndpoints
|
|
38
|
-
from rasa.plugin import plugin_manager
|
|
39
38
|
from rasa.shared.exceptions import RasaException
|
|
40
39
|
from rasa.shared.utils.yaml import read_config_file
|
|
41
40
|
from rasa.utils import licensing
|
|
@@ -45,7 +44,7 @@ logger = logging.getLogger() # get the root logger
|
|
|
45
44
|
|
|
46
45
|
def create_http_input_channels(
|
|
47
46
|
channel: Optional[Text], credentials_file: Optional[Text]
|
|
48
|
-
) -> List[
|
|
47
|
+
) -> List[InputChannel]:
|
|
49
48
|
"""Instantiate the chosen input channel."""
|
|
50
49
|
if credentials_file:
|
|
51
50
|
all_credentials = read_config_file(credentials_file)
|
|
@@ -59,22 +58,45 @@ def create_http_input_channels(
|
|
|
59
58
|
"To connect to all given channels, omit the '--connector' "
|
|
60
59
|
"argument.".format(channel)
|
|
61
60
|
)
|
|
62
|
-
return [
|
|
61
|
+
return [
|
|
62
|
+
_create_single_channel(
|
|
63
|
+
channel,
|
|
64
|
+
all_credentials.get(channel),
|
|
65
|
+
)
|
|
66
|
+
]
|
|
63
67
|
else:
|
|
64
68
|
return [_create_single_channel(c, k) for c, k in all_credentials.items()]
|
|
65
69
|
|
|
66
70
|
|
|
67
|
-
def _create_single_channel(
|
|
71
|
+
def _create_single_channel(
|
|
72
|
+
channel: Text,
|
|
73
|
+
credentials: Optional[Dict[Text, Any]],
|
|
74
|
+
) -> Any:
|
|
75
|
+
"""Create a single input channel based on the channel name and credentials.
|
|
76
|
+
|
|
77
|
+
Args:
|
|
78
|
+
channel: The name of the input channel to create.
|
|
79
|
+
credentials: The credentials for the input channel.
|
|
80
|
+
|
|
81
|
+
Returns:
|
|
82
|
+
An instance of the input channel class.
|
|
83
|
+
|
|
84
|
+
Raises:
|
|
85
|
+
RasaException: If the channel class cannot be found or instantiated.
|
|
86
|
+
"""
|
|
68
87
|
from rasa.core.channels import BUILTIN_CHANNELS
|
|
69
88
|
|
|
70
89
|
if channel in BUILTIN_CHANNELS:
|
|
71
|
-
|
|
90
|
+
channel_class = BUILTIN_CHANNELS[channel]
|
|
91
|
+
|
|
92
|
+
return channel_class.from_credentials(credentials)
|
|
72
93
|
else:
|
|
73
94
|
# try to load channel based on class name
|
|
74
95
|
try:
|
|
75
96
|
input_channel_class = rasa.shared.utils.common.class_from_module_path(
|
|
76
97
|
channel
|
|
77
98
|
)
|
|
99
|
+
|
|
78
100
|
return input_channel_class.from_credentials(credentials)
|
|
79
101
|
except (AttributeError, ImportError):
|
|
80
102
|
raise RasaException(
|
|
@@ -108,7 +130,7 @@ def _is_apple_silicon_system() -> bool:
|
|
|
108
130
|
|
|
109
131
|
|
|
110
132
|
def configure_app(
|
|
111
|
-
input_channels: Optional[List[
|
|
133
|
+
input_channels: Optional[List[InputChannel]] = None,
|
|
112
134
|
cors: Optional[Union[Text, List[Text], None]] = None,
|
|
113
135
|
auth_token: Optional[Text] = None,
|
|
114
136
|
enable_api: bool = True,
|
|
@@ -190,10 +212,6 @@ def configure_app(
|
|
|
190
212
|
logger.info("Killing Sanic server now.")
|
|
191
213
|
running_app.stop() # kill the sanic server
|
|
192
214
|
|
|
193
|
-
@app.after_server_stop
|
|
194
|
-
async def after_server_stop(running_app: Sanic) -> None:
|
|
195
|
-
plugin_manager().hook.after_server_stop()
|
|
196
|
-
|
|
197
215
|
if server_listeners:
|
|
198
216
|
for listener, event in server_listeners:
|
|
199
217
|
app.register_listener(listener, event)
|
|
@@ -346,3 +364,7 @@ async def close_resources(app: Sanic, _: AbstractEventLoop) -> None:
|
|
|
346
364
|
event_broker = current_agent.tracker_store.event_broker
|
|
347
365
|
if event_broker:
|
|
348
366
|
await event_broker.close()
|
|
367
|
+
|
|
368
|
+
privacy_manager = current_agent.privacy_manager
|
|
369
|
+
if privacy_manager:
|
|
370
|
+
privacy_manager.stop()
|
|
@@ -671,7 +671,7 @@ def _create_from_endpoint_config(
|
|
|
671
671
|
|
|
672
672
|
structlogger.debug(
|
|
673
673
|
"tracker_store.create_tracker_store_from_endpoint_config",
|
|
674
|
-
|
|
674
|
+
event_info=f"Connected to {tracker_store.__class__.__name__}.",
|
|
675
675
|
)
|
|
676
676
|
|
|
677
677
|
return tracker_store
|
|
@@ -47,8 +47,8 @@ import rasa.shared.utils.io
|
|
|
47
47
|
import rasa.utils.io as io_utils
|
|
48
48
|
from rasa import telemetry
|
|
49
49
|
from rasa.core import run, utils
|
|
50
|
+
from rasa.core.available_endpoints import AvailableEndpoints
|
|
50
51
|
from rasa.core.constants import DEFAULT_SERVER_FORMAT, DEFAULT_SERVER_PORT
|
|
51
|
-
from rasa.core.utils import AvailableEndpoints
|
|
52
52
|
from rasa.shared.constants import (
|
|
53
53
|
DEFAULT_SENDER_ID,
|
|
54
54
|
DOCS_URL_NLU_BASED_POLICIES,
|
rasa/core/utils.py
CHANGED
|
@@ -2,7 +2,7 @@ import logging
|
|
|
2
2
|
import os
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
from socket import SOCK_DGRAM, SOCK_STREAM
|
|
5
|
-
from typing import TYPE_CHECKING, Any, Dict,
|
|
5
|
+
from typing import TYPE_CHECKING, Any, Dict, Optional, Set, Text, Tuple, Union
|
|
6
6
|
|
|
7
7
|
import numpy as np
|
|
8
8
|
import structlog
|
|
@@ -11,6 +11,7 @@ from sanic import Sanic
|
|
|
11
11
|
import rasa.cli.utils as cli_utils
|
|
12
12
|
import rasa.shared.utils.io
|
|
13
13
|
from rasa.constants import DEFAULT_SANIC_WORKERS, ENV_SANIC_WORKERS
|
|
14
|
+
from rasa.core.available_endpoints import AvailableEndpoints
|
|
14
15
|
from rasa.core.constants import (
|
|
15
16
|
ACTIVE_FLOW_METADATA_KEY,
|
|
16
17
|
DOMAIN_GROUND_TRUTH_METADATA_KEY,
|
|
@@ -19,12 +20,12 @@ from rasa.core.constants import (
|
|
|
19
20
|
)
|
|
20
21
|
from rasa.core.lock_store import InMemoryLockStore, LockStore, RedisLockStore
|
|
21
22
|
from rasa.shared.constants import DEFAULT_ENDPOINTS_PATH, TCP_PROTOCOL
|
|
22
|
-
from rasa.shared.core.constants import
|
|
23
|
+
from rasa.shared.core.constants import (
|
|
24
|
+
SlotMappingType,
|
|
25
|
+
)
|
|
23
26
|
from rasa.shared.core.trackers import DialogueStateTracker
|
|
24
27
|
from rasa.utils.endpoints import (
|
|
25
28
|
EndpointConfig,
|
|
26
|
-
read_endpoint_config,
|
|
27
|
-
read_property_config_from_endpoints_file,
|
|
28
29
|
)
|
|
29
30
|
from rasa.utils.io import write_yaml
|
|
30
31
|
|
|
@@ -36,6 +37,25 @@ if TYPE_CHECKING:
|
|
|
36
37
|
structlogger = structlog.get_logger()
|
|
37
38
|
|
|
38
39
|
|
|
40
|
+
def read_endpoints_from_path(
|
|
41
|
+
endpoints_path: Optional[Union[Path, str]] = None,
|
|
42
|
+
) -> AvailableEndpoints:
|
|
43
|
+
"""Get `AvailableEndpoints` object from specified path.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
endpoints_path: Path of the endpoints file to be read. If `None` the
|
|
47
|
+
default path for that file is used (`endpoints.yml`).
|
|
48
|
+
|
|
49
|
+
Returns:
|
|
50
|
+
`AvailableEndpoints` object read from endpoints file.
|
|
51
|
+
|
|
52
|
+
"""
|
|
53
|
+
endpoints_config_path = cli_utils.get_validated_path(
|
|
54
|
+
endpoints_path, "endpoints", DEFAULT_ENDPOINTS_PATH, True
|
|
55
|
+
)
|
|
56
|
+
return AvailableEndpoints.get_instance(endpoints_config_path)
|
|
57
|
+
|
|
58
|
+
|
|
39
59
|
def configure_file_logging(
|
|
40
60
|
logger_obj: logging.Logger,
|
|
41
61
|
log_file: Optional[Text],
|
|
@@ -177,99 +197,6 @@ def is_limit_reached(num_messages: int, limit: Optional[int]) -> bool:
|
|
|
177
197
|
return limit is not None and num_messages >= limit
|
|
178
198
|
|
|
179
199
|
|
|
180
|
-
class AvailableEndpoints:
|
|
181
|
-
"""Collection of configured endpoints."""
|
|
182
|
-
|
|
183
|
-
_instance = None
|
|
184
|
-
|
|
185
|
-
@classmethod
|
|
186
|
-
def read_endpoints(cls, endpoint_file: Text) -> "AvailableEndpoints":
|
|
187
|
-
"""Read the different endpoints from a yaml file."""
|
|
188
|
-
nlg = read_endpoint_config(endpoint_file, endpoint_type="nlg")
|
|
189
|
-
nlu = read_endpoint_config(endpoint_file, endpoint_type="nlu")
|
|
190
|
-
action = read_endpoint_config(endpoint_file, endpoint_type="action_endpoint")
|
|
191
|
-
model = read_endpoint_config(endpoint_file, endpoint_type="models")
|
|
192
|
-
tracker_store = read_endpoint_config(
|
|
193
|
-
endpoint_file, endpoint_type="tracker_store"
|
|
194
|
-
)
|
|
195
|
-
lock_store = read_endpoint_config(endpoint_file, endpoint_type="lock_store")
|
|
196
|
-
event_broker = read_endpoint_config(endpoint_file, endpoint_type="event_broker")
|
|
197
|
-
vector_store = read_endpoint_config(endpoint_file, endpoint_type="vector_store")
|
|
198
|
-
model_groups = read_property_config_from_endpoints_file(
|
|
199
|
-
endpoint_file, property_name="model_groups"
|
|
200
|
-
)
|
|
201
|
-
privacy = read_property_config_from_endpoints_file(
|
|
202
|
-
endpoint_file, property_name="privacy"
|
|
203
|
-
)
|
|
204
|
-
|
|
205
|
-
return cls(
|
|
206
|
-
nlg,
|
|
207
|
-
nlu,
|
|
208
|
-
action,
|
|
209
|
-
model,
|
|
210
|
-
tracker_store,
|
|
211
|
-
lock_store,
|
|
212
|
-
event_broker,
|
|
213
|
-
vector_store,
|
|
214
|
-
model_groups,
|
|
215
|
-
privacy,
|
|
216
|
-
)
|
|
217
|
-
|
|
218
|
-
def __init__(
|
|
219
|
-
self,
|
|
220
|
-
nlg: Optional[EndpointConfig] = None,
|
|
221
|
-
nlu: Optional[EndpointConfig] = None,
|
|
222
|
-
action: Optional[EndpointConfig] = None,
|
|
223
|
-
model: Optional[EndpointConfig] = None,
|
|
224
|
-
tracker_store: Optional[EndpointConfig] = None,
|
|
225
|
-
lock_store: Optional[EndpointConfig] = None,
|
|
226
|
-
event_broker: Optional[EndpointConfig] = None,
|
|
227
|
-
vector_store: Optional[EndpointConfig] = None,
|
|
228
|
-
model_groups: Optional[List[Dict[str, Any]]] = None,
|
|
229
|
-
privacy: Optional[Dict[Text, Any]] = None,
|
|
230
|
-
) -> None:
|
|
231
|
-
"""Create an `AvailableEndpoints` object."""
|
|
232
|
-
self.model = model
|
|
233
|
-
self.action = action
|
|
234
|
-
self.nlu = nlu
|
|
235
|
-
self.nlg = nlg
|
|
236
|
-
self.tracker_store = tracker_store
|
|
237
|
-
self.lock_store = lock_store
|
|
238
|
-
self.event_broker = event_broker
|
|
239
|
-
self.vector_store = vector_store
|
|
240
|
-
self.model_groups = model_groups
|
|
241
|
-
self.privacy = privacy
|
|
242
|
-
|
|
243
|
-
@classmethod
|
|
244
|
-
def get_instance(
|
|
245
|
-
cls, endpoint_file: Optional[Text] = DEFAULT_ENDPOINTS_PATH
|
|
246
|
-
) -> "AvailableEndpoints":
|
|
247
|
-
"""Get the singleton instance of AvailableEndpoints."""
|
|
248
|
-
# Ensure that the instance is initialized only once.
|
|
249
|
-
if cls._instance is None:
|
|
250
|
-
cls._instance = cls.read_endpoints(endpoint_file)
|
|
251
|
-
return cls._instance
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
def read_endpoints_from_path(
|
|
255
|
-
endpoints_path: Optional[Union[Path, Text]] = None,
|
|
256
|
-
) -> AvailableEndpoints:
|
|
257
|
-
"""Get `AvailableEndpoints` object from specified path.
|
|
258
|
-
|
|
259
|
-
Args:
|
|
260
|
-
endpoints_path: Path of the endpoints file to be read. If `None` the
|
|
261
|
-
default path for that file is used (`endpoints.yml`).
|
|
262
|
-
|
|
263
|
-
Returns:
|
|
264
|
-
`AvailableEndpoints` object read from endpoints file.
|
|
265
|
-
|
|
266
|
-
"""
|
|
267
|
-
endpoints_config_path = cli_utils.get_validated_path(
|
|
268
|
-
endpoints_path, "endpoints", DEFAULT_ENDPOINTS_PATH, True
|
|
269
|
-
)
|
|
270
|
-
return AvailableEndpoints.get_instance(endpoints_config_path)
|
|
271
|
-
|
|
272
|
-
|
|
273
200
|
def _lock_store_is_multi_worker_compatible(
|
|
274
201
|
lock_store: Union[EndpointConfig, LockStore, None],
|
|
275
202
|
) -> bool:
|
|
@@ -143,7 +143,8 @@ class IntentBasedRouter(GraphComponent):
|
|
|
143
143
|
if route_session_to_calm is None:
|
|
144
144
|
commands = self._generate_command_using_intent(message, flows, tracker)
|
|
145
145
|
structlogger.info(
|
|
146
|
-
"intent_based_router.predicated_commands",
|
|
146
|
+
"intent_based_router.predicated_commands",
|
|
147
|
+
commands=commands, # doesn't contain PII
|
|
147
148
|
)
|
|
148
149
|
return commands
|
|
149
150
|
elif route_session_to_calm is True:
|
|
@@ -23,11 +23,14 @@ from rasa.engine.recipes.default_recipe import DefaultV1Recipe
|
|
|
23
23
|
from rasa.engine.storage.resource import Resource
|
|
24
24
|
from rasa.engine.storage.storage import ModelStorage
|
|
25
25
|
from rasa.shared.constants import (
|
|
26
|
+
LOGIT_BIAS_CONFIG_KEY,
|
|
27
|
+
MAX_COMPLETION_TOKENS_CONFIG_KEY,
|
|
26
28
|
MODEL_CONFIG_KEY,
|
|
27
29
|
OPENAI_PROVIDER,
|
|
28
30
|
PROMPT_CONFIG_KEY,
|
|
29
31
|
PROVIDER_CONFIG_KEY,
|
|
30
32
|
ROUTE_TO_CALM_SLOT,
|
|
33
|
+
TEMPERATURE_CONFIG_KEY,
|
|
31
34
|
TIMEOUT_CONFIG_KEY,
|
|
32
35
|
)
|
|
33
36
|
from rasa.shared.core.trackers import DialogueStateTracker
|
|
@@ -66,9 +69,11 @@ DEFAULT_LLM_CONFIG = {
|
|
|
66
69
|
PROVIDER_CONFIG_KEY: OPENAI_PROVIDER,
|
|
67
70
|
MODEL_CONFIG_KEY: DEFAULT_OPENAI_CHAT_MODEL_NAME,
|
|
68
71
|
TIMEOUT_CONFIG_KEY: 7,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
TEMPERATURE_CONFIG_KEY: 0.0,
|
|
73
|
+
MAX_COMPLETION_TOKENS_CONFIG_KEY: 1,
|
|
74
|
+
LOGIT_BIAS_CONFIG_KEY: {
|
|
75
|
+
str(token_id): 100 for token_id in A_TO_C_TOKEN_IDS_CHATGPT
|
|
76
|
+
},
|
|
72
77
|
}
|
|
73
78
|
|
|
74
79
|
structlogger = structlog.get_logger()
|
|
@@ -81,6 +81,7 @@ class CannotHandleCommand(Command):
|
|
|
81
81
|
mapper = {
|
|
82
82
|
CommandSyntaxVersion.v1: "CannotHandle()",
|
|
83
83
|
CommandSyntaxVersion.v2: "cannot handle",
|
|
84
|
+
CommandSyntaxVersion.v3: "cannot handle",
|
|
84
85
|
}
|
|
85
86
|
return mapper.get(
|
|
86
87
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -100,6 +101,7 @@ class CannotHandleCommand(Command):
|
|
|
100
101
|
mapper = {
|
|
101
102
|
CommandSyntaxVersion.v1: r"CannotHandle\(\)",
|
|
102
103
|
CommandSyntaxVersion.v2: r"""^[\s\W\d]*cannot handle['"`]*$""",
|
|
104
|
+
CommandSyntaxVersion.v3: r"""^[\s\W\d]*cannot handle['"`]*$""",
|
|
103
105
|
}
|
|
104
106
|
return mapper.get(
|
|
105
107
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -134,6 +134,7 @@ class CancelFlowCommand(Command):
|
|
|
134
134
|
mapper = {
|
|
135
135
|
CommandSyntaxVersion.v1: "CancelFlow()",
|
|
136
136
|
CommandSyntaxVersion.v2: "cancel flow",
|
|
137
|
+
CommandSyntaxVersion.v3: "cancel flow",
|
|
137
138
|
}
|
|
138
139
|
return mapper.get(
|
|
139
140
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -150,6 +151,7 @@ class CancelFlowCommand(Command):
|
|
|
150
151
|
mapper = {
|
|
151
152
|
CommandSyntaxVersion.v1: r"CancelFlow\(\)",
|
|
152
153
|
CommandSyntaxVersion.v2: r"""^[\s\W\d]*cancel flow['"`]*$""",
|
|
154
|
+
CommandSyntaxVersion.v3: r"""^[\s\W\d]*cancel flow['"`]*$""",
|
|
153
155
|
}
|
|
154
156
|
return mapper.get(
|
|
155
157
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -66,6 +66,7 @@ class ChitChatAnswerCommand(FreeFormAnswerCommand):
|
|
|
66
66
|
mapper = {
|
|
67
67
|
CommandSyntaxVersion.v1: "ChitChat()",
|
|
68
68
|
CommandSyntaxVersion.v2: "offtopic reply",
|
|
69
|
+
CommandSyntaxVersion.v3: "offtopic reply",
|
|
69
70
|
}
|
|
70
71
|
return mapper.get(
|
|
71
72
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -82,6 +83,7 @@ class ChitChatAnswerCommand(FreeFormAnswerCommand):
|
|
|
82
83
|
mapper = {
|
|
83
84
|
CommandSyntaxVersion.v1: r"ChitChat\(\)",
|
|
84
85
|
CommandSyntaxVersion.v2: r"""^[\s\W\d]*offtopic reply['"`]*$""",
|
|
86
|
+
CommandSyntaxVersion.v3: r"""^[\s\W\d]*offtopic reply['"`]*$""",
|
|
85
87
|
}
|
|
86
88
|
return mapper.get(
|
|
87
89
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -102,6 +102,7 @@ class ClarifyCommand(Command):
|
|
|
102
102
|
mapper = {
|
|
103
103
|
CommandSyntaxVersion.v1: f"Clarify({', '.join(self.options)})",
|
|
104
104
|
CommandSyntaxVersion.v2: f"disambiguate flows {' '.join(self.options)}",
|
|
105
|
+
CommandSyntaxVersion.v3: f"disambiguate flows {' '.join(self.options)}",
|
|
105
106
|
}
|
|
106
107
|
return mapper.get(
|
|
107
108
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -119,7 +120,10 @@ class ClarifyCommand(Command):
|
|
|
119
120
|
mapper = {
|
|
120
121
|
CommandSyntaxVersion.v1: r"Clarify\(([\"\'a-zA-Z0-9_, -]*)\)",
|
|
121
122
|
CommandSyntaxVersion.v2: (
|
|
122
|
-
r"""^[\s\W\d]*disambiguate flows (["'a-zA-Z0-9_, -]*)[
|
|
123
|
+
r"""^[\s\W\d]*disambiguate flows (["'a-zA-Z0-9_, -]*)[\W]*$"""
|
|
124
|
+
),
|
|
125
|
+
CommandSyntaxVersion.v3: (
|
|
126
|
+
r"""^[\s\W\d]*disambiguate flows (["'a-zA-Z0-9_, -]*)[\W]*$"""
|
|
123
127
|
),
|
|
124
128
|
}
|
|
125
129
|
return mapper.get(
|
|
@@ -73,6 +73,7 @@ class HumanHandoffCommand(Command):
|
|
|
73
73
|
mapper = {
|
|
74
74
|
CommandSyntaxVersion.v1: "HumanHandoff()",
|
|
75
75
|
CommandSyntaxVersion.v2: "hand over",
|
|
76
|
+
CommandSyntaxVersion.v3: "hand over",
|
|
76
77
|
}
|
|
77
78
|
return mapper.get(
|
|
78
79
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -89,6 +90,7 @@ class HumanHandoffCommand(Command):
|
|
|
89
90
|
mapper = {
|
|
90
91
|
CommandSyntaxVersion.v1: r"HumanHandoff\(\)",
|
|
91
92
|
CommandSyntaxVersion.v2: r"""^[\s\W\d]*hand over['"`]*$""",
|
|
93
|
+
CommandSyntaxVersion.v3: r"""^[\s\W\d]*hand over['"`]*$""",
|
|
92
94
|
}
|
|
93
95
|
return mapper.get(
|
|
94
96
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -66,6 +66,7 @@ class KnowledgeAnswerCommand(FreeFormAnswerCommand):
|
|
|
66
66
|
mapper = {
|
|
67
67
|
CommandSyntaxVersion.v1: "SearchAndReply()",
|
|
68
68
|
CommandSyntaxVersion.v2: "provide info",
|
|
69
|
+
CommandSyntaxVersion.v3: "search and reply",
|
|
69
70
|
}
|
|
70
71
|
return mapper.get(
|
|
71
72
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -82,6 +83,7 @@ class KnowledgeAnswerCommand(FreeFormAnswerCommand):
|
|
|
82
83
|
mapper = {
|
|
83
84
|
CommandSyntaxVersion.v1: r"SearchAndReply\(\)",
|
|
84
85
|
CommandSyntaxVersion.v2: r"""^[\s\W\d]*provide info['"`]*$""",
|
|
86
|
+
CommandSyntaxVersion.v3: r"""^[\s\W\d]*search and reply['"`]*$""",
|
|
85
87
|
}
|
|
86
88
|
return mapper.get(
|
|
87
89
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -67,6 +67,7 @@ class RepeatBotMessagesCommand(Command):
|
|
|
67
67
|
mapper = {
|
|
68
68
|
CommandSyntaxVersion.v1: "RepeatLastBotMessages()",
|
|
69
69
|
CommandSyntaxVersion.v2: "repeat message",
|
|
70
|
+
CommandSyntaxVersion.v3: "repeat message",
|
|
70
71
|
}
|
|
71
72
|
return mapper.get(
|
|
72
73
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -83,6 +84,7 @@ class RepeatBotMessagesCommand(Command):
|
|
|
83
84
|
mapper = {
|
|
84
85
|
CommandSyntaxVersion.v1: r"RepeatLastBotMessages\(\)",
|
|
85
86
|
CommandSyntaxVersion.v2: r"""^[\s\W\d]*repeat message['"`]*$""",
|
|
87
|
+
CommandSyntaxVersion.v3: r"""^[\s\W\d]*repeat message['"`]*$""",
|
|
86
88
|
}
|
|
87
89
|
return mapper.get(
|
|
88
90
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -13,6 +13,7 @@ from rasa.dialogue_understanding.commands.command_syntax_manager import (
|
|
|
13
13
|
)
|
|
14
14
|
from rasa.dialogue_understanding.commands.utils import (
|
|
15
15
|
clean_extracted_value,
|
|
16
|
+
find_default_flows_collecting_slot,
|
|
16
17
|
get_nullable_slot_value,
|
|
17
18
|
)
|
|
18
19
|
from rasa.dialogue_understanding.patterns.collect_information import (
|
|
@@ -136,6 +137,11 @@ class SetSlotCommand(Command):
|
|
|
136
137
|
):
|
|
137
138
|
# Get the other predicted flows from the most recent message on the tracker.
|
|
138
139
|
predicted_flows = get_flows_predicted_to_start_from_tracker(tracker)
|
|
140
|
+
if not predicted_flows:
|
|
141
|
+
# If no predicted flows, check for default flows collecting the slot.
|
|
142
|
+
predicted_flows = find_default_flows_collecting_slot(
|
|
143
|
+
self.name, all_flows
|
|
144
|
+
)
|
|
139
145
|
use_slot_fill = any(
|
|
140
146
|
step.collect == self.name and not step.ask_before_filling
|
|
141
147
|
for flow in all_flows.underlying_flows
|
|
@@ -170,6 +176,7 @@ class SetSlotCommand(Command):
|
|
|
170
176
|
mapper = {
|
|
171
177
|
CommandSyntaxVersion.v1: f"SetSlot({self.name}, {self.value})",
|
|
172
178
|
CommandSyntaxVersion.v2: f"set slot {self.name} {self.value}",
|
|
179
|
+
CommandSyntaxVersion.v3: f"set slot {self.name} {self.value}",
|
|
173
180
|
}
|
|
174
181
|
return mapper.get(
|
|
175
182
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -190,7 +197,10 @@ class SetSlotCommand(Command):
|
|
|
190
197
|
r"""SetSlot\(['"]?([a-zA-Z_][a-zA-Z0-9_-]*)['"]?, ?['"]?(.*)['"]?\)"""
|
|
191
198
|
),
|
|
192
199
|
CommandSyntaxVersion.v2: (
|
|
193
|
-
r"""^[\s\W\d]*set slot ['"`]?([a-zA-Z_][a-zA-Z0-9_-]*)['"`]? ['"`]?(.+?)[
|
|
200
|
+
r"""^[\s\W\d]*set slot ['"`]?([a-zA-Z_][a-zA-Z0-9_-]*)['"`]? ['"`]?(.+?)[\W]*$""" # noqa: E501
|
|
201
|
+
),
|
|
202
|
+
CommandSyntaxVersion.v3: (
|
|
203
|
+
r"""^[\s\W\d]*set slot ['"`]?([a-zA-Z_][a-zA-Z0-9_-]*)['"`]? ['"`]?(.+?)[\W]*$""" # noqa: E501
|
|
194
204
|
),
|
|
195
205
|
}
|
|
196
206
|
return mapper.get(
|
|
@@ -82,6 +82,7 @@ class SkipQuestionCommand(Command):
|
|
|
82
82
|
mapper = {
|
|
83
83
|
CommandSyntaxVersion.v1: "SkipQuestion()",
|
|
84
84
|
CommandSyntaxVersion.v2: "skip question",
|
|
85
|
+
CommandSyntaxVersion.v3: "skip question",
|
|
85
86
|
}
|
|
86
87
|
return mapper.get(
|
|
87
88
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -98,6 +99,7 @@ class SkipQuestionCommand(Command):
|
|
|
98
99
|
mapper = {
|
|
99
100
|
CommandSyntaxVersion.v1: r"SkipQuestion\(\)",
|
|
100
101
|
CommandSyntaxVersion.v2: r"""^[\s\W\d]*skip question['"`]*$""",
|
|
102
|
+
CommandSyntaxVersion.v3: r"""^[\s\W\d]*skip question['"`]*$""",
|
|
101
103
|
}
|
|
102
104
|
return mapper.get(
|
|
103
105
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -117,6 +117,7 @@ class StartFlowCommand(Command):
|
|
|
117
117
|
mapper = {
|
|
118
118
|
CommandSyntaxVersion.v1: f"StartFlow({self.flow})",
|
|
119
119
|
CommandSyntaxVersion.v2: f"start flow {self.flow}",
|
|
120
|
+
CommandSyntaxVersion.v3: f"start flow {self.flow}",
|
|
120
121
|
}
|
|
121
122
|
return mapper.get(
|
|
122
123
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -135,6 +136,9 @@ class StartFlowCommand(Command):
|
|
|
135
136
|
CommandSyntaxVersion.v2: (
|
|
136
137
|
r"""^[\s\W\d]*start flow ['"`]?([a-zA-Z0-9_-]+)['"`]*"""
|
|
137
138
|
),
|
|
139
|
+
CommandSyntaxVersion.v3: (
|
|
140
|
+
r"""^[\s\W\d]*start flow ['"`]?([a-zA-Z0-9_-]+)['"`]*"""
|
|
141
|
+
),
|
|
138
142
|
}
|
|
139
143
|
return mapper.get(
|
|
140
144
|
CommandSyntaxManager.get_syntax_version(),
|
|
@@ -7,18 +7,18 @@ from rasa.dialogue_understanding.patterns.validate_slot import (
|
|
|
7
7
|
)
|
|
8
8
|
from rasa.shared.constants import ACTION_ASK_PREFIX, UTTER_ASK_PREFIX
|
|
9
9
|
from rasa.shared.core.events import Event, SlotSet
|
|
10
|
+
from rasa.shared.core.flows import FlowsList
|
|
10
11
|
from rasa.shared.core.slots import Slot
|
|
11
12
|
from rasa.shared.core.trackers import DialogueStateTracker
|
|
12
13
|
|
|
13
14
|
if TYPE_CHECKING:
|
|
14
15
|
from rasa.dialogue_understanding.commands import StartFlowCommand
|
|
15
|
-
from rasa.shared.core.flows import FlowsList
|
|
16
16
|
|
|
17
17
|
structlogger = structlog.get_logger()
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
def start_flow_by_name(
|
|
21
|
-
flow_name: str, flows:
|
|
21
|
+
flow_name: str, flows: FlowsList
|
|
22
22
|
) -> Optional["StartFlowCommand"]:
|
|
23
23
|
from rasa.dialogue_understanding.commands import StartFlowCommand
|
|
24
24
|
|
|
@@ -126,3 +126,27 @@ def create_validate_frames_from_slot_set_events(
|
|
|
126
126
|
validate_frames.append(frame)
|
|
127
127
|
|
|
128
128
|
return tracker, validate_frames
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def find_default_flows_collecting_slot(
|
|
132
|
+
slot_name: str, all_flows: FlowsList
|
|
133
|
+
) -> List[str]:
|
|
134
|
+
"""Find default flows that have collect steps matching the specified slot name.
|
|
135
|
+
|
|
136
|
+
Args:
|
|
137
|
+
slot_name: The name of the slot to search for.
|
|
138
|
+
all_flows: All flows in the assistant.
|
|
139
|
+
|
|
140
|
+
Returns:
|
|
141
|
+
List of flow IDs for default flows that collect the specified slot
|
|
142
|
+
without asking before filling.
|
|
143
|
+
"""
|
|
144
|
+
return [
|
|
145
|
+
flow.id
|
|
146
|
+
for flow in all_flows.underlying_flows
|
|
147
|
+
if flow.is_rasa_default_flow
|
|
148
|
+
and any(
|
|
149
|
+
step.collect == slot_name and not step.ask_before_filling
|
|
150
|
+
for step in flow.get_collect_steps()
|
|
151
|
+
)
|
|
152
|
+
]
|
|
@@ -8,8 +8,13 @@ from rasa.dialogue_understanding.generator.llm_command_generator import (
|
|
|
8
8
|
from rasa.dialogue_understanding.generator.multi_step.multi_step_llm_command_generator import ( # noqa: E501
|
|
9
9
|
MultiStepLLMCommandGenerator,
|
|
10
10
|
)
|
|
11
|
-
from rasa.dialogue_understanding.generator.single_step.
|
|
11
|
+
from rasa.dialogue_understanding.generator.single_step.compact_llm_command_generator import ( # noqa: E501
|
|
12
12
|
CompactLLMCommandGenerator,
|
|
13
|
+
)
|
|
14
|
+
from rasa.dialogue_understanding.generator.single_step.search_ready_llm_command_generator import ( # noqa: E501
|
|
15
|
+
SearchReadyLLMCommandGenerator,
|
|
16
|
+
)
|
|
17
|
+
from rasa.dialogue_understanding.generator.single_step.single_step_llm_command_generator import ( # noqa: E501
|
|
13
18
|
SingleStepLLMCommandGenerator,
|
|
14
19
|
)
|
|
15
20
|
|
|
@@ -20,4 +25,5 @@ __all__ = [
|
|
|
20
25
|
"MultiStepLLMCommandGenerator",
|
|
21
26
|
"SingleStepLLMCommandGenerator",
|
|
22
27
|
"CompactLLMCommandGenerator",
|
|
28
|
+
"SearchReadyLLMCommandGenerator",
|
|
23
29
|
]
|
|
@@ -321,7 +321,10 @@ class CommandGenerator:
|
|
|
321
321
|
if commands and len(checked_commands) != len(commands):
|
|
322
322
|
structlogger.info(
|
|
323
323
|
"command_generator.check_commands_against_startable_flows.startable_commands",
|
|
324
|
-
commands=
|
|
324
|
+
commands=[
|
|
325
|
+
checked_command.__class__.__name__
|
|
326
|
+
for checked_command in checked_commands
|
|
327
|
+
],
|
|
325
328
|
)
|
|
326
329
|
|
|
327
330
|
return checked_commands
|
|
@@ -357,7 +360,6 @@ class CommandGenerator:
|
|
|
357
360
|
"command_generator.evaluate_message.error",
|
|
358
361
|
event_info="Invalid message",
|
|
359
362
|
errors=[e.as_dict() for e in errors],
|
|
360
|
-
message=message.get(TEXT),
|
|
361
363
|
)
|
|
362
364
|
return errors
|
|
363
365
|
|
|
@@ -81,7 +81,7 @@ def _get_additional_parsing_logic(
|
|
|
81
81
|
|
|
82
82
|
def validate_custom_commands(command_classes: List[Type[PromptCommand]]) -> None:
|
|
83
83
|
clz_not_inheriting_from_command_clz = [
|
|
84
|
-
command_clz
|
|
84
|
+
command_clz.__name__
|
|
85
85
|
for command_clz in command_classes
|
|
86
86
|
if not issubclass(command_clz, Command)
|
|
87
87
|
]
|
|
@@ -99,7 +99,7 @@ def validate_custom_commands(command_classes: List[Type[PromptCommand]]) -> None
|
|
|
99
99
|
sys.exit(1)
|
|
100
100
|
|
|
101
101
|
clz_not_adhering_to_prompt_command_protocol = [
|
|
102
|
-
command_clz
|
|
102
|
+
command_clz.__name__
|
|
103
103
|
for command_clz in command_classes
|
|
104
104
|
if not isinstance(command_clz, PromptCommand)
|
|
105
105
|
]
|