rasa-pro 3.13.0.dev20250612__py3-none-any.whl → 3.13.0.dev20250613__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of rasa-pro might be problematic. Click here for more details.

Files changed (156) hide show
  1. rasa/__main__.py +0 -3
  2. rasa/api.py +1 -1
  3. rasa/cli/dialogue_understanding_test.py +1 -1
  4. rasa/cli/e2e_test.py +1 -1
  5. rasa/cli/evaluate.py +1 -1
  6. rasa/cli/export.py +1 -1
  7. rasa/cli/llm_fine_tuning.py +12 -11
  8. rasa/cli/project_templates/defaults.py +133 -0
  9. rasa/cli/run.py +1 -1
  10. rasa/cli/studio/link.py +53 -0
  11. rasa/cli/studio/pull.py +78 -0
  12. rasa/cli/studio/push.py +78 -0
  13. rasa/cli/studio/studio.py +12 -0
  14. rasa/cli/studio/upload.py +8 -0
  15. rasa/cli/train.py +1 -1
  16. rasa/cli/utils.py +1 -1
  17. rasa/cli/x.py +1 -1
  18. rasa/constants.py +2 -0
  19. rasa/core/__init__.py +0 -16
  20. rasa/core/actions/action.py +5 -1
  21. rasa/core/actions/action_repeat_bot_messages.py +18 -22
  22. rasa/core/actions/action_run_slot_rejections.py +0 -1
  23. rasa/core/agent.py +16 -1
  24. rasa/core/available_endpoints.py +146 -0
  25. rasa/core/brokers/pika.py +1 -2
  26. rasa/core/channels/botframework.py +2 -2
  27. rasa/core/channels/channel.py +2 -2
  28. rasa/core/channels/hangouts.py +8 -5
  29. rasa/core/channels/mattermost.py +1 -1
  30. rasa/core/channels/rasa_chat.py +2 -4
  31. rasa/core/channels/rest.py +5 -4
  32. rasa/core/channels/studio_chat.py +3 -2
  33. rasa/core/channels/vier_cvg.py +1 -2
  34. rasa/core/channels/voice_ready/audiocodes.py +1 -8
  35. rasa/core/channels/voice_stream/audiocodes.py +7 -4
  36. rasa/core/channels/voice_stream/genesys.py +2 -2
  37. rasa/core/channels/voice_stream/twilio_media_streams.py +10 -5
  38. rasa/core/channels/voice_stream/voice_channel.py +33 -22
  39. rasa/core/http_interpreter.py +3 -7
  40. rasa/core/jobs.py +2 -1
  41. rasa/core/nlg/contextual_response_rephraser.py +38 -11
  42. rasa/core/nlg/generator.py +0 -1
  43. rasa/core/nlg/interpolator.py +2 -3
  44. rasa/core/nlg/summarize.py +39 -5
  45. rasa/core/policies/enterprise_search_policy.py +290 -66
  46. rasa/core/policies/enterprise_search_prompt_with_relevancy_check_and_citation_template.jinja2 +63 -0
  47. rasa/core/policies/flow_policy.py +1 -1
  48. rasa/core/policies/flows/flow_executor.py +96 -17
  49. rasa/core/policies/intentless_policy.py +24 -16
  50. rasa/core/processor.py +104 -51
  51. rasa/core/run.py +33 -11
  52. rasa/core/tracker_stores/tracker_store.py +1 -1
  53. rasa/core/training/interactive.py +1 -1
  54. rasa/core/utils.py +24 -97
  55. rasa/dialogue_understanding/coexistence/intent_based_router.py +2 -1
  56. rasa/dialogue_understanding/coexistence/llm_based_router.py +8 -3
  57. rasa/dialogue_understanding/commands/can_not_handle_command.py +2 -0
  58. rasa/dialogue_understanding/commands/cancel_flow_command.py +2 -0
  59. rasa/dialogue_understanding/commands/chit_chat_answer_command.py +2 -0
  60. rasa/dialogue_understanding/commands/clarify_command.py +5 -1
  61. rasa/dialogue_understanding/commands/command_syntax_manager.py +1 -0
  62. rasa/dialogue_understanding/commands/human_handoff_command.py +2 -0
  63. rasa/dialogue_understanding/commands/knowledge_answer_command.py +2 -0
  64. rasa/dialogue_understanding/commands/repeat_bot_messages_command.py +2 -0
  65. rasa/dialogue_understanding/commands/set_slot_command.py +11 -1
  66. rasa/dialogue_understanding/commands/skip_question_command.py +2 -0
  67. rasa/dialogue_understanding/commands/start_flow_command.py +4 -0
  68. rasa/dialogue_understanding/commands/utils.py +26 -2
  69. rasa/dialogue_understanding/generator/__init__.py +7 -1
  70. rasa/dialogue_understanding/generator/command_generator.py +4 -2
  71. rasa/dialogue_understanding/generator/command_parser.py +2 -2
  72. rasa/dialogue_understanding/generator/command_parser_validator.py +63 -0
  73. rasa/dialogue_understanding/generator/constants.py +2 -2
  74. rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v3_gpt_4o_2024_11_20_template.jinja2 +78 -0
  75. rasa/dialogue_understanding/generator/single_step/compact_llm_command_generator.py +28 -463
  76. rasa/dialogue_understanding/generator/single_step/search_ready_llm_command_generator.py +147 -0
  77. rasa/dialogue_understanding/generator/single_step/single_step_based_llm_command_generator.py +477 -0
  78. rasa/dialogue_understanding/generator/single_step/single_step_llm_command_generator.py +8 -58
  79. rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +37 -25
  80. rasa/dialogue_understanding/patterns/domain_for_patterns.py +190 -0
  81. rasa/dialogue_understanding/processor/command_processor.py +3 -3
  82. rasa/dialogue_understanding/processor/command_processor_component.py +3 -3
  83. rasa/dialogue_understanding/stack/frames/flow_stack_frame.py +17 -4
  84. rasa/dialogue_understanding/utils.py +68 -12
  85. rasa/dialogue_understanding_test/du_test_case.py +1 -1
  86. rasa/dialogue_understanding_test/du_test_runner.py +4 -22
  87. rasa/dialogue_understanding_test/test_case_simulation/test_case_tracker_simulator.py +2 -6
  88. rasa/e2e_test/e2e_test_runner.py +1 -1
  89. rasa/engine/constants.py +1 -1
  90. rasa/engine/recipes/default_recipe.py +26 -2
  91. rasa/engine/validation.py +3 -2
  92. rasa/hooks.py +0 -28
  93. rasa/llm_fine_tuning/annotation_module.py +39 -9
  94. rasa/llm_fine_tuning/conversations.py +3 -0
  95. rasa/llm_fine_tuning/llm_data_preparation_module.py +66 -49
  96. rasa/llm_fine_tuning/paraphrasing/conversation_rephraser.py +4 -2
  97. rasa/llm_fine_tuning/paraphrasing/rephrase_validator.py +52 -44
  98. rasa/llm_fine_tuning/paraphrasing_module.py +10 -12
  99. rasa/llm_fine_tuning/storage.py +4 -4
  100. rasa/llm_fine_tuning/utils.py +63 -1
  101. rasa/model_manager/model_api.py +88 -0
  102. rasa/model_manager/trainer_service.py +4 -4
  103. rasa/plugin.py +1 -11
  104. rasa/privacy/__init__.py +0 -0
  105. rasa/privacy/constants.py +83 -0
  106. rasa/privacy/event_broker_utils.py +77 -0
  107. rasa/privacy/privacy_config.py +281 -0
  108. rasa/privacy/privacy_config_schema.json +86 -0
  109. rasa/privacy/privacy_filter.py +340 -0
  110. rasa/privacy/privacy_manager.py +576 -0
  111. rasa/server.py +23 -2
  112. rasa/shared/constants.py +6 -0
  113. rasa/shared/core/constants.py +4 -3
  114. rasa/shared/core/domain.py +7 -0
  115. rasa/shared/core/events.py +37 -7
  116. rasa/shared/core/flows/flow.py +1 -2
  117. rasa/shared/core/flows/flows_yaml_schema.json +3 -0
  118. rasa/shared/core/flows/steps/collect.py +46 -2
  119. rasa/shared/core/slots.py +28 -0
  120. rasa/shared/exceptions.py +4 -0
  121. rasa/shared/providers/_configs/azure_openai_client_config.py +4 -0
  122. rasa/shared/providers/_configs/openai_client_config.py +4 -0
  123. rasa/shared/providers/embedding/_base_litellm_embedding_client.py +3 -0
  124. rasa/shared/providers/llm/_base_litellm_client.py +5 -2
  125. rasa/shared/utils/llm.py +161 -6
  126. rasa/shared/utils/yaml.py +32 -0
  127. rasa/studio/data_handler.py +3 -3
  128. rasa/studio/download/download.py +37 -60
  129. rasa/studio/download/flows.py +23 -31
  130. rasa/studio/link.py +200 -0
  131. rasa/studio/pull.py +94 -0
  132. rasa/studio/push.py +131 -0
  133. rasa/studio/upload.py +117 -67
  134. rasa/telemetry.py +82 -25
  135. rasa/tracing/config.py +3 -4
  136. rasa/tracing/constants.py +19 -1
  137. rasa/tracing/instrumentation/attribute_extractors.py +10 -2
  138. rasa/tracing/instrumentation/instrumentation.py +53 -2
  139. rasa/tracing/instrumentation/metrics.py +98 -15
  140. rasa/tracing/metric_instrument_provider.py +75 -3
  141. rasa/utils/common.py +1 -27
  142. rasa/utils/log_utils.py +1 -45
  143. rasa/validator.py +2 -8
  144. rasa/version.py +1 -1
  145. {rasa_pro-3.13.0.dev20250612.dist-info → rasa_pro-3.13.0.dev20250613.dist-info}/METADATA +5 -6
  146. {rasa_pro-3.13.0.dev20250612.dist-info → rasa_pro-3.13.0.dev20250613.dist-info}/RECORD +149 -135
  147. rasa/anonymization/__init__.py +0 -2
  148. rasa/anonymization/anonymisation_rule_yaml_reader.py +0 -91
  149. rasa/anonymization/anonymization_pipeline.py +0 -286
  150. rasa/anonymization/anonymization_rule_executor.py +0 -266
  151. rasa/anonymization/anonymization_rule_orchestrator.py +0 -119
  152. rasa/anonymization/schemas/config.yml +0 -47
  153. rasa/anonymization/utils.py +0 -118
  154. {rasa_pro-3.13.0.dev20250612.dist-info → rasa_pro-3.13.0.dev20250613.dist-info}/NOTICE +0 -0
  155. {rasa_pro-3.13.0.dev20250612.dist-info → rasa_pro-3.13.0.dev20250613.dist-info}/WHEEL +0 -0
  156. {rasa_pro-3.13.0.dev20250612.dist-info → rasa_pro-3.13.0.dev20250613.dist-info}/entry_points.txt +0 -0
