rasa-pro 3.13.0.dev7__py3-none-any.whl → 3.13.0.dev8__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 +34 -9
- 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 +283 -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 +9 -7
- 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/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 +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/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 +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/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 +3 -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/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.dev7.dist-info → rasa_pro-3.13.0.dev8.dist-info}/METADATA +5 -6
- {rasa_pro-3.13.0.dev7.dist-info → rasa_pro-3.13.0.dev8.dist-info}/RECORD +143 -129
- 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.dev7.dist-info → rasa_pro-3.13.0.dev8.dist-info}/NOTICE +0 -0
- {rasa_pro-3.13.0.dev7.dist-info → rasa_pro-3.13.0.dev8.dist-info}/WHEEL +0 -0
- {rasa_pro-3.13.0.dev7.dist-info → rasa_pro-3.13.0.dev8.dist-info}/entry_points.txt +0 -0
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import copy
|
|
2
|
-
import json
|
|
3
|
-
import logging
|
|
4
|
-
from typing import Any, Dict, List, Optional, Text
|
|
5
|
-
|
|
6
|
-
from rasa.anonymization.anonymization_rule_executor import (
|
|
7
|
-
AnonymizationRuleExecutor,
|
|
8
|
-
AnonymizationRuleList,
|
|
9
|
-
)
|
|
10
|
-
from rasa.core.brokers.broker import EventBroker
|
|
11
|
-
from rasa.core.brokers.kafka import KafkaEventBroker
|
|
12
|
-
|
|
13
|
-
logger = logging.getLogger(__name__)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class AnonymizationRuleOrchestrator:
|
|
17
|
-
"""Orchestrates the execution of anonymization rules."""
|
|
18
|
-
|
|
19
|
-
def __init__(
|
|
20
|
-
self,
|
|
21
|
-
event_broker: Optional[EventBroker],
|
|
22
|
-
anonymization_rule_list: AnonymizationRuleList,
|
|
23
|
-
):
|
|
24
|
-
"""Initializes the orchestrator."""
|
|
25
|
-
self.event_broker = (
|
|
26
|
-
event_broker if isinstance(event_broker, KafkaEventBroker) else None
|
|
27
|
-
)
|
|
28
|
-
self.anonymization_rule_executor = AnonymizationRuleExecutor(
|
|
29
|
-
anonymization_rule_list
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
def anonymize_event(self, event: Dict[Text, Any]) -> Dict[Text, Any]:
|
|
33
|
-
"""Anonymizes one of the supported event types.
|
|
34
|
-
|
|
35
|
-
The supported event types: user, bot, slot, entities.
|
|
36
|
-
"""
|
|
37
|
-
event_copy = copy.deepcopy(event)
|
|
38
|
-
event_type = event["event"]
|
|
39
|
-
|
|
40
|
-
if event_type == "user" or event_type == "bot":
|
|
41
|
-
if event["text"] is None:
|
|
42
|
-
return event_copy
|
|
43
|
-
|
|
44
|
-
anonymized_text = self.anonymization_rule_executor.run(event["text"])
|
|
45
|
-
event_copy["text"] = anonymized_text
|
|
46
|
-
|
|
47
|
-
if "parse_data" in event_copy:
|
|
48
|
-
event_copy["parse_data"]["text"] = anonymized_text
|
|
49
|
-
|
|
50
|
-
entities = event_copy["parse_data"]["entities"]
|
|
51
|
-
|
|
52
|
-
if entities:
|
|
53
|
-
anonymized_entities = self._anonymize_entities(entities)
|
|
54
|
-
event_copy["parse_data"]["entities"] = anonymized_entities
|
|
55
|
-
|
|
56
|
-
elif event_type == "slot":
|
|
57
|
-
slot_value = event["value"]
|
|
58
|
-
|
|
59
|
-
if slot_value is None:
|
|
60
|
-
return event_copy
|
|
61
|
-
elif not isinstance(slot_value, str):
|
|
62
|
-
slot_value = json.dumps(slot_value)
|
|
63
|
-
|
|
64
|
-
anonymized_value = self.anonymization_rule_executor.run(slot_value)
|
|
65
|
-
event_copy["value"] = anonymized_value
|
|
66
|
-
|
|
67
|
-
elif event_type == "entities":
|
|
68
|
-
entities = event_copy["entities"]
|
|
69
|
-
anonymized_entities = self._anonymize_entities(entities)
|
|
70
|
-
|
|
71
|
-
event_copy["entities"] = anonymized_entities
|
|
72
|
-
else:
|
|
73
|
-
logger.debug(f"Unsupported event type for anonymization: {event_type}.")
|
|
74
|
-
|
|
75
|
-
return event_copy
|
|
76
|
-
|
|
77
|
-
def publish_event(
|
|
78
|
-
self, anonymized_event: Dict[Text, Any], is_anonymized: bool
|
|
79
|
-
) -> None:
|
|
80
|
-
"""Publishes the anonymized event to the event broker."""
|
|
81
|
-
if self.event_broker is None:
|
|
82
|
-
return None
|
|
83
|
-
|
|
84
|
-
# this assumes that the event broker's topic attribute
|
|
85
|
-
# is set to the correct anonymization topic
|
|
86
|
-
if is_anonymized:
|
|
87
|
-
event_type = anonymized_event["event"]
|
|
88
|
-
sender_id = anonymized_event["sender_id"]
|
|
89
|
-
logger.debug(
|
|
90
|
-
f"Publishing event of type '{event_type}' from "
|
|
91
|
-
f"sender ID '{sender_id}' to "
|
|
92
|
-
f"Kafka topic '{self.event_broker.topic}'. "
|
|
93
|
-
f"The anonymization pipeline used rule named "
|
|
94
|
-
f"'{self.anonymization_rule_executor.anonymization_rule_list.id}'."
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
self.event_broker.publish(anonymized_event)
|
|
98
|
-
|
|
99
|
-
def _anonymize_entities(
|
|
100
|
-
self, entities: List[Dict[Text, Any]]
|
|
101
|
-
) -> List[Dict[Text, Any]]:
|
|
102
|
-
"""Anonymizes entities."""
|
|
103
|
-
anonymized_entities = []
|
|
104
|
-
|
|
105
|
-
for entity in entities:
|
|
106
|
-
entity_value = entity.get("value")
|
|
107
|
-
|
|
108
|
-
if entity_value is not None:
|
|
109
|
-
value = self.anonymization_rule_executor.run(str(entity_value))
|
|
110
|
-
entity["value"] = value
|
|
111
|
-
anonymized_entities.append(entity)
|
|
112
|
-
|
|
113
|
-
return anonymized_entities
|
|
114
|
-
|
|
115
|
-
def anonymize_log_message(self, message: Text) -> Any:
|
|
116
|
-
"""Anonymizes log messages."""
|
|
117
|
-
if self.event_broker:
|
|
118
|
-
return None
|
|
119
|
-
return self.anonymization_rule_executor.run(message)
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
allowempty: True
|
|
2
|
-
mapping:
|
|
3
|
-
anonymization:
|
|
4
|
-
type: "map"
|
|
5
|
-
mapping:
|
|
6
|
-
rule_lists:
|
|
7
|
-
type: "seq"
|
|
8
|
-
matching: "any"
|
|
9
|
-
required: True
|
|
10
|
-
sequence:
|
|
11
|
-
- type: "map"
|
|
12
|
-
mapping:
|
|
13
|
-
id:
|
|
14
|
-
type: "str"
|
|
15
|
-
required: True
|
|
16
|
-
rules:
|
|
17
|
-
type: "seq"
|
|
18
|
-
required: True
|
|
19
|
-
matching: "any"
|
|
20
|
-
sequence:
|
|
21
|
-
- type: "map"
|
|
22
|
-
mapping:
|
|
23
|
-
entity:
|
|
24
|
-
type: "str"
|
|
25
|
-
required: True
|
|
26
|
-
substitution:
|
|
27
|
-
type: "str"
|
|
28
|
-
enum: ["text", "mask", "faker"]
|
|
29
|
-
required: False
|
|
30
|
-
value:
|
|
31
|
-
type: "str"
|
|
32
|
-
required: False
|
|
33
|
-
|
|
34
|
-
metadata:
|
|
35
|
-
type: "map"
|
|
36
|
-
required: True
|
|
37
|
-
mapping:
|
|
38
|
-
language:
|
|
39
|
-
type: "str"
|
|
40
|
-
required: True
|
|
41
|
-
model_name:
|
|
42
|
-
type: "any"
|
|
43
|
-
required: True
|
|
44
|
-
model_provider:
|
|
45
|
-
type: "str"
|
|
46
|
-
required: True
|
|
47
|
-
enum: ["spacy", "stanza", "transformers"]
|
rasa/anonymization/utils.py
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
import os
|
|
3
|
-
from pathlib import Path
|
|
4
|
-
from typing import Any, Dict, Optional, Text
|
|
5
|
-
|
|
6
|
-
from rasa.shared.exceptions import RasaException, YamlException
|
|
7
|
-
from rasa.shared.utils.yaml import (
|
|
8
|
-
read_config_file,
|
|
9
|
-
read_yaml_file,
|
|
10
|
-
validate_yaml_content_using_schema,
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
logger = logging.getLogger(__name__)
|
|
14
|
-
SCHEMA_FILE = Path(__file__).parent / "schemas" / "config.yml"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def read_endpoint_config(
|
|
18
|
-
filename: Optional[Text], endpoint_type: Text
|
|
19
|
-
) -> Optional[Dict[Text, Any]]:
|
|
20
|
-
"""Reads a configuration file from disk and extract one config."""
|
|
21
|
-
if not filename:
|
|
22
|
-
return None
|
|
23
|
-
|
|
24
|
-
try:
|
|
25
|
-
content = read_config_file(filename, reader_type=["safe", "rt"])
|
|
26
|
-
|
|
27
|
-
if content.get(endpoint_type) is None:
|
|
28
|
-
return None
|
|
29
|
-
|
|
30
|
-
return content
|
|
31
|
-
except FileNotFoundError:
|
|
32
|
-
logger.error(
|
|
33
|
-
"Failed to read configuration from {}. No such file.".format(
|
|
34
|
-
os.path.abspath(filename)
|
|
35
|
-
),
|
|
36
|
-
)
|
|
37
|
-
return None
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def extract_anonymization_traits(
|
|
41
|
-
anonymization_config: Optional[Dict[Text, Any]], endpoint_type: Text
|
|
42
|
-
) -> Dict[Text, Any]:
|
|
43
|
-
"""Extract anonymization traits from the anonymization config.
|
|
44
|
-
|
|
45
|
-
Args:
|
|
46
|
-
anonymization_config: The anonymization config.
|
|
47
|
-
endpoint_type: The endpoint type.
|
|
48
|
-
|
|
49
|
-
Returns:
|
|
50
|
-
A dictionary containing the anonymization traits.
|
|
51
|
-
"""
|
|
52
|
-
if not anonymization_config:
|
|
53
|
-
return {"enabled": False}
|
|
54
|
-
|
|
55
|
-
anonymization_value = anonymization_config.get(endpoint_type)
|
|
56
|
-
if not anonymization_value:
|
|
57
|
-
logger.debug("Anonymization config found but nothing is defined.")
|
|
58
|
-
return {"enabled": False}
|
|
59
|
-
|
|
60
|
-
try:
|
|
61
|
-
validate_anonymization_yaml(anonymization_config)
|
|
62
|
-
except RasaException as exception:
|
|
63
|
-
logger.debug(exception)
|
|
64
|
-
return {"enabled": False}
|
|
65
|
-
|
|
66
|
-
rule_lists = anonymization_value.get("rule_lists", [])
|
|
67
|
-
|
|
68
|
-
traits = {
|
|
69
|
-
"enabled": True,
|
|
70
|
-
"metadata": anonymization_value.get("metadata", {}),
|
|
71
|
-
"number_of_rule_lists": len(rule_lists),
|
|
72
|
-
"number_of_rules": 0,
|
|
73
|
-
"substitutions": {
|
|
74
|
-
"mask": 0,
|
|
75
|
-
"faker": 0,
|
|
76
|
-
"text": 0,
|
|
77
|
-
"not_defined": 0,
|
|
78
|
-
},
|
|
79
|
-
"entities": set(),
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
for rule_list in rule_lists:
|
|
83
|
-
traits["number_of_rules"] += len(rule_list.get("rules", []))
|
|
84
|
-
for rule in rule_list.get("rules", []):
|
|
85
|
-
traits["substitutions"][rule.get("substitution", "not_defined")] += 1
|
|
86
|
-
traits["entities"].add(rule.get("entity"))
|
|
87
|
-
|
|
88
|
-
entities = list(traits["entities"])
|
|
89
|
-
entities.sort()
|
|
90
|
-
traits["entities"] = entities
|
|
91
|
-
|
|
92
|
-
return traits
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
def validate_anonymization_yaml(yaml_content: Dict[Text, Any]) -> None:
|
|
96
|
-
"""Checks if the yaml_content adheres to the anonymization rule schema.
|
|
97
|
-
|
|
98
|
-
If the yaml_content is not in the right format, an exception will be raised.
|
|
99
|
-
"""
|
|
100
|
-
schema = read_yaml_file(SCHEMA_FILE, reader_type=("safe", "rt"))
|
|
101
|
-
try:
|
|
102
|
-
validate_yaml_content_using_schema(yaml_content, schema)
|
|
103
|
-
except YamlException as exception:
|
|
104
|
-
raise RasaException(
|
|
105
|
-
f"Invalid configuration for `anonymization_rules` : {exception}"
|
|
106
|
-
) from exception
|
|
107
|
-
|
|
108
|
-
rule_lists = yaml_content.get("anonymization", {}).get("rule_lists", [])
|
|
109
|
-
|
|
110
|
-
rule_set = set()
|
|
111
|
-
for rule_list in rule_lists:
|
|
112
|
-
rule_id = rule_list.get("id")
|
|
113
|
-
if rule_id in rule_set:
|
|
114
|
-
raise RasaException(
|
|
115
|
-
f"Invalid configuration for `anonymization_rules` :"
|
|
116
|
-
f"Duplicate rule id: '{rule_id}' encountered in rule_lists"
|
|
117
|
-
)
|
|
118
|
-
rule_set.add(rule_id)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|