rasa-pro 3.12.4__py3-none-any.whl → 3.12.6__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.

Files changed (49) hide show
  1. rasa/core/actions/action.py +0 -6
  2. rasa/core/channels/voice_ready/audiocodes.py +52 -17
  3. rasa/core/channels/voice_stream/audiocodes.py +53 -9
  4. rasa/core/channels/voice_stream/genesys.py +146 -16
  5. rasa/core/policies/flows/flow_executor.py +3 -38
  6. rasa/core/policies/intentless_policy.py +6 -59
  7. rasa/core/processor.py +19 -5
  8. rasa/core/utils.py +53 -0
  9. rasa/dialogue_understanding/commands/cancel_flow_command.py +4 -59
  10. rasa/dialogue_understanding/commands/start_flow_command.py +0 -41
  11. rasa/dialogue_understanding/generator/_jinja_filters.py +9 -0
  12. rasa/dialogue_understanding/generator/command_generator.py +67 -0
  13. rasa/dialogue_understanding/generator/constants.py +4 -0
  14. rasa/dialogue_understanding/generator/llm_based_command_generator.py +22 -16
  15. rasa/dialogue_understanding/generator/nlu_command_adapter.py +1 -1
  16. rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v2_claude_3_5_sonnet_20240620_template.jinja2 +2 -2
  17. rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v2_gpt_4o_2024_11_20_template.jinja2 +2 -2
  18. rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +0 -61
  19. rasa/dialogue_understanding/processor/command_processor.py +27 -70
  20. rasa/dialogue_understanding/processor/command_processor_component.py +5 -2
  21. rasa/dialogue_understanding/stack/utils.py +0 -38
  22. rasa/e2e_test/llm_judge_prompts/answer_relevance_prompt_template.jinja2 +1 -1
  23. rasa/engine/validation.py +36 -1
  24. rasa/model_training.py +2 -1
  25. rasa/shared/constants.py +2 -0
  26. rasa/shared/core/constants.py +0 -8
  27. rasa/shared/core/domain.py +12 -3
  28. rasa/shared/core/flows/flow.py +0 -17
  29. rasa/shared/core/flows/flows_yaml_schema.json +3 -38
  30. rasa/shared/core/flows/steps/collect.py +5 -18
  31. rasa/shared/core/flows/utils.py +1 -16
  32. rasa/shared/core/policies/__init__.py +0 -0
  33. rasa/shared/core/policies/utils.py +87 -0
  34. rasa/shared/core/slot_mappings.py +23 -5
  35. rasa/shared/nlu/constants.py +0 -1
  36. rasa/shared/utils/common.py +11 -1
  37. rasa/tracing/instrumentation/attribute_extractors.py +2 -0
  38. rasa/validator.py +1 -123
  39. rasa/version.py +1 -1
  40. {rasa_pro-3.12.4.dist-info → rasa_pro-3.12.6.dist-info}/METADATA +4 -5
  41. {rasa_pro-3.12.4.dist-info → rasa_pro-3.12.6.dist-info}/RECORD +44 -46
  42. {rasa_pro-3.12.4.dist-info → rasa_pro-3.12.6.dist-info}/WHEEL +1 -1
  43. README.md +0 -38
  44. rasa/core/actions/action_handle_digressions.py +0 -164
  45. rasa/dialogue_understanding/commands/handle_digressions_command.py +0 -144
  46. rasa/dialogue_understanding/patterns/handle_digressions.py +0 -81
  47. rasa/keys +0 -1
  48. {rasa_pro-3.12.4.dist-info → rasa_pro-3.12.6.dist-info}/NOTICE +0 -0
  49. {rasa_pro-3.12.4.dist-info → rasa_pro-3.12.6.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,87 @@
1
+ from typing import Set, Text
2
+
3
+ from rasa.dialogue_understanding.patterns.chitchat import FLOW_PATTERN_CHITCHAT
4
+ from rasa.graph_components.providers.forms_provider import Forms
5
+ from rasa.graph_components.providers.responses_provider import Responses
6
+ from rasa.shared.constants import (
7
+ REQUIRED_SLOTS_KEY,
8
+ UTTER_ASK_PREFIX,
9
+ UTTER_FREE_CHITCHAT_RESPONSE,
10
+ )
11
+ from rasa.shared.core.constants import ACTION_TRIGGER_CHITCHAT
12
+ from rasa.shared.core.domain import Domain
13
+ from rasa.shared.core.flows import FlowsList
14
+ from rasa.shared.core.training_data.structures import StoryGraph
15
+
16
+
17
+ def collect_form_responses(forms: Forms) -> Set[Text]:
18
+ """Collect responses that belong the requested slots in forms.
19
+
20
+ Args:
21
+ forms: the forms from the domain
22
+ Returns:
23
+ all utterances used in forms
24
+ """
25
+ form_responses = set()
26
+ for _, form_info in forms.data.items():
27
+ for required_slot in form_info.get(REQUIRED_SLOTS_KEY, []):
28
+ form_responses.add(f"{UTTER_ASK_PREFIX}{required_slot}")
29
+ return form_responses
30
+
31
+
32
+ def filter_responses_for_intentless_policy(
33
+ responses: Responses, forms: Forms, flows: FlowsList
34
+ ) -> Responses:
35
+ """Filters out responses that are unwanted for the intentless policy.
36
+
37
+ This includes utterances used in flows and forms.
38
+
39
+ Args:
40
+ responses: the responses from the domain
41
+ forms: the forms from the domain
42
+ flows: all flows
43
+ Returns:
44
+ The remaining, relevant responses for the intentless policy.
45
+ """
46
+ form_responses = collect_form_responses(forms)
47
+ flow_responses = flows.utterances
48
+ combined_responses = form_responses | flow_responses
49
+ filtered_responses = {
50
+ name: variants
51
+ for name, variants in responses.data.items()
52
+ if name not in combined_responses
53
+ }
54
+
55
+ pattern_chitchat = flows.flow_by_id(FLOW_PATTERN_CHITCHAT)
56
+
57
+ # The following condition is highly unlikely, but mypy requires the case
58
+ # of pattern_chitchat == None to be addressed
59
+ if not pattern_chitchat:
60
+ return Responses(data=filtered_responses)
61
+
62
+ # if action_trigger_chitchat, filter out "utter_free_chitchat_response"
63
+ has_action_trigger_chitchat = pattern_chitchat.has_action_step(
64
+ ACTION_TRIGGER_CHITCHAT
65
+ )
66
+ if has_action_trigger_chitchat:
67
+ filtered_responses.pop(UTTER_FREE_CHITCHAT_RESPONSE, None)
68
+
69
+ return Responses(data=filtered_responses)
70
+
71
+
72
+ def contains_intentless_policy_responses(
73
+ flows: FlowsList, domain: Domain, story_graph: StoryGraph
74
+ ) -> bool:
75
+ """Checks if IntentlessPolicy has applicable responses: either responses in the
76
+ domain that are not part of any flow, or if there are e2e stories.
77
+ """
78
+ responses = filter_responses_for_intentless_policy(
79
+ Responses(data=domain.responses), Forms(data=domain.forms), flows
80
+ )
81
+
82
+ has_applicable_responses = bool(
83
+ responses and responses.data and len(responses.data) > 0
84
+ )
85
+ has_e2e_stories = bool(story_graph and story_graph.has_e2e_stories())
86
+
87
+ return has_applicable_responses or has_e2e_stories
@@ -115,6 +115,18 @@ class SlotMapping(BaseModel):
115
115
  )
