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
@@ -767,8 +767,8 @@ def extract_attrs_for_intentless_policy_generate_llm_answer(
767
767
  return extend_attributes_with_prompt_tokens_length(self, attributes, prompt)
768
768
 
769
769
 
770
- def extract_attrs_for_enterprise_search_generate_llm_answer(
771
- self: "EnterpriseSearchPolicy", llm: "BaseLLM", prompt: str
770
+ def extract_attrs_for_enterprise_search_invoke_llm(
771
+ self: "EnterpriseSearchPolicy", prompt: str
772
772
  ) -> Dict[str, Any]:
773
773
  from rasa.core.policies.enterprise_search_policy import (
774
774
  DEFAULT_EMBEDDINGS_CONFIG,
@@ -784,6 +784,14 @@ def extract_attrs_for_enterprise_search_generate_llm_answer(
784
784
  return extend_attributes_with_prompt_tokens_length(self, attributes, prompt)
785
785
 
786
786
 
787
+ def extract_attrs_for_enterprise_search_parse_llm_relevancy_check_response(
788
+ self: "EnterpriseSearchPolicy", llm_answer: str
789
+ ) -> Dict[str, Any]:
790
+ return {
791
+ "llm_answer": llm_answer,
792
+ }
793
+
794
+
787
795
  def extract_current_context_attribute(stack: DialogueStack) -> Dict[str, Any]:
788
796
  """Utility function to extract the current context from the dialogue stack."""
789
797
  current_context = stack.current_context()
@@ -44,6 +44,7 @@ from rasa.dialogue_understanding.generator import (
44
44
  CompactLLMCommandGenerator,
45
45
  LLMCommandGenerator,
46
46
  MultiStepLLMCommandGenerator,
47
+ SearchReadyLLMCommandGenerator,
47
48
  SingleStepLLMCommandGenerator,
48
49
  )
49
50
  from rasa.dialogue_understanding.generator.flow_retrieval import FlowRetrieval
@@ -66,9 +67,11 @@ from rasa.tracing.instrumentation.intentless_policy_instrumentation import (
66
67
  from rasa.tracing.instrumentation.metrics import (
67
68
  record_callable_duration_metrics,
68
69
  record_compact_llm_command_generator_metrics,
70
+ record_enterprise_search_policy_metrics,
69
71
  record_llm_command_generator_metrics,
70
72
  record_multi_step_llm_command_generator_metrics,
71
73
  record_request_size_in_bytes,
74
+ record_search_ready_llm_command_generator_metrics,
72
75
  record_single_step_llm_command_generator_metrics,
73
76
  )
74
77
  from rasa.utils.endpoints import EndpointConfig, concat_url
@@ -291,6 +294,9 @@ SingleStepLLMCommandGeneratorType = TypeVar(
291
294
  CompactLLMCommandGeneratorType = TypeVar(
292
295
  "CompactLLMCommandGeneratorType", bound=CompactLLMCommandGenerator
293
296
  )
297
+ SearchReadyLLMCommandGeneratorType = TypeVar(
298
+ "SearchReadyLLMCommandGeneratorType", bound=SearchReadyLLMCommandGenerator
299
+ )
294
300
  MultiStepLLMCommandGeneratorType = TypeVar(
295
301
  "MultiStepLLMCommandGeneratorType", bound=MultiStepLLMCommandGenerator
296
302
  )
@@ -326,6 +332,9 @@ def instrument(
326
332
  compact_llm_command_generator_class: Optional[
327
333
  Type[CompactLLMCommandGeneratorType]
328
334
  ] = None,
335
+ search_ready_llm_command_generator_class: Optional[
336
+ Type[SearchReadyLLMCommandGeneratorType]
337
+ ] = None,
329
338
  multi_step_llm_command_generator_class: Optional[
330
339
  Type[MultiStepLLMCommandGeneratorType]
331
340
  ] = None,
@@ -379,6 +388,9 @@ def instrument(
379
388
  :param compact_llm_command_generator_class: The `CompactLLMCommandGenerator`
380
389
  to be instrumented. If `None` is given, no `CompactLLMCommandGenerator` will
381
390
  be instrumented.
391
+ :param search_ready_llm_command_generator_class: The`SearchReadyLLMCommandGenerator`
392
+ to be instrumented. If `None` is given, no `SearchReadyLLMCommandGenerator` will
393
+ be instrumented.
382
394
  :param multi_step_llm_command_generator_class: The `MultiStepLLMCommandGenerator`
383
395
  to be instrumented. If `None` is given, no `MultiStepLLMCommandGenerator` will
384
396
  be instrumented.
@@ -527,6 +539,37 @@ def instrument(
527
539
  )
528
540
  mark_class_as_instrumented(compact_llm_command_generator_class)
529
541
 
542
+ if (
543
+ search_ready_llm_command_generator_class is not None
544
+ and not class_is_instrumented(search_ready_llm_command_generator_class)
545
+ ):
546
+ _instrument_method(
547
+ tracer_provider.get_tracer(
548
+ search_ready_llm_command_generator_class.__module__
549
+ ),
550
+ search_ready_llm_command_generator_class,
551
+ "invoke_llm",
552
+ attribute_extractors.extract_attrs_for_llm_based_command_generator,
553
+ metrics_recorder=record_search_ready_llm_command_generator_metrics,
554
+ )
555
+ _instrument_method(
556
+ tracer_provider.get_tracer(
557
+ search_ready_llm_command_generator_class.__module__
558
+ ),
559
+ search_ready_llm_command_generator_class,
560
+ "_check_commands_against_startable_flows",
561
+ attribute_extractors.extract_attrs_for_check_commands_against_startable_flows,
562
+ )
563
+ _instrument_perform_health_check_method_for_component(
564
+ tracer_provider.get_tracer(
565
+ search_ready_llm_command_generator_class.__module__
566
+ ),
567
+ search_ready_llm_command_generator_class,
568
+ "perform_llm_health_check",
569
+ attribute_extractors.extract_attrs_for_performing_health_check,
570
+ )
571
+ mark_class_as_instrumented(search_ready_llm_command_generator_class)
572
+
530
573
  if multi_step_llm_command_generator_class is not None and not class_is_instrumented(
531
574
  multi_step_llm_command_generator_class
532
575
  ):
@@ -562,6 +605,7 @@ def instrument(
562
605
  llm_command_generator_class,
563
606
  single_step_llm_command_generator_class,
564
607
  compact_llm_command_generator_class,
608
+ search_ready_llm_command_generator_class,
565
609
  multi_step_llm_command_generator_class,
566
610
  )
567
611
  )
@@ -847,8 +891,15 @@ def _instrument_enterprise_search_policy(
847
891
  _instrument_method(
848
892
  tracer,
849
893
  policy_class,
850
- "_generate_llm_answer",
851
- attribute_extractors.extract_attrs_for_enterprise_search_generate_llm_answer,
894
+ "_invoke_llm",
895
+ attribute_extractors.extract_attrs_for_enterprise_search_invoke_llm,
896
+ metrics_recorder=record_enterprise_search_policy_metrics,
897
+ )
898
+ _instrument_method(
899
+ tracer,
900
+ policy_class,
901
+ "_parse_llm_relevancy_check_response",
902
+ attribute_extractors.extract_attrs_for_enterprise_search_parse_llm_relevancy_check_response,
852
903
  )
853
904
  _instrument_perform_health_check_method_for_component(
854
905
  tracer_provider.get_tracer(policy_class.__module__),
@@ -9,6 +9,7 @@ from rasa.dialogue_understanding.generator import (
9
9
  CompactLLMCommandGenerator,
10
10
  LLMCommandGenerator,
11
11
  MultiStepLLMCommandGenerator,
12
+ SearchReadyLLMCommandGenerator,
12
13
  SingleStepLLMCommandGenerator,
13
14
  )
14
15
  from rasa.tracing.constants import (
@@ -17,7 +18,10 @@ from rasa.tracing.constants import (
17
18
  COMPACT_LLM_COMMAND_GENERATOR_MEMORY_USAGE_METRIC_NAME,
18
19
  COMPACT_LLM_COMMAND_GENERATOR_PROMPT_TOKEN_USAGE_METRIC_NAME,
19
20
  CONTEXTUAL_RESPONSE_REPHRASER_LLM_RESPONSE_DURATION_METRIC_NAME,
21
+ ENTERPRISE_SEARCH_POLICY_CPU_USAGE_METRIC_NAME,
20
22
  ENTERPRISE_SEARCH_POLICY_LLM_RESPONSE_DURATION_METRIC_NAME,
23
+ ENTERPRISE_SEARCH_POLICY_MEMORY_USAGE_METRIC_NAME,
24
+ ENTERPRISE_SEARCH_POLICY_PROMPT_TOKEN_USAGE_METRIC_NAME,
21
25
  INTENTLESS_POLICY_LLM_RESPONSE_DURATION_METRIC_NAME,
22
26
  LLM_COMMAND_GENERATOR_CPU_USAGE_METRIC_NAME,
23
27
  LLM_COMMAND_GENERATOR_LLM_RESPONSE_DURATION_METRIC_NAME,
@@ -31,6 +35,10 @@ from rasa.tracing.constants import (
31
35
  RASA_CLIENT_REQUEST_BODY_SIZE_METRIC_NAME,
32
36
  RASA_CLIENT_REQUEST_DURATION_METRIC_NAME,
33
37
  REQUEST_BODY_SIZE_IN_BYTES_ATTRIBUTE_NAME,
38
+ SEARCH_READY_LLM_COMMAND_GENERATOR_CPU_USAGE_METRIC_NAME,
39
+ SEARCH_READY_LLM_COMMAND_GENERATOR_LLM_RESPONSE_DURATION_METRIC_NAME,
40
+ SEARCH_READY_LLM_COMMAND_GENERATOR_MEMORY_USAGE_METRIC_NAME,
41
+ SEARCH_READY_LLM_COMMAND_GENERATOR_PROMPT_TOKEN_USAGE_METRIC_NAME,
34
42
  SINGLE_STEP_LLM_COMMAND_GENERATOR_CPU_USAGE_METRIC_NAME,
35
43
  SINGLE_STEP_LLM_COMMAND_GENERATOR_LLM_RESPONSE_DURATION_METRIC_NAME,
36
44
  SINGLE_STEP_LLM_COMMAND_GENERATOR_MEMORY_USAGE_METRIC_NAME,
@@ -40,7 +48,7 @@ from rasa.tracing.metric_instrument_provider import MetricInstrumentProvider
40
48
  from rasa.utils.endpoints import EndpointConfig
41
49
 
42
50
 
43
- def record_llm_based_command_generator_cpu_usage(
51
+ def record_llm_based_component_cpu_usage(
44
52
  metric_instrument_provider: MetricInstrumentProvider,
45
53
  metric_name: str,
46
54
  ) -> None:
@@ -60,8 +68,10 @@ def record_llm_based_command_generator_cpu_usage(
60
68
  cpu_usage = psutil.cpu_percent()
61
69
  metric_instrument.record(amount=cpu_usage)
62
70
 
71
+ return None
63
72
 
64
- def record_llm_based_command_generator_memory_usage(
73
+
74
+ def record_llm_based_component_memory_usage(
65
75
  metric_instrument_provider: MetricInstrumentProvider,
66
76
  metric_name: str,
67
77
  ) -> None:
@@ -81,8 +91,10 @@ def record_llm_based_command_generator_memory_usage(
81
91
  memory_usage = psutil.virtual_memory().percent
82
92
  metric_instrument.record(amount=memory_usage)
83
93
 
94
+ return None
95
+
84
96
 
85
- def record_llm_based_command_generator_prompt_token(
97
+ def record_llm_based_component_prompt_token(
86
98
  metric_instrument_provider: MetricInstrumentProvider,
87
99
  attributes: Dict[str, Any],
88
100
  metric_name: str,
@@ -116,6 +128,8 @@ def record_llm_based_command_generator_prompt_token(
116
128
  amount=prompt_tokens_len,
117
129
  )
118
130
 
131
+ return None
132
+
119
133
 
120
134
  def record_llm_command_generator_metrics(attributes: Dict[str, Any]) -> None:
121
135
  """
@@ -132,17 +146,18 @@ def record_llm_command_generator_metrics(attributes: Dict[str, Any]) -> None:
132
146
  if not instrument_provider.instruments:
133
147
  return None
134
148
 
135
- record_llm_based_command_generator_cpu_usage(
149
+ record_llm_based_component_cpu_usage(
136
150
  instrument_provider, LLM_COMMAND_GENERATOR_CPU_USAGE_METRIC_NAME
137
151
  )
138
- record_llm_based_command_generator_memory_usage(
152
+ record_llm_based_component_memory_usage(
139
153
  instrument_provider, LLM_COMMAND_GENERATOR_MEMORY_USAGE_METRIC_NAME
140
154
  )
141
- record_llm_based_command_generator_prompt_token(
155
+ record_llm_based_component_prompt_token(
142
156
  instrument_provider,
143
157
  attributes,
144
158
  LLM_COMMAND_GENERATOR_PROMPT_TOKEN_USAGE_METRIC_NAME,
145
159
  )
160
+ return None
146
161
 
147
162
 
148
163
  def record_single_step_llm_command_generator_metrics(
@@ -162,17 +177,18 @@ def record_single_step_llm_command_generator_metrics(
162
177
  if not instrument_provider.instruments:
163
178
  return None
164
179
 
165
- record_llm_based_command_generator_cpu_usage(
180
+ record_llm_based_component_cpu_usage(
166
181
  instrument_provider, SINGLE_STEP_LLM_COMMAND_GENERATOR_CPU_USAGE_METRIC_NAME
167
182
  )
168
- record_llm_based_command_generator_memory_usage(
183
+ record_llm_based_component_memory_usage(
169
184
  instrument_provider, SINGLE_STEP_LLM_COMMAND_GENERATOR_MEMORY_USAGE_METRIC_NAME
170
185
  )
171
- record_llm_based_command_generator_prompt_token(
186
+ record_llm_based_component_prompt_token(
172
187
  instrument_provider,
173
188
  attributes,
174
189
  SINGLE_STEP_LLM_COMMAND_GENERATOR_PROMPT_TOKEN_USAGE_METRIC_NAME,
175
190
  )
191
+ return None
176
192
 
177
193
 
178
194
  def record_compact_llm_command_generator_metrics(
@@ -192,17 +208,49 @@ def record_compact_llm_command_generator_metrics(
192
208
  if not instrument_provider.instruments:
193
209
  return None
194
210
 
195
- record_llm_based_command_generator_cpu_usage(
211
+ record_llm_based_component_cpu_usage(
196
212
  instrument_provider, COMPACT_LLM_COMMAND_GENERATOR_CPU_USAGE_METRIC_NAME
197
213
  )
198
- record_llm_based_command_generator_memory_usage(
214
+ record_llm_based_component_memory_usage(
199
215
  instrument_provider, COMPACT_LLM_COMMAND_GENERATOR_MEMORY_USAGE_METRIC_NAME
200
216
  )
201
- record_llm_based_command_generator_prompt_token(
217
+ record_llm_based_component_prompt_token(
202
218
  instrument_provider,
203
219
  attributes,
204
220
  COMPACT_LLM_COMMAND_GENERATOR_PROMPT_TOKEN_USAGE_METRIC_NAME,
205
221
  )
222
+ return None
223
+
224
+
225
+ def record_search_ready_llm_command_generator_metrics(
226
+ attributes: Dict[str, Any],
227
+ ) -> None:
228
+ """
229
+ Record measurements for SearchReadyLLMCommandGenerator specific metrics.
230
+
231
+ The recording is done by the opentelemetry.metrics.Histogram instruments.
232
+ These instruments are registered to the MetricInstrumentProvider internal singleton.
233
+
234
+ :param attributes: Extracted tracing attributes
235
+ :return: None
236
+ """
237
+ instrument_provider = MetricInstrumentProvider()
238
+
239
+ if not instrument_provider.instruments:
240
+ return None
241
+
242
+ record_llm_based_component_cpu_usage(
243
+ instrument_provider, SEARCH_READY_LLM_COMMAND_GENERATOR_CPU_USAGE_METRIC_NAME
244
+ )
245
+ record_llm_based_component_memory_usage(
246
+ instrument_provider, SEARCH_READY_LLM_COMMAND_GENERATOR_MEMORY_USAGE_METRIC_NAME
247
+ )
248
+ record_llm_based_component_prompt_token(
249
+ instrument_provider,
250
+ attributes,
251
+ SEARCH_READY_LLM_COMMAND_GENERATOR_PROMPT_TOKEN_USAGE_METRIC_NAME,
252
+ )
253
+ return None
206
254
 
207
255
 
208
256
  def record_multi_step_llm_command_generator_metrics(attributes: Dict[str, Any]) -> None:
@@ -220,17 +268,47 @@ def record_multi_step_llm_command_generator_metrics(attributes: Dict[str, Any])
220
268
  if not instrument_provider.instruments:
221
269
  return None
222
270
 
223
- record_llm_based_command_generator_cpu_usage(
271
+ record_llm_based_component_cpu_usage(
224
272
  instrument_provider, MULTI_STEP_LLM_COMMAND_GENERATOR_CPU_USAGE_METRIC_NAME
225
273
  )
226
- record_llm_based_command_generator_memory_usage(
274
+ record_llm_based_component_memory_usage(
227
275
  instrument_provider, MULTI_STEP_LLM_COMMAND_GENERATOR_MEMORY_USAGE_METRIC_NAME
228
276
  )
229
- record_llm_based_command_generator_prompt_token(
277
+ record_llm_based_component_prompt_token(
230
278
  instrument_provider,
231
279
  attributes,
232
280
  MULTI_STEP_LLM_COMMAND_GENERATOR_PROMPT_TOKEN_USAGE_METRIC_NAME,
233
281
  )
282
+ return None
283
+
284
+
285
+ def record_enterprise_search_policy_metrics(attributes: Dict[str, Any]) -> None:
286
+ """
287
+ Record measurements for EnterpriseSearchPolicy specific metrics.
288
+
289
+ The recording is done by the opentelemetry.metrics.Histogram instruments.
290
+ These instruments are registered to the MetricInstrumentProvider internal singleton.
291
+
292
+ :param attributes: Extracted tracing attributes
293
+ :return: None
294
+ """
295
+ instrument_provider = MetricInstrumentProvider()
296
+
297
+ if not instrument_provider.instruments:
298
+ return None
299
+
300
+ record_llm_based_component_cpu_usage(
301
+ instrument_provider, ENTERPRISE_SEARCH_POLICY_CPU_USAGE_METRIC_NAME
302
+ )
303
+ record_llm_based_component_memory_usage(
304
+ instrument_provider, ENTERPRISE_SEARCH_POLICY_MEMORY_USAGE_METRIC_NAME
305
+ )
306
+ record_llm_based_component_prompt_token(
307
+ instrument_provider,
308
+ attributes,
309
+ ENTERPRISE_SEARCH_POLICY_PROMPT_TOKEN_USAGE_METRIC_NAME,
310
+ )
311
+ return None
234
312
 
235
313
 
236
314
  def record_callable_duration_metrics(
@@ -276,6 +354,11 @@ def record_callable_duration_metrics(
276
354
  COMPACT_LLM_COMMAND_GENERATOR_LLM_RESPONSE_DURATION_METRIC_NAME
277
355
  )
278
356
 
357
+ if type(self) == SearchReadyLLMCommandGenerator:
358
+ metric_instrument = instrument_provider.get_instrument(
359
+ SEARCH_READY_LLM_COMMAND_GENERATOR_LLM_RESPONSE_DURATION_METRIC_NAME
360
+ )
361
+
279
362
  if type(self) == MultiStepLLMCommandGenerator:
280
363
  metric_instrument = instrument_provider.get_instrument(
281
364
  MULTI_STEP_LLM_COMMAND_GENERATOR_LLM_RESPONSE_DURATION_METRIC_NAME
@@ -10,7 +10,10 @@ from rasa.tracing.constants import (
10
10
  COMPACT_LLM_COMMAND_GENERATOR_PROMPT_TOKEN_USAGE_METRIC_NAME,
11
11
  CONTEXTUAL_RESPONSE_REPHRASER_LLM_RESPONSE_DURATION_METRIC_NAME,
12
12
  DURATION_UNIT_NAME,
13
+ ENTERPRISE_SEARCH_POLICY_CPU_USAGE_METRIC_NAME,
13
14
  ENTERPRISE_SEARCH_POLICY_LLM_RESPONSE_DURATION_METRIC_NAME,
15
+ ENTERPRISE_SEARCH_POLICY_MEMORY_USAGE_METRIC_NAME,
16
+ ENTERPRISE_SEARCH_POLICY_PROMPT_TOKEN_USAGE_METRIC_NAME,
14
17
  INTENTLESS_POLICY_LLM_RESPONSE_DURATION_METRIC_NAME,
15
18
  LLM_BASED_COMMAND_GENERATOR_CPU_MEMORY_USAGE_UNIT_NAME,
16
19
  LLM_COMMAND_GENERATOR_CPU_USAGE_METRIC_NAME,
@@ -23,6 +26,10 @@ from rasa.tracing.constants import (
23
26
  MULTI_STEP_LLM_COMMAND_GENERATOR_PROMPT_TOKEN_USAGE_METRIC_NAME,
24
27
  RASA_CLIENT_REQUEST_BODY_SIZE_METRIC_NAME,
25
28
  RASA_CLIENT_REQUEST_DURATION_METRIC_NAME,
29
+ SEARCH_READY_LLM_COMMAND_GENERATOR_CPU_USAGE_METRIC_NAME,
30
+ SEARCH_READY_LLM_COMMAND_GENERATOR_LLM_RESPONSE_DURATION_METRIC_NAME,
31
+ SEARCH_READY_LLM_COMMAND_GENERATOR_MEMORY_USAGE_METRIC_NAME,
32
+ SEARCH_READY_LLM_COMMAND_GENERATOR_PROMPT_TOKEN_USAGE_METRIC_NAME,
26
33
  SINGLE_STEP_LLM_COMMAND_GENERATOR_CPU_USAGE_METRIC_NAME,
27
34
  SINGLE_STEP_LLM_COMMAND_GENERATOR_LLM_RESPONSE_DURATION_METRIC_NAME,
28
35
  SINGLE_STEP_LLM_COMMAND_GENERATOR_MEMORY_USAGE_METRIC_NAME,
@@ -48,7 +55,9 @@ class MetricInstrumentProvider(metaclass=Singleton):
48
55
  **self._create_llm_command_generator_instruments(meter),
49
56
  **self._create_single_step_llm_command_generator_instruments(meter),
50
57
  **self._create_compact_llm_command_generator_instruments(meter),
58
+ **self._create_search_ready_llm_command_generator_instruments(meter),
51
59
  **self._create_multi_step_llm_command_generator_instruments(meter),
60
+ **self._create_enterprise_search_policy_instruments(meter),
52
61
  **self._create_llm_response_duration_instruments(meter),
53
62
  **self._create_client_request_instruments(meter),
54
63
  }
@@ -162,6 +171,41 @@ class MetricInstrumentProvider(metaclass=Singleton):
162
171
  COMPACT_LLM_COMMAND_GENERATOR_LLM_RESPONSE_DURATION_METRIC_NAME: compact_llm_response_duration_llm_command_generator, # noqa: E501
163
172
  }
164
173
 
174
+ @staticmethod
175
+ def _create_search_ready_llm_command_generator_instruments(
176
+ meter: Meter,
177
+ ) -> Dict[str, Any]:
178
+ search_ready_llm_command_generator_cpu_usage = meter.create_histogram(
179
+ name=SEARCH_READY_LLM_COMMAND_GENERATOR_CPU_USAGE_METRIC_NAME,
180
+ description="CPU percentage for SearchReadyLLMCommandGenerator",
181
+ unit=LLM_BASED_COMMAND_GENERATOR_CPU_MEMORY_USAGE_UNIT_NAME,
182
+ )
183
+
184
+ search_ready_llm_command_generator_memory_usage = meter.create_histogram(
185
+ name=SEARCH_READY_LLM_COMMAND_GENERATOR_MEMORY_USAGE_METRIC_NAME,
186
+ description="RAM memory usage for SearchReadyLLMCommandGenerator",
187
+ unit=LLM_BASED_COMMAND_GENERATOR_CPU_MEMORY_USAGE_UNIT_NAME,
188
+ )
189
+
190
+ search_ready_llm_command_generator_prompt_token_usage = meter.create_histogram(
191
+ name=SEARCH_READY_LLM_COMMAND_GENERATOR_PROMPT_TOKEN_USAGE_METRIC_NAME,
192
+ description="SearchReadyLLMCommandGenerator prompt token length",
193
+ unit="1",
194
+ )
195
+
196
+ search_ready_llm_response_duration_command_generator = meter.create_histogram(
197
+ name=SEARCH_READY_LLM_COMMAND_GENERATOR_LLM_RESPONSE_DURATION_METRIC_NAME,
198
+ description="The duration of SearchReadyLLMCommandGenerator's LLM call",
199
+ unit=DURATION_UNIT_NAME,
200
+ )
201
+
202
+ return {
203
+ SEARCH_READY_LLM_COMMAND_GENERATOR_CPU_USAGE_METRIC_NAME: search_ready_llm_command_generator_cpu_usage, # noqa: E501
204
+ SEARCH_READY_LLM_COMMAND_GENERATOR_MEMORY_USAGE_METRIC_NAME: search_ready_llm_command_generator_memory_usage, # noqa: E501
205
+ SEARCH_READY_LLM_COMMAND_GENERATOR_PROMPT_TOKEN_USAGE_METRIC_NAME: search_ready_llm_command_generator_prompt_token_usage, # noqa: E501
206
+ SEARCH_READY_LLM_COMMAND_GENERATOR_LLM_RESPONSE_DURATION_METRIC_NAME: search_ready_llm_response_duration_command_generator, # noqa: E501
207
+ }
208
+
165
209
  @staticmethod
166
210
  def _create_multi_step_llm_command_generator_instruments(
167
211
  meter: Meter,
@@ -198,13 +242,42 @@ class MetricInstrumentProvider(metaclass=Singleton):
198
242
  }
199
243
 
200
244
  @staticmethod
201
- def _create_llm_response_duration_instruments(meter: Meter) -> Dict[str, Any]:
202
- llm_response_duration_enterprise_search = meter.create_histogram(
245
+ def _create_enterprise_search_policy_instruments(
246
+ meter: Meter,
247
+ ) -> Dict[str, Any]:
248
+ enterprise_search_policy_cpu_usage = meter.create_histogram(
249
+ name=ENTERPRISE_SEARCH_POLICY_CPU_USAGE_METRIC_NAME,
250
+ description="CPU percentage for EnterpriseSearchPolicy",
251
+ unit=LLM_BASED_COMMAND_GENERATOR_CPU_MEMORY_USAGE_UNIT_NAME,
252
+ )
253
+
254
+ enterprise_search_policy_memory_usage = meter.create_histogram(
255
+ name=ENTERPRISE_SEARCH_POLICY_MEMORY_USAGE_METRIC_NAME,
256
+ description="RAM memory usage for EnterpriseSearchPolicy",
257
+ unit=LLM_BASED_COMMAND_GENERATOR_CPU_MEMORY_USAGE_UNIT_NAME,
258
+ )
259
+
260
+ enterprise_search_policy_prompt_token_usage = meter.create_histogram(
261
+ name=ENTERPRISE_SEARCH_POLICY_PROMPT_TOKEN_USAGE_METRIC_NAME,
262
+ description="EnterpriseSearchPolicy prompt token length",
263
+ unit="1",
264
+ )
265
+
266
+ enterprise_search_policy_llm_response_duration = meter.create_histogram(
203
267
  name=ENTERPRISE_SEARCH_POLICY_LLM_RESPONSE_DURATION_METRIC_NAME,
204
268
  description="The duration of EnterpriseSearchPolicy's LLM call",
205
269
  unit=DURATION_UNIT_NAME,
206
270
  )
207
271
 
272
+ return {
273
+ ENTERPRISE_SEARCH_POLICY_CPU_USAGE_METRIC_NAME: enterprise_search_policy_cpu_usage, # noqa: E501
274
+ ENTERPRISE_SEARCH_POLICY_MEMORY_USAGE_METRIC_NAME: enterprise_search_policy_memory_usage, # noqa: E501
275
+ ENTERPRISE_SEARCH_POLICY_PROMPT_TOKEN_USAGE_METRIC_NAME: enterprise_search_policy_prompt_token_usage, # noqa: E501
276
+ ENTERPRISE_SEARCH_POLICY_LLM_RESPONSE_DURATION_METRIC_NAME: enterprise_search_policy_llm_response_duration, # noqa: E501
277
+ }
278
+
279
+ @staticmethod
280
+ def _create_llm_response_duration_instruments(meter: Meter) -> Dict[str, Any]:
208
281
  llm_response_duration_intentless = meter.create_histogram(
209
282
  name=INTENTLESS_POLICY_LLM_RESPONSE_DURATION_METRIC_NAME,
210
283
  description="The duration of IntentlessPolicy's LLM call",
@@ -218,7 +291,6 @@ class MetricInstrumentProvider(metaclass=Singleton):
218
291
  )
219
292
 
220
293
  return {
221
- ENTERPRISE_SEARCH_POLICY_LLM_RESPONSE_DURATION_METRIC_NAME: llm_response_duration_enterprise_search, # noqa: E501
222
294
  INTENTLESS_POLICY_LLM_RESPONSE_DURATION_METRIC_NAME: llm_response_duration_intentless, # noqa: E501
223
295
  CONTEXTUAL_RESPONSE_REPHRASER_LLM_RESPONSE_DURATION_METRIC_NAME: llm_response_duration_contextual_nlg, # noqa: E501
224
296
  }
rasa/utils/common.py CHANGED
@@ -29,7 +29,6 @@ import numpy as np
29
29
 
30
30
  import rasa.shared.utils.io
31
31
  import rasa.utils.io
32
- from rasa.anonymization import ENV_LOG_LEVEL_FAKER, ENV_LOG_LEVEL_PRESIDIO
33
32
  from rasa.constants import (
34
33
  DEFAULT_LOG_LEVEL_LIBRARIES,
35
34
  ENV_LOG_LEVEL_KAFKA,
@@ -53,7 +52,7 @@ EXPECTED_WARNINGS: List[Tuple[Type[Warning], str]] = [
53
52
  np.VisibleDeprecationWarning,
54
53
  "Creating an ndarray from ragged nested sequences.*",
55
54
  ),
56
- # raised by pycountry (rasa-plus anonymization), magic_filter, google rpc
55
+ # raised by magic_filter, google rpc
57
56
  # and probably other dependencies that use pkg_resources instead of importlib
58
57
  (DeprecationWarning, ".*pkg_resources.*"),
59
58
  # This warning is triggered by sanic-cors 2.0.0 and by langchain -> faiss.
@@ -281,8 +280,6 @@ def configure_library_logging() -> None:
281
280
  update_matplotlib_log_level(library_log_level)
282
281
  update_kafka_log_level(library_log_level)
283
282
  update_rabbitmq_log_level(library_log_level)
284
- update_presidio_log_level(library_log_level)
285
- update_faker_log_level(library_log_level)
286
283
 
287
284
 
288
285
  def update_apscheduler_log_level() -> None:
@@ -407,29 +404,6 @@ def update_rabbitmq_log_level(library_log_level: Text) -> None:
407
404
  logging.getLogger("aiormq").setLevel(log_level)
408
405
 
409
406
 
410
- def update_presidio_log_level(library_log_level: Text) -> None:
411
- """Set the log level of presidio.
412
-
413
- Uses the library specific log level or the general libraries log level.
414
- """
415
- log_level = os.environ.get(ENV_LOG_LEVEL_PRESIDIO, library_log_level)
416
- presidio_loggers = ["presidio_analyzer", "presidio_anonymizer"]
417
-
418
- for logger_name in presidio_loggers:
419
- logging.getLogger(logger_name).setLevel(log_level)
420
- logging.getLogger(logger_name).propagate = False
421
-
422
-
423
- def update_faker_log_level(library_log_level: Text) -> None:
424
- """Set the log level of faker.
425
-
426
- Uses the library specific log level or the general libraries log level.
427
- """
428
- log_level = os.environ.get(ENV_LOG_LEVEL_FAKER, library_log_level)
429
- logging.getLogger("faker").setLevel(log_level)
430
- logging.getLogger("faker").propagate = False
431
-
432
-
433
407
  def sort_list_of_dicts_by_first_key(dicts: List[Dict]) -> List[Dict]:
434
408
  """Sorts a list of dictionaries by their first key."""
435
409
  return sorted(dicts, key=lambda d: next(iter(d.keys())))
rasa/utils/log_utils.py CHANGED
@@ -3,14 +3,13 @@ from __future__ import annotations
3
3
  import logging
4
4
  import os
5
5
  import sys
6
- from typing import Any, Dict, Optional
6
+ from typing import Any, Optional
7
7
 
8
8
  import structlog
9
9
  from structlog.dev import ConsoleRenderer
10
10
  from structlog.typing import EventDict, WrappedLogger
11
11
  from structlog_sentry import SentryProcessor
12
12
 
13
- from rasa.plugin import plugin_manager
14
13
  from rasa.shared.constants import (
15
14
  DEFAULT_LOG_LEVEL,
16
15
  DEFAULT_LOG_LEVEL_LLM,
@@ -35,48 +34,6 @@ class HumanConsoleRenderer(ConsoleRenderer):
35
34
  return super().__call__(logger, name, event_dict)
36
35
 
37
36
 
38
- def _anonymizer(
39
- _: structlog.BoundLogger, __: str, event_dict: Dict[str, Any]
40
- ) -> Dict[str, Any]:
41
- """Anonymizes event dict."""
42
- anonymizable_keys = [
43
- "text",
44
- "response_text",
45
- "user_text",
46
- "slots",
47
- "parse_data_text",
48
- "parse_data_entities",
49
- "prediction_events",
50
- "tracker_latest_message",
51
- "prefilled_slots",
52
- "message",
53
- "response",
54
- "slot_candidates",
55
- "rasa_event",
56
- "rasa_events",
57
- "tracker_states",
58
- "current_states",
59
- "old_states",
60
- "current_states",
61
- "successes",
62
- "current_entity",
63
- "next_entity",
64
- "states",
65
- "entity",
66
- "token_text",
67
- "user_message",
68
- "json_message",
69
- ]
70
- anonymization_pipeline = plugin_manager().hook.get_anonymization_pipeline()
71
-
72
- if anonymization_pipeline:
73
- for key in anonymizable_keys:
74
- if key in event_dict:
75
- anonymized_value = anonymization_pipeline.log_run(event_dict[key])
76
- event_dict[key] = anonymized_value
77
- return event_dict
78
-
79
-
80
37
  def configure_structlog(
81
38
  log_level: Optional[int] = None,
82
39
  include_time: bool = False,
@@ -95,7 +52,6 @@ def configure_structlog(
95
52
  )
96
53
 
97
54
  shared_processors = [
98
- _anonymizer,
99
55
  # Processors that have nothing to do with output,
100
56
  # e.g., add timestamps or log level names.
101
57
  # If log level is too low, abort pipeline and throw away log entry.
rasa/validator.py CHANGED
@@ -1014,11 +1014,6 @@ class Validator:
1014
1014
  for sv in slot_value
1015
1015
  ]
1016
1016
  if not all(slot_values_validity):
1017
- invalid_slot_values = [
1018
- sv
1019
- for (sv, slot_value_valid) in zip(slot_value, slot_values_validity)
1020
- if not slot_value_valid
1021
- ]
1022
1017
  structlogger.error(
1023
1018
  "validator.verify_predicates.link.invalid_condition",
1024
1019
  step=step_id,
@@ -1027,8 +1022,7 @@ class Validator:
1027
1022
  event_info=(
1028
1023
  f"Detected invalid condition '{link_condition}' "
1029
1024
  f"at step '{step_id}' for flow id '{flow_id}'. "
1030
- f"Values {invalid_slot_values} are not valid values "
1031
- f"for slot {slot_name}. "
1025
+ f"The condition contains invalid values for slot {slot_name}. "
1032
1026
  f"Please make sure that all conditions are valid."
1033
1027
  ),
1034
1028
  )
@@ -1998,7 +1992,7 @@ class Validator:
1998
1992
  "validator.validate_conditional_response_variation_predicates.invalid_slot",
1999
1993
  utter=utter_name,
2000
1994
  event_info=(
2001
- f"Detected invalid slot '{slot_namespace[1]}' in "
1995
+ f"Detected invalid slot '{slot_namespace[0]}' in "
2002
1996
  f"condition '{condition}' for response variation "
2003
1997
  f"'{utter_name}'. Please make sure that all slots "
2004
1998
  f"are specified in the domain file."
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.13.0.dev20250612"
3
+ __version__ = "3.13.0.dev20250613"