@@ -1,4 +1,3 @@
1
- import copy
2
1
  import logging
3
2
  from typing import Any, Dict, Optional, Text
4
3
 
@@ -49,7 +48,6 @@ class RasaNLUHttpInterpreter:
49
48
  if not self.endpoint_config or self.endpoint_config.url is None:
50
49
  structlogger.error(
51
50
  "http.parse.text",
52
- text=copy.deepcopy(text),
53
51
  event_info="No rasa NLU server specified!",
54
52
  )
55
53
  return None
@@ -71,18 +69,16 @@ class RasaNLUHttpInterpreter:
71
69
  if resp.status == 200:
72
70
  return await resp.json()
73
71
  else:
74
- response_text = await resp.text()
75
72
  structlogger.error(
76
73
  "http.parse.text.failure",
77
- text=copy.deepcopy(text),
78
- response_text=copy.deepcopy(response_text),
74
+ event_info="Failed to parse text",
79
75
  )
80
76
  return None
81
- except Exception: # skipcq: PYL-W0703
77
+ except Exception as e: # skipcq: PYL-W0703
82
78
  # need to catch all possible exceptions when doing http requests
83
79
  # (timeouts, value errors, parser errors, ...)
84
80
  structlogger.exception(
85
81
  "http.parse.text.exception",
86
- text=copy.deepcopy(text),
82
+ event_info=f"Exception occurred while parsing text. Error: {e}",
87
83
  )
