rasa-pro 3.14.0.dev3__py3-none-any.whl → 3.14.0.dev4__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/agents/constants.py +8 -0
- rasa/agents/core/agent_protocol.py +1 -2
- rasa/agents/protocol/a2a/a2a_agent.py +628 -17
- rasa/agents/protocol/mcp/mcp_base_agent.py +4 -2
- rasa/core/actions/action.py +13 -8
- rasa/core/available_agents.py +3 -0
- rasa/core/channels/development_inspector.py +3 -3
- rasa/core/channels/hangouts.py +2 -2
- rasa/core/channels/inspector/dist/assets/{arc-2e78c586.js → arc-63212852.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-806b712e.js → blockDiagram-38ab4fdb-eecf6b13.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-0745efa9.js → c4Diagram-3d4e48cf-8f798a9a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/channel-0cd70adf.js +1 -0
- rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-7bd1082b.js → classDiagram-70f12bd4-df71a04c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-d937ba49.js → classDiagram-v2-f2320105-9b275968.js} +1 -1
- rasa/core/channels/inspector/dist/assets/clone-a0f9c4ed.js +1 -0
- rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-a2a564ca.js → createText-2e5e7dd3-1c669cad.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-b5256940.js → edges-e0da2a9e-b1553799.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-e6883ad2.js → erDiagram-9861fffd-112388d6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-e576fc02.js → flowDb-956e92f1-fdebec47.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-2e298d01.js → flowDiagram-66a62f08-6280ede1.js} +1 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-de9cc4aa.js +1 -0
- rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-dd7b150a.js → flowchart-elk-definition-4a651766-e1dc03e5.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-5b79575c.js → ganttDiagram-c361ad54-83f68c51.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-3016f40a.js → gitGraphDiagram-72cf32ee-22f8666f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{graph-3e19170f.js → graph-ca9e6217.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-3862675e-eb9c86de.js → index-3862675e-c5ceb692.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-1bd9135e.js → index-3e293924.js} +3 -3
- rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-b4280e4d.js → infoDiagram-f8f76790-faa9999b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-556091f8.js → journeyDiagram-49397b02-c4dda8d9.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-08436411.js → layout-d4307784.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{line-683c4f3b.js → line-0567aaa7.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-cee6d791.js → linear-c11b95cf.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-a0bf0b1a.js → mindmap-definition-fc14e90a-0c7d3ca9.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-3730d5c4.js → pieDiagram-8a3498a8-34b433fa.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-12a20fed.js → quadrantDiagram-120e2f19-4cab816e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-b9732102.js → requirementDiagram-deff3bca-8c22fa9e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-a2e72776.js → sankeyDiagram-04a897e0-70ce9e8e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-8b7a76bb.js → sequenceDiagram-704730f1-fbcd7fc9.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-e65853ac.js → stateDiagram-587899a1-45f05ea6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-6f58a44b.js → stateDiagram-v2-d93cdb3a-beab1ea6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-df25b934.js → styles-6aaf32cf-2f29dbd5.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-9a916d00-88357141.js → styles-9a916d00-951eac83.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-c10674c1-d600174d.js → styles-c10674c1-897fbfdd.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-4adc3e0b.js → svgDrawCommon-08f97a94-d667fac1.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-42816fa1.js → timeline-definition-85554ec2-e3205144.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-621eb66a.js → xychartDiagram-e933f94c-4abeb0e2.js} +1 -1
- rasa/core/channels/inspector/dist/index.html +1 -1
- rasa/core/channels/inspector/src/components/DialogueStack.tsx +1 -1
- rasa/core/channels/studio_chat.py +6 -6
- rasa/core/channels/voice_stream/genesys.py +1 -1
- rasa/core/policies/flows/flow_executor.py +42 -1
- rasa/core/policies/intentless_policy.py +1 -1
- rasa/core/policies/unexpected_intent_policy.py +1 -0
- rasa/core/processor.py +12 -14
- rasa/core/tracker_stores/tracker_store.py +3 -7
- rasa/core/train.py +1 -1
- rasa/core/training/interactive.py +16 -16
- rasa/core/training/story_conflict.py +5 -5
- rasa/dialogue_understanding/generator/llm_command_generator.py +1 -1
- rasa/dialogue_understanding/generator/multi_step/multi_step_llm_command_generator.py +1 -1
- rasa/e2e_test/e2e_test_runner.py +7 -2
- rasa/engine/caching.py +2 -2
- rasa/engine/recipes/default_components.py +10 -18
- rasa/graph_components/validators/default_recipe_validator.py +134 -134
- rasa/hooks.py +5 -5
- rasa/llm_fine_tuning/utils.py +2 -2
- rasa/model_manager/warm_rasa_process.py +1 -1
- rasa/nlu/extractors/extractor.py +2 -1
- rasa/plugin.py +8 -8
- rasa/privacy/privacy_manager.py +11 -2
- rasa/server.py +4 -2
- rasa/shared/core/events.py +9 -1
- rasa/shared/core/flows/yaml_flows_io.py +1 -1
- rasa/shared/core/slots.py +2 -2
- rasa/shared/core/trackers.py +5 -2
- rasa/shared/exceptions.py +4 -0
- rasa/shared/utils/yaml.py +3 -1
- rasa/tracing/instrumentation/instrumentation.py +8 -8
- rasa/tracing/instrumentation/intentless_policy_instrumentation.py +4 -4
- rasa/utils/log_utils.py +1 -1
- rasa/utils/ml_utils.py +1 -1
- rasa/utils/tensorflow/rasa_layers.py +1 -1
- rasa/utils/train_utils.py +15 -15
- rasa/validator.py +16 -14
- rasa/version.py +1 -1
- {rasa_pro-3.14.0.dev3.dist-info → rasa_pro-3.14.0.dev4.dist-info}/METADATA +12 -15
- {rasa_pro-3.14.0.dev3.dist-info → rasa_pro-3.14.0.dev4.dist-info}/RECORD +90 -90
- rasa/core/channels/inspector/dist/assets/channel-c436ca7c.js +0 -1
- rasa/core/channels/inspector/dist/assets/clone-50dd656b.js +0 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-2b2aeaf8.js +0 -1
- {rasa_pro-3.14.0.dev3.dist-info → rasa_pro-3.14.0.dev4.dist-info}/NOTICE +0 -0
- {rasa_pro-3.14.0.dev3.dist-info → rasa_pro-3.14.0.dev4.dist-info}/WHEEL +0 -0
- {rasa_pro-3.14.0.dev3.dist-info → rasa_pro-3.14.0.dev4.dist-info}/entry_points.txt +0 -0
|
@@ -100,12 +100,12 @@ class StudioTrackerUpdatePlugin:
|
|
|
100
100
|
"""Remove tasks that have already completed."""
|
|
101
101
|
self.tasks = [task for task in self.tasks if not task.done()]
|
|
102
102
|
|
|
103
|
-
@hookimpl
|
|
103
|
+
@hookimpl
|
|
104
104
|
def after_new_user_message(self, tracker: "DialogueStateTracker") -> None:
|
|
105
105
|
"""Triggers a tracker update notification after a new user message."""
|
|
106
106
|
self.handle_tracker_update(tracker)
|
|
107
107
|
|
|
108
|
-
@hookimpl
|
|
108
|
+
@hookimpl
|
|
109
109
|
def after_action_executed(self, tracker: "DialogueStateTracker") -> None:
|
|
110
110
|
"""Triggers a tracker update notification after an action is executed."""
|
|
111
111
|
self.handle_tracker_update(tracker)
|
|
@@ -125,7 +125,7 @@ class StudioTrackerUpdatePlugin:
|
|
|
125
125
|
self.tasks.append(task)
|
|
126
126
|
self._cleanup_tasks()
|
|
127
127
|
|
|
128
|
-
@hookimpl
|
|
128
|
+
@hookimpl
|
|
129
129
|
def after_server_stop(self) -> None:
|
|
130
130
|
"""Cancels all remaining tasks when the server stops."""
|
|
131
131
|
self._cancel_tasks()
|
|
@@ -446,7 +446,7 @@ class StudioChatInput(SocketIOInput, VoiceInputChannel):
|
|
|
446
446
|
if sid in self.active_connections:
|
|
447
447
|
del self.active_connections[sid]
|
|
448
448
|
|
|
449
|
-
@hookimpl
|
|
449
|
+
@hookimpl
|
|
450
450
|
def after_server_stop(self) -> None:
|
|
451
451
|
"""Cleanup background tasks and active connections when the server stops."""
|
|
452
452
|
structlogger.info("studio_chat.after_server_stop.cleanup")
|
|
@@ -531,7 +531,7 @@ class StudioVoiceOutputChannel(VoiceOutputChannel):
|
|
|
531
531
|
|
|
532
532
|
def create_marker_message(self, recipient_id: str) -> Tuple[str, str]:
|
|
533
533
|
message_id = uuid.uuid4().hex
|
|
534
|
-
marker_data = {"marker": message_id}
|
|
534
|
+
marker_data: Dict[str, Any] = {"marker": message_id}
|
|
535
535
|
|
|
536
536
|
# Include comprehensive latency information if available
|
|
537
537
|
latency_data = {
|
|
@@ -546,7 +546,7 @@ class StudioVoiceOutputChannel(VoiceOutputChannel):
|
|
|
546
546
|
|
|
547
547
|
# Add latency data to marker if any metrics are available
|
|
548
548
|
if latency_data:
|
|
549
|
-
marker_data["latency"] = latency_data
|
|
549
|
+
marker_data["latency"] = latency_data
|
|
550
550
|
|
|
551
551
|
return json.dumps(marker_data), message_id
|
|
552
552
|
|
|
@@ -274,7 +274,7 @@ class GenesysInputChannel(VoiceInputChannel):
|
|
|
274
274
|
|
|
275
275
|
def handle_ping(self, ws: Websocket, message: dict) -> None:
|
|
276
276
|
"""Handle ping message from Genesys."""
|
|
277
|
-
response = {
|
|
277
|
+
response: Dict[str, Any] = {
|
|
278
278
|
"version": "2",
|
|
279
279
|
"type": "pong",
|
|
280
280
|
"seq": self._get_next_sequence(),
|
|
@@ -10,9 +10,11 @@ from structlog.contextvars import bound_contextvars
|
|
|
10
10
|
|
|
11
11
|
from rasa.agents.agent_manager import AgentManager
|
|
12
12
|
from rasa.agents.constants import (
|
|
13
|
+
A2A_AGENT_CONTEXT_ID_KEY,
|
|
13
14
|
AGENT_METADATA_AGENT_RESPONSE_KEY,
|
|
14
15
|
AGENT_METADATA_EXIT_IF_KEY,
|
|
15
16
|
AGENT_METADATA_TOOL_RESULTS_KEY,
|
|
17
|
+
MAX_AGENT_RETRY_DELAY_SECONDS,
|
|
16
18
|
)
|
|
17
19
|
from rasa.agents.core.types import AgentStatus, ProtocolType
|
|
18
20
|
from rasa.agents.schemas import AgentInput, AgentOutput
|
|
@@ -112,7 +114,6 @@ structlogger = structlog.get_logger()
|
|
|
112
114
|
|
|
113
115
|
MAX_NUMBER_OF_STEPS = 250
|
|
114
116
|
|
|
115
|
-
MAX_AGENT_RETRY_DELAY_SECONDS = 5
|
|
116
117
|
MAX_AGENT_RETRIES = 3
|
|
117
118
|
|
|
118
119
|
# Slots that should not be forwarded to sub-agents via AgentInput
|
|
@@ -940,6 +941,9 @@ async def run_agent(
|
|
|
940
941
|
if agent_stack_frame and agent_stack_frame.metadata
|
|
941
942
|
else {}
|
|
942
943
|
)
|
|
944
|
+
_update_agent_input_metadata_with_events(
|
|
945
|
+
agent_input_metadata, step.call, step.flow_id, tracker
|
|
946
|
+
)
|
|
943
947
|
if step.exit_if:
|
|
944
948
|
# TODO: this is a temporary fix to reset the slots covered by the exit_if
|
|
945
949
|
if (
|
|
@@ -996,6 +1000,7 @@ async def run_agent(
|
|
|
996
1000
|
output.response_message or ""
|
|
997
1001
|
)
|
|
998
1002
|
output.metadata[AGENT_METADATA_TOOL_RESULTS_KEY] = output.tool_results or []
|
|
1003
|
+
_update_agent_events(final_events, output.metadata)
|
|
999
1004
|
|
|
1000
1005
|
top_stack_frame = stack.top()
|
|
1001
1006
|
# update the agent stack frame if it is already on the stack
|
|
@@ -1022,6 +1027,8 @@ async def run_agent(
|
|
|
1022
1027
|
)
|
|
1023
1028
|
return PauseFlowReturnPrediction(action_prediction)
|
|
1024
1029
|
elif output.status == AgentStatus.COMPLETED:
|
|
1030
|
+
output.metadata = output.metadata or {}
|
|
1031
|
+
_update_agent_events(final_events, output.metadata)
|
|
1025
1032
|
structlogger.debug(
|
|
1026
1033
|
"flow.step.run_agent.completed",
|
|
1027
1034
|
agent_name=step.call,
|
|
@@ -1040,6 +1047,8 @@ async def run_agent(
|
|
|
1040
1047
|
else:
|
|
1041
1048
|
return ContinueFlowWithNextStep(events=final_events)
|
|
1042
1049
|
elif output.status == AgentStatus.FATAL_ERROR:
|
|
1050
|
+
output.metadata = output.metadata or {}
|
|
1051
|
+
_update_agent_events(final_events, output.metadata)
|
|
1043
1052
|
# the agent failed, trigger pattern_internal_error
|
|
1044
1053
|
structlogger.error(
|
|
1045
1054
|
"flow.step.run_agent.fatal_error",
|
|
@@ -1057,6 +1066,8 @@ async def run_agent(
|
|
|
1057
1066
|
stack.push(InternalErrorPatternFlowStackFrame())
|
|
1058
1067
|
return ContinueFlowWithNextStep(events=final_events)
|
|
1059
1068
|
else:
|
|
1069
|
+
output.metadata = output.metadata or {}
|
|
1070
|
+
_update_agent_events(final_events, output.metadata)
|
|
1060
1071
|
structlogger.error(
|
|
1061
1072
|
"flow.step.run_agent.unknown_status",
|
|
1062
1073
|
agent_name=step.call,
|
|
@@ -1209,3 +1220,33 @@ def _prepare_slots_for_agent(
|
|
|
1209
1220
|
)
|
|
1210
1221
|
|
|
1211
1222
|
return filtered_slots
|
|
1223
|
+
|
|
1224
|
+
|
|
1225
|
+
def _update_agent_events(events: List[Event], metadata: Dict[str, Any]) -> None:
|
|
1226
|
+
"""Update the agent events based on the agent output metadata if needed."""
|
|
1227
|
+
if A2A_AGENT_CONTEXT_ID_KEY in metadata:
|
|
1228
|
+
# If the context ID is present, we need to store it in the AgentStarted
|
|
1229
|
+
# event, so that it can be re-used later in case the agent is restarted.
|
|
1230
|
+
for event in events:
|
|
1231
|
+
if isinstance(event, AgentStarted):
|
|
1232
|
+
event.context_id = metadata[A2A_AGENT_CONTEXT_ID_KEY]
|
|
1233
|
+
|
|
1234
|
+
|
|
1235
|
+
def _update_agent_input_metadata_with_events(
|
|
1236
|
+
metadata: Dict[str, Any], agent_id: str, flow_id: str, tracker: DialogueStateTracker
|
|
1237
|
+
) -> None:
|
|
1238
|
+
"""Update the agent input metadata with the events."""
|
|
1239
|
+
agent_started_events = [
|
|
1240
|
+
event
|
|
1241
|
+
for event in tracker.events
|
|
1242
|
+
if type(event) == AgentStarted
|
|
1243
|
+
and event.agent_id == agent_id
|
|
1244
|
+
and event.flow_id == flow_id
|
|
1245
|
+
]
|
|
1246
|
+
if agent_started_events:
|
|
1247
|
+
# If we have context ID from the previous agent run, we want to
|
|
1248
|
+
# include it in the metadata so that the agent can continue the same
|
|
1249
|
+
# context.
|
|
1250
|
+
agent_started_event = agent_started_events[-1]
|
|
1251
|
+
if agent_started_event.context_id:
|
|
1252
|
+
metadata[A2A_AGENT_CONTEXT_ID_KEY] = agent_started_event.context_id
|
|
@@ -5,7 +5,7 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Text, Tuple
|
|
|
5
5
|
|
|
6
6
|
import structlog
|
|
7
7
|
import tiktoken
|
|
8
|
-
from deprecated import deprecated # type: ignore[import]
|
|
8
|
+
from deprecated import deprecated # type: ignore[import-untyped]
|
|
9
9
|
from jinja2 import Template
|
|
10
10
|
from langchain.docstore.document import Document
|
|
11
11
|
from langchain.schema.embeddings import Embeddings
|
|
@@ -624,6 +624,7 @@ class UnexpecTEDIntentPolicy(TEDPolicy):
|
|
|
624
624
|
query_intent = (
|
|
625
625
|
last_user_uttered_event.intent_name
|
|
626
626
|
if last_user_uttered_event is not None
|
|
627
|
+
and isinstance(last_user_uttered_event, UserUttered)
|
|
627
628
|
else ""
|
|
628
629
|
)
|
|
629
630
|
is_unlikely_intent = self._check_unlikely_intent(
|
rasa/core/processor.py
CHANGED
|
@@ -730,7 +730,7 @@ class MessageProcessor:
|
|
|
730
730
|
if not self.domain or self.domain.is_empty():
|
|
731
731
|
return
|
|
732
732
|
|
|
733
|
-
intent = parse_data[
|
|
733
|
+
intent = parse_data[INTENT][INTENT_NAME_KEY]
|
|
734
734
|
if intent and intent not in self.domain.intents:
|
|
735
735
|
rasa.shared.utils.io.raise_warning(
|
|
736
736
|
f"Parsed an intent '{intent}' "
|
|
@@ -739,7 +739,7 @@ class MessageProcessor:
|
|
|
739
739
|
docs=DOCS_URL_DOMAINS,
|
|
740
740
|
)
|
|
741
741
|
|
|
742
|
-
entities = parse_data[
|
|
742
|
+
entities = parse_data[ENTITIES] or []
|
|
743
743
|
for element in entities:
|
|
744
744
|
entity = element["entity"]
|
|
745
745
|
if entity and entity not in self.domain.entities:
|
|
@@ -823,9 +823,9 @@ class MessageProcessor:
|
|
|
823
823
|
self._update_full_retrieval_intent(parse_data)
|
|
824
824
|
structlogger.debug(
|
|
825
825
|
"processor.message.parse",
|
|
826
|
-
parse_data_text=copy.deepcopy(parse_data[
|
|
827
|
-
parse_data_intent=parse_data[
|
|
828
|
-
parse_data_entities=copy.deepcopy(parse_data[
|
|
826
|
+
parse_data_text=copy.deepcopy(parse_data[TEXT]),
|
|
827
|
+
parse_data_intent=parse_data[INTENT],
|
|
828
|
+
parse_data_entities=copy.deepcopy(parse_data[ENTITIES]),
|
|
829
829
|
)
|
|
830
830
|
|
|
831
831
|
self._check_for_unseen_features(parse_data)
|
|
@@ -974,7 +974,7 @@ class MessageProcessor:
|
|
|
974
974
|
f"invalid intent: {parse_data[INTENT]['name']}. "
|
|
975
975
|
f"Returning CannotHandleCommand() as a fallback."
|
|
976
976
|
),
|
|
977
|
-
invalid_intent=parse_data[INTENT][
|
|
977
|
+
invalid_intent=parse_data[INTENT][INTENT_NAME_KEY],
|
|
978
978
|
)
|
|
979
979
|
commands.append(
|
|
980
980
|
CannotHandleCommand(RASA_PATTERN_CANNOT_HANDLE_INVALID_INTENT)
|
|
@@ -984,7 +984,7 @@ class MessageProcessor:
|
|
|
984
984
|
|
|
985
985
|
def _contains_undefined_intent(self, message: Message) -> bool:
|
|
986
986
|
"""Checks if the message contains an undefined intent."""
|
|
987
|
-
intent_name = message.get(INTENT, {}).get(
|
|
987
|
+
intent_name = message.get(INTENT, {}).get(INTENT_NAME_KEY)
|
|
988
988
|
return intent_name is not None and intent_name not in self.domain.intents
|
|
989
989
|
|
|
990
990
|
async def _parse_message_with_graph(
|
|
@@ -1034,8 +1034,8 @@ class MessageProcessor:
|
|
|
1034
1034
|
tracker.update(
|
|
1035
1035
|
UserUttered(
|
|
1036
1036
|
message.text,
|
|
1037
|
-
parse_data[
|
|
1038
|
-
parse_data[
|
|
1037
|
+
parse_data[INTENT],
|
|
1038
|
+
parse_data[ENTITIES],
|
|
1039
1039
|
parse_data,
|
|
1040
1040
|
input_channel=message.input_channel,
|
|
1041
1041
|
message_id=message.message_id,
|
|
@@ -1044,7 +1044,7 @@ class MessageProcessor:
|
|
|
1044
1044
|
self.domain,
|
|
1045
1045
|
)
|
|
1046
1046
|
|
|
1047
|
-
if parse_data[
|
|
1047
|
+
if parse_data[ENTITIES]:
|
|
1048
1048
|
self._log_slots(tracker)
|
|
1049
1049
|
|
|
1050
1050
|
plugin_manager().hook.after_new_user_message(tracker=tracker)
|
|
@@ -1472,11 +1472,9 @@ class MessageProcessor:
|
|
|
1472
1472
|
# tracker has never expired if sessions are disabled
|
|
1473
1473
|
return False
|
|
1474
1474
|
|
|
1475
|
-
user_uttered_event
|
|
1476
|
-
UserUttered
|
|
1477
|
-
)
|
|
1475
|
+
user_uttered_event = tracker.get_last_event_for(UserUttered)
|
|
1478
1476
|
|
|
1479
|
-
if not user_uttered_event:
|
|
1477
|
+
if not user_uttered_event or not isinstance(user_uttered_event, UserUttered):
|
|
1480
1478
|
# there is no user event so far so the session should not be considered
|
|
1481
1479
|
# expired
|
|
1482
1480
|
return False
|
|
@@ -542,7 +542,7 @@ class FailSafeTrackerStore(TrackerStore):
|
|
|
542
542
|
return self._tracker_store.domain
|
|
543
543
|
|
|
544
544
|
@domain.setter
|
|
545
|
-
def domain(self, domain: Domain) -> None:
|
|
545
|
+
def domain(self, domain: Optional[Domain]) -> None:
|
|
546
546
|
self._tracker_store.domain = domain
|
|
547
547
|
|
|
548
548
|
if self._fallback_tracker_store:
|
|
@@ -805,9 +805,7 @@ class AwaitableTrackerStore(TrackerStore):
|
|
|
805
805
|
async def retrieve(self, sender_id: Text) -> Optional[DialogueStateTracker]:
|
|
806
806
|
"""Wrapper to call `retrieve` method of primary tracker store."""
|
|
807
807
|
result = self._tracker_store.retrieve(sender_id)
|
|
808
|
-
return (
|
|
809
|
-
await result if isawaitable(result) else result # type: ignore[return-value, misc]
|
|
810
|
-
)
|
|
808
|
+
return await result if isawaitable(result) else result
|
|
811
809
|
|
|
812
810
|
async def keys(self) -> Iterable[Text]:
|
|
813
811
|
"""Wrapper to call `keys` method of primary tracker store."""
|
|
@@ -834,6 +832,4 @@ class AwaitableTrackerStore(TrackerStore):
|
|
|
834
832
|
) -> Optional[DialogueStateTracker]:
|
|
835
833
|
"""Wrapper to call `retrieve_full_tracker` method of primary tracker store."""
|
|
836
834
|
result = self._tracker_store.retrieve_full_tracker(conversation_id)
|
|
837
|
-
return (
|
|
838
|
-
await result if isawaitable(result) else result # type: ignore[return-value, misc]
|
|
839
|
-
)
|
|
835
|
+
return await result if isawaitable(result) else result
|
rasa/core/train.py
CHANGED
|
@@ -46,7 +46,7 @@ async def train_comparison_models(
|
|
|
46
46
|
output=str(Path(output_path, f"run_{r +1}")),
|
|
47
47
|
fixed_model_name=config_name + PERCENTAGE_KEY + str(percentage),
|
|
48
48
|
additional_arguments={
|
|
49
|
-
**additional_arguments,
|
|
49
|
+
**(additional_arguments or {}),
|
|
50
50
|
"exclusion_percentage": percentage,
|
|
51
51
|
},
|
|
52
52
|
)
|
|
@@ -91,7 +91,7 @@ from rasa.shared.core.training_data.visualization import (
|
|
|
91
91
|
)
|
|
92
92
|
from rasa.shared.exceptions import InvalidConfigException
|
|
93
93
|
from rasa.shared.importers.rasa import TrainingDataImporter
|
|
94
|
-
from rasa.shared.nlu.constants import INTENT_NAME_KEY, TEXT
|
|
94
|
+
from rasa.shared.nlu.constants import ENTITIES, INTENT, INTENT_NAME_KEY, TEXT
|
|
95
95
|
|
|
96
96
|
# noinspection PyProtectedMember
|
|
97
97
|
from rasa.shared.nlu.training_data import loading
|
|
@@ -789,7 +789,7 @@ def _collect_messages(events: List[Dict[Text, Any]]) -> List[Message]:
|
|
|
789
789
|
data = event.get("parse_data", {})
|
|
790
790
|
rasa_nlu_training_data_utils.remove_untrainable_entities_from(data)
|
|
791
791
|
msg = Message.build(
|
|
792
|
-
data[
|
|
792
|
+
data[TEXT], data[INTENT][INTENT_NAME_KEY], data[ENTITIES]
|
|
793
793
|
)
|
|
794
794
|
messages.append(msg)
|
|
795
795
|
elif event.get("event") == UserUtteranceReverted.type_name and messages:
|
|
@@ -901,13 +901,13 @@ def _get_nlu_target_format(export_path: Text) -> Text:
|
|
|
901
901
|
|
|
902
902
|
def _entities_from_messages(messages: List[Message]) -> List[Text]:
|
|
903
903
|
"""Return all entities that occur in at least one of the messages."""
|
|
904
|
-
return list({e["entity"] for m in messages for e in m.data.get(
|
|
904
|
+
return list({e["entity"] for m in messages for e in m.data.get(ENTITIES, [])})
|
|
905
905
|
|
|
906
906
|
|
|
907
907
|
def _intents_from_messages(messages: List[Message]) -> Set[Text]:
|
|
908
908
|
"""Return all intents that occur in at least one of the messages."""
|
|
909
909
|
# set of distinct intents
|
|
910
|
-
distinct_intents = {m.data[
|
|
910
|
+
distinct_intents = {m.data[INTENT] for m in messages if INTENT in m.data}
|
|
911
911
|
|
|
912
912
|
return distinct_intents
|
|
913
913
|
|
|
@@ -1191,11 +1191,11 @@ def _as_md_message(parse_data: Dict[Text, Any]) -> Text:
|
|
|
1191
1191
|
"""Display the parse data of a message in markdown format."""
|
|
1192
1192
|
from rasa.shared.nlu.training_data.formats.readerwriter import TrainingDataWriter
|
|
1193
1193
|
|
|
1194
|
-
if parse_data.get(
|
|
1195
|
-
return parse_data[
|
|
1194
|
+
if parse_data.get(TEXT, "").startswith(INTENT_MESSAGE_PREFIX):
|
|
1195
|
+
return parse_data[TEXT]
|
|
1196
1196
|
|
|
1197
|
-
if not parse_data.get(
|
|
1198
|
-
parse_data[
|
|
1197
|
+
if not parse_data.get(ENTITIES):
|
|
1198
|
+
parse_data[ENTITIES] = []
|
|
1199
1199
|
|
|
1200
1200
|
return TrainingDataWriter.generate_message(parse_data)
|
|
1201
1201
|
|
|
@@ -1207,7 +1207,7 @@ def _validate_user_regex(latest_message: Dict[Text, Any], intents: List[Text]) -
|
|
|
1207
1207
|
`/greet`. Return `True` if the intent is a known one.
|
|
1208
1208
|
"""
|
|
1209
1209
|
parse_data = latest_message.get("parse_data", {})
|
|
1210
|
-
intent = parse_data.get(
|
|
1210
|
+
intent = parse_data.get(INTENT, {}).get(INTENT_NAME_KEY)
|
|
1211
1211
|
|
|
1212
1212
|
if intent in intents:
|
|
1213
1213
|
return True
|
|
@@ -1224,8 +1224,8 @@ async def _validate_user_text(
|
|
|
1224
1224
|
"""
|
|
1225
1225
|
parse_data = latest_message.get("parse_data", {})
|
|
1226
1226
|
text = _as_md_message(parse_data)
|
|
1227
|
-
intent = parse_data.get(
|
|
1228
|
-
entities = parse_data.get(
|
|
1227
|
+
intent = parse_data.get(INTENT, {}).get(INTENT_NAME_KEY)
|
|
1228
|
+
entities = parse_data.get(ENTITIES, [])
|
|
1229
1229
|
if entities:
|
|
1230
1230
|
message = (
|
|
1231
1231
|
f"Is the intent '{intent}' correct for '{text}' and are "
|
|
@@ -1276,9 +1276,9 @@ async def _validate_nlu(
|
|
|
1276
1276
|
|
|
1277
1277
|
entities = await _correct_entities(latest_message, endpoint, conversation_id)
|
|
1278
1278
|
corrected_nlu = {
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1279
|
+
INTENT: corrected_intent,
|
|
1280
|
+
ENTITIES: entities,
|
|
1281
|
+
TEXT: latest_message.get("text"),
|
|
1282
1282
|
}
|
|
1283
1283
|
|
|
1284
1284
|
await _correct_wrong_nlu(corrected_nlu, events, endpoint, conversation_id)
|
|
@@ -1315,9 +1315,9 @@ def _merge_annotated_and_original_entities(
|
|
|
1315
1315
|
# overwrite entities which have already been
|
|
1316
1316
|
# annotated in the original annotation to preserve
|
|
1317
1317
|
# additional entity parser information
|
|
1318
|
-
entities = parse_annotated.get(
|
|
1318
|
+
entities = parse_annotated.get(ENTITIES, [])[:]
|
|
1319
1319
|
for i, entity in enumerate(entities):
|
|
1320
|
-
for original_entity in parse_original.get(
|
|
1320
|
+
for original_entity in parse_original.get(ENTITIES, []):
|
|
1321
1321
|
if _is_same_entity_annotation(entity, original_entity):
|
|
1322
1322
|
entities[i] = original_entity
|
|
1323
1323
|
break
|
|
@@ -14,7 +14,7 @@ from rasa.shared.core.constants import (
|
|
|
14
14
|
from rasa.shared.core.domain import Domain, State
|
|
15
15
|
from rasa.shared.core.events import ActionExecuted, Event
|
|
16
16
|
from rasa.shared.core.generator import TrackerWithCachedStates
|
|
17
|
-
from rasa.shared.nlu.constants import TEXT
|
|
17
|
+
from rasa.shared.nlu.constants import INTENT, TEXT
|
|
18
18
|
from rasa.shared.nlu.training_data.message import Message
|
|
19
19
|
|
|
20
20
|
logger = logging.getLogger(__name__)
|
|
@@ -362,12 +362,12 @@ def _get_previous_event(
|
|
|
362
362
|
previous_event_type = "bot utterance"
|
|
363
363
|
previous_event_name = state[PREVIOUS_ACTION]["action_text"]
|
|
364
364
|
elif USER in state.keys():
|
|
365
|
-
if
|
|
365
|
+
if INTENT in state[USER]:
|
|
366
366
|
previous_event_type = "intent"
|
|
367
|
-
previous_event_name = state[USER][
|
|
368
|
-
elif
|
|
367
|
+
previous_event_name = state[USER][INTENT]
|
|
368
|
+
elif TEXT in state[USER]:
|
|
369
369
|
previous_event_type = "user utterance"
|
|
370
|
-
previous_event_name = state[USER][
|
|
370
|
+
previous_event_name = state[USER][TEXT]
|
|
371
371
|
|
|
372
372
|
if not isinstance(previous_event_name, (str, type(None))):
|
|
373
373
|
# While the Substate type doesn't restrict the value of `action_text` /
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from typing import Any, Dict, List, Optional, Text, Union
|
|
2
2
|
|
|
3
3
|
import structlog
|
|
4
|
-
from deprecated import deprecated # type: ignore[import]
|
|
4
|
+
from deprecated import deprecated # type: ignore[import-untyped]
|
|
5
5
|
|
|
6
6
|
from rasa.dialogue_understanding.generator.single_step.single_step_llm_command_generator import ( # noqa: E501
|
|
7
7
|
SingleStepLLMCommandGenerator,
|
|
@@ -2,7 +2,7 @@ import importlib.resources
|
|
|
2
2
|
from typing import Any, Dict, List, Optional, Text, Tuple, Union
|
|
3
3
|
|
|
4
4
|
import structlog
|
|
5
|
-
from deprecated import deprecated # type: ignore[import]
|
|
5
|
+
from deprecated import deprecated # type: ignore[import-untyped]
|
|
6
6
|
from jinja2 import Template
|
|
7
7
|
|
|
8
8
|
import rasa.shared.utils.io
|
rasa/e2e_test/e2e_test_runner.py
CHANGED
|
@@ -747,7 +747,7 @@ class E2ETestRunner:
|
|
|
747
747
|
test_result = test_turns[index]
|
|
748
748
|
if index in failure_points:
|
|
749
749
|
diff_test_text, diff_actual_text = cls._handle_fail_diff(
|
|
750
|
-
test_result,
|
|
750
|
+
test_result,
|
|
751
751
|
latest_response,
|
|
752
752
|
cls._select_bot_utter_turns(test_turns, index),
|
|
753
753
|
) # test_result can only be TestStep in failure_points
|
|
@@ -811,7 +811,12 @@ class E2ETestRunner:
|
|
|
811
811
|
"""
|
|
812
812
|
# This will only be used when the TestCase is not started
|
|
813
813
|
# with a user step
|
|
814
|
-
|
|
814
|
+
latest_response_event = test_turns[-1]
|
|
815
|
+
if not isinstance(latest_response_event, ActualStepOutput):
|
|
816
|
+
raise ValueError(
|
|
817
|
+
f"Expected ActualStepOutput, got {type(latest_response_event)}"
|
|
818
|
+
)
|
|
819
|
+
latest_response: ActualStepOutput = latest_response_event
|
|
815
820
|
failures = []
|
|
816
821
|
match = None
|
|
817
822
|
for position in range(last_user_step_position, len(test_turns) - 1):
|
rasa/engine/caching.py
CHANGED
|
@@ -5,7 +5,7 @@ import logging
|
|
|
5
5
|
import shutil
|
|
6
6
|
from datetime import datetime
|
|
7
7
|
from pathlib import Path
|
|
8
|
-
from typing import Any, List, Optional, Text, Tuple
|
|
8
|
+
from typing import Any, List, Optional, Text, Tuple, Union
|
|
9
9
|
|
|
10
10
|
import sqlalchemy as sa
|
|
11
11
|
import sqlalchemy.orm
|
|
@@ -294,7 +294,7 @@ class LocalTrainingCache(TrainingCache):
|
|
|
294
294
|
|
|
295
295
|
def _cache_output_to_disk(
|
|
296
296
|
self, output: Cacheable, model_storage: ModelStorage
|
|
297
|
-
) -> Tuple[Optional[Text], Optional[Text]]:
|
|
297
|
+
) -> Tuple[Optional[Union[Path, Text]], Optional[Text]]:
|
|
298
298
|
tempdir_name = rasa.utils.common.get_temp_dir_name()
|
|
299
299
|
|
|
300
300
|
# Use `TempDirectoryPath` instead of `tempfile.TemporaryDirectory` as this
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
from rasa.core.policies.enterprise_search_policy import EnterpriseSearchPolicy
|
|
2
2
|
from rasa.core.policies.flow_policy import FlowPolicy
|
|
3
3
|
from rasa.core.policies.intentless_policy import IntentlessPolicy
|
|
4
|
-
from rasa.core.policies.memoization import AugmentedMemoizationPolicy
|
|
5
|
-
from rasa.core.policies.rule_policy import RulePolicy
|
|
6
|
-
from rasa.core.policies.ted_policy import TEDPolicy
|
|
7
|
-
from rasa.core.policies.unexpected_intent_policy import UnexpecTEDIntentPolicy
|
|
4
|
+
from rasa.core.policies.memoization import AugmentedMemoizationPolicy
|
|
8
5
|
from rasa.dialogue_understanding.coexistence.intent_based_router import (
|
|
9
6
|
IntentBasedRouter,
|
|
10
7
|
)
|
|
@@ -13,7 +10,6 @@ from rasa.dialogue_understanding.generator import (
|
|
|
13
10
|
LLMCommandGenerator,
|
|
14
11
|
)
|
|
15
12
|
from rasa.dialogue_understanding.generator.nlu_command_adapter import NLUCommandAdapter
|
|
16
|
-
from rasa.nlu.classifiers.diet_classifier import DIETClassifier
|
|
17
13
|
from rasa.nlu.classifiers.fallback_classifier import FallbackClassifier
|
|
18
14
|
from rasa.nlu.classifiers.keyword_intent_classifier import KeywordIntentClassifier
|
|
19
15
|
from rasa.nlu.classifiers.logistic_regression_classifier import (
|
|
@@ -21,14 +17,11 @@ from rasa.nlu.classifiers.logistic_regression_classifier import (
|
|
|
21
17
|
)
|
|
22
18
|
from rasa.nlu.classifiers.mitie_intent_classifier import MitieIntentClassifier
|
|
23
19
|
from rasa.nlu.classifiers.sklearn_intent_classifier import SklearnIntentClassifier
|
|
24
|
-
from rasa.nlu.extractors.crf_entity_extractor import CRFEntityExtractor
|
|
25
20
|
from rasa.nlu.extractors.duckling_entity_extractor import DucklingEntityExtractor
|
|
26
21
|
from rasa.nlu.extractors.entity_synonyms import EntitySynonymMapper
|
|
27
22
|
from rasa.nlu.extractors.mitie_entity_extractor import MitieEntityExtractor
|
|
28
23
|
from rasa.nlu.extractors.regex_entity_extractor import RegexEntityExtractor
|
|
29
24
|
from rasa.nlu.extractors.spacy_entity_extractor import SpacyEntityExtractor
|
|
30
|
-
from rasa.nlu.featurizers.dense_featurizer.convert_featurizer import ConveRTFeaturizer
|
|
31
|
-
from rasa.nlu.featurizers.dense_featurizer.lm_featurizer import LanguageModelFeaturizer
|
|
32
25
|
from rasa.nlu.featurizers.dense_featurizer.mitie_featurizer import MitieFeaturizer
|
|
33
26
|
from rasa.nlu.featurizers.dense_featurizer.spacy_featurizer import SpacyFeaturizer
|
|
34
27
|
from rasa.nlu.featurizers.sparse_featurizer.count_vectors_featurizer import (
|
|
@@ -38,7 +31,6 @@ from rasa.nlu.featurizers.sparse_featurizer.lexical_syntactic_featurizer import
|
|
|
38
31
|
LexicalSyntacticFeaturizer,
|
|
39
32
|
)
|
|
40
33
|
from rasa.nlu.featurizers.sparse_featurizer.regex_featurizer import RegexFeaturizer
|
|
41
|
-
from rasa.nlu.selectors.response_selector import ResponseSelector
|
|
42
34
|
from rasa.nlu.tokenizers.jieba_tokenizer import JiebaTokenizer
|
|
43
35
|
from rasa.nlu.tokenizers.mitie_tokenizer import MitieTokenizer
|
|
44
36
|
from rasa.nlu.tokenizers.spacy_tokenizer import SpacyTokenizer
|
|
@@ -48,7 +40,7 @@ from rasa.nlu.utils.spacy_utils import SpacyNLP
|
|
|
48
40
|
|
|
49
41
|
DEFAULT_COMPONENTS = [
|
|
50
42
|
# Message Classifiers
|
|
51
|
-
DIETClassifier,
|
|
43
|
+
# DIETClassifier,
|
|
52
44
|
FallbackClassifier,
|
|
53
45
|
KeywordIntentClassifier,
|
|
54
46
|
MitieIntentClassifier,
|
|
@@ -59,9 +51,9 @@ DEFAULT_COMPONENTS = [
|
|
|
59
51
|
LLMBasedRouter,
|
|
60
52
|
IntentBasedRouter,
|
|
61
53
|
# Response Selectors
|
|
62
|
-
ResponseSelector,
|
|
54
|
+
# ResponseSelector,
|
|
63
55
|
# Message Entity Extractors
|
|
64
|
-
CRFEntityExtractor,
|
|
56
|
+
# CRFEntityExtractor,
|
|
65
57
|
DucklingEntityExtractor,
|
|
66
58
|
EntitySynonymMapper,
|
|
67
59
|
MitieEntityExtractor,
|
|
@@ -69,11 +61,11 @@ DEFAULT_COMPONENTS = [
|
|
|
69
61
|
RegexEntityExtractor,
|
|
70
62
|
# Message Feauturizers
|
|
71
63
|
LexicalSyntacticFeaturizer,
|
|
72
|
-
ConveRTFeaturizer,
|
|
64
|
+
# ConveRTFeaturizer,
|
|
73
65
|
MitieFeaturizer,
|
|
74
66
|
SpacyFeaturizer,
|
|
75
67
|
CountVectorsFeaturizer,
|
|
76
|
-
LanguageModelFeaturizer,
|
|
68
|
+
# LanguageModelFeaturizer,
|
|
77
69
|
RegexFeaturizer,
|
|
78
70
|
# Tokenizers
|
|
79
71
|
JiebaTokenizer,
|
|
@@ -84,10 +76,10 @@ DEFAULT_COMPONENTS = [
|
|
|
84
76
|
MitieNLP,
|
|
85
77
|
SpacyNLP,
|
|
86
78
|
# Dialogue Management Policies
|
|
87
|
-
TEDPolicy,
|
|
88
|
-
UnexpecTEDIntentPolicy,
|
|
89
|
-
RulePolicy,
|
|
90
|
-
MemoizationPolicy,
|
|
79
|
+
# TEDPolicy,
|
|
80
|
+
# UnexpecTEDIntentPolicy,
|
|
81
|
+
# RulePolicy,
|
|
82
|
+
# MemoizationPolicy,
|
|
91
83
|
AugmentedMemoizationPolicy,
|
|
92
84
|
FlowPolicy,
|
|
93
85
|
EnterpriseSearchPolicy,
|