rasa-pro 3.13.0.dev20250612__py3-none-any.whl → 3.13.0rc1__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 (252) 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 -8
  5. rasa/cli/evaluate.py +1 -1
  6. rasa/cli/export.py +3 -1
  7. rasa/cli/llm_fine_tuning.py +12 -11
  8. rasa/cli/project_templates/defaults.py +133 -0
  9. rasa/cli/project_templates/tutorial/config.yml +1 -1
  10. rasa/cli/project_templates/tutorial/endpoints.yml +1 -1
  11. rasa/cli/run.py +1 -1
  12. rasa/cli/studio/download.py +1 -23
  13. rasa/cli/studio/link.py +52 -0
  14. rasa/cli/studio/pull.py +79 -0
  15. rasa/cli/studio/push.py +78 -0
  16. rasa/cli/studio/studio.py +12 -0
  17. rasa/cli/studio/train.py +0 -1
  18. rasa/cli/studio/upload.py +8 -0
  19. rasa/cli/train.py +1 -1
  20. rasa/cli/utils.py +1 -1
  21. rasa/cli/x.py +1 -1
  22. rasa/constants.py +2 -0
  23. rasa/core/__init__.py +0 -16
  24. rasa/core/actions/action.py +5 -1
  25. rasa/core/actions/action_repeat_bot_messages.py +18 -22
  26. rasa/core/actions/action_run_slot_rejections.py +0 -1
  27. rasa/core/agent.py +16 -1
  28. rasa/core/available_endpoints.py +146 -0
  29. rasa/core/brokers/pika.py +1 -2
  30. rasa/core/channels/__init__.py +2 -0
  31. rasa/core/channels/botframework.py +2 -2
  32. rasa/core/channels/channel.py +2 -2
  33. rasa/core/channels/development_inspector.py +1 -1
  34. rasa/core/channels/facebook.py +1 -4
  35. rasa/core/channels/hangouts.py +8 -5
  36. rasa/core/channels/inspector/README.md +3 -3
  37. rasa/core/channels/inspector/dist/assets/{arc-c4b064fc.js → arc-371401b1.js} +1 -1
  38. rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-215b5026.js → blockDiagram-38ab4fdb-3f126156.js} +1 -1
  39. rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-2b54a0a3.js → c4Diagram-3d4e48cf-12f22eb7.js} +1 -1
  40. rasa/core/channels/inspector/dist/assets/channel-f1efda17.js +1 -0
  41. rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-daacea5f.js → classDiagram-70f12bd4-03b1d386.js} +1 -1
  42. rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-930d4dc2.js → classDiagram-v2-f2320105-84f69d63.js} +1 -1
  43. rasa/core/channels/inspector/dist/assets/clone-fdf164e2.js +1 -0
  44. rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-83c206ba.js → createText-2e5e7dd3-ca47fd38.js} +1 -1
  45. rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-b0eb01d0.js → edges-e0da2a9e-f837ca8a.js} +1 -1
  46. rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-17586500.js → erDiagram-9861fffd-8717ac54.js} +1 -1
  47. rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-be2a1776.js → flowDb-956e92f1-94f38b83.js} +1 -1
  48. rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-c2120ebd.js → flowDiagram-66a62f08-b616f9fb.js} +1 -1
  49. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-7d7a1629.js +1 -0
  50. rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-a6ab5c48.js → flowchart-elk-definition-4a651766-f5d24bb8.js} +1 -1
  51. rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-ef613457.js → ganttDiagram-c361ad54-b43ba8d9.js} +1 -1
  52. rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-d59185b3.js → gitGraphDiagram-72cf32ee-c3aafaa5.js} +1 -1
  53. rasa/core/channels/inspector/dist/assets/{graph-0f155405.js → graph-0d0a2c10.js} +1 -1
  54. rasa/core/channels/inspector/dist/assets/{index-3862675e-d5f1d1b7.js → index-3862675e-58ea0305.js} +1 -1
  55. rasa/core/channels/inspector/dist/assets/{index-47737d3a.js → index-cce6f8a1.js} +3 -3
  56. rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-b07d141f.js → infoDiagram-f8f76790-b8f60461.js} +1 -1
  57. rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-1936d429.js → journeyDiagram-49397b02-95be5545.js} +1 -1
  58. rasa/core/channels/inspector/dist/assets/{layout-dde8d0f3.js → layout-da885b9b.js} +1 -1
  59. rasa/core/channels/inspector/dist/assets/{line-0c2c7ee0.js → line-f1c817d3.js} +1 -1
  60. rasa/core/channels/inspector/dist/assets/{linear-35dd89a4.js → linear-d42801e6.js} +1 -1
  61. rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-56192851.js → mindmap-definition-fc14e90a-a38923a6.js} +1 -1
  62. rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-fc21ed78.js → pieDiagram-8a3498a8-ca6e71e9.js} +1 -1
  63. rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-25e98518.js → quadrantDiagram-120e2f19-b290dae9.js} +1 -1
  64. rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-546ff1f5.js → requirementDiagram-deff3bca-03f02ceb.js} +1 -1
  65. rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-02d8b82d.js → sankeyDiagram-04a897e0-c49eee40.js} +1 -1
  66. rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-3ca5a92e.js → sequenceDiagram-704730f1-b2cd6a3d.js} +1 -1
  67. rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-128ea07c.js → stateDiagram-587899a1-e53a2028.js} +1 -1
  68. rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-95f290af.js → stateDiagram-v2-d93cdb3a-e1982a03.js} +1 -1
  69. rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-4984898a.js → styles-6aaf32cf-d0226ca5.js} +1 -1
  70. rasa/core/channels/inspector/dist/assets/{styles-9a916d00-1bf266ba.js → styles-9a916d00-0e21dc00.js} +1 -1
  71. rasa/core/channels/inspector/dist/assets/{styles-c10674c1-60521c63.js → styles-c10674c1-9588494e.js} +1 -1
  72. rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-a25b6e12.js → svgDrawCommon-08f97a94-be478d4f.js} +1 -1
  73. rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-0fc086bf.js → timeline-definition-85554ec2-74631749.js} +1 -1
  74. rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-44ee592e.js → xychartDiagram-e933f94c-a043552f.js} +1 -1
  75. rasa/core/channels/inspector/dist/index.html +1 -1
  76. rasa/core/channels/inspector/src/components/RecruitmentPanel.tsx +1 -1
  77. rasa/core/channels/mattermost.py +1 -1
  78. rasa/core/channels/rasa_chat.py +2 -4
  79. rasa/core/channels/rest.py +5 -4
  80. rasa/core/channels/socketio.py +56 -41
  81. rasa/core/channels/studio_chat.py +314 -10
  82. rasa/core/channels/vier_cvg.py +1 -2
  83. rasa/core/channels/voice_ready/audiocodes.py +2 -9
  84. rasa/core/channels/voice_stream/asr/azure.py +9 -0
  85. rasa/core/channels/voice_stream/audiocodes.py +8 -5
  86. rasa/core/channels/voice_stream/browser_audio.py +1 -1
  87. rasa/core/channels/voice_stream/genesys.py +2 -2
  88. rasa/core/channels/voice_stream/jambonz.py +166 -0
  89. rasa/core/channels/voice_stream/tts/__init__.py +8 -0
  90. rasa/core/channels/voice_stream/twilio_media_streams.py +17 -5
  91. rasa/core/channels/voice_stream/voice_channel.py +44 -24
  92. rasa/core/exporter.py +36 -0
  93. rasa/core/http_interpreter.py +3 -7
  94. rasa/core/information_retrieval/faiss.py +18 -11
  95. rasa/core/information_retrieval/ingestion/faq_parser.py +158 -0
  96. rasa/core/jobs.py +2 -1
  97. rasa/core/nlg/contextual_response_rephraser.py +48 -12
  98. rasa/core/nlg/generator.py +0 -1
  99. rasa/core/nlg/interpolator.py +2 -3
  100. rasa/core/nlg/summarize.py +39 -5
  101. rasa/core/policies/enterprise_search_policy.py +298 -184
  102. rasa/core/policies/enterprise_search_policy_config.py +241 -0
  103. rasa/core/policies/enterprise_search_prompt_with_relevancy_check_and_citation_template.jinja2 +64 -0
  104. rasa/core/policies/flow_policy.py +1 -1
  105. rasa/core/policies/flows/flow_executor.py +96 -17
  106. rasa/core/policies/intentless_policy.py +71 -26
  107. rasa/core/processor.py +104 -51
  108. rasa/core/run.py +33 -11
  109. rasa/core/tracker_stores/tracker_store.py +1 -1
  110. rasa/core/training/interactive.py +1 -1
  111. rasa/core/utils.py +35 -99
  112. rasa/dialogue_understanding/coexistence/intent_based_router.py +2 -1
  113. rasa/dialogue_understanding/coexistence/llm_based_router.py +13 -17
  114. rasa/dialogue_understanding/commands/__init__.py +4 -0
  115. rasa/dialogue_understanding/commands/can_not_handle_command.py +2 -0
  116. rasa/dialogue_understanding/commands/cancel_flow_command.py +6 -2
  117. rasa/dialogue_understanding/commands/chit_chat_answer_command.py +2 -0
  118. rasa/dialogue_understanding/commands/clarify_command.py +7 -3
  119. rasa/dialogue_understanding/commands/command_syntax_manager.py +1 -0
  120. rasa/dialogue_understanding/commands/correct_slots_command.py +5 -6
  121. rasa/dialogue_understanding/commands/error_command.py +1 -1
  122. rasa/dialogue_understanding/commands/human_handoff_command.py +3 -3
  123. rasa/dialogue_understanding/commands/knowledge_answer_command.py +2 -0
  124. rasa/dialogue_understanding/commands/repeat_bot_messages_command.py +2 -0
  125. rasa/dialogue_understanding/commands/set_slot_command.py +15 -5
  126. rasa/dialogue_understanding/commands/skip_question_command.py +3 -3
  127. rasa/dialogue_understanding/commands/start_flow_command.py +7 -3
  128. rasa/dialogue_understanding/commands/utils.py +26 -2
  129. rasa/dialogue_understanding/generator/__init__.py +7 -1
  130. rasa/dialogue_understanding/generator/command_generator.py +15 -3
  131. rasa/dialogue_understanding/generator/command_parser.py +2 -2
  132. rasa/dialogue_understanding/generator/command_parser_validator.py +63 -0
  133. rasa/dialogue_understanding/generator/constants.py +2 -2
  134. rasa/dialogue_understanding/generator/nlu_command_adapter.py +2 -2
  135. rasa/dialogue_understanding/generator/prompt_templates/command_prompt_template.jinja2 +0 -2
  136. rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v2_claude_3_5_sonnet_20240620_template.jinja2 +1 -0
  137. rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v2_gpt_4o_2024_11_20_template.jinja2 +1 -0
  138. rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v3_claude_3_5_sonnet_20240620_template.jinja2 +79 -0
  139. rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v3_gpt_4o_2024_11_20_template.jinja2 +79 -0
  140. rasa/dialogue_understanding/generator/single_step/compact_llm_command_generator.py +28 -463
  141. rasa/dialogue_understanding/generator/single_step/search_ready_llm_command_generator.py +147 -0
  142. rasa/dialogue_understanding/generator/single_step/single_step_based_llm_command_generator.py +461 -0
  143. rasa/dialogue_understanding/generator/single_step/single_step_llm_command_generator.py +11 -64
  144. rasa/dialogue_understanding/patterns/cancel.py +1 -2
  145. rasa/dialogue_understanding/patterns/clarify.py +1 -1
  146. rasa/dialogue_understanding/patterns/correction.py +2 -2
  147. rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +37 -25
  148. rasa/dialogue_understanding/patterns/domain_for_patterns.py +190 -0
  149. rasa/dialogue_understanding/processor/command_processor.py +11 -12
  150. rasa/dialogue_understanding/processor/command_processor_component.py +3 -3
  151. rasa/dialogue_understanding/stack/frames/flow_stack_frame.py +17 -4
  152. rasa/dialogue_understanding/stack/utils.py +3 -1
  153. rasa/dialogue_understanding/utils.py +68 -12
  154. rasa/dialogue_understanding_test/du_test_case.py +1 -1
  155. rasa/dialogue_understanding_test/du_test_runner.py +4 -22
  156. rasa/dialogue_understanding_test/test_case_simulation/test_case_tracker_simulator.py +2 -6
  157. rasa/e2e_test/e2e_test_coverage_report.py +1 -1
  158. rasa/e2e_test/e2e_test_runner.py +1 -1
  159. rasa/engine/constants.py +1 -1
  160. rasa/engine/graph.py +2 -2
  161. rasa/engine/recipes/default_recipe.py +26 -2
  162. rasa/engine/validation.py +3 -2
  163. rasa/hooks.py +0 -28
  164. rasa/llm_fine_tuning/annotation_module.py +39 -9
  165. rasa/llm_fine_tuning/conversations.py +3 -0
  166. rasa/llm_fine_tuning/llm_data_preparation_module.py +66 -49
  167. rasa/llm_fine_tuning/paraphrasing/conversation_rephraser.py +5 -7
  168. rasa/llm_fine_tuning/paraphrasing/rephrase_validator.py +52 -44
  169. rasa/llm_fine_tuning/paraphrasing_module.py +10 -12
  170. rasa/llm_fine_tuning/storage.py +4 -4
  171. rasa/llm_fine_tuning/utils.py +63 -1
  172. rasa/model_manager/model_api.py +88 -0
  173. rasa/model_manager/trainer_service.py +4 -4
  174. rasa/plugin.py +1 -11
  175. rasa/privacy/__init__.py +0 -0
  176. rasa/privacy/constants.py +83 -0
  177. rasa/privacy/event_broker_utils.py +77 -0
  178. rasa/privacy/privacy_config.py +281 -0
  179. rasa/privacy/privacy_config_schema.json +86 -0
  180. rasa/privacy/privacy_filter.py +340 -0
  181. rasa/privacy/privacy_manager.py +576 -0
  182. rasa/server.py +23 -2
  183. rasa/shared/constants.py +18 -0
  184. rasa/shared/core/command_payload_reader.py +1 -5
  185. rasa/shared/core/constants.py +4 -3
  186. rasa/shared/core/domain.py +7 -0
  187. rasa/shared/core/events.py +38 -10
  188. rasa/shared/core/flows/constants.py +2 -0
  189. rasa/shared/core/flows/flow.py +127 -14
  190. rasa/shared/core/flows/flows_list.py +18 -1
  191. rasa/shared/core/flows/flows_yaml_schema.json +3 -0
  192. rasa/shared/core/flows/steps/collect.py +46 -2
  193. rasa/shared/core/flows/steps/link.py +7 -2
  194. rasa/shared/core/flows/validation.py +25 -5
  195. rasa/shared/core/slots.py +28 -0
  196. rasa/shared/core/training_data/story_reader/yaml_story_reader.py +1 -4
  197. rasa/shared/exceptions.py +4 -0
  198. rasa/shared/providers/_configs/azure_openai_client_config.py +6 -2
  199. rasa/shared/providers/_configs/default_litellm_client_config.py +1 -1
  200. rasa/shared/providers/_configs/huggingface_local_embedding_client_config.py +1 -1
  201. rasa/shared/providers/_configs/openai_client_config.py +5 -1
  202. rasa/shared/providers/_configs/rasa_llm_client_config.py +1 -1
  203. rasa/shared/providers/_configs/self_hosted_llm_client_config.py +1 -1
  204. rasa/shared/providers/_configs/utils.py +0 -99
  205. rasa/shared/providers/embedding/_base_litellm_embedding_client.py +3 -0
  206. rasa/shared/providers/llm/_base_litellm_client.py +5 -2
  207. rasa/shared/utils/common.py +1 -1
  208. rasa/shared/utils/configs.py +110 -0
  209. rasa/shared/utils/constants.py +0 -3
  210. rasa/shared/utils/llm.py +195 -9
  211. rasa/shared/utils/pykwalify_extensions.py +0 -9
  212. rasa/shared/utils/yaml.py +32 -0
  213. rasa/studio/constants.py +1 -0
  214. rasa/studio/data_handler.py +11 -4
  215. rasa/studio/download.py +167 -0
  216. rasa/studio/link.py +200 -0
  217. rasa/studio/prompts.py +223 -0
  218. rasa/studio/pull/__init__.py +0 -0
  219. rasa/studio/{download/flows.py → pull/data.py} +23 -160
  220. rasa/studio/{download → pull}/domains.py +1 -1
  221. rasa/studio/pull/pull.py +235 -0
  222. rasa/studio/push.py +136 -0
  223. rasa/studio/train.py +1 -1
  224. rasa/studio/upload.py +117 -67
  225. rasa/telemetry.py +82 -25
  226. rasa/tracing/config.py +3 -4
  227. rasa/tracing/constants.py +19 -1
  228. rasa/tracing/instrumentation/attribute_extractors.py +30 -8
  229. rasa/tracing/instrumentation/instrumentation.py +53 -2
  230. rasa/tracing/instrumentation/metrics.py +98 -15
  231. rasa/tracing/metric_instrument_provider.py +75 -3
  232. rasa/utils/common.py +7 -22
  233. rasa/utils/log_utils.py +1 -45
  234. rasa/validator.py +2 -8
  235. rasa/version.py +1 -1
  236. {rasa_pro-3.13.0.dev20250612.dist-info → rasa_pro-3.13.0rc1.dist-info}/METADATA +8 -9
  237. {rasa_pro-3.13.0.dev20250612.dist-info → rasa_pro-3.13.0rc1.dist-info}/RECORD +241 -220
  238. rasa/anonymization/__init__.py +0 -2
  239. rasa/anonymization/anonymisation_rule_yaml_reader.py +0 -91
  240. rasa/anonymization/anonymization_pipeline.py +0 -286
  241. rasa/anonymization/anonymization_rule_executor.py +0 -266
  242. rasa/anonymization/anonymization_rule_orchestrator.py +0 -119
  243. rasa/anonymization/schemas/config.yml +0 -47
  244. rasa/anonymization/utils.py +0 -118
  245. rasa/core/channels/inspector/dist/assets/channel-3730f5fd.js +0 -1
  246. rasa/core/channels/inspector/dist/assets/clone-e847561e.js +0 -1
  247. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-efbbfe00.js +0 -1
  248. rasa/studio/download/download.py +0 -439
  249. /rasa/{studio/download → core/information_retrieval/ingestion}/__init__.py +0 -0
  250. {rasa_pro-3.13.0.dev20250612.dist-info → rasa_pro-3.13.0rc1.dist-info}/NOTICE +0 -0
  251. {rasa_pro-3.13.0.dev20250612.dist-info → rasa_pro-3.13.0rc1.dist-info}/WHEEL +0 -0
  252. {rasa_pro-3.13.0.dev20250612.dist-info → rasa_pro-3.13.0rc1.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,241 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import asdict, dataclass
4
+ from typing import Any, Dict, List, Optional
5
+
6
+ import structlog
7
+
8
+ from rasa.core.constants import (
9
+ POLICY_MAX_HISTORY,
10
+ POLICY_PRIORITY,
11
+ SEARCH_POLICY_PRIORITY,
12
+ )
13
+ from rasa.shared.constants import (
14
+ EMBEDDINGS_CONFIG_KEY,
15
+ LLM_CONFIG_KEY,
16
+ MAX_COMPLETION_TOKENS_CONFIG_KEY,
17
+ MAX_RETRIES_CONFIG_KEY,
18
+ MODEL_CONFIG_KEY,
19
+ OPENAI_PROVIDER,
20
+ PROMPT_CONFIG_KEY,
21
+ PROMPT_TEMPLATE_CONFIG_KEY,
22
+ PROVIDER_CONFIG_KEY,
23
+ TEMPERATURE_CONFIG_KEY,
24
+ TIMEOUT_CONFIG_KEY,
25
+ )
26
+ from rasa.shared.utils.configs import (
27
+ raise_deprecation_warnings,
28
+ resolve_aliases,
29
+ validate_forbidden_keys,
30
+ validate_required_keys,
31
+ )
32
+ from rasa.shared.utils.llm import (
33
+ DEFAULT_ENTERPRISE_SEARCH_POLICY_MODEL_NAME,
34
+ DEFAULT_OPENAI_EMBEDDING_MODEL_NAME,
35
+ resolve_model_client_config,
36
+ )
37
+
38
+ structlogger = structlog.get_logger()
39
+
40
+
41
+ SOURCE_PROPERTY = "source"
42
+ VECTOR_STORE_TYPE_PROPERTY = "type"
43
+ VECTOR_STORE_PROPERTY = "vector_store"
44
+ VECTOR_STORE_THRESHOLD_PROPERTY = "threshold"
45
+ TRACE_TOKENS_PROPERTY = "trace_prompt_tokens"
46
+ CITATION_ENABLED_PROPERTY = "citation_enabled"
47
+ USE_LLM_PROPERTY = "use_generative_llm"
48
+ CHECK_RELEVANCY_PROPERTY = "check_relevancy"
49
+ MAX_MESSAGES_IN_QUERY_KEY = "max_messages_in_query"
50
+
51
+ DEFAULT_VECTOR_STORE_TYPE = "faiss"
52
+ DEFAULT_VECTOR_STORE_THRESHOLD = 0.0
53
+ DEFAULT_VECTOR_STORE = {
54
+ VECTOR_STORE_TYPE_PROPERTY: DEFAULT_VECTOR_STORE_TYPE,
55
+ SOURCE_PROPERTY: "./docs",
56
+ VECTOR_STORE_THRESHOLD_PROPERTY: DEFAULT_VECTOR_STORE_THRESHOLD,
57
+ }
58
+
59
+ DEFAULT_CHECK_RELEVANCY_PROPERTY = False
60
+ DEFAULT_USE_LLM_PROPERTY = True
61
+ DEFAULT_CITATION_ENABLED_PROPERTY = False
62
+ DEFAULT_TRACE_PROMPT_TOKEN_PROPERTY = False
63
+
64
+ DEFAULT_MAX_MESSAGES_IN_QUERY = 2
65
+
66
+ DEFAULT_LLM_CONFIG = {
67
+ PROVIDER_CONFIG_KEY: OPENAI_PROVIDER,
68
+ MODEL_CONFIG_KEY: DEFAULT_ENTERPRISE_SEARCH_POLICY_MODEL_NAME,
69
+ TIMEOUT_CONFIG_KEY: 10,
70
+ TEMPERATURE_CONFIG_KEY: 0.0,
71
+ MAX_COMPLETION_TOKENS_CONFIG_KEY: 256,
72
+ MAX_RETRIES_CONFIG_KEY: 1,
73
+ }
74
+
75
+ DEFAULT_EMBEDDINGS_CONFIG = {
76
+ PROVIDER_CONFIG_KEY: OPENAI_PROVIDER,
77
+ MODEL_CONFIG_KEY: DEFAULT_OPENAI_EMBEDDING_MODEL_NAME,
78
+ }
79
+
80
+ DEFAULT_ENTERPRISE_SEARCH_CONFIG = {
81
+ POLICY_PRIORITY: SEARCH_POLICY_PRIORITY,
82
+ VECTOR_STORE_PROPERTY: DEFAULT_VECTOR_STORE,
83
+ }
84
+
85
+ REQUIRED_KEYS: List[str] = []
86
+
87
+ FORBIDDEN_KEYS: List[str] = []
88
+
89
+ DEPRECATED_ALIASES_TO_STANDARD_KEY_MAPPING = {
90
+ PROMPT_CONFIG_KEY: PROMPT_TEMPLATE_CONFIG_KEY
91
+ }
92
+
93
+
94
+ @dataclass
95
+ class EnterpriseSearchPolicyConfig:
96
+ """Parses configuration for Enterprise Search Policy."""
97
+
98
+ # TODO: llm_config, embeddings_config, and vector_store_config should also be parsed
99
+ # as "Config" objects. Likely part of a broader Rasa 4.0 rewrite where all
100
+ # components rely on configuration parser. So, for example, llm_config and
101
+ # embeddings_config should be parsed as ClientConfig objects, and
102
+ # vector_store_config parsed as VectorStoreConfig object.
103
+ llm_config: dict
104
+ embeddings_config: dict
105
+ vector_store_config: dict
106
+
107
+ prompt_template: str
108
+
109
+ use_generative_llm: bool = DEFAULT_USE_LLM_PROPERTY
110
+ enable_citation: bool = DEFAULT_CITATION_ENABLED_PROPERTY
111
+ check_relevancy: bool = DEFAULT_CHECK_RELEVANCY_PROPERTY
112
+
113
+ max_history: Optional[int] = None
114
+ max_messages_in_query: int = DEFAULT_MAX_MESSAGES_IN_QUERY
115
+ trace_prompt_tokens: bool = DEFAULT_TRACE_PROMPT_TOKEN_PROPERTY
116
+
117
+ @property
118
+ def vector_store_type(self) -> str:
119
+ # TODO: In the future this should ideally be part of the Vector config
120
+ # and not the property of the EnterpriseSearch config
121
+ return (
122
+ self.vector_store_config.get(VECTOR_STORE_TYPE_PROPERTY)
123
+ or DEFAULT_VECTOR_STORE_TYPE
124
+ )
125
+
126
+ @property
127
+ def vector_store_threshold(self) -> float:
128
+ # TODO: In the future this should ideally be part of the Vector config
129
+ # and not the property of the EnterpriseSearch config
130
+ return (
131
+ self.vector_store_config.get(VECTOR_STORE_THRESHOLD_PROPERTY)
132
+ or DEFAULT_VECTOR_STORE_THRESHOLD
133
+ )
134
+
135
+ @property
136
+ def vector_store_source(self) -> Optional[str]:
137
+ # TODO: In the future this should ideally be part of the Vector config
138
+ # and not the property of the EnterpriseSearch config
139
+ return self.vector_store_config.get(SOURCE_PROPERTY)
140
+
141
+ def __post_init__(self) -> None:
142
+ if self.check_relevancy and not self.use_generative_llm:
143
+ structlogger.warning(
144
+ "enterprise_search_policy"
145
+ ".relevancy_check_enabled_with_disabled_generative_search",
146
+ event_info=(
147
+ f"The config parameter '{CHECK_RELEVANCY_PROPERTY}' is set to"
148
+ f"'True', but the generative search is disabled (config"
149
+ f"parameter '{USE_LLM_PROPERTY}' is set to 'False'). As a result, "
150
+ "the relevancy check for the generative search will be disabled. "
151
+ f"To use this check, set the config parameter '{USE_LLM_PROPERTY}' "
152
+ f"to `True`."
153
+ ),
154
+ )
155
+ if self.enable_citation and not self.use_generative_llm:
156
+ structlogger.warning(
157
+ "enterprise_search_policy"
158
+ ".citation_enabled_with_disabled_generative_search",
159
+ event_info=(
160
+ f"The config parameter '{CITATION_ENABLED_PROPERTY}' is set to"
161
+ f"'True', but the generative search is disabled (config"
162
+ f"parameter '{USE_LLM_PROPERTY}' is set to 'False'). As a result, "
163
+ "the citation for the generative search will be disabled. "
164
+ f"To use this check, set the config parameter '{USE_LLM_PROPERTY}' "
165
+ f"to `True`."
166
+ ),
167
+ )
168
+
169
+ @classmethod
170
+ def from_dict(cls, config: dict) -> EnterpriseSearchPolicyConfig:
171
+ """Initializes a dataclass from the passed config.
172
+
173
+ Args:
174
+ config: (dict) The config from which to initialize.
175
+
176
+ Raises:
177
+ ValueError: Config is missing required keys.
178
+
179
+ Returns:
180
+ AzureOpenAIClientConfig
181
+ """
182
+ # Resolve LLM config
183
+ llm_config = (
184
+ resolve_model_client_config(
185
+ config.get(LLM_CONFIG_KEY), EnterpriseSearchPolicyConfig.__name__
186
+ )
187
+ or DEFAULT_LLM_CONFIG
188
+ )
189
+
190
+ # Resolve embeddings config
191
+ embeddings_config = (
192
+ resolve_model_client_config(
193
+ config.get(EMBEDDINGS_CONFIG_KEY), EnterpriseSearchPolicyConfig.__name__
194
+ )
195
+ or DEFAULT_EMBEDDINGS_CONFIG
196
+ )
197
+
198
+ # Vector store config
199
+ vector_store_config = config.get(VECTOR_STORE_PROPERTY, DEFAULT_VECTOR_STORE)
200
+
201
+ # Check for deprecated keys
202
+ raise_deprecation_warnings(
203
+ config, DEPRECATED_ALIASES_TO_STANDARD_KEY_MAPPING, "EnterpriseSearchPolicy"
204
+ )
205
+ # Resolve any potential aliases (e.g. 'prompt_template' vs 'prompt')
206
+ config = cls.resolve_config_aliases(config)
207
+
208
+ # Validate that the required keys are present
209
+ validate_required_keys(config, REQUIRED_KEYS)
210
+ # Validate that the forbidden keys are not present
211
+ validate_forbidden_keys(config, FORBIDDEN_KEYS)
212
+
213
+ this = EnterpriseSearchPolicyConfig(
214
+ llm_config=llm_config,
215
+ embeddings_config=embeddings_config,
216
+ vector_store_config=vector_store_config,
217
+ prompt_template=config.get(PROMPT_TEMPLATE_CONFIG_KEY),
218
+ use_generative_llm=config.get(USE_LLM_PROPERTY, DEFAULT_USE_LLM_PROPERTY),
219
+ enable_citation=config.get(
220
+ CITATION_ENABLED_PROPERTY, DEFAULT_CITATION_ENABLED_PROPERTY
221
+ ),
222
+ check_relevancy=config.get(
223
+ CHECK_RELEVANCY_PROPERTY, DEFAULT_CHECK_RELEVANCY_PROPERTY
224
+ ),
225
+ max_history=config.get(POLICY_MAX_HISTORY),
226
+ max_messages_in_query=config.get(
227
+ MAX_MESSAGES_IN_QUERY_KEY, DEFAULT_MAX_MESSAGES_IN_QUERY
228
+ ),
229
+ trace_prompt_tokens=config.get(
230
+ TRACE_TOKENS_PROPERTY, DEFAULT_TRACE_PROMPT_TOKEN_PROPERTY
231
+ ),
232
+ )
233
+ return this
234
+
235
+ def to_dict(self) -> dict:
236
+ """Converts the config instance into a dictionary."""
237
+ return asdict(self)
238
+
239
+ @staticmethod
240
+ def resolve_config_aliases(config: Dict[str, Any]) -> Dict[str, Any]:
241
+ return resolve_aliases(config, DEPRECATED_ALIASES_TO_STANDARD_KEY_MAPPING)
@@ -0,0 +1,64 @@
1
+ Based on the provided documents and the recent conversation context, answer the following question.
2
+ Before responding, ensure the answer is directly supported by the documents or context.
3
+ Do not make assumptions or infer beyond the given information.
4
+ Only answer if you are more than 80% confident that the response is fully supported.
5
+ If the answer cannot be determined, respond with: [NO_RAG_ANSWER]
6
+
7
+ ### Relevant Documents
8
+ Use the following documents to answer the question:
9
+ {% for doc in docs %}
10
+ {{ loop.cycle("*")}}. {{ doc.metadata }}
11
+ {{ doc.text }}
12
+ {% endfor %}
13
+
14
+ {% if citation_enabled %}
15
+ ### Citing Sources
16
+ Find the sources from the documents that are most relevant to answering the question.
17
+ The sources must be extracted from the given document metadata source property and not from the conversation context.
18
+ If there are no relevant sources, write "No relevant sources" instead.
19
+
20
+ For each source you cite, follow a 1-based numbering system for citations.
21
+ Start with [1] for the first source you refer to, regardless of its index in the provided list of documents.
22
+ If you cite another source, use the next number in sequence, [2], and so on.
23
+ Ensure each source is only assigned one number, even if referenced multiple times.
24
+ If you refer back to a previously cited source, use its originally assigned number.
25
+
26
+ For example, if you first cite the third source in the list, refer to it as [1].
27
+ If you then cite the first source in the list, refer to it as [2].
28
+ If you mention the third source again, still refer to it as [1].
29
+
30
+ Don't say "According to Source [1]" when answering. Instead, make references to sources relevant to each section of the answer solely by adding the bracketed number at the end of the relevant sentence.
31
+ #### Formatting
32
+ First print the answer with in-text citations which follow a numbered order starting with index 1, then add the sources section.
33
+ The format of your overall answer must look like what's shown between the <example></example> tags.
34
+ Make sure to follow the formatting exactly and remove any line breaks or whitespaces between the answer and the Sources section.
35
+ <example>
36
+ You can use flows to model business logic in Rasa assistants. [1] You can use the Enterprise Search Policy to search vector stores for relevant knowledge base documents. [2]
37
+ Sources:
38
+ [1] https://rasa.com/docs/rasa-pro/concepts/flows
39
+ [2] https://rasa.com/docs/rasa-pro/concepts/policies/enterprise-search-policy
40
+ </example>
41
+ {% endif %}
42
+
43
+ {% if slots|length > 0 %}
44
+ ### Slots or Variables
45
+ Here are the variables of the currently active conversation which may be used to answer the question:
46
+ {% for slot in slots -%}
47
+ - name: {{ slot.name }}, value: {{ slot.value }}, type: {{ slot.type }}
48
+ {% endfor %}
49
+ {% endif %}
50
+ ### Current Conversation
51
+ Transcript of the current conversation, use it to determine the context of the question:
52
+ {{ current_conversation }}
53
+
54
+
55
+ ## Answering the Question
56
+ Based on the above sections, please formulate an answer to the question or request in the user's last message.
57
+ It is important that you ensure the answer is grounded in the provided documents and conversation context.
58
+ Avoid speculating or making assumptions beyond the given information and keep your answers short, 2 to 3 sentences at most.
59
+
60
+ {% if citation_enabled %}
61
+ If you are unable to find an answer in the given relevant documents, do not cite sources from elsewhere in the conversation context.
62
+ {% endif %}
63
+
64
+ Your answer:
@@ -150,12 +150,12 @@ class FlowPolicy(Policy):
150
150
  except FlowCircuitBreakerTrippedException as e:
151
151
  structlogger.error(
152
152
  "flow.circuit_breaker",
153
- dialogue_stack=e.dialogue_stack,
154
153
  number_of_steps_taken=e.number_of_steps_taken,
155
154
  event_info=(
156
155
  "The flow circuit breaker tripped. "
157
156
  "There appears to be an infinite loop in the flows."
158
157
  ),
158
+ error=str(e),
159
159
  )
160
160
  # end the current flow and start the internal error flow
161
161
  updated_stack = tracker.stack
@@ -9,6 +9,7 @@ from structlog.contextvars import (
9
9
  bound_contextvars,
10
10
  )
11
11
 
12
+ from rasa.core.available_endpoints import AvailableEndpoints
12
13
  from rasa.core.constants import ACTIVE_FLOW_METADATA_KEY, STEP_ID_METADATA_KEY
13
14
  from rasa.core.policies.flows.flow_exceptions import (
14
15
  FlowCircuitBreakerTrippedException,
@@ -24,6 +25,7 @@ from rasa.core.policies.flows.flow_step_result import (
24
25
  from rasa.dialogue_understanding.commands import CancelFlowCommand
25
26
  from rasa.dialogue_understanding.patterns.cancel import CancelPatternFlowStackFrame
26
27
  from rasa.dialogue_understanding.patterns.collect_information import (
28
+ FLOW_PATTERN_COLLECT_INFORMATION,
27
29
  CollectInformationPatternFlowStackFrame,
28
30
  )
29
31
  from rasa.dialogue_understanding.patterns.completed import (
@@ -54,6 +56,7 @@ from rasa.dialogue_understanding.stack.utils import (
54
56
  from rasa.shared.constants import RASA_PATTERN_HUMAN_HANDOFF
55
57
  from rasa.shared.core.constants import (
56
58
  ACTION_LISTEN_NAME,
59
+ SILENCE_TIMEOUT_SLOT,
57
60
  )
58
61
  from rasa.shared.core.events import (
59
62
  Event,
@@ -123,7 +126,6 @@ def is_condition_satisfied(
123
126
  structlogger.error(
124
127
  "flow.predicate.error",
125
128
  predicate=predicate,
126
- document=document,
127
129
  error=str(e),
128
130
  )
129
131
  return False
@@ -177,7 +179,7 @@ def select_next_step_id(
177
179
  "flow.link.failed_to_select_branch",
178
180
  current=current,
179
181
  links=next_step.links,
180
- tracker=tracker,
182
+ sender_id=tracker.sender_id,
181
183
  )
182
184
  return None
183
185
 
@@ -191,7 +193,7 @@ def select_next_step_id(
191
193
  structlogger.error(
192
194
  "flow.step.failed_to_select_next_step",
193
195
  step=current,
194
- tracker=tracker,
196
+ sender_id=tracker.sender_id,
195
197
  )
196
198
  return None
197
199
 
@@ -226,19 +228,6 @@ def events_from_set_slots_step(step: SetSlotsFlowStep) -> List[Event]:
226
228
  return [SlotSet(slot["key"], slot["value"]) for slot in step.slots]
227
229
 
228
230
 
229
- def events_for_collect_step_execution(
230
- step: CollectInformationFlowStep, tracker: DialogueStateTracker
231
- ) -> List[Event]:
232
- """Create the events needed to prepare for the execution of a collect step."""
233
- # reset the slots that always need to be explicitly collected
234
- slot = tracker.slots.get(step.collect, None)
235
-
236
- if slot and step.ask_before_filling:
237
- return [SlotSet(step.collect, None)]
238
- else:
239
- return []
240
-
241
-
242
231
  def trigger_pattern_continue_interrupted(
243
232
  current_frame: DialogueStackFrame,
244
233
  stack: DialogueStack,
@@ -600,6 +589,12 @@ def run_step(
600
589
  # the START_STEP meta step
601
590
  initial_events.append(FlowStarted(flow.id, metadata=stack.current_context()))
602
591
 
592
+ # FLow does not start with collect step or we are not in collect information pattern
593
+ if _first_step_is_not_collect(
594
+ step, previous_step_id
595
+ ) and not _in_collect_information_pattern(flow):
596
+ _append_global_silence_timeout_event(initial_events, tracker)
597
+
603
598
  if isinstance(step, CollectInformationFlowStep):
604
599
  return _run_collect_information_step(
605
600
  available_actions,
@@ -629,12 +624,32 @@ def run_step(
629
624
  return ContinueFlowWithNextStep(events=initial_events)
630
625
 
631
626
  elif isinstance(step, EndFlowStep):
627
+ # If pattern collect information flow is ending,
628
+ # we need to reset the silence timeout slot to its global value.
629
+ if flow.id == FLOW_PATTERN_COLLECT_INFORMATION:
630
+ _append_global_silence_timeout_event(initial_events, tracker)
631
+
632
632
  return _run_end_step(flow, flows, initial_events, stack, tracker)
633
633
 
634
634
  else:
635
635
  raise FlowException(f"Unknown flow step type {type(step)}")
636
636
 
637
637
 
638
+ def _first_step_is_not_collect(
639
+ step: FlowStep,
640
+ previous_step_id: str,
641
+ ) -> bool:
642
+ """Check if the first step is not a collect information step."""
643
+ return (previous_step_id == START_STEP) and not isinstance(
644
+ step, CollectInformationFlowStep
645
+ )
646
+
647
+
648
+ def _in_collect_information_pattern(flow: Flow) -> bool:
649
+ """Check if the current flow is a collect information pattern."""
650
+ return flow.id == FLOW_PATTERN_COLLECT_INFORMATION
651
+
652
+
638
653
  def _run_end_step(
639
654
  flow: Flow,
640
655
  flows: FlowsList,
@@ -745,5 +760,69 @@ def _run_collect_information_step(
745
760
  step.collect, stack, step.rejections, step.utter, step.collect_action
746
761
  )
747
762
 
748
- events: List[Event] = events_for_collect_step_execution(step, tracker)
763
+ events: List[Event] = _events_for_collect_step_execution(step, tracker)
749
764
  return ContinueFlowWithNextStep(events=initial_events + events)
765
+
766
+
767
+ def _events_for_collect_step_execution(
768
+ step: CollectInformationFlowStep, tracker: DialogueStateTracker
769
+ ) -> List[Event]:
770
+ """Create the events needed to prepare for the execution of a collect step."""
771
+ # reset the slots that always need to be explicitly collected
772
+
773
+ events = _silence_timeout_events_for_collect_step(step, tracker)
774
+
775
+ slot = tracker.slots.get(step.collect, None)
776
+ if slot and step.ask_before_filling:
777
+ events.append(SlotSet(step.collect, None))
778
+
779
+ return events
780
+
781
+
782
+ def _silence_timeout_events_for_collect_step(
783
+ step: CollectInformationFlowStep, tracker: DialogueStateTracker
784
+ ) -> List[Event]:
785
+ events: List[Event] = []
786
+
787
+ silence_timeout = (
788
+ AvailableEndpoints.get_instance().interaction_handling.global_silence_timeout
789
+ )
790
+
791
+ if step.silence_timeout:
792
+ structlogger.debug(
793
+ "flow.step.run.adjusting_silence_timeout",
794
+ duration=step.silence_timeout,
795
+ collect=step.collect,
796
+ )
797
+
798
+ silence_timeout = step.silence_timeout
799
+ else:
800
+ structlogger.debug(
801
+ "flow.step.run.reset_silence_timeout_to_global",
802
+ duration=silence_timeout,
803
+ collect=step.collect,
804
+ )
805
+
806
+ current_silence_timeout = tracker.get_slot(SILENCE_TIMEOUT_SLOT)
807
+
808
+ if current_silence_timeout != silence_timeout:
809
+ events.append(SlotSet(SILENCE_TIMEOUT_SLOT, silence_timeout))
810
+
811
+ return events
812
+
813
+
814
+ def _append_global_silence_timeout_event(
815
+ events: List[Event], tracker: DialogueStateTracker
816
+ ) -> None:
817
+ current_silence_timeout = tracker.get_slot(SILENCE_TIMEOUT_SLOT)
818
+ global_silence_timeout = (
819
+ AvailableEndpoints.get_instance().interaction_handling.global_silence_timeout
820
+ )
821
+
822
+ if current_silence_timeout != global_silence_timeout:
823
+ events.append(
824
+ SlotSet(
825
+ SILENCE_TIMEOUT_SLOT,
826
+ AvailableEndpoints.get_instance().interaction_handling.global_silence_timeout,
827
+ )
828
+ )