rasa-pro 3.13.0.dev7__py3-none-any.whl → 3.13.0.dev9__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/development_inspector.py +1 -1
- rasa/core/channels/facebook.py +1 -4
- rasa/core/channels/hangouts.py +8 -5
- rasa/core/channels/inspector/README.md +3 -3
- rasa/core/channels/inspector/dist/assets/{arc-c4b064fc.js → arc-02053cc1.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-215b5026.js → blockDiagram-38ab4fdb-008b6289.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-2b54a0a3.js → c4Diagram-3d4e48cf-fb2597be.js} +1 -1
- rasa/core/channels/inspector/dist/assets/channel-078dada8.js +1 -0
- rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-daacea5f.js → classDiagram-70f12bd4-7f847e00.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-930d4dc2.js → classDiagram-v2-f2320105-ba1d689b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/clone-5b4516de.js +1 -0
- rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-83c206ba.js → createText-2e5e7dd3-dd8e67c4.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-b0eb01d0.js → edges-e0da2a9e-10784939.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-17586500.js → erDiagram-9861fffd-24947ae6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-be2a1776.js → flowDb-956e92f1-a9ced505.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-c2120ebd.js → flowDiagram-66a62f08-afda9c7c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-f9613071.js +1 -0
- rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-a6ab5c48.js → flowchart-elk-definition-4a651766-6ef530b8.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-ef613457.js → ganttDiagram-c361ad54-0c7dd39a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-d59185b3.js → gitGraphDiagram-72cf32ee-b57239d6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{graph-0f155405.js → graph-9ed57cec.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-3862675e-d5f1d1b7.js → index-3862675e-233090de.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-47737d3a.js → index-72184470.js} +3 -3
- rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-b07d141f.js → infoDiagram-f8f76790-aa116649.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-1936d429.js → journeyDiagram-49397b02-e51877cc.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-dde8d0f3.js → layout-3ca3798c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{line-0c2c7ee0.js → line-26ee10d3.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-35dd89a4.js → linear-aedded32.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-56192851.js → mindmap-definition-fc14e90a-d8957261.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-fc21ed78.js → pieDiagram-8a3498a8-d771f885.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-25e98518.js → quadrantDiagram-120e2f19-09fdf50c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-546ff1f5.js → requirementDiagram-deff3bca-9f0af02e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-02d8b82d.js → sankeyDiagram-04a897e0-84415b37.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-3ca5a92e.js → sequenceDiagram-704730f1-8dec4055.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-128ea07c.js → stateDiagram-587899a1-c5431d07.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-95f290af.js → stateDiagram-v2-d93cdb3a-274e77d9.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-4984898a.js → styles-6aaf32cf-e364a1d7.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-9a916d00-1bf266ba.js → styles-9a916d00-0dae36f6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-c10674c1-60521c63.js → styles-c10674c1-c4641675.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-a25b6e12.js → svgDrawCommon-08f97a94-831fe9a1.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-0fc086bf.js → timeline-definition-85554ec2-c3304b3a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-44ee592e.js → xychartDiagram-e933f94c-da799369.js} +1 -1
- rasa/core/channels/inspector/dist/index.html +1 -1
- rasa/core/channels/inspector/src/components/RecruitmentPanel.tsx +1 -1
- 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/socketio.py +56 -41
- rasa/core/channels/studio_chat.py +314 -10
- rasa/core/channels/vier_cvg.py +1 -2
- rasa/core/channels/voice_ready/audiocodes.py +2 -9
- rasa/core/channels/voice_stream/audiocodes.py +8 -5
- rasa/core/channels/voice_stream/browser_audio.py +1 -1
- rasa/core/channels/voice_stream/genesys.py +2 -2
- rasa/core/channels/voice_stream/tts/__init__.py +8 -0
- rasa/core/channels/voice_stream/twilio_media_streams.py +10 -5
- rasa/core/channels/voice_stream/voice_channel.py +39 -23
- rasa/core/http_interpreter.py +3 -7
- rasa/core/information_retrieval/faiss.py +18 -11
- rasa/core/information_retrieval/ingestion/__init__.py +0 -0
- rasa/core/information_retrieval/ingestion/faq_parser.py +158 -0
- rasa/core/jobs.py +2 -1
- rasa/core/nlg/contextual_response_rephraser.py +44 -10
- 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 +262 -62
- 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 +56 -17
- 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 +9 -6
- rasa/dialogue_understanding/commands/can_not_handle_command.py +2 -0
- rasa/dialogue_understanding/commands/cancel_flow_command.py +5 -1
- 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/correct_slots_command.py +1 -3
- rasa/dialogue_understanding/commands/human_handoff_command.py +2 -0
- rasa/dialogue_understanding/commands/knowledge_answer_command.py +4 -2
- 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/nlu_command_adapter.py +2 -2
- rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v2_gpt_4o_2024_11_20_template.jinja2 +12 -33
- 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 +26 -461
- 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 +11 -64
- rasa/dialogue_understanding/patterns/cancel.py +1 -2
- rasa/dialogue_understanding/patterns/clarify.py +1 -1
- rasa/dialogue_understanding/patterns/correction.py +2 -2
- 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 +6 -7
- rasa/dialogue_understanding/processor/command_processor_component.py +3 -3
- rasa/dialogue_understanding/stack/frames/flow_stack_frame.py +17 -4
- rasa/dialogue_understanding/stack/utils.py +3 -1
- 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/graph.py +2 -2
- 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 +1 -5
- 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 +14 -0
- rasa/shared/core/command_payload_reader.py +1 -5
- rasa/shared/core/constants.py +4 -3
- rasa/shared/core/domain.py +7 -0
- rasa/shared/core/events.py +38 -10
- 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/flows/validation.py +16 -3
- rasa/shared/core/slots.py +28 -0
- rasa/shared/core/training_data/story_reader/yaml_story_reader.py +1 -4
- rasa/shared/exceptions.py +4 -0
- rasa/shared/utils/common.py +1 -1
- rasa/shared/utils/llm.py +191 -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.dev7.dist-info → rasa_pro-3.13.0.dev9.dist-info}/METADATA +7 -8
- {rasa_pro-3.13.0.dev7.dist-info → rasa_pro-3.13.0.dev9.dist-info}/RECORD +205 -189
- 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/core/channels/inspector/dist/assets/channel-3730f5fd.js +0 -1
- rasa/core/channels/inspector/dist/assets/clone-e847561e.js +0 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-efbbfe00.js +0 -1
- {rasa_pro-3.13.0.dev7.dist-info → rasa_pro-3.13.0.dev9.dist-info}/NOTICE +0 -0
- {rasa_pro-3.13.0.dev7.dist-info → rasa_pro-3.13.0.dev9.dist-info}/WHEEL +0 -0
- {rasa_pro-3.13.0.dev7.dist-info → rasa_pro-3.13.0.dev9.dist-info}/entry_points.txt +0 -0
rasa/shared/core/domain.py
CHANGED
|
@@ -32,6 +32,7 @@ from ruamel.yaml.scalarstring import DoubleQuotedScalarString
|
|
|
32
32
|
import rasa.shared.core.slot_mappings
|
|
33
33
|
import rasa.shared.utils.common
|
|
34
34
|
import rasa.shared.utils.io
|
|
35
|
+
from rasa.core.available_endpoints import AvailableEndpoints
|
|
35
36
|
from rasa.shared.constants import (
|
|
36
37
|
DEFAULT_CARRY_OVER_SLOTS_TO_NEW_SESSION,
|
|
37
38
|
DEFAULT_SESSION_EXPIRATION_TIME_IN_MINUTES,
|
|
@@ -48,6 +49,7 @@ from rasa.shared.core.constants import (
|
|
|
48
49
|
ACTION_SHOULD_SEND_DOMAIN,
|
|
49
50
|
KEY_MAPPING_TYPE,
|
|
50
51
|
KNOWLEDGE_BASE_SLOT_NAMES,
|
|
52
|
+
SILENCE_TIMEOUT_SLOT,
|
|
51
53
|
SLOT_MAPPINGS,
|
|
52
54
|
SlotMappingType,
|
|
53
55
|
)
|
|
@@ -306,6 +308,11 @@ class Domain:
|
|
|
306
308
|
responses = data.get(KEY_RESPONSES, {})
|
|
307
309
|
|
|
308
310
|
domain_slots = data.get(KEY_SLOTS, {})
|
|
311
|
+
for slot_name, slot in domain_slots.items():
|
|
312
|
+
if slot_name == SILENCE_TIMEOUT_SLOT:
|
|
313
|
+
slot["initial_value"] = (
|
|
314
|
+
AvailableEndpoints.get_instance().interaction_handling.global_silence_timeout
|
|
315
|
+
)
|
|
309
316
|
slots = cls.collect_slots(domain_slots)
|
|
310
317
|
domain_actions = data.get(KEY_ACTIONS, [])
|
|
311
318
|
actions = cls._collect_action_names(domain_actions)
|
rasa/shared/core/events.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
import abc
|
|
2
4
|
import copy
|
|
3
5
|
import json
|
|
@@ -6,7 +8,7 @@ import re
|
|
|
6
8
|
import time
|
|
7
9
|
import uuid
|
|
8
10
|
from abc import ABC
|
|
9
|
-
from datetime import datetime
|
|
11
|
+
from datetime import datetime, timezone
|
|
10
12
|
from typing import (
|
|
11
13
|
TYPE_CHECKING,
|
|
12
14
|
Any,
|
|
@@ -124,9 +126,7 @@ def deserialise_events(serialized_events: List[Dict[Text, Any]]) -> List["Event"
|
|
|
124
126
|
if event:
|
|
125
127
|
deserialised.append(event)
|
|
126
128
|
else:
|
|
127
|
-
structlogger.warning(
|
|
128
|
-
"event.deserialization.failed", rasa_event=copy.deepcopy(event)
|
|
129
|
-
)
|
|
129
|
+
structlogger.warning("event.deserialization.failed")
|
|
130
130
|
|
|
131
131
|
return deserialised
|
|
132
132
|
|
|
@@ -453,6 +453,7 @@ class UserUttered(Event):
|
|
|
453
453
|
message_id: Optional[Text] = None,
|
|
454
454
|
metadata: Optional[Dict] = None,
|
|
455
455
|
use_text_for_featurization: Optional[bool] = None,
|
|
456
|
+
anonymized_at: Optional[float] = None,
|
|
456
457
|
) -> None:
|
|
457
458
|
"""Creates event for incoming user message.
|
|
458
459
|
|
|
@@ -467,6 +468,7 @@ class UserUttered(Event):
|
|
|
467
468
|
message_id: Unique ID for message.
|
|
468
469
|
use_text_for_featurization: `True` if the message's text was used to predict
|
|
469
470
|
next action. `False` if the message's intent was used.
|
|
471
|
+
anonymized_at: When the event was anonymized in the tracker store.
|
|
470
472
|
|
|
471
473
|
"""
|
|
472
474
|
self.text = text
|
|
@@ -500,7 +502,11 @@ class UserUttered(Event):
|
|
|
500
502
|
if parse_data:
|
|
501
503
|
self.parse_data.update(**parse_data)
|
|
502
504
|
|
|
503
|
-
self._anonymized_at: Optional[datetime] =
|
|
505
|
+
self._anonymized_at: Optional[datetime] = (
|
|
506
|
+
datetime.fromtimestamp(anonymized_at, tz=timezone.utc)
|
|
507
|
+
if anonymized_at is not None
|
|
508
|
+
else None
|
|
509
|
+
)
|
|
504
510
|
|
|
505
511
|
@property
|
|
506
512
|
def anonymized_at(self) -> Optional[datetime]:
|
|
@@ -525,6 +531,7 @@ class UserUttered(Event):
|
|
|
525
531
|
input_channel: Optional[Text] = None,
|
|
526
532
|
message_id: Optional[Text] = None,
|
|
527
533
|
metadata: Optional[Dict] = None,
|
|
534
|
+
anonymized_at: Optional[float] = None,
|
|
528
535
|
) -> "UserUttered":
|
|
529
536
|
return UserUttered(
|
|
530
537
|
text,
|
|
@@ -535,6 +542,7 @@ class UserUttered(Event):
|
|
|
535
542
|
input_channel,
|
|
536
543
|
message_id,
|
|
537
544
|
metadata,
|
|
545
|
+
anonymized_at,
|
|
538
546
|
)
|
|
539
547
|
|
|
540
548
|
def __hash__(self) -> int:
|
|
@@ -633,7 +641,9 @@ class UserUttered(Event):
|
|
|
633
641
|
"input_channel": getattr(self, "input_channel", None),
|
|
634
642
|
"message_id": getattr(self, "message_id", None),
|
|
635
643
|
"metadata": self.metadata,
|
|
636
|
-
"anonymized_at": self.anonymized_at
|
|
644
|
+
"anonymized_at": self.anonymized_at.timestamp()
|
|
645
|
+
if self.anonymized_at
|
|
646
|
+
else None,
|
|
637
647
|
}
|
|
638
648
|
)
|
|
639
649
|
return _dict
|
|
@@ -693,6 +703,7 @@ class UserUttered(Event):
|
|
|
693
703
|
parameters.get("input_channel"),
|
|
694
704
|
parameters.get("message_id"),
|
|
695
705
|
parameters.get("metadata"),
|
|
706
|
+
parameters.get("anonymized_at"),
|
|
696
707
|
)
|
|
697
708
|
]
|
|
698
709
|
except KeyError as e:
|
|
@@ -920,6 +931,7 @@ class BotUttered(SkipEventInMDStoryMixin):
|
|
|
920
931
|
data: Optional[Dict] = None,
|
|
921
932
|
metadata: Optional[Dict[Text, Any]] = None,
|
|
922
933
|
timestamp: Optional[float] = None,
|
|
934
|
+
anonymized_at: Optional[float] = None,
|
|
923
935
|
) -> None:
|
|
924
936
|
"""Creates event for a bot response.
|
|
925
937
|
|
|
@@ -928,10 +940,15 @@ class BotUttered(SkipEventInMDStoryMixin):
|
|
|
928
940
|
data: Additional data for more complex utterances (e.g. buttons).
|
|
929
941
|
timestamp: When the event was created.
|
|
930
942
|
metadata: Additional event metadata.
|
|
943
|
+
anonymized_at: When the event was anonymized in the tracker store.
|
|
931
944
|
"""
|
|
932
945
|
self.text = text
|
|
933
946
|
self.data = data or {}
|
|
934
|
-
self._anonymized_at: Optional[datetime] =
|
|
947
|
+
self._anonymized_at: Optional[datetime] = (
|
|
948
|
+
datetime.fromtimestamp(anonymized_at, tz=timezone.utc)
|
|
949
|
+
if anonymized_at is not None
|
|
950
|
+
else None
|
|
951
|
+
)
|
|
935
952
|
super().__init__(timestamp, metadata)
|
|
936
953
|
|
|
937
954
|
@property
|
|
@@ -1040,7 +1057,9 @@ class BotUttered(SkipEventInMDStoryMixin):
|
|
|
1040
1057
|
"text": self.text,
|
|
1041
1058
|
"data": self.data,
|
|
1042
1059
|
"metadata": self.metadata,
|
|
1043
|
-
"anonymized_at": self.anonymized_at
|
|
1060
|
+
"anonymized_at": self.anonymized_at.timestamp()
|
|
1061
|
+
if self.anonymized_at
|
|
1062
|
+
else None,
|
|
1044
1063
|
}
|
|
1045
1064
|
)
|
|
1046
1065
|
return d
|
|
@@ -1053,6 +1072,7 @@ class BotUttered(SkipEventInMDStoryMixin):
|
|
|
1053
1072
|
parameters.get("data"),
|
|
1054
1073
|
parameters.get("metadata"),
|
|
1055
1074
|
parameters.get("timestamp"),
|
|
1075
|
+
parameters.get("anonymized_at"),
|
|
1056
1076
|
)
|
|
1057
1077
|
except KeyError as e:
|
|
1058
1078
|
raise ValueError(f"Failed to parse bot uttered event. {e}")
|
|
@@ -1077,6 +1097,7 @@ class SlotSet(Event):
|
|
|
1077
1097
|
timestamp: Optional[float] = None,
|
|
1078
1098
|
metadata: Optional[Dict[Text, Any]] = None,
|
|
1079
1099
|
filled_by: Optional[str] = None,
|
|
1100
|
+
anonymized_at: Optional[float] = None,
|
|
1080
1101
|
) -> None:
|
|
1081
1102
|
"""Creates event to set slot.
|
|
1082
1103
|
|
|
@@ -1089,7 +1110,11 @@ class SlotSet(Event):
|
|
|
1089
1110
|
self.key = key
|
|
1090
1111
|
self.value = value
|
|
1091
1112
|
self._filled_by = filled_by
|
|
1092
|
-
self._anonymized_at: Optional[datetime] =
|
|
1113
|
+
self._anonymized_at: Optional[datetime] = (
|
|
1114
|
+
datetime.fromtimestamp(anonymized_at, tz=timezone.utc)
|
|
1115
|
+
if anonymized_at is not None
|
|
1116
|
+
else None
|
|
1117
|
+
)
|
|
1093
1118
|
super().__init__(timestamp, metadata)
|
|
1094
1119
|
|
|
1095
1120
|
@property
|
|
@@ -1156,7 +1181,9 @@ class SlotSet(Event):
|
|
|
1156
1181
|
"name": self.key,
|
|
1157
1182
|
"value": self.value,
|
|
1158
1183
|
"filled_by": self.filled_by,
|
|
1159
|
-
"anonymized_at": self.anonymized_at
|
|
1184
|
+
"anonymized_at": self.anonymized_at.timestamp()
|
|
1185
|
+
if self.anonymized_at
|
|
1186
|
+
else None,
|
|
1160
1187
|
}
|
|
1161
1188
|
)
|
|
1162
1189
|
return d
|
|
@@ -1170,6 +1197,7 @@ class SlotSet(Event):
|
|
|
1170
1197
|
parameters.get("timestamp"),
|
|
1171
1198
|
parameters.get("metadata"),
|
|
1172
1199
|
filled_by=parameters.get("filled_by"),
|
|
1200
|
+
anonymized_at=parameters.get("anonymized_at"),
|
|
1173
1201
|
)
|
|
1174
1202
|
except KeyError as e:
|
|
1175
1203
|
raise ValueError(f"Failed to parse set slot event. {e}")
|
rasa/shared/core/flows/flow.py
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from dataclasses import dataclass
|
|
4
|
-
from typing import Any, Dict, List, Set, Text
|
|
4
|
+
from typing import Any, Dict, List, Optional, Set, Text, Union
|
|
5
|
+
|
|
6
|
+
import structlog
|
|
5
7
|
|
|
6
8
|
from rasa.shared.constants import ACTION_ASK_PREFIX, UTTER_ASK_PREFIX
|
|
7
9
|
from rasa.shared.core.flows.flow_step import FlowStep
|
|
8
10
|
from rasa.shared.core.slots import SlotRejection
|
|
11
|
+
from rasa.shared.exceptions import RasaException
|
|
9
12
|
|
|
10
13
|
DEFAULT_ASK_BEFORE_FILLING = False
|
|
11
14
|
DEFAULT_RESET_AFTER_FLOW_ENDS = True
|
|
12
15
|
DEFAULT_FORCE_SLOT_FILLING = False
|
|
13
16
|
|
|
17
|
+
logger = structlog.get_logger(__name__)
|
|
18
|
+
|
|
19
|
+
SilenceTimeoutInstructionType = Union[int, float, Dict[str, Any]]
|
|
20
|
+
|
|
14
21
|
|
|
15
22
|
@dataclass
|
|
16
23
|
class CollectInformationFlowStep(FlowStep):
|
|
@@ -30,6 +37,8 @@ class CollectInformationFlowStep(FlowStep):
|
|
|
30
37
|
"""Whether to reset the slot value at the end of the flow."""
|
|
31
38
|
force_slot_filling: bool = False
|
|
32
39
|
"""Whether to keep only the SetSlot command for the collected slot."""
|
|
40
|
+
silence_timeout: Optional[float] = None
|
|
41
|
+
"""The silence timeout for the collect information step."""
|
|
33
42
|
|
|
34
43
|
@classmethod
|
|
35
44
|
def from_json(
|
|
@@ -44,6 +53,11 @@ class CollectInformationFlowStep(FlowStep):
|
|
|
44
53
|
Returns:
|
|
45
54
|
A CollectInformationFlowStep object
|
|
46
55
|
"""
|
|
56
|
+
|
|
57
|
+
silence_timeout = cls._deserialise_silence_timeout(
|
|
58
|
+
data.get("silence_timeout", None)
|
|
59
|
+
)
|
|
60
|
+
|
|
47
61
|
base = super().from_json(flow_id, data)
|
|
48
62
|
return CollectInformationFlowStep(
|
|
49
63
|
collect=data["collect"],
|
|
@@ -58,14 +72,40 @@ class CollectInformationFlowStep(FlowStep):
|
|
|
58
72
|
for rejection in data.get("rejections", [])
|
|
59
73
|
],
|
|
60
74
|
force_slot_filling=data.get("force_slot_filling", False),
|
|
75
|
+
silence_timeout=silence_timeout,
|
|
61
76
|
**base.__dict__,
|
|
62
77
|
)
|
|
63
78
|
|
|
79
|
+
@staticmethod
|
|
80
|
+
def _deserialise_silence_timeout(
|
|
81
|
+
silence_timeout_json: Optional[SilenceTimeoutInstructionType],
|
|
82
|
+
) -> Optional[float]:
|
|
83
|
+
"""Deserialize silence timeout from JSON."""
|
|
84
|
+
if not silence_timeout_json:
|
|
85
|
+
return None
|
|
86
|
+
|
|
87
|
+
if not isinstance(silence_timeout_json, (int, float)):
|
|
88
|
+
raise RasaException(
|
|
89
|
+
f"Invalid silence timeout value: {silence_timeout_json}. "
|
|
90
|
+
"If defined at collect step, silence timeout must be a number."
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
silence_timeout = silence_timeout_json
|
|
94
|
+
|
|
95
|
+
if silence_timeout and silence_timeout < 0:
|
|
96
|
+
raise RasaException(
|
|
97
|
+
f"Invalid silence timeout value: {silence_timeout}. "
|
|
98
|
+
"Silence timeout must be a non-negative number."
|
|
99
|
+
)
|
|
100
|
+
return silence_timeout
|
|
101
|
+
|
|
64
102
|
@staticmethod
|
|
65
103
|
def _default_utter(collect: str) -> str:
|
|
66
104
|
return f"{UTTER_ASK_PREFIX}{collect}"
|
|
67
105
|
|
|
68
|
-
def as_json(
|
|
106
|
+
def as_json(
|
|
107
|
+
self, step_properties: Optional[Dict[Text, Any]] = None
|
|
108
|
+
) -> Dict[str, Any]:
|
|
69
109
|
"""Serialize the CollectInformationFlowStep object.
|
|
70
110
|
|
|
71
111
|
Returns:
|
|
@@ -78,6 +118,9 @@ class CollectInformationFlowStep(FlowStep):
|
|
|
78
118
|
data["reset_after_flow_ends"] = self.reset_after_flow_ends
|
|
79
119
|
data["rejections"] = [rejection.as_dict() for rejection in self.rejections]
|
|
80
120
|
data["force_slot_filling"] = self.force_slot_filling
|
|
121
|
+
if self.silence_timeout:
|
|
122
|
+
data["silence_timeout"] = self.silence_timeout
|
|
123
|
+
|
|
81
124
|
return super().as_json(step_properties=data)
|
|
82
125
|
|
|
83
126
|
@property
|
|
@@ -100,6 +143,7 @@ class CollectInformationFlowStep(FlowStep):
|
|
|
100
143
|
and self.ask_before_filling == other.ask_before_filling
|
|
101
144
|
and self.reset_after_flow_ends == other.reset_after_flow_ends
|
|
102
145
|
and self.force_slot_filling == other.force_slot_filling
|
|
146
|
+
and self.silence_timeout == other.silence_timeout
|
|
103
147
|
and super().__eq__(other)
|
|
104
148
|
)
|
|
105
149
|
return False
|
|
@@ -8,6 +8,7 @@ from typing import List, Optional, Set, Text
|
|
|
8
8
|
|
|
9
9
|
from rasa.shared.constants import (
|
|
10
10
|
RASA_DEFAULT_FLOW_PATTERN_PREFIX,
|
|
11
|
+
RASA_PATTERN_CHITCHAT,
|
|
11
12
|
RASA_PATTERN_HUMAN_HANDOFF,
|
|
12
13
|
RASA_PATTERN_INTERNAL_ERROR,
|
|
13
14
|
)
|
|
@@ -186,8 +187,10 @@ class ReferenceToPatternException(RasaException):
|
|
|
186
187
|
return message + "Patterns can not be used as a target for a call step."
|
|
187
188
|
else:
|
|
188
189
|
return message + (
|
|
189
|
-
"
|
|
190
|
-
"
|
|
190
|
+
"Patterns cannot be used as a target in link steps, except for "
|
|
191
|
+
"'pattern_human_handoff', which may be linked from both user-defined "
|
|
192
|
+
"flows and other patterns. 'pattern_chitchat' may only be linked "
|
|
193
|
+
"from other patterns."
|
|
191
194
|
)
|
|
192
195
|
|
|
193
196
|
|
|
@@ -597,7 +600,13 @@ def validate_patterns_are_not_called_or_linked(flows: "FlowsList") -> None:
|
|
|
597
600
|
if (
|
|
598
601
|
isinstance(step, LinkFlowStep)
|
|
599
602
|
and step.link.startswith(RASA_DEFAULT_FLOW_PATTERN_PREFIX)
|
|
603
|
+
# Allow linking to human-handoff from both patterns
|
|
604
|
+
# and user-defined flows
|
|
600
605
|
and step.link != RASA_PATTERN_HUMAN_HANDOFF
|
|
606
|
+
# Allow linking to 'pattern_chitchat' only from other patterns
|
|
607
|
+
and not (
|
|
608
|
+
flow.is_rasa_default_flow and step.link == RASA_PATTERN_CHITCHAT
|
|
609
|
+
)
|
|
601
610
|
):
|
|
602
611
|
raise ReferenceToPatternException(
|
|
603
612
|
step.link, flow.id, step.id, call_step=False
|
|
@@ -617,7 +626,8 @@ def validate_patterns_are_not_calling_or_linking_other_flows(
|
|
|
617
626
|
"""Validates that patterns do not contain call or link steps.
|
|
618
627
|
|
|
619
628
|
Link steps to user flows are allowed for all patterns but 'pattern_internal_error'.
|
|
620
|
-
Link steps to other patterns, except for 'pattern_human_handoff'
|
|
629
|
+
Link steps to other patterns, except for 'pattern_human_handoff' and
|
|
630
|
+
'pattern_chitchat' are forbidden.
|
|
621
631
|
"""
|
|
622
632
|
for flow in flows.underlying_flows:
|
|
623
633
|
if not flow.is_rasa_default_flow:
|
|
@@ -627,6 +637,9 @@ def validate_patterns_are_not_calling_or_linking_other_flows(
|
|
|
627
637
|
if step.link == RASA_PATTERN_HUMAN_HANDOFF:
|
|
628
638
|
# links to 'pattern_human_handoff' are allowed
|
|
629
639
|
continue
|
|
640
|
+
if step.link == RASA_PATTERN_CHITCHAT:
|
|
641
|
+
# links to 'pattern_chitchat' are allowed
|
|
642
|
+
continue
|
|
630
643
|
if step.link.startswith(RASA_DEFAULT_FLOW_PATTERN_PREFIX):
|
|
631
644
|
# all other patterns are allowed to link to user flows, but not
|
|
632
645
|
# to other patterns
|
rasa/shared/core/slots.py
CHANGED
|
@@ -311,6 +311,34 @@ class Slot(ABC):
|
|
|
311
311
|
"""Indicates if the slot requires validation."""
|
|
312
312
|
return True if self.validation else False
|
|
313
313
|
|
|
314
|
+
def to_dict(
|
|
315
|
+
self,
|
|
316
|
+
*,
|
|
317
|
+
include_private: bool = False,
|
|
318
|
+
) -> Dict[str, Any]:
|
|
319
|
+
"""Return a dictionary with attributes of this slot instance.
|
|
320
|
+
|
|
321
|
+
Args:
|
|
322
|
+
include_private: If `True`, private attributes are included.
|
|
323
|
+
|
|
324
|
+
Returns:
|
|
325
|
+
A plain `dict` that can be JSON-serialised.
|
|
326
|
+
"""
|
|
327
|
+
result: Dict[str, Any] = {}
|
|
328
|
+
|
|
329
|
+
for attr, value in vars(self).items():
|
|
330
|
+
if not include_private and attr.startswith("_"):
|
|
331
|
+
continue
|
|
332
|
+
|
|
333
|
+
if attr == "mappings":
|
|
334
|
+
result[attr] = [mapping.as_dict() for mapping in value]
|
|
335
|
+
continue
|
|
336
|
+
|
|
337
|
+
result[attr] = value
|
|
338
|
+
|
|
339
|
+
result.setdefault("type", self.type_name)
|
|
340
|
+
return result
|
|
341
|
+
|
|
314
342
|
|
|
315
343
|
class FloatSlot(Slot):
|
|
316
344
|
"""A slot storing a float value."""
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import copy
|
|
2
1
|
import functools
|
|
3
2
|
import json
|
|
4
3
|
import logging
|
|
@@ -648,9 +647,7 @@ class YAMLStoryReader(StoryReader):
|
|
|
648
647
|
# message text did start with the special prefix -- however, a user might
|
|
649
648
|
# just have decided to start their text this way.
|
|
650
649
|
if not match:
|
|
651
|
-
structlogger.warning(
|
|
652
|
-
"message.parsing.failed", user_text=copy.deepcopy(user_text)
|
|
653
|
-
)
|
|
650
|
+
structlogger.warning("message.parsing.failed")
|
|
654
651
|
return message
|
|
655
652
|
|
|
656
653
|
# Extract attributes from the match - and validate it via the domain.
|
rasa/shared/exceptions.py
CHANGED
|
@@ -165,3 +165,7 @@ class ProviderClientAPIException(RasaException):
|
|
|
165
165
|
|
|
166
166
|
class ProviderClientValidationError(RasaException):
|
|
167
167
|
"""Raised for errors that occur during validation of the API client."""
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
class FinetuningDataPreparationException(RasaException):
|
|
171
|
+
"""Raised when there is an error in data preparation for fine-tuning."""
|
rasa/shared/utils/common.py
CHANGED
|
@@ -384,7 +384,7 @@ def display_research_study_prompt() -> None:
|
|
|
384
384
|
{separator}
|
|
385
385
|
Want to help shape the future of Rasa Pro?
|
|
386
386
|
Share your feedback in a short conversation with our team.
|
|
387
|
-
Sign up at: https://
|
|
387
|
+
Sign up at: https://rasa.com/book-feedback-call
|
|
388
388
|
{separator}
|
|
389
389
|
"""
|
|
390
390
|
print_success(message)
|