88
84
  return None
rasa/core/jobs.py CHANGED
@@ -1,12 +1,13 @@
1
1
  import asyncio
2
2
  import logging
3
+ from typing import Optional
3
4
 
4
5
  from apscheduler.schedulers.asyncio import AsyncIOScheduler
5
6
  from pytz import UnknownTimeZoneError, utc
6
7
 
7
8
  import rasa.shared.utils.io
8
9
 
9
- __scheduler = None
10
+ __scheduler: Optional[AsyncIOScheduler] = None
10
11
 
11
12
  logger = logging.getLogger(__name__)
12
13
 
@@ -5,15 +5,20 @@ from jinja2 import Template
5
5
 
6
6
  from rasa import telemetry
7
7
  from rasa.core.nlg.response import TemplatedNaturalLanguageGenerator
8
- from rasa.core.nlg.summarize import summarize_conversation
8
+ from rasa.core.nlg.summarize import (
9
+ _count_multiple_utterances_as_single_turn,
10
+ summarize_conversation,
11
+ )
9
12
  from rasa.shared.constants import (
10
13
  LLM_CONFIG_KEY,
14
+ MAX_COMPLETION_TOKENS_CONFIG_KEY,
11
15
  MODEL_CONFIG_KEY,
12
16
  MODEL_GROUP_ID_CONFIG_KEY,
13
17
  MODEL_NAME_CONFIG_KEY,
14
18
  OPENAI_PROVIDER,
15
19
  PROMPT_CONFIG_KEY,
16
20
  PROVIDER_CONFIG_KEY,
21
+ TEMPERATURE_CONFIG_KEY,
17
22
  TIMEOUT_CONFIG_KEY,
18
23
  )
19
24
  from rasa.shared.core.domain import KEY_RESPONSES_TEXT, Domain
@@ -53,12 +58,13 @@ RESPONSE_SUMMARISE_CONVERSATION_KEY = "summarize_conversation"
53
58
  DEFAULT_REPHRASE_ALL = False
54
59
  DEFAULT_SUMMARIZE_HISTORY = True
55
60
  DEFAULT_MAX_HISTORICAL_TURNS = 5
61
+ DEFAULT_COUNT_MULTIPLE_UTTERANCES_AS_SINGLE_TURN = True
56
62
 
57
63
  DEFAULT_LLM_CONFIG = {
58
64
  PROVIDER_CONFIG_KEY: OPENAI_PROVIDER,
59
65
  MODEL_CONFIG_KEY: DEFAULT_OPENAI_GENERATE_MODEL_NAME,
60
- "temperature": 0.3,
61
- "max_tokens": DEFAULT_OPENAI_MAX_GENERATED_TOKENS,
66
+ TEMPERATURE_CONFIG_KEY: 0.3,
67
+ MAX_COMPLETION_TOKENS_CONFIG_KEY: DEFAULT_OPENAI_MAX_GENERATED_TOKENS,
62
68
  TIMEOUT_CONFIG_KEY: 5,
63
69
  }
64
70
 
@@ -70,6 +76,7 @@ its meaning. Use simple {{language}}.
70
76
  Context / previous conversation with the user:
71
77
  {{history}}
72
78
 
79
+ Last user message:
73
80
  {{current_input}}
74
81
 
75
82
  Suggested AI Response: {{suggested_response}}
@@ -122,6 +129,11 @@ class ContextualResponseRephraser(
122
129
  "max_historical_turns", DEFAULT_MAX_HISTORICAL_TURNS
123
130
  )
124
131
 
132
+ self.count_multiple_utterances_as_single_turn = self.nlg_endpoint.kwargs.get(
133
+ "count_multiple_utterances_as_single_turn",
134
+ DEFAULT_COUNT_MULTIPLE_UTTERANCES_AS_SINGLE_TURN,
135
+ )
136
+
125
137
  self.llm_config = resolve_model_client_config(
126
138
  self.nlg_endpoint.kwargs.get(LLM_CONFIG_KEY),
127
139
  ContextualResponseRephraser.__name__,
@@ -258,8 +270,16 @@ class ContextualResponseRephraser(
258
270
  Returns:
259
271
  The history for the prompt.
260
272
  """
273
+ # Count multiple utterances by bot/user as single turn in conversation history
274
+ turns_wrapper = (
275
+ _count_multiple_utterances_as_single_turn
276
+ if self.count_multiple_utterances_as_single_turn
277
+ else None
278
+ )
261
279
  llm = llm_factory(self.llm_config, DEFAULT_LLM_CONFIG)
262
- return await summarize_conversation(tracker, llm, max_turns=5)
280
+ return await summarize_conversation(
281
+ tracker, llm, max_turns=5, turns_wrapper=turns_wrapper
282
+ )
263
283
 
264
284
  async def rephrase(
265
285
  self,
@@ -281,19 +301,26 @@ class ContextualResponseRephraser(
281
301
 
282
302
  prompt_template_text = self._template_for_response_rephrasing(response)
283
303
 
284
- # Retrieve inputs for the dynamic prompt
285
- latest_message = self._last_message_if_human(tracker)
286
- current_input = f"{USER}: {latest_message}" if latest_message else ""
304
+ # Last user message (=current input) should always be in prompt if available
305
+ last_message_by_user = getattr(tracker.latest_message, "text", "")
306
+ current_input = (
307
+ f"{USER}: {last_message_by_user}" if last_message_by_user else ""
308
+ )
287
309
 
288
310
  # Only summarise conversation history if flagged
289
311
  if self.summarize_history:
290
312
  history = await self._create_history(tracker)
291
313
  else:
292
- # make sure the transcript/history contains the last user utterance
314
+ # Count multiple utterances by bot/user as single turn
315
+ turns_wrapper = (
316
+ _count_multiple_utterances_as_single_turn
317
+ if self.count_multiple_utterances_as_single_turn
318
+ else None
319
+ )
293
320
  max_turns = max(self.max_historical_turns, 1)
294
- history = tracker_as_readable_transcript(tracker, max_turns=max_turns)
295
- # the history already contains the current input
296
- current_input = ""
321
+ history = tracker_as_readable_transcript(
322
+ tracker, max_turns=max_turns, turns_wrapper=turns_wrapper
323
+ )
297
324
 
298
325
  prompt = Template(prompt_template_text).render(
299
326
  history=history,
@@ -292,7 +292,6 @@ def _evaluate_predicate(constraint: str, filled_slots: Dict[Text, Any]) -> bool:
292
292
  structlogger.error(
293
293
  "rasa.core.nlg.generator.evaluate_conditional_response_predicate.error",
294
294
  predicate=constraint,
295
- document=document,
296
295
  error=str(e),
297
296
  )
298
297
  return False
@@ -1,4 +1,3 @@
1
- import copy
2
1
  import logging
3
2
  import re
4
3
  from typing import Any, Dict, List, Text, Union
@@ -70,9 +69,9 @@ def interpolate_format_template(response: Text, values: Dict[Text, Text]) -> Tex
70
69
  )
71
70
  structlogger.exception(
72
71
  "interpolator.interpolate.text",
73
- response=copy.deepcopy(response),
74
72
  placeholder_key=e.args[0],
75
73
  event_info=event_info,
74
+ error=str(e),
76
75
  )
77
76
  return response
78
77
 
@@ -98,9 +97,9 @@ def interpolate_jinja_template(response: Text, values: Dict[Text, Any]) -> Text:
98
97
  )
99
98
  structlogger.exception(
100
99
  "interpolator.interpolate.text",
101
- response=copy.deepcopy(response),
102
100
  placeholder_key=e.args[0],
103
101
  event_info=event_info,
102
+ error=str(e),
104
103
  )
105
104
  return response
106
105
 
@@ -1,4 +1,5 @@
1
- from typing import Optional
1
+ from itertools import groupby
2
+ from typing import Callable, List, Optional
2
3
 
3
4
  import structlog
4
5
  from jinja2 import Template
@@ -23,20 +24,49 @@ SUMMARY_PROMPT_TEMPLATE = Template(_DEFAULT_SUMMARIZER_TEMPLATE)
23
24
  MAX_TURNS_DEFAULT = 20
24
25
 
25
26
 
27
+ def _count_multiple_utterances_as_single_turn(transcript: List[str]) -> List[str]:
28
+ """Counts multiple utterances as a single turn.
29
+
30
+ Args:
31
+ transcript: the lines of the transcript
32
+
33
+ Returns:
34
+ transcript: with multiple utterances counted as a single turn
35
+ """
36
+ if not transcript:
37
+ return []
38
+
39
+ def get_speaker_label(line: str) -> str:
40
+ return line.partition(": ")[0] if ": " in line else ""
41
+
42
+ modified_transcript = [
43
+ f"{speaker}: {' '.join(line.partition(': ')[2] for line in group)}"
44
+ for speaker, group in groupby(transcript, key=get_speaker_label)
45
+ if speaker
46
+ ]
47
+
48
+ return modified_transcript
49
+
50
+
26
51
  def _create_summarization_prompt(
27
- tracker: DialogueStateTracker, max_turns: Optional[int]
52
+ tracker: DialogueStateTracker,
53
+ max_turns: Optional[int],
54
+ turns_wrapper: Optional[Callable[[List[str]], List[str]]],
28
55
  ) -> str:
29
56
  """Creates an LLM prompt to summarize the conversation in the tracker.
30
57
 
31
58
  Args:
32
59
  tracker: tracker of the conversation to be summarized
33
60
  max_turns: maximum number of turns to summarize
61
+ turns_wrapper: optional function to wrap the turns
34
62
 
35
63
 
36
64
  Returns:
37
65
  The prompt to summarize the conversation.
38
66
  """
39
- transcript = tracker_as_readable_transcript(tracker, max_turns=max_turns)
67
+ transcript = tracker_as_readable_transcript(
68
+ tracker, max_turns=max_turns, turns_wrapper=turns_wrapper
69
+ )
40
70
  return SUMMARY_PROMPT_TEMPLATE.render(
41
71
  conversation=transcript,
42
72
  )
@@ -46,6 +76,7 @@ async def summarize_conversation(
46
76
  tracker: DialogueStateTracker,
47
77
  llm: LLMClient,
48
78
  max_turns: Optional[int] = MAX_TURNS_DEFAULT,
79
+ turns_wrapper: Optional[Callable[[List[str]], List[str]]] = None,
49
80
  ) -> str:
50
81
  """Summarizes the dialogue using the LLM.
51
82
 
@@ -53,11 +84,12 @@ async def summarize_conversation(
53
84
  tracker: the tracker to summarize
54
85
  llm: the LLM to use for summarization
55
86
  max_turns: maximum number of turns to summarize
87
+ turns_wrapper: optional function to wrap the turns
56
88
 
57
89
  Returns:
58
90
  The summary of the dialogue.
59
91
  """
60
- prompt = _create_summarization_prompt(tracker, max_turns)
92
+ prompt = _create_summarization_prompt(tracker, max_turns, turns_wrapper)
61
93
  try:
62
94
  llm_response = await llm.acompletion(prompt)
63
95
  summarization = llm_response.choices[0].strip()
@@ -66,6 +98,8 @@ async def summarize_conversation(
66
98
  )
67
99
  return summarization
68
100
  except Exception as e:
69
- transcript = tracker_as_readable_transcript(tracker, max_turns=max_turns)
101
+ transcript = tracker_as_readable_transcript(
102
+ tracker, max_turns=max_turns, turns_wrapper=turns_wrapper
103
+ )
70
104
  structlogger.error("summarization.error", error=e)
71
105
  return transcript