rasa-pro 3.12.18__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 (330) hide show
  1. rasa/__main__.py +3 -4
  2. rasa/api.py +1 -1
  3. rasa/builder/create_openai_vector_store.py +69 -0
  4. rasa/builder/llm-helper-schema.json +69 -0
  5. rasa/builder/prompt_to_bot.py +645 -0
  6. rasa/builder/scrape_rasa_docs.py +97 -0
  7. rasa/builder/skill_to_bot_prompt.jinja +158 -0
  8. rasa/cli/dialogue_understanding_test.py +1 -1
  9. rasa/cli/e2e_test.py +1 -1
  10. rasa/cli/evaluate.py +2 -2
  11. rasa/cli/export.py +3 -3
  12. rasa/cli/llm_fine_tuning.py +1 -1
  13. rasa/cli/project_templates/default/config.yml +5 -32
  14. rasa/cli/project_templates/{calm → default}/e2e_tests/cancelations/user_cancels_during_a_correction.yml +1 -1
  15. rasa/cli/project_templates/{calm → default}/e2e_tests/cancelations/user_changes_mind_on_a_whim.yml +1 -1
  16. rasa/cli/project_templates/{calm → default}/e2e_tests/corrections/user_corrects_contact_handle.yml +1 -1
  17. rasa/cli/project_templates/{calm → default}/e2e_tests/corrections/user_corrects_contact_name.yml +1 -1
  18. rasa/cli/project_templates/{calm → default}/e2e_tests/happy_paths/user_adds_contact_to_their_list.yml +1 -1
  19. rasa/cli/project_templates/{calm → default}/e2e_tests/happy_paths/user_lists_contacts.yml +1 -1
  20. rasa/cli/project_templates/{calm → default}/e2e_tests/happy_paths/user_removes_contact.yml +1 -1
  21. rasa/cli/project_templates/{calm → default}/e2e_tests/happy_paths/user_removes_contact_from_list.yml +1 -1
  22. rasa/cli/project_templates/default/endpoints.yml +18 -2
  23. rasa/cli/project_templates/defaults.py +133 -0
  24. rasa/cli/run.py +1 -1
  25. rasa/cli/scaffold.py +2 -3
  26. rasa/cli/studio/download.py +1 -1
  27. rasa/cli/studio/link.py +53 -0
  28. rasa/cli/studio/pull.py +78 -0
  29. rasa/cli/studio/push.py +78 -0
  30. rasa/cli/studio/studio.py +12 -0
  31. rasa/cli/studio/upload.py +5 -3
  32. rasa/cli/train.py +1 -1
  33. rasa/cli/utils.py +1 -1
  34. rasa/cli/x.py +1 -1
  35. rasa/constants.py +2 -0
  36. rasa/core/__init__.py +0 -16
  37. rasa/core/actions/action.py +43 -29
  38. rasa/core/actions/action_repeat_bot_messages.py +18 -22
  39. rasa/core/actions/action_run_slot_rejections.py +1 -2
  40. rasa/core/agent.py +18 -3
  41. rasa/core/available_endpoints.py +146 -0
  42. rasa/core/brokers/kafka.py +4 -0
  43. rasa/core/brokers/pika.py +5 -2
  44. rasa/core/brokers/sql.py +1 -1
  45. rasa/core/channels/botframework.py +2 -2
  46. rasa/core/channels/channel.py +2 -2
  47. rasa/core/channels/development_inspector.py +1 -1
  48. rasa/core/channels/facebook.py +1 -4
  49. rasa/core/channels/hangouts.py +8 -5
  50. rasa/core/channels/inspector/.eslintrc.cjs +12 -6
  51. rasa/core/channels/inspector/.prettierrc +5 -0
  52. rasa/core/channels/inspector/README.md +11 -5
  53. rasa/core/channels/inspector/dist/assets/{arc-9f75cc3b.js → arc-02053cc1.js} +1 -1
  54. rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-7f34db23.js → blockDiagram-38ab4fdb-008b6289.js} +1 -1
  55. rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-948bab2c.js → c4Diagram-3d4e48cf-fb2597be.js} +1 -1
  56. rasa/core/channels/inspector/dist/assets/channel-078dada8.js +1 -0
  57. rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-53b0dd0e.js → classDiagram-70f12bd4-7f847e00.js} +1 -1
  58. rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-fdf789e7.js → classDiagram-v2-f2320105-ba1d689b.js} +1 -1
  59. rasa/core/channels/inspector/dist/assets/clone-5b4516de.js +1 -0
  60. rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-87c4ece5.js → createText-2e5e7dd3-dd8e67c4.js} +1 -1
  61. rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-5a8b0749.js → edges-e0da2a9e-10784939.js} +1 -1
  62. rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-66da90e2.js → erDiagram-9861fffd-24947ae6.js} +1 -1
  63. rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-10044f05.js → flowDb-956e92f1-a9ced505.js} +1 -1
  64. rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-f338f66a.js → flowDiagram-66a62f08-afda9c7c.js} +1 -1
  65. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-f9613071.js +1 -0
  66. rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-b13140aa.js → flowchart-elk-definition-4a651766-6ef530b8.js} +1 -1
  67. rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-f2b4a55a.js → ganttDiagram-c361ad54-0c7dd39a.js} +1 -1
  68. rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-dedc298d.js → gitGraphDiagram-72cf32ee-b57239d6.js} +1 -1
  69. rasa/core/channels/inspector/dist/assets/{graph-4ede11ff.js → graph-9ed57cec.js} +1 -1
  70. rasa/core/channels/inspector/dist/assets/{index-3862675e-65549d37.js → index-3862675e-233090de.js} +1 -1
  71. rasa/core/channels/inspector/dist/assets/{index-3a23e736.js → index-72184470.js} +123 -123
  72. rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-65439671.js → infoDiagram-f8f76790-aa116649.js} +1 -1
  73. rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-56d03d98.js → journeyDiagram-49397b02-e51877cc.js} +1 -1
  74. rasa/core/channels/inspector/dist/assets/{layout-dd48f7f4.js → layout-3ca3798c.js} +1 -1
  75. rasa/core/channels/inspector/dist/assets/{line-1569ad2c.js → line-26ee10d3.js} +1 -1
  76. rasa/core/channels/inspector/dist/assets/{linear-48bf4935.js → linear-aedded32.js} +1 -1
  77. rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-688504c1.js → mindmap-definition-fc14e90a-d8957261.js} +1 -1
  78. rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-78b6d7e6.js → pieDiagram-8a3498a8-d771f885.js} +1 -1
  79. rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-048b84b3.js → quadrantDiagram-120e2f19-09fdf50c.js} +1 -1
  80. rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-dd67f107.js → requirementDiagram-deff3bca-9f0af02e.js} +1 -1
  81. rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-8128436e.js → sankeyDiagram-04a897e0-84415b37.js} +1 -1
  82. rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-1a0d1461.js → sequenceDiagram-704730f1-8dec4055.js} +1 -1
  83. rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-46d388ed.js → stateDiagram-587899a1-c5431d07.js} +1 -1
  84. rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-ea42951a.js → stateDiagram-v2-d93cdb3a-274e77d9.js} +1 -1
  85. rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-7427ed0c.js → styles-6aaf32cf-e364a1d7.js} +1 -1
  86. rasa/core/channels/inspector/dist/assets/{styles-9a916d00-ff5e5a16.js → styles-9a916d00-0dae36f6.js} +1 -1
  87. rasa/core/channels/inspector/dist/assets/{styles-c10674c1-7b3680cf.js → styles-c10674c1-c4641675.js} +1 -1
  88. rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-f860f2ad.js → svgDrawCommon-08f97a94-831fe9a1.js} +1 -1
  89. rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-2eebf0c8.js → timeline-definition-85554ec2-c3304b3a.js} +1 -1
  90. rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-5d7f4e96.js → xychartDiagram-e933f94c-da799369.js} +1 -1
  91. rasa/core/channels/inspector/dist/index.html +1 -1
  92. rasa/core/channels/inspector/package.json +3 -1
  93. rasa/core/channels/inspector/src/App.tsx +91 -90
  94. rasa/core/channels/inspector/src/components/Chat.tsx +45 -41
  95. rasa/core/channels/inspector/src/components/DiagramFlow.tsx +40 -40
  96. rasa/core/channels/inspector/src/components/DialogueInformation.tsx +57 -57
  97. rasa/core/channels/inspector/src/components/DialogueStack.tsx +36 -27
  98. rasa/core/channels/inspector/src/components/ExpandIcon.tsx +4 -4
  99. rasa/core/channels/inspector/src/components/FullscreenButton.tsx +7 -7
  100. rasa/core/channels/inspector/src/components/LoadingSpinner.tsx +28 -12
  101. rasa/core/channels/inspector/src/components/NoActiveFlow.tsx +9 -9
  102. rasa/core/channels/inspector/src/components/RasaLogo.tsx +5 -5
  103. rasa/core/channels/inspector/src/components/RecruitmentPanel.tsx +55 -60
  104. rasa/core/channels/inspector/src/components/SaraDiagrams.tsx +5 -5
  105. rasa/core/channels/inspector/src/components/Slots.tsx +22 -22
  106. rasa/core/channels/inspector/src/components/Welcome.tsx +28 -31
  107. rasa/core/channels/inspector/src/helpers/audio/audiostream.ts +245 -0
  108. rasa/core/channels/inspector/src/helpers/audio/microphone-processor.js +12 -0
  109. rasa/core/channels/inspector/src/helpers/audio/playback-processor.js +36 -0
  110. rasa/core/channels/inspector/src/helpers/conversation.ts +7 -7
  111. rasa/core/channels/inspector/src/helpers/formatters.test.ts +181 -181
  112. rasa/core/channels/inspector/src/helpers/formatters.ts +111 -111
  113. rasa/core/channels/inspector/src/helpers/utils.ts +78 -61
  114. rasa/core/channels/inspector/src/main.tsx +8 -8
  115. rasa/core/channels/inspector/src/theme/Button/Button.ts +8 -8
  116. rasa/core/channels/inspector/src/theme/Heading/Heading.ts +7 -7
  117. rasa/core/channels/inspector/src/theme/Input/Input.ts +9 -9
  118. rasa/core/channels/inspector/src/theme/Link/Link.ts +6 -6
  119. rasa/core/channels/inspector/src/theme/Modal/Modal.ts +13 -13
  120. rasa/core/channels/inspector/src/theme/Table/Table.tsx +10 -10
  121. rasa/core/channels/inspector/src/theme/Tooltip/Tooltip.ts +5 -5
  122. rasa/core/channels/inspector/src/theme/base/breakpoints.ts +7 -7
  123. rasa/core/channels/inspector/src/theme/base/colors.ts +64 -64
  124. rasa/core/channels/inspector/src/theme/base/fonts/fontFaces.css +21 -18
  125. rasa/core/channels/inspector/src/theme/base/radii.ts +8 -8
  126. rasa/core/channels/inspector/src/theme/base/shadows.ts +5 -5
  127. rasa/core/channels/inspector/src/theme/base/sizes.ts +5 -5
  128. rasa/core/channels/inspector/src/theme/base/space.ts +12 -12
  129. rasa/core/channels/inspector/src/theme/base/styles.ts +5 -5
  130. rasa/core/channels/inspector/src/theme/base/typography.ts +12 -12
  131. rasa/core/channels/inspector/src/theme/base/zIndices.ts +3 -3
  132. rasa/core/channels/inspector/src/theme/index.ts +38 -38
  133. rasa/core/channels/inspector/src/types.ts +56 -50
  134. rasa/core/channels/inspector/yarn.lock +5 -0
  135. rasa/core/channels/mattermost.py +1 -1
  136. rasa/core/channels/rasa_chat.py +2 -4
  137. rasa/core/channels/rest.py +5 -4
  138. rasa/core/channels/socketio.py +56 -41
  139. rasa/core/channels/studio_chat.py +337 -71
  140. rasa/core/channels/vier_cvg.py +1 -2
  141. rasa/core/channels/voice_ready/audiocodes.py +4 -11
  142. rasa/core/channels/voice_stream/audiocodes.py +8 -5
  143. rasa/core/channels/voice_stream/browser_audio.py +1 -1
  144. rasa/core/channels/voice_stream/genesys.py +2 -2
  145. rasa/core/channels/voice_stream/tts/__init__.py +8 -0
  146. rasa/core/channels/voice_stream/twilio_media_streams.py +10 -5
  147. rasa/core/channels/voice_stream/voice_channel.py +65 -23
  148. rasa/core/concurrent_lock_store.py +24 -10
  149. rasa/core/evaluation/marker_tracker_loader.py +1 -1
  150. rasa/core/exporter.py +1 -1
  151. rasa/core/http_interpreter.py +3 -7
  152. rasa/core/information_retrieval/faiss.py +18 -11
  153. rasa/core/information_retrieval/ingestion/__init__.py +0 -0
  154. rasa/core/information_retrieval/ingestion/faq_parser.py +158 -0
  155. rasa/core/jobs.py +2 -1
  156. rasa/core/lock_store.py +151 -60
  157. rasa/core/nlg/contextual_response_rephraser.py +17 -7
  158. rasa/core/nlg/generator.py +5 -22
  159. rasa/core/nlg/interpolator.py +2 -3
  160. rasa/core/nlg/response.py +6 -43
  161. rasa/core/nlg/summarize.py +1 -1
  162. rasa/core/nlg/translate.py +0 -8
  163. rasa/core/policies/enterprise_search_policy.py +262 -62
  164. rasa/core/policies/enterprise_search_prompt_with_relevancy_check_and_citation_template.jinja2 +63 -0
  165. rasa/core/policies/flow_policy.py +1 -1
  166. rasa/core/policies/flows/flow_executor.py +96 -17
  167. rasa/core/policies/intentless_policy.py +56 -17
  168. rasa/core/processor.py +64 -49
  169. rasa/core/run.py +33 -11
  170. rasa/core/tracker_stores/__init__.py +0 -0
  171. rasa/core/{auth_retry_tracker_store.py → tracker_stores/auth_retry_tracker_store.py} +5 -1
  172. rasa/core/tracker_stores/dynamo_tracker_store.py +218 -0
  173. rasa/core/tracker_stores/mongo_tracker_store.py +206 -0
  174. rasa/core/tracker_stores/redis_tracker_store.py +219 -0
  175. rasa/core/tracker_stores/sql_tracker_store.py +555 -0
  176. rasa/core/tracker_stores/tracker_store.py +805 -0
  177. rasa/core/training/interactive.py +1 -1
  178. rasa/core/utils.py +24 -95
  179. rasa/dialogue_understanding/coexistence/intent_based_router.py +2 -1
  180. rasa/dialogue_understanding/coexistence/llm_based_router.py +9 -6
  181. rasa/dialogue_understanding/commands/can_not_handle_command.py +2 -0
  182. rasa/dialogue_understanding/commands/cancel_flow_command.py +5 -1
  183. rasa/dialogue_understanding/commands/chit_chat_answer_command.py +2 -0
  184. rasa/dialogue_understanding/commands/clarify_command.py +4 -0
  185. rasa/dialogue_understanding/commands/command_syntax_manager.py +1 -0
  186. rasa/dialogue_understanding/commands/correct_slots_command.py +1 -3
  187. rasa/dialogue_understanding/commands/human_handoff_command.py +2 -0
  188. rasa/dialogue_understanding/commands/knowledge_answer_command.py +2 -0
  189. rasa/dialogue_understanding/commands/repeat_bot_messages_command.py +2 -0
  190. rasa/dialogue_understanding/commands/set_slot_command.py +4 -0
  191. rasa/dialogue_understanding/commands/skip_question_command.py +2 -0
  192. rasa/dialogue_understanding/commands/start_flow_command.py +4 -0
  193. rasa/dialogue_understanding/generator/__init__.py +7 -1
  194. rasa/dialogue_understanding/generator/command_generator.py +4 -2
  195. rasa/dialogue_understanding/generator/command_parser.py +2 -2
  196. rasa/dialogue_understanding/generator/command_parser_validator.py +63 -0
  197. rasa/dialogue_understanding/generator/llm_based_command_generator.py +1 -2
  198. rasa/dialogue_understanding/generator/nlu_command_adapter.py +2 -2
  199. rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v3_gpt_4o_2024_11_20_template.jinja2 +78 -0
  200. rasa/dialogue_understanding/generator/single_step/compact_llm_command_generator.py +26 -461
  201. rasa/dialogue_understanding/generator/single_step/search_ready_llm_command_generator.py +147 -0
  202. rasa/dialogue_understanding/generator/single_step/single_step_based_llm_command_generator.py +477 -0
  203. rasa/dialogue_understanding/generator/single_step/single_step_llm_command_generator.py +11 -64
  204. rasa/dialogue_understanding/patterns/cancel.py +1 -2
  205. rasa/dialogue_understanding/patterns/clarify.py +1 -1
  206. rasa/dialogue_understanding/patterns/correction.py +2 -2
  207. rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +37 -25
  208. rasa/dialogue_understanding/patterns/domain_for_patterns.py +190 -0
  209. rasa/dialogue_understanding/processor/command_processor.py +6 -7
  210. rasa/dialogue_understanding/stack/utils.py +3 -1
  211. rasa/dialogue_understanding_test/command_metric_calculation.py +7 -40
  212. rasa/dialogue_understanding_test/command_metrics.py +38 -0
  213. rasa/dialogue_understanding_test/du_test_case.py +58 -25
  214. rasa/dialogue_understanding_test/du_test_result.py +228 -132
  215. rasa/dialogue_understanding_test/du_test_runner.py +11 -2
  216. rasa/dialogue_understanding_test/du_test_schema.yml +3 -3
  217. rasa/dialogue_understanding_test/io.py +35 -8
  218. rasa/e2e_test/e2e_test_runner.py +1 -1
  219. rasa/e2e_test/e2e_test_schema.yml +3 -3
  220. rasa/engine/constants.py +1 -1
  221. rasa/engine/graph.py +2 -2
  222. rasa/engine/recipes/default_recipe.py +1 -1
  223. rasa/engine/validation.py +3 -2
  224. rasa/hooks.py +2 -30
  225. rasa/llm_fine_tuning/paraphrasing/conversation_rephraser.py +1 -5
  226. rasa/model_manager/model_api.py +90 -2
  227. rasa/model_manager/socket_bridge.py +0 -7
  228. rasa/model_manager/trainer_service.py +15 -12
  229. rasa/plugin.py +2 -15
  230. rasa/privacy/__init__.py +0 -0
  231. rasa/privacy/constants.py +83 -0
  232. rasa/privacy/event_broker_utils.py +77 -0
  233. rasa/privacy/privacy_config.py +281 -0
  234. rasa/privacy/privacy_config_schema.json +86 -0
  235. rasa/privacy/privacy_filter.py +340 -0
  236. rasa/privacy/privacy_manager.py +576 -0
  237. rasa/server.py +23 -2
  238. rasa/shared/constants.py +14 -0
  239. rasa/shared/core/command_payload_reader.py +1 -5
  240. rasa/shared/core/constants.py +4 -3
  241. rasa/shared/core/domain.py +172 -11
  242. rasa/shared/core/events.py +100 -6
  243. rasa/shared/core/flows/flow.py +35 -8
  244. rasa/shared/core/flows/flow_step.py +26 -4
  245. rasa/shared/core/flows/flow_step_links.py +15 -0
  246. rasa/shared/core/flows/flow_step_sequence.py +6 -0
  247. rasa/shared/core/flows/flows_yaml_schema.json +3 -0
  248. rasa/shared/core/flows/nlu_trigger.py +13 -0
  249. rasa/shared/core/flows/steps/action.py +7 -4
  250. rasa/shared/core/flows/steps/call.py +11 -4
  251. rasa/shared/core/flows/steps/collect.py +71 -6
  252. rasa/shared/core/flows/steps/internal.py +6 -1
  253. rasa/shared/core/flows/steps/link.py +7 -4
  254. rasa/shared/core/flows/steps/no_operation.py +7 -4
  255. rasa/shared/core/flows/steps/set_slots.py +8 -4
  256. rasa/shared/core/flows/validation.py +16 -3
  257. rasa/shared/core/flows/yaml_flows_io.py +106 -5
  258. rasa/shared/core/slots.py +33 -1
  259. rasa/shared/core/trackers.py +4 -10
  260. rasa/shared/core/training_data/story_reader/yaml_story_reader.py +1 -4
  261. rasa/shared/importers/importer.py +14 -0
  262. rasa/shared/importers/static.py +63 -0
  263. rasa/shared/providers/llm/default_litellm_llm_client.py +2 -2
  264. rasa/shared/utils/common.py +43 -1
  265. rasa/shared/utils/llm.py +155 -3
  266. rasa/shared/utils/yaml.py +32 -0
  267. rasa/studio/data_handler.py +3 -3
  268. rasa/studio/download/__init__.py +0 -0
  269. rasa/studio/download/domains.py +49 -0
  270. rasa/studio/download/download.py +416 -0
  271. rasa/studio/download/flows.py +351 -0
  272. rasa/studio/link.py +200 -0
  273. rasa/studio/pull.py +94 -0
  274. rasa/studio/push.py +131 -0
  275. rasa/studio/results_logger.py +6 -1
  276. rasa/studio/upload.py +185 -71
  277. rasa/telemetry.py +83 -26
  278. rasa/tracing/config.py +4 -5
  279. rasa/tracing/constants.py +19 -1
  280. rasa/tracing/instrumentation/attribute_extractors.py +47 -9
  281. rasa/tracing/instrumentation/instrumentation.py +54 -3
  282. rasa/tracing/instrumentation/metrics.py +98 -15
  283. rasa/tracing/metric_instrument_provider.py +75 -3
  284. rasa/utils/common.py +37 -27
  285. rasa/utils/endpoints.py +22 -1
  286. rasa/utils/licensing.py +2 -3
  287. rasa/utils/log_utils.py +1 -45
  288. rasa/validator.py +9 -11
  289. rasa/version.py +1 -1
  290. {rasa_pro-3.12.18.dist-info → rasa_pro-3.13.0a1.dev1.dist-info}/METADATA +12 -13
  291. {rasa_pro-3.12.18.dist-info → rasa_pro-3.13.0a1.dev1.dist-info}/RECORD +308 -283
  292. rasa/anonymization/__init__.py +0 -2
  293. rasa/anonymization/anonymisation_rule_yaml_reader.py +0 -91
  294. rasa/anonymization/anonymization_pipeline.py +0 -286
  295. rasa/anonymization/anonymization_rule_executor.py +0 -266
  296. rasa/anonymization/anonymization_rule_orchestrator.py +0 -119
  297. rasa/anonymization/schemas/config.yml +0 -47
  298. rasa/anonymization/utils.py +0 -118
  299. rasa/cli/project_templates/calm/config.yml +0 -10
  300. rasa/cli/project_templates/calm/credentials.yml +0 -33
  301. rasa/cli/project_templates/calm/endpoints.yml +0 -58
  302. rasa/cli/project_templates/default/actions/actions.py +0 -27
  303. rasa/cli/project_templates/default/data/nlu.yml +0 -91
  304. rasa/cli/project_templates/default/data/rules.yml +0 -13
  305. rasa/cli/project_templates/default/data/stories.yml +0 -30
  306. rasa/cli/project_templates/default/domain.yml +0 -34
  307. rasa/cli/project_templates/default/tests/test_stories.yml +0 -91
  308. rasa/core/channels/inspector/dist/assets/channel-dfa68278.js +0 -1
  309. rasa/core/channels/inspector/dist/assets/clone-edb7f119.js +0 -1
  310. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-65e7c670.js +0 -1
  311. rasa/core/channels/inspector/src/helpers/audiostream.ts +0 -191
  312. rasa/core/tracker_store.py +0 -1792
  313. rasa/studio/download.py +0 -489
  314. /rasa/{cli/project_templates/calm/actions → builder}/__init__.py +0 -0
  315. /rasa/cli/project_templates/{calm → default}/actions/action_template.py +0 -0
  316. /rasa/cli/project_templates/{calm → default}/actions/add_contact.py +0 -0
  317. /rasa/cli/project_templates/{calm → default}/actions/db.py +0 -0
  318. /rasa/cli/project_templates/{calm → default}/actions/list_contacts.py +0 -0
  319. /rasa/cli/project_templates/{calm → default}/actions/remove_contact.py +0 -0
  320. /rasa/cli/project_templates/{calm → default}/data/flows/add_contact.yml +0 -0
  321. /rasa/cli/project_templates/{calm → default}/data/flows/list_contacts.yml +0 -0
  322. /rasa/cli/project_templates/{calm → default}/data/flows/remove_contact.yml +0 -0
  323. /rasa/cli/project_templates/{calm → default}/db/contacts.json +0 -0
  324. /rasa/cli/project_templates/{calm → default}/domain/add_contact.yml +0 -0
  325. /rasa/cli/project_templates/{calm → default}/domain/list_contacts.yml +0 -0
  326. /rasa/cli/project_templates/{calm → default}/domain/remove_contact.yml +0 -0
  327. /rasa/cli/project_templates/{calm → default}/domain/shared.yml +0 -0
  328. {rasa_pro-3.12.18.dist-info → rasa_pro-3.13.0a1.dev1.dist-info}/NOTICE +0 -0
  329. {rasa_pro-3.12.18.dist-info → rasa_pro-3.13.0a1.dev1.dist-info}/WHEEL +0 -0
  330. {rasa_pro-3.12.18.dist-info → rasa_pro-3.13.0a1.dev1.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,78 @@
1
+ ## Task Description
2
+ Your task is to analyze the current conversation context and generate a list of actions to start new business processes that we call flows, to extract slots, or respond to off-topic and knowledge requests.
3
+
4
+ ---
5
+
6
+ ## Available Flows and Slots
7
+ Use the following structured data:
8
+ ```json
9
+ {"flows":[{% for flow in available_flows %}{"name":"{{ flow.name }}","description":{{ flow.description | to_json_escaped_string }}{% if flow.slots %},"slots":[{% for slot in flow.slots %}{"name":"{{ slot.name }}"{% if slot.description %},"description":{{ slot.description | to_json_escaped_string }}{% endif %}{% if slot.allowed_values %},"allowed_values":{{ slot.allowed_values }}{% endif %}}{% if not loop.last %},{% endif %}{% endfor %}]{% endif %}}{% if not loop.last %},{% endif %}{% endfor %}]}
10
+ ```
11
+
12
+ ---
13
+
14
+ ## Available Actions:
15
+ * `start flow flow_name`: Start a flow. For example, `start flow transfer_money` or `start flow list_contacts`.
16
+ * `set slot slot_name slot_value`: Set a slot for the active flow. For example, `set slot transfer_money_recipient Freddy`. Can be used to correct and change previously set values.
17
+ * `disambiguate flows flow_name1 flow_name2 ... flow_name_n`: When a message could refer to multiple flows, list the possible flows as options to clarify. Example: `disambiguate flows list_contacts add_contact remove_contact`.
18
+ * `search and reply`: Provide a response from the knowledge base to address the user’s inquiry when no flows fit, including domain knowledge, FAQs, and all off-topic or social messages.
19
+ * `cancel flow`: Cancel the current flow if the user requests it.
20
+
21
+ ---
22
+
23
+ ## General Instructions
24
+ ### Start Flow
25
+ * Only start a flow if the user's message is clear and fully addressed by that flow's description and purpose.
26
+ * Pay close attention to exact wording and scope in the flow description — do not assume or “stretch” the intended use of a flow.
27
+ ### Set Slot
28
+ * Do not fill slots with abstract values or placeholders.
29
+ * For categorical slots try to match the user message with allowed slot values. Use "other" if you cannot match it.
30
+ * Set the boolean slots based on the user response. Map positive responses to `True`, and negative to `False`.
31
+ * Extract text slot values exactly as provided by the user. Avoid assumptions, format changes, or partial extractions.
32
+ ### Disambiguate Flows
33
+ * Use `disambiguate flows` when the user's message matches multiple flows and you cannot decide which flow is most appropriate.
34
+ * If the user message is short and not precise enough to start a flow or `search and reply`, disambiguate.
35
+ * If a single flow is a strong/plausible fit, prefer starting that flow directly.
36
+ * If a user's message unambiguously and distinctly matches multiple flows, start all relevant flows at once (rather than disambiguating).
37
+ ### Search and Reply
38
+ * Only start `search and reply` if the user intent is clear.
39
+ * Flow Priority: If you are unsure between starting a flow or `search and reply`, always prioritize starting a flow.
40
+ ### Cancel Flow
41
+ * Do not cancel any flow unless the user explicitly requests it.
42
+ * Multiple flows can be started without cancelling the previous, if the user wants to pursue multiple processes.
43
+ ### General Tips
44
+ * Only use information provided by the user.
45
+ * Strictly adhere to the provided action format.
46
+ * Focus on the last message and take it one step at a time.
47
+ * Use the previous conversation steps only to aid understanding.
48
+
49
+ ---
50
+
51
+ ## Decision Rule Table
52
+ | Condition | Action |
53
+ |-------------------------------------------------------|--------------------|
54
+ | Flow perfectly matches user's message | start flow |
55
+ | Multiple flows are equally strong, relevant matches | disambiguate flows |
56
+ | User's message is unclear or imprecise | disambiguate flows |
57
+ | No flow fits at all, but knowledge base may help | search and reply |
58
+
59
+ ---
60
+
61
+ ## Current State
62
+ {% if current_flow != None %}Use the following structured data:
63
+ ```json
64
+ {"active_flow":"{{ current_flow }}","current_step":{"requested_slot":"{{ current_slot }}","requested_slot_description":{{ current_slot_description | to_json_escaped_string }}},"slots":[{% for slot in flow_slots %}{"name":"{{ slot.name }}","value":"{{ slot.value }}","type":"{{ slot.type }}"{% if slot.description %},"description":{{ slot.description | to_json_escaped_string }}{% endif %}{% if slot.allowed_values %},"allowed_values":"{{ slot.allowed_values }}"{% endif %}}{% if not loop.last %},{% endif %}{% endfor %}]}
65
+ ```{% else %}
66
+ You are currently not inside any flow.{% endif %}
67
+
68
+ ---
69
+
70
+ ## Conversation History
71
+ {{ current_conversation }}
72
+
73
+ ---
74
+
75
+ ## Task
76
+ Create an action list with one action per line in response to the user's last message: """{{ user_message }}""".
77
+
78
+ Your action list:
@@ -1,28 +1,12 @@
1
- import copy
2
- from typing import Any, Dict, List, Literal, Optional, Text
1
+ from typing import Any, Dict, Literal, Optional, Text
3
2
 
4
3
  import structlog
5
4
 
6
- import rasa.shared.utils.io
7
- from rasa.dialogue_understanding.commands import (
8
- CannotHandleCommand,
9
- Command,
10
- ErrorCommand,
11
- SetSlotCommand,
12
- )
13
5
  from rasa.dialogue_understanding.commands.command_syntax_manager import (
14
- CommandSyntaxManager,
15
6
  CommandSyntaxVersion,
16
7
  )
17
- from rasa.dialogue_understanding.generator import LLMBasedCommandGenerator
18
- from rasa.dialogue_understanding.generator.command_parser import (
19
- parse_commands as parse_commands_using_command_parsers,
20
- )
21
8
  from rasa.dialogue_understanding.generator.constants import (
22
- COMMAND_PROMPT_FILE_NAME,
23
9
  DEFAULT_OPENAI_MAX_GENERATED_TOKENS,
24
- FLOW_RETRIEVAL_KEY,
25
- LLM_BASED_COMMAND_GENERATOR_CONFIG_FILE,
26
10
  LLM_CONFIG_KEY,
27
11
  MODEL_CONFIG_KEY,
28
12
  MODEL_NAME_CLAUDE_3_5_SONNET_20240620,
@@ -30,15 +14,10 @@ from rasa.dialogue_understanding.generator.constants import (
30
14
  OPENAI_PROVIDER,
31
15
  PROVIDER_CONFIG_KEY,
32
16
  TIMEOUT_CONFIG_KEY,
33
- USER_INPUT_CONFIG_KEY,
34
17
  )
35
- from rasa.dialogue_understanding.generator.flow_retrieval import FlowRetrieval
36
- from rasa.dialogue_understanding.stack.utils import top_flow_frame
37
- from rasa.dialogue_understanding.utils import (
38
- add_commands_to_message_parse_data,
39
- add_prompt_to_message_parse_data,
18
+ from rasa.dialogue_understanding.generator.single_step.single_step_based_llm_command_generator import ( # noqa: E501
19
+ SingleStepBasedLLMCommandGenerator,
40
20
  )
41
- from rasa.engine.graph import ExecutionContext
42
21
  from rasa.engine.recipes.default_recipe import DefaultV1Recipe
43
22
  from rasa.engine.storage.resource import Resource
44
23
  from rasa.engine.storage.storage import ModelStorage
@@ -46,33 +25,14 @@ from rasa.shared.constants import (
46
25
  ANTHROPIC_PROVIDER,
47
26
  AWS_BEDROCK_PROVIDER,
48
27
  AZURE_OPENAI_PROVIDER,
49
- EMBEDDINGS_CONFIG_KEY,
50
28
  MAX_COMPLETION_TOKENS_CONFIG_KEY,
51
29
  PROMPT_TEMPLATE_CONFIG_KEY,
52
- ROUTE_TO_CALM_SLOT,
53
30
  TEMPERATURE_CONFIG_KEY,
54
31
  )
55
- from rasa.shared.core.flows import FlowsList
56
- from rasa.shared.core.trackers import DialogueStateTracker
57
- from rasa.shared.exceptions import ProviderClientAPIException
58
- from rasa.shared.nlu.constants import LLM_COMMANDS, LLM_PROMPT, TEXT
59
- from rasa.shared.nlu.training_data.message import Message
60
- from rasa.shared.providers.llm.llm_response import LLMResponse
61
- from rasa.shared.utils.constants import (
62
- LOG_COMPONENT_SOURCE_METHOD_FINGERPRINT_ADDON,
63
- LOG_COMPONENT_SOURCE_METHOD_INIT,
64
- )
65
- from rasa.shared.utils.io import deep_container_fingerprint
66
32
  from rasa.shared.utils.llm import (
67
- allowed_values_for_slot,
68
33
  get_default_prompt_template_based_on_model,
69
34
  get_prompt_template,
70
- resolve_model_client_config,
71
- sanitize_message_for_prompt,
72
- tracker_as_readable_transcript,
73
35
  )
74
- from rasa.utils.beta import BetaNotEnabledException, ensure_beta_feature_is_enabled
75
- from rasa.utils.log_utils import log_llm
76
36
 
77
37
  structlogger = structlog.get_logger()
78
38
 
@@ -111,67 +71,13 @@ FALLBACK_COMMAND_PROMPT_TEMPLATE_FILE_NAME = (
111
71
  )
112
72
 
113
73
 
114
- class CommandParserValidatorSingleton:
115
- """Singleton class to validate the command parser.
116
-
117
- This class is used to validate the command parser. It keeps track of the number of
118
- consecutive turns where no commands are parsed by the command parser. If the
119
- number of consecutive turns exceeds a certain threshold, a warning is logged.
120
- The prompt can use a DSL syntax that can be incompatible with the command syntax
121
- used by the command parser. This class helps to detect such incompatibilities.
122
- """
123
-
124
- MAX_CONSECUTIVE_TURNS_NO_COMMAND_PREDICTED = 5
125
- _NO_COMMAND_PREDICTED_TURN_COUNTER = 0
126
- _command_parser_validated = False
127
-
128
- @classmethod
129
- def get_no_command_predicted_turn_counter(cls) -> int:
130
- return cls._NO_COMMAND_PREDICTED_TURN_COUNTER
131
-
132
- @classmethod
133
- def should_validate_command_parser(cls) -> bool:
134
- return not cls._command_parser_validated
135
-
136
- @classmethod
137
- def reset_command_parser_validation(cls) -> None:
138
- cls._NO_COMMAND_PREDICTED_TURN_COUNTER = 0
139
- cls._command_parser_validated = False
140
-
141
- @classmethod
142
- def validate_if_commands_are_parsed_from_llm_response(
143
- cls, commands: List[Command], llm_response: str
144
- ) -> None:
145
- if llm_response and not commands:
146
- cls._NO_COMMAND_PREDICTED_TURN_COUNTER += 1
147
- else:
148
- # Reset the counter if commands are generated, and mark
149
- # the command parser as validated.
150
- cls._NO_COMMAND_PREDICTED_TURN_COUNTER = 0
151
- cls._command_parser_validated = True
152
- return
153
-
154
- if (
155
- cls._NO_COMMAND_PREDICTED_TURN_COUNTER
156
- >= cls.MAX_CONSECUTIVE_TURNS_NO_COMMAND_PREDICTED
157
- ):
158
- structlogger.warning(
159
- "llm_command_generator.predict_commands.command_parser_not_working",
160
- event_info=(
161
- f"No commands were generated by the command parser for the last "
162
- f"{cls._NO_COMMAND_PREDICTED_TURN_COUNTER} times. Check if you "
163
- "are running incompatible prompt and LLM command generator."
164
- ),
165
- )
166
-
167
-
168
74
  @DefaultV1Recipe.register(
169
75
  [
170
76
  DefaultV1Recipe.ComponentType.COMMAND_GENERATOR,
171
77
  ],
172
78
  is_trainable=True,
173
79
  )
174
- class CompactLLMCommandGenerator(LLMBasedCommandGenerator):
80
+ class CompactLLMCommandGenerator(SingleStepBasedLLMCommandGenerator):
175
81
  """A single step LLM-based command generator."""
176
82
 
177
83
  def __init__(
@@ -190,366 +96,20 @@ class CompactLLMCommandGenerator(LLMBasedCommandGenerator):
190
96
  **kwargs,
191
97
  )
192
98
 
193
- # Get the prompt template from the config or the default prompt template.
194
- self.prompt_template = self._resolve_component_prompt_template(
195
- self.config, prompt_template, log_context=LOG_COMPONENT_SOURCE_METHOD_INIT
196
- )
197
-
198
- # Set the command syntax version to v2
199
- CommandSyntaxManager.set_syntax_version(
200
- self.get_component_command_syntax_version()
201
- )
202
-
203
- self.trace_prompt_tokens = self.config.get("trace_prompt_tokens", False)
204
- self.repeat_command_enabled = self.is_repeat_command_enabled()
205
-
206
- ### Implementations of LLMBasedCommandGenerator parent
207
99
  @staticmethod
208
- def get_default_config() -> Dict[str, Any]:
209
- """The component's default config (see parent class for full docstring)."""
210
- return {
211
- PROMPT_TEMPLATE_CONFIG_KEY: None,
212
- USER_INPUT_CONFIG_KEY: None,
213
- LLM_CONFIG_KEY: None,
214
- FLOW_RETRIEVAL_KEY: FlowRetrieval.get_default_config(),
215
- }
216
-
217
- def persist(self) -> None:
218
- """Persist this component to disk for future loading."""
219
- self._persist_prompt_template()
220
- self._persist_config()
221
- if self.flow_retrieval is not None:
222
- self.flow_retrieval.persist()
223
-
224
- def _persist_prompt_template(self) -> None:
225
- """Persist prompt template for future loading."""
226
- with self._model_storage.write_to(self._resource) as path:
227
- rasa.shared.utils.io.write_text_file(
228
- self.prompt_template, path / COMMAND_PROMPT_FILE_NAME
229
- )
230
-
231
- def _persist_config(self) -> None:
232
- """Persist config as a source of truth for resolved clients."""
233
- with self._model_storage.write_to(self._resource) as path:
234
- rasa.shared.utils.io.dump_obj_as_json_to_file(
235
- path / LLM_BASED_COMMAND_GENERATOR_CONFIG_FILE, self.config
236
- )
237
-
238
- @classmethod
239
- def load(
240
- cls: Any,
241
- config: Dict[str, Any],
242
- model_storage: ModelStorage,
243
- resource: Resource,
244
- execution_context: ExecutionContext,
245
- **kwargs: Any,
246
- ) -> "CompactLLMCommandGenerator":
247
- """Loads trained component (see parent class for full docstring)."""
248
- # Perform health check of the LLM API endpoint
249
- llm_config = resolve_model_client_config(config.get(LLM_CONFIG_KEY, {}))
250
- cls.perform_llm_health_check(
251
- llm_config,
252
- cls.get_default_llm_config(),
253
- "compact_llm_command_generator.load",
254
- cls.__name__,
255
- )
256
-
257
- # load prompt template from the model storage.
258
- prompt_template = cls.load_prompt_template_from_model_storage(
259
- model_storage, resource, COMMAND_PROMPT_FILE_NAME
260
- )
261
-
262
- # init base command generator
263
- command_generator = cls(config, model_storage, resource, prompt_template)
264
- # load flow retrieval if enabled
265
- if command_generator.enabled_flow_retrieval:
266
- command_generator.flow_retrieval = cls.load_flow_retrival(
267
- command_generator.config, model_storage, resource
268
- )
269
-
270
- return command_generator
271
-
272
- async def predict_commands(
273
- self,
274
- message: Message,
275
- flows: FlowsList,
276
- tracker: Optional[DialogueStateTracker] = None,
277
- **kwargs: Any,
278
- ) -> List[Command]:
279
- """Predict commands using the LLM.
280
-
281
- Args:
282
- message: The message from the user.
283
- flows: The flows available to the user.
284
- tracker: The tracker containing the current state of the conversation.
285
- **kwargs: Keyword arguments for forward compatibility.
286
-
287
- Returns:
288
- The commands generated by the llm.
289
- """
290
- prior_commands = self._get_prior_commands(message)
291
-
292
- if tracker is None or flows.is_empty():
293
- # cannot do anything if there are no flows or no tracker
294
- return prior_commands
295
-
296
- if self._should_skip_llm_call(prior_commands, flows, tracker):
297
- return prior_commands
298
-
299
- try:
300
- commands = await self._predict_commands(message, flows, tracker)
301
- except ProviderClientAPIException:
302
- # if command predictions resulted in API exception
303
- # "predict" the ErrorCommand
304
- commands = [ErrorCommand()]
305
- structlogger.warning(
306
- "llm_command_generator.predict_commands.api_exception",
307
- event_info=(
308
- "ProviderClientAPIException occurred while predicting commands."
309
- ),
310
- commands=commands,
311
- )
312
-
313
- if not commands and not prior_commands:
314
- # no commands are parsed or there's an invalid command
315
- structlogger.warning(
316
- "llm_command_generator.predict_commands",
317
- message="No commands were predicted as the LLM response could "
318
- "not be parsed or the LLM responded with an invalid command. "
319
- "Returning a CannotHandleCommand instead.",
320
- )
321
- commands = [CannotHandleCommand()]
322
-
323
- if tracker.has_coexistence_routing_slot:
324
- # if coexistence feature is used, set the routing slot
325
- commands += [SetSlotCommand(ROUTE_TO_CALM_SLOT, True)]
326
-
327
- log_llm(
328
- logger=structlogger,
329
- log_module=self.__class__.__name__,
330
- log_event="llm_command_generator.predict_commands.finished",
331
- commands=commands,
332
- )
333
-
334
- domain = kwargs.get("domain")
335
- commands = self._check_commands_against_slot_mappings(commands, tracker, domain)
336
-
337
- return self._check_commands_overlap(prior_commands, commands)
338
-
339
- async def _predict_commands(
340
- self,
341
- message: Message,
342
- flows: FlowsList,
343
- tracker: Optional[DialogueStateTracker] = None,
344
- ) -> List[Command]:
345
- """Predict commands using the LLM.
346
-
347
- Args:
348
- message: The message from the user.
349
- flows: The flows available to the user.
350
- tracker: The tracker containing the current state of the conversation.
351
-
352
- Returns:
353
- The commands generated by the llm.
354
-
355
- Raises:
356
- ProviderClientAPIException: If API calls raised an error.
357
- """
358
- # retrieve flows
359
- filtered_flows = await self.filter_flows(message, flows, tracker)
360
-
361
- flow_prompt = self.render_template(message, tracker, filtered_flows, flows)
362
- log_llm(
363
- logger=structlogger,
364
- log_module=self.__class__.__name__,
365
- log_event="llm_command_generator.predict_commands.prompt_rendered",
366
- prompt=flow_prompt,
367
- )
368
-
369
- response = await self.invoke_llm(flow_prompt)
370
- llm_response = LLMResponse.ensure_llm_response(response)
371
- # The check for 'None' maintains compatibility with older versions
372
- # of LLMCommandGenerator. In previous implementations, 'invoke_llm'
373
- # might return 'None' to indicate a failure to generate actions.
374
- if llm_response is None or not llm_response.choices:
375
- structlogger.warning(
376
- "llm_command_generator.predict_commands.no_actions_generated",
377
- event_info=(
378
- "No actions were generated by the LLM. Returning an ErrorCommand."
379
- ),
380
- )
381
- return [ErrorCommand()]
382
-
383
- action_list = llm_response.choices[0]
384
-
385
- log_llm(
386
- logger=structlogger,
387
- log_module=self.__class__.__name__,
388
- log_event="llm_command_generator.predict_commands.actions_generated",
389
- action_list=action_list,
390
- )
391
-
392
- commands = self.parse_commands(action_list, tracker, flows)
393
-
394
- if CommandParserValidatorSingleton.should_validate_command_parser():
395
- CommandParserValidatorSingleton.validate_if_commands_are_parsed_from_llm_response(
396
- commands, action_list
397
- )
398
-
399
- self._update_message_parse_data_for_fine_tuning(message, commands, flow_prompt)
400
- add_commands_to_message_parse_data(message, self.__class__.__name__, commands)
401
- add_prompt_to_message_parse_data(
402
- message=message,
403
- component_name=self.__class__.__name__,
404
- prompt_name="command_generator_prompt",
405
- user_prompt=flow_prompt,
406
- llm_response=llm_response,
407
- )
408
-
409
- return commands
100
+ def get_default_prompt_template_file_name() -> str:
101
+ """Get the default prompt template file name for the command generator."""
102
+ return DEFAULT_COMMAND_PROMPT_TEMPLATE_FILE_NAME
410
103
 
411
104
  @staticmethod
412
- def _update_message_parse_data_for_fine_tuning(
413
- message: Message, commands: List[Command], prompt: str
414
- ) -> None:
415
- from rasa.llm_fine_tuning.annotation_module import preparing_fine_tuning_data
416
-
417
- if preparing_fine_tuning_data:
418
- # Add commands and prompt to the message object in order to create
419
- # prompt -> commands pairs for fine-tuning
420
- message.set(
421
- LLM_COMMANDS,
422
- [command.as_dict() for command in commands],
423
- add_to_output=True,
424
- )
425
- message.set(LLM_PROMPT, prompt, add_to_output=True)
426
-
427
- @classmethod
428
- def parse_commands(
429
- cls, actions: Optional[str], tracker: DialogueStateTracker, flows: FlowsList
430
- ) -> List[Command]:
431
- """Parse the actions returned by the llm into intent and entities.
432
-
433
- Args:
434
- actions: The actions returned by the llm.
435
- tracker: The tracker containing the current state of the conversation.
436
- flows: the list of flows
437
-
438
- Returns:
439
- The parsed commands.
440
- """
441
- commands = parse_commands_using_command_parsers(actions, flows)
442
- if not commands:
443
- structlogger.warning(
444
- f"{cls.__name__}.parse_commands",
445
- message="No commands were parsed from the LLM actions.",
446
- actions=actions,
447
- )
105
+ def get_fallback_prompt_template_file_name() -> str:
106
+ """Get the fallback prompt template file name for the command generator."""
107
+ return FALLBACK_COMMAND_PROMPT_TEMPLATE_FILE_NAME
448
108
 
449
- return commands
450
-
451
- ### Helper methods
452
- def render_template(
453
- self,
454
- message: Message,
455
- tracker: DialogueStateTracker,
456
- startable_flows: FlowsList,
457
- all_flows: FlowsList,
458
- ) -> str:
459
- """Render the jinja template to create the prompt for the LLM.
460
-
461
- Args:
462
- message: The current message from the user.
463
- tracker: The tracker containing the current state of the conversation.
464
- startable_flows: The flows startable at this point in time by the user.
465
- all_flows: all flows present in the assistant
466
-
467
- Returns:
468
- The rendered prompt template.
469
- """
470
- # need to make this distinction here because current step of the
471
- # top_calling_frame would be the call step, but we need the collect step from
472
- # the called frame. If no call is active calling and called frame are the same.
473
- top_calling_frame = top_flow_frame(tracker.stack)
474
- top_called_frame = top_flow_frame(tracker.stack, ignore_call_frames=False)
475
-
476
- top_flow = top_calling_frame.flow(all_flows) if top_calling_frame else None
477
- current_step = top_called_frame.step(all_flows) if top_called_frame else None
478
-
479
- flow_slots = self.prepare_current_flow_slots_for_template(
480
- top_flow, current_step, tracker
481
- )
482
- current_slot, current_slot_description = self.prepare_current_slot_for_template(
483
- current_step
484
- )
485
- current_slot_type = None
486
- current_slot_allowed_values = None
487
- if current_slot:
488
- current_slot_type = (
489
- slot.type_name
490
- if (slot := tracker.slots.get(current_slot)) is not None
491
- else None
492
- )
493
- current_slot_allowed_values = allowed_values_for_slot(
494
- tracker.slots.get(current_slot)
495
- )
496
- current_conversation = tracker_as_readable_transcript(tracker)
497
- latest_user_message = sanitize_message_for_prompt(message.get(TEXT))
498
- current_conversation += f"\nUSER: {latest_user_message}"
499
-
500
- inputs = {
501
- "available_flows": self.prepare_flows_for_template(
502
- startable_flows, tracker
503
- ),
504
- "current_conversation": current_conversation,
505
- "flow_slots": flow_slots,
506
- "current_flow": top_flow.id if top_flow is not None else None,
507
- "current_slot": current_slot,
508
- "current_slot_description": current_slot_description,
509
- "current_slot_type": current_slot_type,
510
- "current_slot_allowed_values": current_slot_allowed_values,
511
- "user_message": latest_user_message,
512
- "is_repeat_command_enabled": self.repeat_command_enabled,
513
- }
514
-
515
- return self.compile_template(self.prompt_template).render(**inputs)
516
-
517
- def is_repeat_command_enabled(self) -> bool:
518
- """Check for feature flag"""
519
- RASA_PRO_BETA_REPEAT_COMMAND_ENV_VAR_NAME = "RASA_PRO_BETA_REPEAT_COMMAND"
520
- try:
521
- ensure_beta_feature_is_enabled(
522
- "Repeat Command",
523
- env_flag=RASA_PRO_BETA_REPEAT_COMMAND_ENV_VAR_NAME,
524
- )
525
- except BetaNotEnabledException:
526
- return False
527
-
528
- return True
529
-
530
- @classmethod
531
- def fingerprint_addon(cls: Any, config: Dict[str, Any]) -> Optional[str]:
532
- """Add a fingerprint for the graph."""
533
- # Get the default prompt template based on the model name
534
- llm_config = resolve_model_client_config(
535
- config.get(LLM_CONFIG_KEY), CompactLLMCommandGenerator.__name__
536
- )
537
- embedding_config = resolve_model_client_config(
538
- config.get(FLOW_RETRIEVAL_KEY, {}).get(EMBEDDINGS_CONFIG_KEY),
539
- FlowRetrieval.__name__,
540
- )
541
-
542
- # Create a copy of the config to avoid modifying the original config
543
- # and update the llm config with the resolved llm config.
544
- _config_copy = copy.deepcopy(config)
545
- _config_copy[LLM_CONFIG_KEY] = llm_config
546
- prompt_template = cls._resolve_component_prompt_template(
547
- _config_copy, log_context=LOG_COMPONENT_SOURCE_METHOD_FINGERPRINT_ADDON
548
- )
549
-
550
- return deep_container_fingerprint(
551
- [prompt_template, llm_config, embedding_config]
552
- )
109
+ @staticmethod
110
+ def get_model_prompt_mapper() -> Dict[str, str]:
111
+ """Get the model prompt mapper for the command generator."""
112
+ return MODEL_PROMPT_MAPPER
553
113
 
554
114
  @staticmethod
555
115
  def get_default_llm_config() -> Dict[str, Any]:
@@ -560,27 +120,32 @@ class CompactLLMCommandGenerator(LLMBasedCommandGenerator):
560
120
  def get_component_command_syntax_version() -> CommandSyntaxVersion:
561
121
  return CommandSyntaxVersion.v2
562
122
 
563
- @staticmethod
123
+ @classmethod
564
124
  def _resolve_component_prompt_template(
125
+ cls,
565
126
  config: Dict[str, Any],
566
127
  prompt_template: Optional[str] = None,
567
128
  log_context: Optional[Literal["init", "fingerprint_addon"]] = None,
129
+ log_source_component: Optional[str] = "CompactLLMCommandGenerator",
568
130
  ) -> Optional[str]:
569
131
  """Get the prompt template from the config or the default prompt template."""
132
+ if prompt_template is not None:
133
+ return prompt_template
134
+
570
135
  # Get the default prompt template based on the model name.
571
136
  default_command_prompt_template = get_default_prompt_template_based_on_model(
572
137
  llm_config=config.get(LLM_CONFIG_KEY, {}) or {},
573
- model_prompt_mapping=MODEL_PROMPT_MAPPER,
574
- default_prompt_path=DEFAULT_COMMAND_PROMPT_TEMPLATE_FILE_NAME,
575
- fallback_prompt_path=FALLBACK_COMMAND_PROMPT_TEMPLATE_FILE_NAME,
576
- log_source_component=CompactLLMCommandGenerator.__name__,
138
+ model_prompt_mapping=cls.get_model_prompt_mapper(),
139
+ default_prompt_path=cls.get_default_prompt_template_file_name(),
140
+ fallback_prompt_path=cls.get_fallback_prompt_template_file_name(),
141
+ log_source_component=log_source_component,
577
142
  log_source_method=log_context,
578
143
  )
579
144
 
580
145
  # Return the prompt template either from the config or the default prompt.
581
- return prompt_template or get_prompt_template(
146
+ return get_prompt_template(
582
147
  config.get(PROMPT_TEMPLATE_CONFIG_KEY),
583
148
  default_command_prompt_template,
584
- log_source_component=CompactLLMCommandGenerator.__name__,
149
+ log_source_component=log_source_component,
585
150
  log_source_method=log_context,
586
151
  )