116
116
  data_copy[KEY_RUN_ACTION_EVERY_TURN] = deprecated_action
117
117
 
118
+ structlogger.warning(
119
+ "slot_mapping.deprecated_action_key_replaced_with_run_action_every_turn",
120
+ slot_name=slot_name,
121
+ event_info=f"The `{KEY_ACTION}` key in slot mappings "
122
+ f"has been replaced with "
123
+ f"the `{KEY_RUN_ACTION_EVERY_TURN}` key. "
124
+ f"This will result in the custom action "
125
+ f"being executed at every conversation turn "
126
+ f"automatically. Remove the key "
127
+ f"to avoid this behavior.",
128
+ )
129
+
118
130
  run_action_every_turn = data_copy.pop(KEY_RUN_ACTION_EVERY_TURN, None)
119
131
 
120
132
  coexistence_system = data_copy.pop(KEY_COEXISTENCE_SYSTEM, None)
@@ -636,12 +648,14 @@ class SlotFillingManager:
636
648
  output_channel: "OutputChannel",
637
649
  nlg: "NaturalLanguageGenerator",
638
650
  recreate_tracker: bool = False,
651
+ slot_events: Optional[List[Event]] = None,
639
652
  ) -> List[Event]:
640
653
  from rasa.core.actions.action import RemoteAction
641
654
  from rasa.shared.core.trackers import DialogueStateTracker
642
655
  from rasa.utils.endpoints import ClientResponseError
643
656
 
644
- slot_events: List[Event] = []
657
+ validated_slot_events: List[Event] = []
658
+ slot_events = slot_events if slot_events is not None else []
645
659
  remote_action = RemoteAction(custom_action, self._action_endpoint)
646
660
  disallowed_types = set()
647
661
 
@@ -661,9 +675,9 @@ class SlotFillingManager:
661
675
  )
662
676
  for event in custom_events:
663
677
  if isinstance(event, SlotSet):
664
- slot_events.append(event)
678
+ validated_slot_events.append(event)
665
679
  elif isinstance(event, BotUttered):
666
- slot_events.append(event)
680
+ validated_slot_events.append(event)
667
681
  else:
668
682
  disallowed_types.add(event.type_name)
669
683
  except (RasaException, ClientResponseError) as e:
@@ -687,7 +701,7 @@ class SlotFillingManager:
687
701
  f"updated with this event.",
688
702
  )
689
703
 
690
- return slot_events
704
+ return validated_slot_events
691
705
 
692
706
  async def execute_validation_action(
693
707
  self,
@@ -710,7 +724,11 @@ class SlotFillingManager:
710
724
  return cast(List[Event], slot_events)
711
725
 
712
726
  validate_events = await self._run_custom_action(
713
- ACTION_VALIDATE_SLOT_MAPPINGS, output_channel, nlg, recreate_tracker=True
727
+ ACTION_VALIDATE_SLOT_MAPPINGS,
728
+ output_channel,
729
+ nlg,
730
+ recreate_tracker=True,
731
+ slot_events=cast(List[Event], slot_events),
714
732
  )
715
733
  validated_slot_names = [
716
734
  event.key for event in validate_events if isinstance(event, SlotSet)
@@ -55,4 +55,3 @@ SPLIT_ENTITIES_BY_COMMA_DEFAULT_VALUE = True
55
55
  SINGLE_ENTITY_ALLOWED_INTERLEAVING_CHARSET = {".", ",", " ", ";"}
56
56
 
57
57
  SET_SLOT_COMMAND = "set slot"
58
- HANDLE_DIGRESSIONS_COMMAND = "handle digressions"
@@ -7,7 +7,17 @@ import os
7
7
  import pkgutil
8
8
  import sys
9
9
  from types import ModuleType
10
- from typing import Any, Callable, Collection, Dict, List, Optional, Sequence, Text, Type
10
+ from typing import (
11
+ Any,
12
+ Callable,
13
+ Collection,
14
+ Dict,
15
+ List,
16
+ Optional,
17
+ Sequence,
18
+ Text,
19
+ Type,
20
+ )
11
21
 
12
22
  import rasa.shared.utils.io
13
23
  from rasa.exceptions import MissingDependencyException
@@ -454,6 +454,7 @@ def extract_attrs_for_execute_commands(
454
454
  all_flows: FlowsList,
455
455
  execution_context: ExecutionContext,
456
456
  story_graph: Optional[StoryGraph] = None,
457
+ domain: Optional[Domain] = None,
457
458
  ) -> Dict[str, Any]:
458
459
  return {
459
460
  "number_of_events": len(tracker.events),
@@ -497,6 +498,7 @@ def extract_attrs_for_clean_up_commands(
497
498
  all_flows: FlowsList,
498
499
  execution_context: ExecutionContext,
499
500
  story_graph: Optional[StoryGraph] = None,
501
+ domain: Optional[Domain] = None,
500
502
  ) -> Dict[str, Any]:
501
503
  commands_list = []
502
504
 
rasa/validator.py CHANGED
@@ -48,7 +48,7 @@ from rasa.shared.core.domain import (
48
48
  Domain,
49
49
  )
50
50
  from rasa.shared.core.events import ActionExecuted, ActiveLoop, UserUttered
51
- from rasa.shared.core.flows import Flow, FlowsList
51
+ from rasa.shared.core.flows import FlowsList
52
52
  from rasa.shared.core.flows.constants import KEY_NAME, KEY_TRANSLATION
53
53
  from rasa.shared.core.flows.flow_step_links import IfFlowStepLink
54
54
  from rasa.shared.core.flows.steps.action import ActionFlowStep
@@ -56,7 +56,6 @@ from rasa.shared.core.flows.steps.collect import CollectInformationFlowStep
56
56
  from rasa.shared.core.flows.steps.link import LinkFlowStep
57
57
  from rasa.shared.core.flows.steps.set_slots import SetSlotsFlowStep
58
58
  from rasa.shared.core.flows.utils import (
59
- ALL_LABEL,
60
59
  get_duplicate_slot_persistence_config_error_message,
61
60
  get_invalid_slot_persistence_config_error_message,
62
61
  warn_deprecated_collect_step_config,
@@ -1281,7 +1280,6 @@ class Validator:
1281
1280
  self.verify_unique_flows(),
1282
1281
  self.verify_predicates(),
1283
1282
  self.verify_slot_persistence_configuration(),
1284
- self.verify_digression_configuration(),
1285
1283
  ]
1286
1284
 
1287
1285
  all_good = all(flow_validation_conditions)
@@ -1830,126 +1828,6 @@ class Validator:
1830
1828
 
1831
1829
  return all_good
1832
1830
 
1833
- def verify_digression_configuration(self) -> bool:
1834
- """Validates the digression configuration in flows."""
1835
- all_good = True
1836
-
1837
- for flow in self.flows.underlying_flows:
1838
- all_good = self._validate_ask_confirm_digressions(flow, all_good)
1839
- all_good = self._validate_block_digressions(flow, all_good)
1840
-
1841
- return all_good
1842
-
1843
- def _validate_ask_confirm_digressions(self, flow: Flow, all_good: bool) -> bool:
1844
- """Validates the ask_confirm_digressions configuration in a flow."""
1845
- for flow_id in flow.ask_confirm_digressions:
1846
- if flow_id == ALL_LABEL:
1847
- continue
1848
- if flow_id not in self.flows.flow_ids:
1849
- structlogger.error(
1850
- "validator.verify_digression_configuration.ask_confirm_digressions",
1851
- flow=flow.id,
1852
- event_info=(
1853
- f"The flow '{flow_id}' is listed in the "
1854
- f"`ask_confirm_digressions` configuration of flow "
1855
- f"'{flow.id}', but it is not found in the "
1856
- f"flows file. Please make sure that the flow id is correct."
1857
- ),
1858
- )
1859
- all_good = False
1860
-
1861
- if flow_id in flow.block_digressions:
1862
- structlogger.error(
1863
- "validator.verify_digression_configuration.overlap_digressions",
1864
- flow=flow.id,
1865
- event_info=(
1866
- f"The flow '{flow_id}' is listed in both the "
1867
- f"`ask_confirm_digressions` and `block_digressions` "
1868
- f"configuration of flow '{flow.id}'. "
1869
- f"Please make sure that the flow id is not listed in both "
1870
- f"configurations."
1871
- ),
1872
- )
1873
- all_good = False
1874
-
1875
- for step in flow.get_collect_steps():
1876
- for flow_id in step.ask_confirm_digressions:
1877
- if flow_id == ALL_LABEL:
1878
- continue
1879
-
1880
- if flow_id not in self.flows.flow_ids:
1881
- structlogger.error(
1882
- "validator.verify_digression_configuration.ask_confirm_digressions",
1883
- flow=flow.id,
1884
- step_id=step.id,
1885
- event_info=(
1886
- f"The flow '{flow_id}' is listed in the "
1887
- f"`ask_confirm_digressions` configuration of step "
1888
- f"'{step.id}' in flow '{flow.id}', but it is "
1889
- f"not found in the flows file. "
1890
- f"Please make sure that the flow id is correct."
1891
- ),
1892
- )
1893
- all_good = False
1894
-
1895
- if flow_id in step.block_digressions:
1896
- structlogger.error(
1897
- "validator.verify_digression_configuration.overlap_digressions",
1898
- flow=flow.id,
1899
- step_id=step.id,
1900
- event_info=(
1901
- f"The flow '{flow_id}' is listed in both the "
1902
- f"`ask_confirm_digressions` and `block_digressions` "
1903
- f"configuration of step '{step.id}' in flow '{flow.id}'. "
1904
- f"Please make sure that the flow id is not listed in both "
1905
- f"configurations."
1906
- ),
1907
- )
1908
- all_good = False
1909
-
1910
- return all_good
1911
-
1912
- def _validate_block_digressions(self, flow: Flow, all_good: bool) -> bool:
1913
- """Validates the block_digressions configuration in a flow."""
1914
- for flow_id in flow.block_digressions:
1915
- if flow_id == ALL_LABEL:
1916
- continue
1917
-
1918
- if flow_id not in self.flows.flow_ids:
1919
- structlogger.error(
1920
- "validator.verify_digression_configuration.block_digressions",
1921
- flow=flow.id,
1922
- event_info=(
1923
- f"The flow '{flow_id}' is listed in the `block_digressions` "
1924
- f"configuration of flow '{flow.id}', but it is not found "
1925
- f"in the flows file. Please make sure that the flow id "
1926
- f"is correct."
1927
- ),
1928
- )
1929
- all_good = False
1930
-
1931
- for step in flow.get_collect_steps():
1932
- for flow_id in step.block_digressions:
1933
- if flow_id == ALL_LABEL:
1934
- continue
1935
-
1936
- if flow_id not in self.flows.flow_ids:
1937
- structlogger.error(
1938
- "validator.verify_digression_configuration.block_digressions",
1939
- flow=flow.id,
1940
- step_id=step.id,
1941
- event_info=(
1942
- f"The flow '{flow_id}' is listed in the "
1943
- f"`block_digressions` configuration of step "
1944
- f"'{step.id}' in flow '{flow.id}', but it is "
1945
- f"not found in the flows file. "
1946
- f"Please make sure that the flow id is correct."
1947
- ),
1948
- )
1949
- all_good = False
1950
-
1951
- return all_good
1952
-
1953
1831
  def verify_slot_validation(self) -> bool:
1954
1832
  """Validates the slot validation configuration in the domain file."""
1955
1833
  all_good = True
rasa/version.py CHANGED
@@ -1,3 +1,3 @@
1
1
  # this file will automatically be changed,
2
2
  # do not add anything but the version number here!
3
- __version__ = "3.12.4"
3
+ __version__ = "3.12.6"
@@ -1,8 +1,7 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: rasa-pro
3
- Version: 3.12.4
3
+ Version: 3.12.6
4
4
  Summary: State-of-the-art open-core Conversational AI framework for Enterprises that natively leverages generative AI for effortless assistant development.
5
- Home-page: https://rasa.com
6
5
  Keywords: nlp,machine-learning,machine-learning-library,bot,bots,botkit,rasa conversational-agents,conversational-ai,chatbot,chatbot-framework,bot-framework
7
6
  Author: Rasa Technologies GmbH
8
7
  Author-email: hi@rasa.com
@@ -86,7 +85,6 @@ Requires-Dist: protobuf (>=4.23.3,<4.25.4)
86
85
  Requires-Dist: psutil (>=5.9.5,<6.0.0)
87
86
  Requires-Dist: psycopg2-binary (>=2.9.9,<2.10.0)
88
87
  Requires-Dist: pycountry (>=22.3.5,<23.0.0)
89
- Requires-Dist: pydantic (>=2.0,<3.0)
90
88
  Requires-Dist: pydot (>=1.4,<1.5)
91
89
  Requires-Dist: pykwalify (>=1.8,<1.9)
92
90
  Requires-Dist: pymilvus (>=2.4.1,<2.4.2)
@@ -135,7 +133,7 @@ Requires-Dist: tensorflow-io-gcs-filesystem (==0.34) ; sys_platform == "darwin"
135
133
  Requires-Dist: tensorflow-io-gcs-filesystem (==0.34) ; sys_platform == "linux"
136
134
  Requires-Dist: tensorflow-macos (==2.14.1) ; sys_platform == "darwin" and platform_machine == "arm64"
137
135
  Requires-Dist: tensorflow-metal (==1.1.0) ; (sys_platform == "darwin" and platform_machine == "arm64") and (extra == "metal")
138
- Requires-Dist: tensorflow-text (==2.14.0) ; sys_platform != "win32" and (platform_machine != "arm64" and platform_machine != "aarch64")
136
+ Requires-Dist: tensorflow-text (==2.14.0) ; sys_platform != "win32" and platform_machine != "arm64" and platform_machine != "aarch64"
139
137
  Requires-Dist: tensorflow_hub (>=0.13.0,<0.14.0)
140
138
  Requires-Dist: terminaltables (>=3.1.10,<3.2.0)
141
139
  Requires-Dist: tiktoken (>=0.7.0,<0.8.0)
@@ -150,6 +148,7 @@ Requires-Dist: webexteamssdk (>=1.6.1,<1.7.0)
150
148
  Requires-Dist: websockets (>=10.4,<11.0)
151
149
  Requires-Dist: wheel (>=0.40.0)
152
150
  Project-URL: Documentation, https://rasa.com/docs
151
+ Project-URL: Homepage, https://rasa.com
153
152
  Project-URL: Repository, https://github.com/rasahq/rasa
154
153
  Description-Content-Type: text/markdown
155
154