rasa-pro 3.12.18.dev1__py3-none-any.whl → 3.13.0a1.dev1__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 (341) hide show
  1. rasa/__init__.py +0 -6
  2. rasa/__main__.py +3 -4
  3. rasa/api.py +1 -1
  4. rasa/builder/create_openai_vector_store.py +69 -0
  5. rasa/builder/llm-helper-schema.json +69 -0
  6. rasa/builder/prompt_to_bot.py +645 -0
  7. rasa/builder/scrape_rasa_docs.py +97 -0
  8. rasa/builder/skill_to_bot_prompt.jinja +158 -0
  9. rasa/cli/dialogue_understanding_test.py +1 -1
  10. rasa/cli/e2e_test.py +1 -1
  11. rasa/cli/evaluate.py +2 -2
  12. rasa/cli/export.py +3 -3
  13. rasa/cli/llm_fine_tuning.py +1 -1
  14. rasa/cli/project_templates/default/config.yml +5 -32
  15. rasa/cli/project_templates/{calm → default}/e2e_tests/cancelations/user_cancels_during_a_correction.yml +1 -1
  16. rasa/cli/project_templates/{calm → default}/e2e_tests/cancelations/user_changes_mind_on_a_whim.yml +1 -1
  17. rasa/cli/project_templates/{calm → default}/e2e_tests/corrections/user_corrects_contact_handle.yml +1 -1
  18. rasa/cli/project_templates/{calm → default}/e2e_tests/corrections/user_corrects_contact_name.yml +1 -1
  19. rasa/cli/project_templates/{calm → default}/e2e_tests/happy_paths/user_adds_contact_to_their_list.yml +1 -1
  20. rasa/cli/project_templates/{calm → default}/e2e_tests/happy_paths/user_lists_contacts.yml +1 -1
  21. rasa/cli/project_templates/{calm → default}/e2e_tests/happy_paths/user_removes_contact.yml +1 -1
  22. rasa/cli/project_templates/{calm → default}/e2e_tests/happy_paths/user_removes_contact_from_list.yml +1 -1
  23. rasa/cli/project_templates/default/endpoints.yml +18 -2
  24. rasa/cli/project_templates/defaults.py +133 -0
  25. rasa/cli/run.py +1 -1
  26. rasa/cli/scaffold.py +2 -3
  27. rasa/cli/studio/download.py +1 -1
  28. rasa/cli/studio/link.py +53 -0
  29. rasa/cli/studio/pull.py +78 -0
  30. rasa/cli/studio/push.py +78 -0
  31. rasa/cli/studio/studio.py +12 -0
  32. rasa/cli/studio/upload.py +5 -3
  33. rasa/cli/train.py +1 -1
  34. rasa/cli/utils.py +1 -1
  35. rasa/cli/x.py +1 -1
  36. rasa/constants.py +2 -0
  37. rasa/core/__init__.py +0 -16
  38. rasa/core/actions/action.py +42 -31
  39. rasa/core/actions/action_repeat_bot_messages.py +18 -22
  40. rasa/core/actions/action_run_slot_rejections.py +1 -2
  41. rasa/core/agent.py +18 -3
  42. rasa/core/available_endpoints.py +146 -0
  43. rasa/core/brokers/kafka.py +4 -0
  44. rasa/core/brokers/pika.py +5 -2
  45. rasa/core/brokers/sql.py +1 -1
  46. rasa/core/channels/botframework.py +2 -2
  47. rasa/core/channels/channel.py +2 -2
  48. rasa/core/channels/development_inspector.py +1 -1
  49. rasa/core/channels/facebook.py +1 -4
  50. rasa/core/channels/hangouts.py +8 -5
  51. rasa/core/channels/inspector/.eslintrc.cjs +12 -6
  52. rasa/core/channels/inspector/.prettierrc +5 -0
  53. rasa/core/channels/inspector/README.md +11 -5
  54. rasa/core/channels/inspector/dist/assets/{arc-9f75cc3b.js → arc-02053cc1.js} +1 -1
  55. rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-7f34db23.js → blockDiagram-38ab4fdb-008b6289.js} +1 -1
  56. rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-948bab2c.js → c4Diagram-3d4e48cf-fb2597be.js} +1 -1
  57. rasa/core/channels/inspector/dist/assets/channel-078dada8.js +1 -0
  58. rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-53b0dd0e.js → classDiagram-70f12bd4-7f847e00.js} +1 -1
  59. rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-fdf789e7.js → classDiagram-v2-f2320105-ba1d689b.js} +1 -1
  60. rasa/core/channels/inspector/dist/assets/clone-5b4516de.js +1 -0
  61. rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-87c4ece5.js → createText-2e5e7dd3-dd8e67c4.js} +1 -1
  62. rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-5a8b0749.js → edges-e0da2a9e-10784939.js} +1 -1
  63. rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-66da90e2.js → erDiagram-9861fffd-24947ae6.js} +1 -1
  64. rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-10044f05.js → flowDb-956e92f1-a9ced505.js} +1 -1
  65. rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-f338f66a.js → flowDiagram-66a62f08-afda9c7c.js} +1 -1
  66. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-f9613071.js +1 -0
  67. rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-b13140aa.js → flowchart-elk-definition-4a651766-6ef530b8.js} +1 -1
  68. rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-f2b4a55a.js → ganttDiagram-c361ad54-0c7dd39a.js} +1 -1
  69. rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-dedc298d.js → gitGraphDiagram-72cf32ee-b57239d6.js} +1 -1
  70. rasa/core/channels/inspector/dist/assets/{graph-4ede11ff.js → graph-9ed57cec.js} +1 -1
  71. rasa/core/channels/inspector/dist/assets/{index-3862675e-65549d37.js → index-3862675e-233090de.js} +1 -1
  72. rasa/core/channels/inspector/dist/assets/{index-3a23e736.js → index-72184470.js} +123 -123
  73. rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-65439671.js → infoDiagram-f8f76790-aa116649.js} +1 -1
  74. rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-56d03d98.js → journeyDiagram-49397b02-e51877cc.js} +1 -1
  75. rasa/core/channels/inspector/dist/assets/{layout-dd48f7f4.js → layout-3ca3798c.js} +1 -1
  76. rasa/core/channels/inspector/dist/assets/{line-1569ad2c.js → line-26ee10d3.js} +1 -1
  77. rasa/core/channels/inspector/dist/assets/{linear-48bf4935.js → linear-aedded32.js} +1 -1
  78. rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-688504c1.js → mindmap-definition-fc14e90a-d8957261.js} +1 -1
  79. rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-78b6d7e6.js → pieDiagram-8a3498a8-d771f885.js} +1 -1
  80. rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-048b84b3.js → quadrantDiagram-120e2f19-09fdf50c.js} +1 -1
  81. rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-dd67f107.js → requirementDiagram-deff3bca-9f0af02e.js} +1 -1
  82. rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-8128436e.js → sankeyDiagram-04a897e0-84415b37.js} +1 -1
  83. rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-1a0d1461.js → sequenceDiagram-704730f1-8dec4055.js} +1 -1
  84. rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-46d388ed.js → stateDiagram-587899a1-c5431d07.js} +1 -1
  85. rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-ea42951a.js → stateDiagram-v2-d93cdb3a-274e77d9.js} +1 -1
  86. rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-7427ed0c.js → styles-6aaf32cf-e364a1d7.js} +1 -1
  87. rasa/core/channels/inspector/dist/assets/{styles-9a916d00-ff5e5a16.js → styles-9a916d00-0dae36f6.js} +1 -1
  88. rasa/core/channels/inspector/dist/assets/{styles-c10674c1-7b3680cf.js → styles-c10674c1-c4641675.js} +1 -1
  89. rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-f860f2ad.js → svgDrawCommon-08f97a94-831fe9a1.js} +1 -1
  90. rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-2eebf0c8.js → timeline-definition-85554ec2-c3304b3a.js} +1 -1
  91. rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-5d7f4e96.js → xychartDiagram-e933f94c-da799369.js} +1 -1
  92. rasa/core/channels/inspector/dist/index.html +1 -1
  93. rasa/core/channels/inspector/package.json +3 -1
  94. rasa/core/channels/inspector/src/App.tsx +91 -90
  95. rasa/core/channels/inspector/src/components/Chat.tsx +45 -41
  96. rasa/core/channels/inspector/src/components/DiagramFlow.tsx +40 -40
  97. rasa/core/channels/inspector/src/components/DialogueInformation.tsx +57 -57
  98. rasa/core/channels/inspector/src/components/DialogueStack.tsx +36 -27
  99. rasa/core/channels/inspector/src/components/ExpandIcon.tsx +4 -4
  100. rasa/core/channels/inspector/src/components/FullscreenButton.tsx +7 -7
  101. rasa/core/channels/inspector/src/components/LoadingSpinner.tsx +28 -12
  102. rasa/core/channels/inspector/src/components/NoActiveFlow.tsx +9 -9
  103. rasa/core/channels/inspector/src/components/RasaLogo.tsx +5 -5
  104. rasa/core/channels/inspector/src/components/RecruitmentPanel.tsx +55 -60
  105. rasa/core/channels/inspector/src/components/SaraDiagrams.tsx +5 -5
  106. rasa/core/channels/inspector/src/components/Slots.tsx +22 -22
  107. rasa/core/channels/inspector/src/components/Welcome.tsx +28 -31
  108. rasa/core/channels/inspector/src/helpers/audio/audiostream.ts +245 -0
  109. rasa/core/channels/inspector/src/helpers/audio/microphone-processor.js +12 -0
  110. rasa/core/channels/inspector/src/helpers/audio/playback-processor.js +36 -0
  111. rasa/core/channels/inspector/src/helpers/conversation.ts +7 -7
  112. rasa/core/channels/inspector/src/helpers/formatters.test.ts +181 -181
  113. rasa/core/channels/inspector/src/helpers/formatters.ts +111 -111
  114. rasa/core/channels/inspector/src/helpers/utils.ts +78 -61
  115. rasa/core/channels/inspector/src/main.tsx +8 -8
  116. rasa/core/channels/inspector/src/theme/Button/Button.ts +8 -8
  117. rasa/core/channels/inspector/src/theme/Heading/Heading.ts +7 -7
  118. rasa/core/channels/inspector/src/theme/Input/Input.ts +9 -9
  119. rasa/core/channels/inspector/src/theme/Link/Link.ts +6 -6
  120. rasa/core/channels/inspector/src/theme/Modal/Modal.ts +13 -13
  121. rasa/core/channels/inspector/src/theme/Table/Table.tsx +10 -10
  122. rasa/core/channels/inspector/src/theme/Tooltip/Tooltip.ts +5 -5
  123. rasa/core/channels/inspector/src/theme/base/breakpoints.ts +7 -7
  124. rasa/core/channels/inspector/src/theme/base/colors.ts +64 -64
  125. rasa/core/channels/inspector/src/theme/base/fonts/fontFaces.css +21 -18
  126. rasa/core/channels/inspector/src/theme/base/radii.ts +8 -8
  127. rasa/core/channels/inspector/src/theme/base/shadows.ts +5 -5
  128. rasa/core/channels/inspector/src/theme/base/sizes.ts +5 -5
  129. rasa/core/channels/inspector/src/theme/base/space.ts +12 -12
  130. rasa/core/channels/inspector/src/theme/base/styles.ts +5 -5
  131. rasa/core/channels/inspector/src/theme/base/typography.ts +12 -12
  132. rasa/core/channels/inspector/src/theme/base/zIndices.ts +3 -3
  133. rasa/core/channels/inspector/src/theme/index.ts +38 -38
  134. rasa/core/channels/inspector/src/types.ts +56 -50
  135. rasa/core/channels/inspector/yarn.lock +5 -0
  136. rasa/core/channels/mattermost.py +1 -1
  137. rasa/core/channels/rasa_chat.py +2 -4
  138. rasa/core/channels/rest.py +5 -4
  139. rasa/core/channels/socketio.py +56 -41
  140. rasa/core/channels/studio_chat.py +337 -71
  141. rasa/core/channels/vier_cvg.py +1 -2
  142. rasa/core/channels/voice_ready/audiocodes.py +4 -11
  143. rasa/core/channels/voice_stream/audiocodes.py +8 -5
  144. rasa/core/channels/voice_stream/browser_audio.py +1 -1
  145. rasa/core/channels/voice_stream/genesys.py +2 -2
  146. rasa/core/channels/voice_stream/tts/__init__.py +8 -0
  147. rasa/core/channels/voice_stream/twilio_media_streams.py +10 -5
  148. rasa/core/channels/voice_stream/voice_channel.py +65 -23
  149. rasa/core/concurrent_lock_store.py +24 -10
  150. rasa/core/evaluation/marker_tracker_loader.py +1 -1
  151. rasa/core/exporter.py +1 -1
  152. rasa/core/http_interpreter.py +3 -7
  153. rasa/core/information_retrieval/faiss.py +18 -11
  154. rasa/core/information_retrieval/ingestion/__init__.py +0 -0
  155. rasa/core/information_retrieval/ingestion/faq_parser.py +158 -0
  156. rasa/core/jobs.py +2 -1
  157. rasa/core/lock_store.py +151 -60
  158. rasa/core/nlg/contextual_response_rephraser.py +17 -7
  159. rasa/core/nlg/generator.py +5 -22
  160. rasa/core/nlg/interpolator.py +2 -3
  161. rasa/core/nlg/response.py +6 -43
  162. rasa/core/nlg/summarize.py +1 -1
  163. rasa/core/nlg/translate.py +0 -8
  164. rasa/core/policies/enterprise_search_policy.py +262 -62
  165. rasa/core/policies/enterprise_search_prompt_with_relevancy_check_and_citation_template.jinja2 +63 -0
  166. rasa/core/policies/flow_policy.py +1 -1
  167. rasa/core/policies/flows/flow_executor.py +96 -17
  168. rasa/core/policies/intentless_policy.py +57 -20
  169. rasa/core/processor.py +114 -54
  170. rasa/core/run.py +33 -11
  171. rasa/core/tracker_stores/__init__.py +0 -0
  172. rasa/core/{auth_retry_tracker_store.py → tracker_stores/auth_retry_tracker_store.py} +5 -1
  173. rasa/core/tracker_stores/dynamo_tracker_store.py +218 -0
  174. rasa/core/tracker_stores/mongo_tracker_store.py +206 -0
  175. rasa/core/tracker_stores/redis_tracker_store.py +219 -0
  176. rasa/core/tracker_stores/sql_tracker_store.py +555 -0
  177. rasa/core/tracker_stores/tracker_store.py +805 -0
  178. rasa/core/training/interactive.py +1 -1
  179. rasa/core/utils.py +24 -95
  180. rasa/dialogue_understanding/coexistence/intent_based_router.py +2 -1
  181. rasa/dialogue_understanding/coexistence/llm_based_router.py +10 -6
  182. rasa/dialogue_understanding/commands/can_not_handle_command.py +2 -0
  183. rasa/dialogue_understanding/commands/cancel_flow_command.py +5 -1
  184. rasa/dialogue_understanding/commands/chit_chat_answer_command.py +2 -0
  185. rasa/dialogue_understanding/commands/clarify_command.py +4 -0
  186. rasa/dialogue_understanding/commands/command_syntax_manager.py +1 -0
  187. rasa/dialogue_understanding/commands/correct_slots_command.py +1 -3
  188. rasa/dialogue_understanding/commands/human_handoff_command.py +2 -0
  189. rasa/dialogue_understanding/commands/knowledge_answer_command.py +2 -0
  190. rasa/dialogue_understanding/commands/repeat_bot_messages_command.py +2 -0
  191. rasa/dialogue_understanding/commands/set_slot_command.py +10 -0
  192. rasa/dialogue_understanding/commands/skip_question_command.py +2 -0
  193. rasa/dialogue_understanding/commands/start_flow_command.py +4 -0
  194. rasa/dialogue_understanding/commands/utils.py +26 -2
  195. rasa/dialogue_understanding/generator/__init__.py +7 -1
  196. rasa/dialogue_understanding/generator/command_generator.py +4 -2
  197. rasa/dialogue_understanding/generator/command_parser.py +2 -2
  198. rasa/dialogue_understanding/generator/command_parser_validator.py +63 -0
  199. rasa/dialogue_understanding/generator/llm_based_command_generator.py +5 -17
  200. rasa/dialogue_understanding/generator/llm_command_generator.py +1 -3
  201. rasa/dialogue_understanding/generator/multi_step/multi_step_llm_command_generator.py +4 -44
  202. rasa/dialogue_understanding/generator/nlu_command_adapter.py +2 -2
  203. rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v3_gpt_4o_2024_11_20_template.jinja2 +78 -0
  204. rasa/dialogue_understanding/generator/single_step/compact_llm_command_generator.py +26 -474
  205. rasa/dialogue_understanding/generator/single_step/search_ready_llm_command_generator.py +147 -0
  206. rasa/dialogue_understanding/generator/single_step/single_step_based_llm_command_generator.py +477 -0
  207. rasa/dialogue_understanding/generator/single_step/single_step_llm_command_generator.py +11 -64
  208. rasa/dialogue_understanding/patterns/cancel.py +1 -2
  209. rasa/dialogue_understanding/patterns/clarify.py +1 -1
  210. rasa/dialogue_understanding/patterns/correction.py +2 -2
  211. rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +37 -25
  212. rasa/dialogue_understanding/patterns/domain_for_patterns.py +190 -0
  213. rasa/dialogue_understanding/processor/command_processor.py +6 -7
  214. rasa/dialogue_understanding/stack/frames/flow_stack_frame.py +17 -4
  215. rasa/dialogue_understanding/stack/utils.py +3 -1
  216. rasa/dialogue_understanding/utils.py +68 -12
  217. rasa/dialogue_understanding_test/command_metric_calculation.py +7 -40
  218. rasa/dialogue_understanding_test/command_metrics.py +38 -0
  219. rasa/dialogue_understanding_test/du_test_case.py +58 -25
  220. rasa/dialogue_understanding_test/du_test_result.py +228 -132
  221. rasa/dialogue_understanding_test/du_test_runner.py +11 -2
  222. rasa/dialogue_understanding_test/io.py +35 -8
  223. rasa/e2e_test/e2e_test_runner.py +1 -1
  224. rasa/engine/constants.py +1 -1
  225. rasa/engine/graph.py +2 -2
  226. rasa/engine/recipes/default_recipe.py +1 -1
  227. rasa/engine/validation.py +3 -2
  228. rasa/hooks.py +2 -85
  229. rasa/llm_fine_tuning/paraphrasing/conversation_rephraser.py +1 -5
  230. rasa/llm_fine_tuning/utils.py +2 -4
  231. rasa/model_manager/model_api.py +90 -2
  232. rasa/model_manager/socket_bridge.py +0 -7
  233. rasa/model_manager/trainer_service.py +15 -12
  234. rasa/plugin.py +2 -15
  235. rasa/privacy/__init__.py +0 -0
  236. rasa/privacy/constants.py +83 -0
  237. rasa/privacy/event_broker_utils.py +77 -0
  238. rasa/privacy/privacy_config.py +281 -0
  239. rasa/privacy/privacy_config_schema.json +86 -0
  240. rasa/privacy/privacy_filter.py +340 -0
  241. rasa/privacy/privacy_manager.py +576 -0
  242. rasa/server.py +23 -2
  243. rasa/shared/constants.py +13 -4
  244. rasa/shared/core/command_payload_reader.py +1 -5
  245. rasa/shared/core/constants.py +4 -3
  246. rasa/shared/core/domain.py +172 -11
  247. rasa/shared/core/events.py +100 -6
  248. rasa/shared/core/flows/flow.py +35 -8
  249. rasa/shared/core/flows/flow_step.py +26 -4
  250. rasa/shared/core/flows/flow_step_links.py +15 -0
  251. rasa/shared/core/flows/flow_step_sequence.py +6 -0
  252. rasa/shared/core/flows/flows_yaml_schema.json +3 -0
  253. rasa/shared/core/flows/nlu_trigger.py +13 -0
  254. rasa/shared/core/flows/steps/action.py +7 -4
  255. rasa/shared/core/flows/steps/call.py +11 -4
  256. rasa/shared/core/flows/steps/collect.py +71 -6
  257. rasa/shared/core/flows/steps/internal.py +6 -1
  258. rasa/shared/core/flows/steps/link.py +7 -4
  259. rasa/shared/core/flows/steps/no_operation.py +7 -4
  260. rasa/shared/core/flows/steps/set_slots.py +8 -4
  261. rasa/shared/core/flows/validation.py +16 -3
  262. rasa/shared/core/flows/yaml_flows_io.py +106 -5
  263. rasa/shared/core/slots.py +33 -1
  264. rasa/shared/core/trackers.py +4 -10
  265. rasa/shared/core/training_data/story_reader/yaml_story_reader.py +1 -4
  266. rasa/shared/importers/importer.py +14 -0
  267. rasa/shared/importers/static.py +63 -0
  268. rasa/shared/providers/constants.py +0 -9
  269. rasa/shared/providers/llm/_base_litellm_client.py +4 -14
  270. rasa/shared/providers/llm/default_litellm_llm_client.py +2 -2
  271. rasa/shared/providers/llm/litellm_router_llm_client.py +7 -17
  272. rasa/shared/providers/llm/llm_client.py +15 -24
  273. rasa/shared/providers/llm/self_hosted_llm_client.py +2 -10
  274. rasa/shared/utils/common.py +43 -1
  275. rasa/shared/utils/llm.py +155 -3
  276. rasa/shared/utils/yaml.py +32 -0
  277. rasa/studio/data_handler.py +3 -3
  278. rasa/studio/download/__init__.py +0 -0
  279. rasa/studio/download/domains.py +49 -0
  280. rasa/studio/download/download.py +416 -0
  281. rasa/studio/download/flows.py +351 -0
  282. rasa/studio/link.py +200 -0
  283. rasa/studio/pull.py +94 -0
  284. rasa/studio/push.py +131 -0
  285. rasa/studio/results_logger.py +6 -1
  286. rasa/studio/upload.py +185 -71
  287. rasa/telemetry.py +83 -26
  288. rasa/tracing/config.py +4 -5
  289. rasa/tracing/constants.py +19 -1
  290. rasa/tracing/instrumentation/attribute_extractors.py +49 -11
  291. rasa/tracing/instrumentation/instrumentation.py +54 -3
  292. rasa/tracing/instrumentation/metrics.py +98 -15
  293. rasa/tracing/metric_instrument_provider.py +75 -3
  294. rasa/utils/common.py +37 -27
  295. rasa/utils/endpoints.py +22 -1
  296. rasa/utils/licensing.py +2 -3
  297. rasa/utils/log_utils.py +1 -45
  298. rasa/validator.py +9 -11
  299. rasa/version.py +1 -1
  300. {rasa_pro-3.12.18.dev1.dist-info → rasa_pro-3.13.0a1.dev1.dist-info}/METADATA +12 -14
  301. {rasa_pro-3.12.18.dev1.dist-info → rasa_pro-3.13.0a1.dev1.dist-info}/RECORD +318 -294
  302. rasa/anonymization/__init__.py +0 -2
  303. rasa/anonymization/anonymisation_rule_yaml_reader.py +0 -91
  304. rasa/anonymization/anonymization_pipeline.py +0 -286
  305. rasa/anonymization/anonymization_rule_executor.py +0 -266
  306. rasa/anonymization/anonymization_rule_orchestrator.py +0 -119
  307. rasa/anonymization/schemas/config.yml +0 -47
  308. rasa/anonymization/utils.py +0 -118
  309. rasa/cli/project_templates/calm/config.yml +0 -10
  310. rasa/cli/project_templates/calm/credentials.yml +0 -33
  311. rasa/cli/project_templates/calm/endpoints.yml +0 -58
  312. rasa/cli/project_templates/default/actions/actions.py +0 -27
  313. rasa/cli/project_templates/default/data/nlu.yml +0 -91
  314. rasa/cli/project_templates/default/data/rules.yml +0 -13
  315. rasa/cli/project_templates/default/data/stories.yml +0 -30
  316. rasa/cli/project_templates/default/domain.yml +0 -34
  317. rasa/cli/project_templates/default/tests/test_stories.yml +0 -91
  318. rasa/core/channels/inspector/dist/assets/channel-dfa68278.js +0 -1
  319. rasa/core/channels/inspector/dist/assets/clone-edb7f119.js +0 -1
  320. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-65e7c670.js +0 -1
  321. rasa/core/channels/inspector/src/helpers/audiostream.ts +0 -191
  322. rasa/core/tracker_store.py +0 -1792
  323. rasa/monkey_patches.py +0 -91
  324. rasa/studio/download.py +0 -489
  325. /rasa/{cli/project_templates/calm/actions → builder}/__init__.py +0 -0
  326. /rasa/cli/project_templates/{calm → default}/actions/action_template.py +0 -0
  327. /rasa/cli/project_templates/{calm → default}/actions/add_contact.py +0 -0
  328. /rasa/cli/project_templates/{calm → default}/actions/db.py +0 -0
  329. /rasa/cli/project_templates/{calm → default}/actions/list_contacts.py +0 -0
  330. /rasa/cli/project_templates/{calm → default}/actions/remove_contact.py +0 -0
  331. /rasa/cli/project_templates/{calm → default}/data/flows/add_contact.yml +0 -0
  332. /rasa/cli/project_templates/{calm → default}/data/flows/list_contacts.yml +0 -0
  333. /rasa/cli/project_templates/{calm → default}/data/flows/remove_contact.yml +0 -0
  334. /rasa/cli/project_templates/{calm → default}/db/contacts.json +0 -0
  335. /rasa/cli/project_templates/{calm → default}/domain/add_contact.yml +0 -0
  336. /rasa/cli/project_templates/{calm → default}/domain/list_contacts.yml +0 -0
  337. /rasa/cli/project_templates/{calm → default}/domain/remove_contact.yml +0 -0
  338. /rasa/cli/project_templates/{calm → default}/domain/shared.yml +0 -0
  339. {rasa_pro-3.12.18.dev1.dist-info → rasa_pro-3.13.0a1.dev1.dist-info}/NOTICE +0 -0
  340. {rasa_pro-3.12.18.dev1.dist-info → rasa_pro-3.13.0a1.dev1.dist-info}/WHEEL +0 -0
  341. {rasa_pro-3.12.18.dev1.dist-info → rasa_pro-3.13.0a1.dev1.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,63 @@
1
+ import logging
2
+ from typing import Dict, Optional, Text
3
+
4
+ from rasa.shared.core.domain import Domain
5
+ from rasa.shared.core.flows import FlowsList
6
+ from rasa.shared.core.training_data.structures import StoryGraph
7
+ from rasa.shared.importers.importer import TrainingDataImporter
8
+ from rasa.shared.nlu.training_data.training_data import TrainingData
9
+ from rasa.shared.utils.common import cached_method
10
+
11
+ logger = logging.getLogger(__name__)
12
+
13
+
14
+ class StaticTrainingDataImporter(TrainingDataImporter):
15
+ """Static `TrainingFileImporter` implementation."""
16
+
17
+ def __init__(
18
+ self,
19
+ domain: Domain,
20
+ stories: Optional[StoryGraph] = None,
21
+ flows: Optional[FlowsList] = None,
22
+ nlu_data: Optional[TrainingData] = None,
23
+ config: Optional[Dict] = None,
24
+ ):
25
+ self.domain = domain
26
+ self.stories = stories or StoryGraph([])
27
+ self.flows = flows or FlowsList(underlying_flows=[])
28
+ self.nlu_data = nlu_data or TrainingData()
29
+ self.config = config or {}
30
+
31
+ @cached_method
32
+ def get_config(self) -> Dict:
33
+ """Retrieves model config (see parent class for full docstring)."""
34
+ return self.config
35
+
36
+ def get_config_file_for_auto_config(self) -> Optional[Text]:
37
+ """Returns config file path for auto-config only if there is a single one."""
38
+ return None
39
+
40
+ @cached_method
41
+ def get_stories(self, exclusion_percentage: Optional[int] = None) -> StoryGraph:
42
+ """Retrieves training stories / rules (see parent class for full docstring)."""
43
+ return self.stories
44
+
45
+ @cached_method
46
+ def get_flows(self) -> FlowsList:
47
+ """Retrieves training stories / rules (see parent class for full docstring)."""
48
+ return self.flows
49
+
50
+ @cached_method
51
+ def get_conversation_tests(self) -> StoryGraph:
52
+ """Retrieves conversation test stories (see parent class for full docstring)."""
53
+ return StoryGraph([])
54
+
55
+ @cached_method
56
+ def get_nlu_data(self, language: Optional[Text] = "en") -> TrainingData:
57
+ """Retrieves NLU training data (see parent class for full docstring)."""
58
+ return self.nlu_data
59
+
60
+ @cached_method
61
+ def get_domain(self) -> Domain:
62
+ """Retrieves model domain (see parent class for full docstring)."""
63
+ return self.domain
@@ -4,12 +4,3 @@ LITE_LLM_API_KEY_FIELD = "api_key"
4
4
  LITE_LLM_API_VERSION_FIELD = "api_version"
5
5
  LITE_LLM_MODEL_FIELD = "model"
6
6
  LITE_LLM_AZURE_AD_TOKEN = "azure_ad_token"
7
-
8
- # Enable or disable Langfuse integration
9
- RASA_LANGFUSE_INTEGRATION_ENABLED_ENV_VAR = "RASA_LANGFUSE_INTEGRATION_ENABLED"
10
- # Langfuse configuration
11
- LANGFUSE_CALLBACK_NAME = "langfuse"
12
- LANGFUSE_HOST_ENV_VAR = "LANGFUSE_HOST"
13
- LANGFUSE_PROJECT_ID_ENV_VAR = "LANGFUSE_PROJECT_ID"
14
- LANGFUSE_PUBLIC_KEY_ENV_VAR = "LANGFUSE_PUBLIC_KEY"
15
- LANGFUSE_SECRET_KEY_ENV_VAR = "LANGFUSE_SECRET_KEY"
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  import logging
4
4
  from abc import abstractmethod
5
- from typing import Any, Dict, List, Optional, Union, cast
5
+ from typing import Any, Dict, List, Union, cast
6
6
 
7
7
  import structlog
8
8
  from litellm import acompletion, completion, validate_environment
@@ -126,11 +126,7 @@ class _BaseLiteLLMClient:
126
126
  raise ProviderClientValidationError(event_info)
127
127
 
128
128
  @suppress_logs(log_level=logging.WARNING)
129
- def completion(
130
- self,
131
- messages: Union[List[dict], List[str], str],
132
- metadata: Optional[Dict[str, Any]] = None,
133
- ) -> LLMResponse:
129
+ def completion(self, messages: Union[List[dict], List[str], str]) -> LLMResponse:
134
130
  """Synchronously generate completions for given list of messages.
135
131
 
136
132
  Args:
@@ -142,7 +138,6 @@ class _BaseLiteLLMClient:
142
138
  - a list of messages. Each message is a string and will be formatted
143
139
  as a user message.
144
140
  - a single message as a string which will be formatted as user message.
145
- metadata: Optional metadata to be passed to the LLM call.
146
141
 
147
142
  Returns:
148
143
  List of message completions.
@@ -160,9 +155,7 @@ class _BaseLiteLLMClient:
160
155
 
161
156
  @suppress_logs(log_level=logging.WARNING)
162
157
  async def acompletion(
163
- self,
164
- messages: Union[List[dict], List[str], str],
165
- metadata: Optional[Dict[str, Any]] = None,
158
+ self, messages: Union[List[dict], List[str], str]
166
159
  ) -> LLMResponse:
167
160
  """Asynchronously generate completions for given list of messages.
168
161
 
@@ -175,7 +168,6 @@ class _BaseLiteLLMClient:
175
168
  - a list of messages. Each message is a string and will be formatted
176
169
  as a user message.
177
170
  - a single message as a string which will be formatted as user message.
178
- metadata: Optional metadata to be passed to the LLM call.
179
171
 
180
172
  Returns:
181
173
  List of message completions.
@@ -186,9 +178,7 @@ class _BaseLiteLLMClient:
186
178
  try:
187
179
  formatted_messages = self._get_formatted_messages(messages)
188
180
  arguments = resolve_environment_variables(self._completion_fn_args)
189
- response = await acompletion(
190
- messages=formatted_messages, metadata=metadata, **arguments
191
- )
181
+ response = await acompletion(messages=formatted_messages, **arguments)
192
182
  return self._format_response(response)
193
183
  except Exception as e:
194
184
  message = ""
@@ -101,11 +101,11 @@ class DefaultLiteLLMClient(_BaseLiteLLMClient):
101
101
  # SageMaker) in Rasa by allowing AWS secrets to be provided as extra
102
102
  # parameters without triggering validation errors due to missing AWS
103
103
  # environment variables.
104
- if self.provider.lower() in [
104
+ if self.provider.lower() in {
105
105
  AWS_BEDROCK_PROVIDER,
106
106
  AWS_SAGEMAKER_PROVIDER,
107
107
  AWS_SAGEMAKER_CHAT_PROVIDER,
108
- ]:
108
+ }:
109
109
  validate_aws_setup_for_litellm_clients(
110
110
  self._litellm_model_name,
111
111
  self._litellm_extra_parameters,
@@ -1,7 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import logging
4
- from typing import Any, Dict, List, Optional, Union
4
+ from typing import Any, Dict, List, Union
5
5
 
6
6
  import structlog
7
7
 
@@ -122,12 +122,9 @@ class LiteLLMRouterLLMClient(_BaseLiteLLMRouterClient, _BaseLiteLLMClient):
122
122
  raise ProviderClientAPIException(e)
123
123
 
124
124
  @suppress_logs(log_level=logging.WARNING)
125
- def completion(
126
- self,
127
- messages: Union[List[dict], List[str], str],
128
- metadata: Optional[Dict[str, Any]] = None,
129
- ) -> LLMResponse:
130
- """Synchronously generate completions for given list of messages.
125
+ def completion(self, messages: Union[List[dict], List[str], str]) -> LLMResponse:
126
+ """
127
+ Synchronously generate completions for given list of messages.
131
128
 
132
129
  Method overrides the base class method to call the appropriate
133
130
  completion method based on the configuration. If the chat completions
@@ -143,11 +140,8 @@ class LiteLLMRouterLLMClient(_BaseLiteLLMRouterClient, _BaseLiteLLMClient):
143
140
  - a list of messages. Each message is a string and will be formatted
144
141
  as a user message.
145
142
  - a single message as a string which will be formatted as user message.
146
- metadata: Optional metadata to be passed to the LLM call.
147
-
148
143
  Returns:
149
144
  List of message completions.
150
-
151
145
  Raises:
152
146
  ProviderClientAPIException: If the API request fails.
153
147
  """
@@ -164,11 +158,10 @@ class LiteLLMRouterLLMClient(_BaseLiteLLMRouterClient, _BaseLiteLLMClient):
164
158
 
165
159
  @suppress_logs(log_level=logging.WARNING)
166
160
  async def acompletion(
167
- self,
168
- messages: Union[List[dict], List[str], str],
169
- metadata: Optional[Dict[str, Any]] = None,
161
+ self, messages: Union[List[dict], List[str], str]
170
162
  ) -> LLMResponse:
171
- """Asynchronously generate completions for given list of messages.
163
+ """
164
+ Asynchronously generate completions for given list of messages.
172
165
 
173
166
  Method overrides the base class method to call the appropriate
174
167
  completion method based on the configuration. If the chat completions
@@ -184,11 +177,8 @@ class LiteLLMRouterLLMClient(_BaseLiteLLMRouterClient, _BaseLiteLLMClient):
184
177
  - a list of messages. Each message is a string and will be formatted
185
178
  as a user message.
186
179
  - a single message as a string which will be formatted as user message.
187
- metadata: Optional metadata to be passed to the LLM call.
188
-
189
180
  Returns:
190
181
  List of message completions.
191
-
192
182
  Raises:
193
183
  ProviderClientAPIException: If the API request fails.
194
184
  """
@@ -1,19 +1,21 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import Any, Dict, List, Optional, Protocol, Union, runtime_checkable
3
+ from typing import Dict, List, Protocol, Union, runtime_checkable
4
4
 
5
5
  from rasa.shared.providers.llm.llm_response import LLMResponse
6
6
 
7
7
 
8
8
  @runtime_checkable
9
9
  class LLMClient(Protocol):
10
- """Protocol for an LLM client that specifies the interface for interacting
10
+ """
11
+ Protocol for an LLM client that specifies the interface for interacting
11
12
  with the API.
12
13
  """
13
14
 
14
15
  @classmethod
15
16
  def from_config(cls, config: dict) -> LLMClient:
16
- """Initializes the llm client with the given configuration.
17
+ """
18
+ Initializes the llm client with the given configuration.
17
19
 
18
20
  This class method should be implemented to parse the given
19
21
  configuration and create an instance of an llm client.
@@ -22,24 +24,17 @@ class LLMClient(Protocol):
22
24
 
23
25
  @property
24
26
  def config(self) -> Dict:
25
- """Returns the configuration for that the llm client is initialized with.
27
+ """
28
+ Returns the configuration for that the llm client is initialized with.
26
29
 
27
30
  This property should be implemented to return a dictionary containing
28
31
  the configuration settings for the llm client.
29
32
  """
30
33
  ...
31
34
 
32
- def completion(
33
- self,
34
- messages: Union[List[dict], List[str], str],
35
- metadata: Optional[Dict[str, Any]] = None,
36
- ) -> LLMResponse:
37
- """Synchronously generate completions for given list of messages.
38
- def completion(
39
- self,
40
- messages: Union[List[dict], List[str], str],
41
- metadata: Optional[Dict[str, Any]] = None,
42
- ) -> LLMResponse:
35
+ def completion(self, messages: Union[List[dict], List[str], str]) -> LLMResponse:
36
+ """
37
+ Synchronously generate completions for given list of messages.
43
38
 
44
39
  This method should be implemented to take a list of messages (as
45
40
  strings) and return a list of completions (as strings).
@@ -53,19 +48,16 @@ class LLMClient(Protocol):
53
48
  - a list of messages. Each message is a string and will be formatted
54
49
  as a user message.
55
50
  - a single message as a string which will be formatted as user message.
56
- metadata: Optional metadata to be passed to the LLM call.
57
-
58
51
  Returns:
59
52
  LLMResponse
60
53
  """
61
54
  ...
62
55
 
63
56
  async def acompletion(
64
- self,
65
- messages: Union[List[dict], List[str], str],
66
- metadata: Optional[Dict[str, Any]] = None,
57
+ self, messages: Union[List[dict], List[str], str]
67
58
  ) -> LLMResponse:
68
- """Asynchronously generate completions for given list of messages.
59
+ """
60
+ Asynchronously generate completions for given list of messages.
69
61
 
70
62
  This method should be implemented to take a list of messages (as
71
63
  strings) and return a list of completions (as strings).
@@ -79,15 +71,14 @@ class LLMClient(Protocol):
79
71
  - a list of messages. Each message is a string and will be formatted
80
72
  as a user message.
81
73
  - a single message as a string which will be formatted as user message.
82
- metadata: Optional metadata to be passed to the LLM call.
83
-
84
74
  Returns:
85
75
  LLMResponse
86
76
  """
87
77
  ...
88
78
 
89
79
  def validate_client_setup(self, *args, **kwargs) -> None: # type: ignore
90
- """Perform client setup validation.
80
+ """
81
+ Perform client setup validation.
91
82
 
92
83
  This method should be implemented to validate whether the client can be
93
84
  used with the parameters provided through configuration or environment
@@ -237,9 +237,7 @@ class SelfHostedLLMClient(_BaseLiteLLMClient):
237
237
  raise ProviderClientAPIException(e)
238
238
 
239
239
  async def acompletion(
240
- self,
241
- messages: Union[List[dict], List[str], str],
242
- metadata: Optional[Dict[str, Any]] = None,
240
+ self, messages: Union[List[dict], List[str], str]
243
241
  ) -> LLMResponse:
244
242
  """Asynchronous completion of the model with the given messages.
245
243
 
@@ -257,7 +255,6 @@ class SelfHostedLLMClient(_BaseLiteLLMClient):
257
255
  - a list of messages. Each message is a string and will be formatted
258
256
  as a user message.
259
257
  - a single message as a string which will be formatted as user message.
260
- metadata: Optional metadata to be passed to the LLM call.
261
258
 
262
259
  Returns:
263
260
  The completion response.
@@ -266,11 +263,7 @@ class SelfHostedLLMClient(_BaseLiteLLMClient):
266
263
  return await super().acompletion(messages)
267
264
  return await self._atext_completion(messages)
268
265
 
269
- def completion(
270
- self,
271
- messages: Union[List[dict], List[str], str],
272
- metadata: Optional[Dict[str, Any]] = None,
273
- ) -> LLMResponse:
266
+ def completion(self, messages: Union[List[dict], List[str], str]) -> LLMResponse:
274
267
  """Completion of the model with the given messages.
275
268
 
276
269
  Method overrides the base class method to call the appropriate
@@ -280,7 +273,6 @@ class SelfHostedLLMClient(_BaseLiteLLMClient):
280
273
 
281
274
  Args:
282
275
  messages: The messages to be used for completion.
283
- metadata: Optional metadata to be passed to the LLM call.
284
276
 
285
277
  Returns:
286
278
  The completion response.
@@ -1,4 +1,5 @@
1
1
  import asyncio
2
+ import copy
2
3
  import functools
3
4
  import importlib
4
5
  import inspect
@@ -288,6 +289,47 @@ def merge_lists_of_dicts(
288
289
  return list(merged_dicts.values())
289
290
 
290
291
 
292
+ def partial_merge_list(
293
+ self_list: List[Any],
294
+ other_list: List[Any],
295
+ is_same_item_fn: Callable[[Any, Any], bool],
296
+ ) -> List[Any]:
297
+ """Merges two lists based on a custom intersection logic."""
298
+ matched_other_indices = set()
299
+ result = []
300
+
301
+ for s_item in self_list:
302
+ match = next(
303
+ (
304
+ (i, o_item)
305
+ for i, o_item in enumerate(other_list)
306
+ if i not in matched_other_indices and is_same_item_fn(s_item, o_item)
307
+ ),
308
+ None,
309
+ )
310
+ if match:
311
+ i, o_item = match
312
+ result.append(copy.deepcopy(o_item))
313
+ matched_other_indices.add(i)
314
+ else:
315
+ result.append(copy.deepcopy(s_item))
316
+
317
+ return result
318
+
319
+
320
+ def partial_merge_dict(
321
+ self_d: Dict[Text, Any], other_d: Dict[Text, Any]
322
+ ) -> Dict[Text, Any]:
323
+ """Merges two dictionaries based on a custom intersection logic."""
324
+ merged = {}
325
+ for k, v in self_d.items():
326
+ if k in other_d:
327
+ merged[k] = copy.deepcopy(other_d[k])
328
+ else:
329
+ merged[k] = copy.deepcopy(v)
330
+ return merged
331
+
332
+
291
333
  def warn_and_exit_if_module_path_contains_rasa_plus(
292
334
  module_path: Text, lookup_path: Optional[str] = None
293
335
  ) -> None:
@@ -342,7 +384,7 @@ def display_research_study_prompt() -> None:
342
384
  {separator}
343
385
  Want to help shape the future of Rasa Pro?
344
386
  Share your feedback in a short conversation with our team.
345
- Sign up at: https://calendly.com/alvaro-rasa/rasa-pro-installation
387
+ Sign up at: https://rasa.com/book-feedback-call
346
388
  {separator}
347
389
  """
348
390
  print_success(message)
rasa/shared/utils/llm.py CHANGED
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  import importlib.resources
2
4
  import json
3
5
  import logging
@@ -20,15 +22,23 @@ from typing import (
20
22
  )
21
23
 
22
24
  import structlog
25
+ from pydantic import BaseModel, Field
23
26
 
24
27
  import rasa.shared.utils.io
25
- from rasa.core.utils import AvailableEndpoints
28
+ from rasa.core.available_endpoints import AvailableEndpoints
26
29
  from rasa.shared.constants import (
30
+ CONFIG_NAME_KEY,
31
+ CONFIG_PIPELINE_KEY,
32
+ CONFIG_POLICIES_KEY,
27
33
  DEFAULT_PROMPT_PACKAGE_NAME,
34
+ LLM_CONFIG_KEY,
28
35
  MODEL_CONFIG_KEY,
29
36
  MODEL_GROUP_CONFIG_KEY,
30
37
  MODEL_GROUP_ID_CONFIG_KEY,
38
+ MODEL_GROUPS_CONFIG_KEY,
31
39
  MODELS_CONFIG_KEY,
40
+ PROMPT_CONFIG_KEY,
41
+ PROMPT_TEMPLATE_CONFIG_KEY,
32
42
  PROVIDER_CONFIG_KEY,
33
43
  RASA_PATTERN_INTERNAL_ERROR_USER_INPUT_EMPTY,
34
44
  RASA_PATTERN_INTERNAL_ERROR_USER_INPUT_TOO_LONG,
@@ -63,6 +73,7 @@ from rasa.shared.providers.mappings import (
63
73
  get_embedding_client_from_provider,
64
74
  get_llm_client_from_provider,
65
75
  )
76
+ from rasa.shared.utils.common import all_subclasses
66
77
  from rasa.shared.utils.constants import LOG_COMPONENT_SOURCE_METHOD_INIT
67
78
 
68
79
  if TYPE_CHECKING:
@@ -110,6 +121,18 @@ _CombineConfigs_F = TypeVar(
110
121
  )
111
122
 
112
123
 
124
+ class SystemPrompts(BaseModel):
125
+ command_generator: str = Field(
126
+ ..., description="Prompt used by the LLM command generator."
127
+ )
128
+ enterprise_search: str = Field(
129
+ ..., description="Prompt for standard enterprise search requests."
130
+ )
131
+ contextual_response_rephraser: str = Field(
132
+ ..., description="Prompt used for re-phrasing assistant responses."
133
+ )
134
+
135
+
113
136
  def _compute_hash_for_cache_from_configs(
114
137
  config_x: Dict[str, Any], config_y: Dict[str, Any]
115
138
  ) -> int:
@@ -821,7 +844,9 @@ def allowed_values_for_slot(slot: Slot) -> Union[str, None]:
821
844
 
822
845
 
823
846
  def resolve_model_client_config(
824
- model_config: Optional[Dict[str, Any]], component_name: Optional[str] = None
847
+ model_config: Optional[Dict[str, Any]],
848
+ component_name: Optional[str] = None,
849
+ model_groups: Optional[List[Dict[str, Any]]] = None,
825
850
  ) -> Optional[Dict[str, Any]]:
826
851
  """Resolve the model group in the model config.
827
852
 
@@ -835,6 +860,7 @@ def resolve_model_client_config(
835
860
  model_config: The model config to be resolved.
836
861
  component_name: The name of the component.
837
862
  component_name: The method of the component.
863
+ model_groups: Model groups from endpoints.yml.
838
864
 
839
865
  Returns:
840
866
  The resolved llm config.
@@ -861,7 +887,12 @@ def resolve_model_client_config(
861
887
 
862
888
  model_group_id = model_config.get(MODEL_GROUP_CONFIG_KEY)
863
889
 
864
- endpoints = AvailableEndpoints.get_instance()
890
+ # If `model_groups` is provided, use it to initialise `AvailableEndpoints`,
891
+ # since `get_instance()` reads from the local endpoints file instead.
892
+ if model_groups:
893
+ endpoints = AvailableEndpoints(model_groups=model_groups)
894
+ else:
895
+ endpoints = AvailableEndpoints.get_instance()
865
896
  if endpoints.model_groups is None:
866
897
  _raise_invalid_config_exception(
867
898
  reason=(
@@ -919,3 +950,124 @@ async def create_tracker_for_user_step(
919
950
 
920
951
  # store the tracker with the unique sender id
921
952
  await agent.tracker_store.save(tracker)
953
+
954
+
955
+ def check_prompt_config_keys_and_warn_if_deprecated(
956
+ config: dict, component_source: str
957
+ ) -> None:
958
+ """Checks and warns about deprecated config parameters."""
959
+ if PROMPT_CONFIG_KEY in config and PROMPT_TEMPLATE_CONFIG_KEY in config:
960
+ structlogger.warning(
961
+ f"{component_source}.init"
962
+ ".both_deprecated_and_non_deprecated_config_keys_used_at_the_same_time",
963
+ event_info=(
964
+ f"Both '{PROMPT_CONFIG_KEY}' and '{PROMPT_TEMPLATE_CONFIG_KEY}' "
965
+ f"are present in the config. '{PROMPT_CONFIG_KEY}' will be ignored "
966
+ f"in favor of {PROMPT_TEMPLATE_CONFIG_KEY}."
967
+ ),
968
+ )
969
+
970
+ # 'prompt' config key is deprecated in favor of 'prompt_template'
971
+ if PROMPT_CONFIG_KEY in config:
972
+ structlogger.warning(
973
+ f"{component_source}.init.deprecated_config_key",
974
+ event_info=(
975
+ f"The config parameter '{PROMPT_CONFIG_KEY}' is deprecated "
976
+ "and will be removed in Rasa 4.0.0. "
977
+ f"Please use the config parameter '{PROMPT_TEMPLATE_CONFIG_KEY}'"
978
+ f" instead. "
979
+ ),
980
+ )
981
+
982
+
983
+ def _get_llm_command_generator_config(
984
+ config: Dict[Text, Any],
985
+ ) -> Optional[Dict[Text, Any]]:
986
+ """Get the llm command generator config from config.yml.
987
+
988
+ Args:
989
+ config: The config.yml file data.
990
+
991
+ Returns:
992
+ The llm command generator config.
993
+ """
994
+ from rasa.dialogue_understanding.generator import LLMBasedCommandGenerator
995
+
996
+ # Collect all LLM based Command Generator class names.
997
+ command_generator_subclasses = all_subclasses(LLMBasedCommandGenerator)
998
+ command_generator_class_names = [
999
+ command_generator.__name__ for command_generator in command_generator_subclasses
1000
+ ]
1001
+
1002
+ # Read the LLM config of the Command Generator from the config.yml file.
1003
+ pipelines = config.get(CONFIG_PIPELINE_KEY, [])
1004
+ for pipeline in pipelines:
1005
+ if pipeline.get(CONFIG_NAME_KEY) in command_generator_class_names:
1006
+ return pipeline.get(LLM_CONFIG_KEY)
1007
+
1008
+ return None
1009
+
1010
+
1011
+ def _get_command_generator_prompt(
1012
+ config: Dict[Text, Any], endpoints: Dict[Text, Any]
1013
+ ) -> Text:
1014
+ """Get the command generator prompt based on the config."""
1015
+ from rasa.dialogue_understanding.generator.single_step.compact_llm_command_generator import ( # noqa: E501
1016
+ DEFAULT_COMMAND_PROMPT_TEMPLATE_FILE_NAME,
1017
+ FALLBACK_COMMAND_PROMPT_TEMPLATE_FILE_NAME,
1018
+ MODEL_PROMPT_MAPPER,
1019
+ )
1020
+
1021
+ model_config = _get_llm_command_generator_config(config)
1022
+ llm_config = resolve_model_client_config(
1023
+ model_config=model_config,
1024
+ model_groups=endpoints.get(MODEL_GROUPS_CONFIG_KEY),
1025
+ )
1026
+ return get_default_prompt_template_based_on_model(
1027
+ llm_config=llm_config,
1028
+ model_prompt_mapping=MODEL_PROMPT_MAPPER,
1029
+ default_prompt_path=DEFAULT_COMMAND_PROMPT_TEMPLATE_FILE_NAME,
1030
+ fallback_prompt_path=FALLBACK_COMMAND_PROMPT_TEMPLATE_FILE_NAME,
1031
+ )
1032
+
1033
+
1034
+ def _get_enterprise_search_prompt(config: Dict[Text, Any]) -> Text:
1035
+ """Get the enterprise search prompt based on the config."""
1036
+ from rasa.core.policies.enterprise_search_policy import EnterpriseSearchPolicy
1037
+
1038
+ def get_enterprise_search_config() -> Dict[Text, Any]:
1039
+ policies = config.get(CONFIG_POLICIES_KEY, [])
1040
+ for policy in policies:
1041
+ if policy.get(CONFIG_NAME_KEY) == EnterpriseSearchPolicy.__name__:
1042
+ return policy
1043
+
1044
+ return {}
1045
+
1046
+ enterprise_search_config = get_enterprise_search_config()
1047
+ return EnterpriseSearchPolicy.get_system_default_prompt_based_on_config(
1048
+ enterprise_search_config
1049
+ )
1050
+
1051
+
1052
+ def get_system_default_prompts(
1053
+ config: Dict[Text, Any], endpoints: Dict[Text, Any]
1054
+ ) -> SystemPrompts:
1055
+ """
1056
+ Returns the system default prompts for the component.
1057
+
1058
+ Args:
1059
+ config: The config.yml file data.
1060
+ endpoints: The endpoints.yml file data.
1061
+
1062
+ Returns:
1063
+ SystemPrompts: A Pydantic model containing all default prompts.
1064
+ """
1065
+ from rasa.core.nlg.contextual_response_rephraser import (
1066
+ DEFAULT_RESPONSE_VARIATION_PROMPT_TEMPLATE,
1067
+ )
1068
+
1069
+ return SystemPrompts(
1070
+ command_generator=_get_command_generator_prompt(config, endpoints),
1071
+ enterprise_search=_get_enterprise_search_prompt(config),
1072
+ contextual_response_rephraser=DEFAULT_RESPONSE_VARIATION_PROMPT_TEMPLATE,
1073
+ )
rasa/shared/utils/yaml.py CHANGED
@@ -21,6 +21,7 @@ from ruamel.yaml import YAML, RoundTripRepresenter, YAMLError
21
21
  from ruamel.yaml.comments import CommentedMap, CommentedSeq
22
22
  from ruamel.yaml.constructor import BaseConstructor, DuplicateKeyError, ScalarNode
23
23
  from ruamel.yaml.loader import SafeLoader
24
+ from ruamel.yaml.scalarstring import LiteralScalarString
24
25
 
25
26
  from rasa.shared.constants import (
26
27
  ASSERTIONS_SCHEMA_EXTENSIONS_FILE,
@@ -794,6 +795,25 @@ def write_yaml(
794
795
  should_preserve_key_order: Whether to force preserve key order in `data`.
795
796
  transform: A function to transform the data before writing it to the file.
796
797
  """
798
+
799
+ def multiline_str_representer(self: Any, value: str) -> Any:
800
+ """Dump multi-line strings as readable YAML block scalars where possible."""
801
+ if "\n" in value:
802
+ # First line after the newline decides: paragraph vs. snippet
803
+ first_line = value.split("\n", 1)[1]
804
+
805
+ # If the first line after the newline is not indented, treat the value
806
+ # as plain text. Indented text is likely pre-formatted YAML/JSON/etc.
807
+ if not first_line.startswith((" ", "\t")):
808
+ return self.represent_scalar(
809
+ "tag:yaml.org,2002:str",
810
+ LiteralScalarString(value),
811
+ style="|",
812
+ )
813
+
814
+ # Fallback: keep default YAML scalar style (plain/quoted)
815
+ return self.represent_scalar("tag:yaml.org,2002:str", value)
816
+
797
817
  _enable_ordered_dict_yaml_dumping()
798
818
 
799
819
  if should_preserve_key_order:
@@ -808,6 +828,7 @@ def write_yaml(
808
828
  type(None),
809
829
  lambda self, _: self.represent_scalar("tag:yaml.org,2002:null", "null"),
810
830
  )
831
+ dumper.representer.add_representer(str, multiline_str_representer)
811
832
 
812
833
  if isinstance(target, StringIO):
813
834
  dumper.dump(data, target, transform=transform)
@@ -1025,6 +1046,17 @@ def validate_yaml_with_jsonschema(
1025
1046
  except (YAMLError, DuplicateKeyError) as e:
1026
1047
  raise YamlSyntaxException(underlying_yaml_exception=e)
1027
1048
 
1049
+ validate_data_with_jsonschema(source_data, schema_content, humanize_error)
1050
+
1051
+
1052
+ def validate_data_with_jsonschema(
1053
+ source_data: Any,
1054
+ schema_content: Any,
1055
+ humanize_error: Callable[
1056
+ [jsonschema.ValidationError], str
1057
+ ] = default_error_humanizer,
1058
+ ) -> None:
1059
+ """Validate Python object against the provided jsonschema content."""
1028
1060
  try:
1029
1061
  jsonschema.validate(source_data, schema_content)
1030
1062
  except jsonschema.ValidationError as error: