rasa-pro 3.14.0.dev6__py3-none-any.whl → 3.14.0.dev8__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 (491) hide show
  1. rasa/agents/agent_manager.py +1 -1
  2. rasa/agents/constants.py +2 -2
  3. rasa/agents/exceptions.py +31 -1
  4. rasa/agents/protocol/a2a/a2a_agent.py +385 -227
  5. rasa/agents/protocol/mcp/mcp_base_agent.py +37 -19
  6. rasa/agents/protocol/mcp/mcp_open_agent.py +31 -8
  7. rasa/agents/protocol/mcp/mcp_task_agent.py +33 -10
  8. rasa/agents/schemas/agent_output.py +1 -1
  9. rasa/agents/utils.py +95 -1
  10. rasa/agents/validation.py +484 -0
  11. rasa/api.py +9 -6
  12. rasa/builder/README.md +120 -0
  13. rasa/builder/__init__.py +0 -0
  14. rasa/builder/auth.py +176 -0
  15. rasa/builder/config.py +92 -0
  16. rasa/builder/copilot/__init__.py +0 -0
  17. rasa/builder/copilot/constants.py +31 -0
  18. rasa/builder/copilot/copilot.py +450 -0
  19. rasa/builder/copilot/copilot_response_handler.py +522 -0
  20. rasa/builder/copilot/copilot_templated_message_provider.py +58 -0
  21. rasa/builder/copilot/exceptions.py +32 -0
  22. rasa/builder/copilot/models.py +500 -0
  23. rasa/builder/copilot/prompts/__init__.py +0 -0
  24. rasa/builder/copilot/prompts/copilot_system_prompt.jinja2 +766 -0
  25. rasa/builder/copilot/prompts/latest_user_message_context_prompt.jinja2 +61 -0
  26. rasa/builder/copilot/signing.py +305 -0
  27. rasa/builder/copilot/telemetry.py +210 -0
  28. rasa/builder/copilot/templated_messages/__init__.py +0 -0
  29. rasa/builder/copilot/templated_messages/copilot_internal_messages_templates.yml +16 -0
  30. rasa/builder/copilot/templated_messages/copilot_templated_responses.yml +38 -0
  31. rasa/builder/document_retrieval/__init__.py +0 -0
  32. rasa/builder/document_retrieval/constants.py +15 -0
  33. rasa/builder/document_retrieval/inkeep-rag-response-schema.json +64 -0
  34. rasa/builder/document_retrieval/inkeep_document_retrieval.py +238 -0
  35. rasa/builder/document_retrieval/models.py +62 -0
  36. rasa/builder/download.py +140 -0
  37. rasa/builder/exceptions.py +91 -0
  38. rasa/builder/guardrails/__init__.py +1 -0
  39. rasa/builder/guardrails/constants.py +9 -0
  40. rasa/builder/guardrails/exceptions.py +4 -0
  41. rasa/builder/guardrails/lakera.py +206 -0
  42. rasa/builder/guardrails/models.py +231 -0
  43. rasa/builder/guardrails/store.py +238 -0
  44. rasa/builder/guardrails/utils.py +328 -0
  45. rasa/builder/job_manager.py +87 -0
  46. rasa/builder/jobs.py +282 -0
  47. rasa/builder/llm_service.py +246 -0
  48. rasa/builder/logging_utils.py +265 -0
  49. rasa/builder/main.py +243 -0
  50. rasa/builder/models.py +216 -0
  51. rasa/builder/project_generator.py +458 -0
  52. rasa/builder/project_info.py +72 -0
  53. rasa/builder/scrape_rasa_docs.py +97 -0
  54. rasa/builder/service.py +1345 -0
  55. rasa/builder/shared/tracker_context.py +212 -0
  56. rasa/builder/skill_to_bot_prompt.jinja2 +164 -0
  57. rasa/builder/template_cache.py +244 -0
  58. rasa/builder/training_service.py +194 -0
  59. rasa/builder/validation_service.py +97 -0
  60. rasa/cli/arguments/train.py +2 -0
  61. rasa/cli/interactive.py +2 -0
  62. rasa/cli/project_templates/basic/README.md +23 -0
  63. rasa/cli/project_templates/basic/actions/__init__ +0 -0
  64. rasa/cli/project_templates/basic/actions/action_human_handoff.py +40 -0
  65. rasa/cli/project_templates/basic/actions/actions.md +10 -0
  66. rasa/cli/project_templates/basic/config.yml +29 -0
  67. rasa/cli/project_templates/basic/credentials.yml +33 -0
  68. rasa/cli/project_templates/basic/data/data.md +9 -0
  69. rasa/cli/project_templates/basic/data/general/feedback.yml +21 -0
  70. rasa/cli/project_templates/basic/data/general/goodbye.yml +6 -0
  71. rasa/cli/project_templates/basic/data/general/hello.yml +6 -0
  72. rasa/cli/project_templates/basic/data/general/help.yml +6 -0
  73. rasa/cli/project_templates/basic/data/general/human_handoff.yml +16 -0
  74. rasa/cli/project_templates/basic/data/general/show_faqs.yml +6 -0
  75. rasa/cli/project_templates/basic/data/system/patterns/pattern_cannot_handle.yml +7 -0
  76. rasa/cli/project_templates/basic/data/system/patterns/pattern_completed.yml +7 -0
  77. rasa/cli/project_templates/basic/data/system/patterns/pattern_correction.yml +7 -0
  78. rasa/cli/project_templates/basic/data/system/patterns/pattern_search.yml +8 -0
  79. rasa/cli/project_templates/basic/data/system/patterns/pattern_session_start.yml +8 -0
  80. rasa/cli/project_templates/basic/docs/docs.md +5 -0
  81. rasa/cli/project_templates/basic/docs/template.txt +28 -0
  82. rasa/cli/project_templates/basic/domain/domain.md +8 -0
  83. rasa/cli/project_templates/basic/domain/general/feedback.yml +25 -0
  84. rasa/cli/project_templates/basic/domain/general/goodbye.yml +9 -0
  85. rasa/cli/project_templates/basic/domain/general/hello.yml +7 -0
  86. rasa/cli/project_templates/basic/domain/general/help.yml +21 -0
  87. rasa/cli/project_templates/basic/domain/general/human_handoff.yml +32 -0
  88. rasa/cli/project_templates/basic/domain/general/show_faqs.yml +14 -0
  89. rasa/cli/project_templates/basic/domain/system/patterns/pattern_cannot_handle.yml +5 -0
  90. rasa/cli/project_templates/basic/domain/system/patterns/pattern_session_start.yml +19 -0
  91. rasa/cli/project_templates/basic/endpoints.yml +67 -0
  92. rasa/cli/project_templates/basic/prompts/rephraser_demo_personality_prompt.jinja2 +38 -0
  93. rasa/cli/project_templates/default/config.yml +4 -0
  94. rasa/cli/project_templates/default/endpoints.yml +4 -0
  95. rasa/cli/project_templates/finance/README.md +25 -0
  96. rasa/cli/project_templates/finance/actions/__init__.py +46 -0
  97. rasa/cli/project_templates/finance/actions/accounts/__init__.py +0 -0
  98. rasa/cli/project_templates/finance/actions/accounts/action_ask_account.py +47 -0
  99. rasa/cli/project_templates/finance/actions/accounts/action_check_balance.py +40 -0
  100. rasa/cli/project_templates/finance/actions/action_session_start.py +74 -0
  101. rasa/cli/project_templates/finance/actions/actions.md +15 -0
  102. rasa/cli/project_templates/finance/actions/cards/__init__.py +0 -0
  103. rasa/cli/project_templates/finance/actions/cards/action_ask_card.py +48 -0
  104. rasa/cli/project_templates/finance/actions/cards/action_check_card_existence.py +36 -0
  105. rasa/cli/project_templates/finance/actions/cards/action_update_card_status.py +54 -0
  106. rasa/cli/project_templates/finance/actions/database.py +277 -0
  107. rasa/cli/project_templates/finance/actions/transfers/__init__.py +0 -0
  108. rasa/cli/project_templates/finance/actions/transfers/action_add_payee.py +52 -0
  109. rasa/cli/project_templates/finance/actions/transfers/action_ask_account_from.py +51 -0
  110. rasa/cli/project_templates/finance/actions/transfers/action_check_payee_existence.py +40 -0
  111. rasa/cli/project_templates/finance/actions/transfers/action_check_sufficient_funds.py +40 -0
  112. rasa/cli/project_templates/finance/actions/transfers/action_list_payees.py +46 -0
  113. rasa/cli/project_templates/finance/actions/transfers/action_process_immediate_payment.py +18 -0
  114. rasa/cli/project_templates/finance/actions/transfers/action_remove_payee.py +49 -0
  115. rasa/cli/project_templates/finance/actions/transfers/action_schedule_payment.py +19 -0
  116. rasa/cli/project_templates/finance/actions/transfers/action_validate_payment_date.py +36 -0
  117. rasa/cli/project_templates/finance/config.yml +23 -0
  118. rasa/cli/project_templates/finance/credentials.yml +32 -0
  119. rasa/cli/project_templates/finance/csvs/accounts.csv +8 -0
  120. rasa/cli/project_templates/finance/csvs/advisors.csv +7 -0
  121. rasa/cli/project_templates/finance/csvs/appointments.csv +211 -0
  122. rasa/cli/project_templates/finance/csvs/branches.csv +10 -0
  123. rasa/cli/project_templates/finance/csvs/cards.csv +11 -0
  124. rasa/cli/project_templates/finance/csvs/payees.csv +11 -0
  125. rasa/cli/project_templates/finance/csvs/transactions.csv +71 -0
  126. rasa/cli/project_templates/finance/csvs/users.csv +4 -0
  127. rasa/cli/project_templates/finance/data/accounts/check_balance.yml +10 -0
  128. rasa/cli/project_templates/finance/data/cards/block_card.yml +66 -0
  129. rasa/cli/project_templates/finance/data/cards/select_card.yml +12 -0
  130. rasa/cli/project_templates/finance/data/data.md +11 -0
  131. rasa/cli/project_templates/finance/data/general/bot_identity.yml +6 -0
  132. rasa/cli/project_templates/finance/data/general/feedback.yml +20 -0
  133. rasa/cli/project_templates/finance/data/general/goodbye.yml +6 -0
  134. rasa/cli/project_templates/finance/data/general/hello.yml +7 -0
  135. rasa/cli/project_templates/finance/data/general/help.yml +9 -0
  136. rasa/cli/project_templates/finance/data/general/human_handoff.yml +16 -0
  137. rasa/cli/project_templates/finance/data/general/welcome.yml +9 -0
  138. rasa/cli/project_templates/finance/data/system/patterns/pattern_chitchat.yml +5 -0
  139. rasa/cli/project_templates/finance/data/system/patterns/pattern_completed.yml +7 -0
  140. rasa/cli/project_templates/finance/data/system/patterns/pattern_correction.yml +7 -0
  141. rasa/cli/project_templates/finance/data/system/patterns/pattern_search.yml +8 -0
  142. rasa/cli/project_templates/finance/data/system/patterns/pattern_session_start.yml +8 -0
  143. rasa/cli/project_templates/finance/data/system/source/accounts.json +51 -0
  144. rasa/cli/project_templates/finance/data/system/source/advisors.json +44 -0
  145. rasa/cli/project_templates/finance/data/system/source/appointments.json +1474 -0
  146. rasa/cli/project_templates/finance/data/system/source/branches.json +47 -0
  147. rasa/cli/project_templates/finance/data/system/source/cards.json +72 -0
  148. rasa/cli/project_templates/finance/data/system/source/payees.json +74 -0
  149. rasa/cli/project_templates/finance/data/system/source/transactions.json +492 -0
  150. rasa/cli/project_templates/finance/data/system/source/users.json +29 -0
  151. rasa/cli/project_templates/finance/data/transfers/add_payee.yml +29 -0
  152. rasa/cli/project_templates/finance/data/transfers/list_payees.yml +5 -0
  153. rasa/cli/project_templates/finance/data/transfers/remove_payee.yml +21 -0
  154. rasa/cli/project_templates/finance/data/transfers/transfer_money.yml +67 -0
  155. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/consequences_of_blocking_card.txt +8 -0
  156. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/reasons_to_block_card.txt +8 -0
  157. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/recovering_from_card_fraud.txt +8 -0
  158. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/tips_for_card_security.txt +8 -0
  159. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/what_to_do_if_card_is_lost.txt +8 -0
  160. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/account_balance_security.txt +7 -0
  161. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/common_balance_inquiries.txt +8 -0
  162. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/methods_to_check_balance.txt +8 -0
  163. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/understanding_balance_updates.txt +8 -0
  164. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/what_to_do_if_balance_is_incorrect.txt +8 -0
  165. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/benefits_of_authorised_payees.txt +8 -0
  166. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/common_issues_with_payees.txt +8 -0
  167. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/general_payee_information.txt +8 -0
  168. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/payee_management_tips.txt +8 -0
  169. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/understanding_payee_types.txt +8 -0
  170. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/common_transfer_errors.txt +8 -0
  171. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/fees_for_transfers.txt +8 -0
  172. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/general_transfer_information.txt +8 -0
  173. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/security_tips_for_transfers.txt +8 -0
  174. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/transfer_processing_times.txt +8 -0
  175. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part1.txt +50 -0
  176. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part10.txt +50 -0
  177. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part11.txt +48 -0
  178. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part12.txt +50 -0
  179. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part13.txt +50 -0
  180. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part14.txt +47 -0
  181. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part15.txt +50 -0
  182. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part16.txt +50 -0
  183. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part17.txt +47 -0
  184. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part18.txt +50 -0
  185. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part19.txt +50 -0
  186. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part2.txt +50 -0
  187. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part20.txt +47 -0
  188. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part21.txt +50 -0
  189. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part22.txt +50 -0
  190. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part23.txt +47 -0
  191. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part24.txt +50 -0
  192. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part25.txt +50 -0
  193. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part26.txt +47 -0
  194. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part27.txt +50 -0
  195. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part28.txt +50 -0
  196. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part29.txt +47 -0
  197. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part3.txt +47 -0
  198. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part30.txt +50 -0
  199. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part31.txt +50 -0
  200. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part32.txt +47 -0
  201. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part33.txt +50 -0
  202. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part34.txt +50 -0
  203. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part35.txt +47 -0
  204. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part36.txt +50 -0
  205. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part37.txt +50 -0
  206. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part38.txt +47 -0
  207. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part39.txt +50 -0
  208. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part4.txt +50 -0
  209. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part40.txt +50 -0
  210. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part41.txt +47 -0
  211. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part42.txt +50 -0
  212. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part43.txt +50 -0
  213. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part44.txt +47 -0
  214. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part45.txt +50 -0
  215. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part46.txt +50 -0
  216. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part47.txt +47 -0
  217. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part48.txt +50 -0
  218. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part49.txt +50 -0
  219. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part5.txt +50 -0
  220. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part50.txt +47 -0
  221. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part51.txt +50 -0
  222. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part52.txt +50 -0
  223. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part53.txt +47 -0
  224. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part54.txt +50 -0
  225. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part55.txt +50 -0
  226. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part56.txt +47 -0
  227. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part57.txt +50 -0
  228. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part58.txt +50 -0
  229. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part59.txt +47 -0
  230. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part6.txt +47 -0
  231. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part60.txt +50 -0
  232. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part61.txt +50 -0
  233. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part7.txt +50 -0
  234. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part8.txt +50 -0
  235. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part9.txt +47 -0
  236. rasa/cli/project_templates/finance/domain/accounts/check_balance.yml +11 -0
  237. rasa/cli/project_templates/finance/domain/cards/block_card.yml +101 -0
  238. rasa/cli/project_templates/finance/domain/cards/select_card.yml +12 -0
  239. rasa/cli/project_templates/finance/domain/domain.md +10 -0
  240. rasa/cli/project_templates/finance/domain/general/agent_details.yml +12 -0
  241. rasa/cli/project_templates/finance/domain/general/bot_identity.yml +5 -0
  242. rasa/cli/project_templates/finance/domain/general/cannot_handle.yml +5 -0
  243. rasa/cli/project_templates/finance/domain/general/defaults.yml +24 -0
  244. rasa/cli/project_templates/finance/domain/general/feedback.yml +28 -0
  245. rasa/cli/project_templates/finance/domain/general/goodbye.yml +7 -0
  246. rasa/cli/project_templates/finance/domain/general/help.yml +5 -0
  247. rasa/cli/project_templates/finance/domain/general/human_handoff.yml +30 -0
  248. rasa/cli/project_templates/finance/domain/general/utils.yml +13 -0
  249. rasa/cli/project_templates/finance/domain/general/welcome.yml +8 -0
  250. rasa/cli/project_templates/finance/domain/transfers/add_payee.yml +47 -0
  251. rasa/cli/project_templates/finance/domain/transfers/list_payees.yml +4 -0
  252. rasa/cli/project_templates/finance/domain/transfers/remove_payee.yml +16 -0
  253. rasa/cli/project_templates/finance/domain/transfers/transfer_money.yml +79 -0
  254. rasa/cli/project_templates/finance/endpoints.yml +66 -0
  255. rasa/cli/project_templates/finance/prompts/rephraser_demo_personality_prompt.jinja2 +19 -0
  256. rasa/cli/project_templates/telco/README.md +25 -0
  257. rasa/cli/project_templates/telco/actions/__init__.py +0 -0
  258. rasa/cli/project_templates/telco/actions/actions.md +12 -0
  259. rasa/cli/project_templates/telco/actions/billing/__init__.py +0 -0
  260. rasa/cli/project_templates/telco/actions/billing/actions_billing.py +204 -0
  261. rasa/cli/project_templates/telco/actions/general/__init__.py +0 -0
  262. rasa/cli/project_templates/telco/actions/general/action_human_handoff.py +49 -0
  263. rasa/cli/project_templates/telco/actions/network/__init__.py +0 -0
  264. rasa/cli/project_templates/telco/actions/network/actions_get_data_from_db.py +48 -0
  265. rasa/cli/project_templates/telco/actions/network/actions_run_diagnostics.py +28 -0
  266. rasa/cli/project_templates/telco/actions/network/actions_session_start.py +18 -0
  267. rasa/cli/project_templates/telco/config.yml +29 -0
  268. rasa/cli/project_templates/telco/credentials.yml +33 -0
  269. rasa/cli/project_templates/telco/csvs/billing.csv +19 -0
  270. rasa/cli/project_templates/telco/csvs/customers.csv +5 -0
  271. rasa/cli/project_templates/telco/data/billing/flow_understand_bill.yml +45 -0
  272. rasa/cli/project_templates/telco/data/data.md +11 -0
  273. rasa/cli/project_templates/telco/data/general/bot_challenge.yml +6 -0
  274. rasa/cli/project_templates/telco/data/general/feedback.yml +20 -0
  275. rasa/cli/project_templates/telco/data/general/goodbye.yml +6 -0
  276. rasa/cli/project_templates/telco/data/general/hello.yml +6 -0
  277. rasa/cli/project_templates/telco/data/general/human_handoff.yml +16 -0
  278. rasa/cli/project_templates/telco/data/general/patterns.yml +30 -0
  279. rasa/cli/project_templates/telco/data/network/flow_reboot_router.yml +8 -0
  280. rasa/cli/project_templates/telco/data/network/flow_reset_router.yml +7 -0
  281. rasa/cli/project_templates/telco/data/network/flow_solve_internet_issue.yml +73 -0
  282. rasa/cli/project_templates/telco/docs/docs.md +5 -0
  283. rasa/cli/project_templates/telco/docs/network/reset_vs_rboot_router.txt +1 -0
  284. rasa/cli/project_templates/telco/docs/network/restart_router.txt +6 -0
  285. rasa/cli/project_templates/telco/docs/network/run_speed_test.txt +6 -0
  286. rasa/cli/project_templates/telco/domain/billing/understand_bill.yml +102 -0
  287. rasa/cli/project_templates/telco/domain/domain.md +14 -0
  288. rasa/cli/project_templates/telco/domain/general/bot_challenge.yml +4 -0
  289. rasa/cli/project_templates/telco/domain/general/feedback.yml +25 -0
  290. rasa/cli/project_templates/telco/domain/general/goodbye.yml +7 -0
  291. rasa/cli/project_templates/telco/domain/general/hello.yml +5 -0
  292. rasa/cli/project_templates/telco/domain/general/human_handoff.yml +26 -0
  293. rasa/cli/project_templates/telco/domain/general/patterns.yml +33 -0
  294. rasa/cli/project_templates/telco/domain/network/reboot_router.yml +21 -0
  295. rasa/cli/project_templates/telco/domain/network/reset_router.yml +12 -0
  296. rasa/cli/project_templates/telco/domain/network/run_speed_test.yml +25 -0
  297. rasa/cli/project_templates/telco/domain/network/solve_internet_issue.yml +75 -0
  298. rasa/cli/project_templates/telco/domain/shared.yml +129 -0
  299. rasa/cli/project_templates/telco/endpoints.yml +67 -0
  300. rasa/cli/project_templates/telco/prompts/rephraser_demo_personality_prompt.jinja2 +40 -0
  301. rasa/cli/project_templates/telco/tests/e2e_test_cases/billing/understand_bill.yml +67 -0
  302. rasa/cli/project_templates/telco/tests/e2e_test_cases/general/bot_challenge.yml +8 -0
  303. rasa/cli/project_templates/telco/tests/e2e_test_cases/general/feedback.yml +46 -0
  304. rasa/cli/project_templates/telco/tests/e2e_test_cases/general/goodbye.yml +9 -0
  305. rasa/cli/project_templates/telco/tests/e2e_test_cases/general/hello.yml +8 -0
  306. rasa/cli/project_templates/telco/tests/e2e_test_cases/general/human_handoff.yml +35 -0
  307. rasa/cli/project_templates/telco/tests/e2e_test_cases/general/patterns.yml +23 -0
  308. rasa/cli/project_templates/telco/tests/e2e_test_cases/network/solve_internet_issue.yml +57 -0
  309. rasa/cli/project_templates/tutorial/config.yml +2 -1
  310. rasa/cli/scaffold.py +46 -2
  311. rasa/cli/train.py +2 -0
  312. rasa/cli/utils.py +85 -1
  313. rasa/core/actions/action.py +2 -7
  314. rasa/core/available_agents.py +49 -26
  315. rasa/core/available_endpoints.py +17 -2
  316. rasa/core/channels/channel.py +4 -3
  317. rasa/core/channels/constants.py +3 -0
  318. rasa/core/channels/development_inspector.py +2 -22
  319. rasa/core/channels/inspector/README.md +26 -14
  320. rasa/core/channels/inspector/dist/assets/{arc-63212852.js → arc-edef10dd.js} +1 -1
  321. rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-eecf6b13.js → blockDiagram-38ab4fdb-49f6762b.js} +1 -1
  322. rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-8f798a9a.js → c4Diagram-3d4e48cf-313c08e6.js} +1 -1
  323. rasa/core/channels/inspector/dist/assets/channel-63aa27d1.js +1 -0
  324. rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-df71a04c.js → classDiagram-70f12bd4-35e41ce9.js} +1 -1
  325. rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-9b275968.js → classDiagram-v2-f2320105-f346068d.js} +1 -1
  326. rasa/core/channels/inspector/dist/assets/clone-5566bae8.js +1 -0
  327. rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-1c669cad.js → createText-2e5e7dd3-7a44bce8.js} +1 -1
  328. rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-b1553799.js → edges-e0da2a9e-d7cf78c7.js} +1 -1
  329. rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-112388d6.js → erDiagram-9861fffd-9813e81c.js} +1 -1
  330. rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-fdebec47.js → flowDb-956e92f1-d8ba0870.js} +1 -1
  331. rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-6280ede1.js → flowDiagram-66a62f08-51f0db4d.js} +1 -1
  332. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-32936074.js +1 -0
  333. rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-e1dc03e5.js → flowchart-elk-definition-4a651766-ff9ea384.js} +1 -1
  334. rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-83f68c51.js → ganttDiagram-c361ad54-a8e13b6b.js} +1 -1
  335. rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-22f8666f.js → gitGraphDiagram-72cf32ee-3b171c6d.js} +1 -1
  336. rasa/core/channels/inspector/dist/assets/{graph-ca9e6217.js → graph-790ef78b.js} +1 -1
  337. rasa/core/channels/inspector/dist/assets/{index-3862675e-c5ceb692.js → index-3862675e-ecdce073.js} +1 -1
  338. rasa/core/channels/inspector/dist/assets/index-d705da80.js +1352 -0
  339. rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-faa9999b.js → infoDiagram-f8f76790-f5a422fe.js} +1 -1
  340. rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-c4dda8d9.js → journeyDiagram-49397b02-3185b7ac.js} +1 -1
  341. rasa/core/channels/inspector/dist/assets/{layout-d4307784.js → layout-837fd3aa.js} +1 -1
  342. rasa/core/channels/inspector/dist/assets/{line-0567aaa7.js → line-7e05afcb.js} +1 -1
  343. rasa/core/channels/inspector/dist/assets/{linear-c11b95cf.js → linear-162eb295.js} +1 -1
  344. rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-0c7d3ca9.js → mindmap-definition-fc14e90a-f4978aee.js} +1 -1
  345. rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-34b433fa.js → pieDiagram-8a3498a8-b25d0a52.js} +1 -1
  346. rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-4cab816e.js → quadrantDiagram-120e2f19-63db1afa.js} +1 -1
  347. rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-8c22fa9e.js → requirementDiagram-deff3bca-1b486cc9.js} +1 -1
  348. rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-70ce9e8e.js → sankeyDiagram-04a897e0-7e795291.js} +1 -1
  349. rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-fbcd7fc9.js → sequenceDiagram-704730f1-b8aba159.js} +1 -1
  350. rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-45f05ea6.js → stateDiagram-587899a1-41529fd5.js} +1 -1
  351. rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-beab1ea6.js → stateDiagram-v2-d93cdb3a-b241043c.js} +1 -1
  352. rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-2f29dbd5.js → styles-6aaf32cf-b5b53234.js} +1 -1
  353. rasa/core/channels/inspector/dist/assets/{styles-9a916d00-951eac83.js → styles-9a916d00-13d138e5.js} +1 -1
  354. rasa/core/channels/inspector/dist/assets/{styles-c10674c1-897fbfdd.js → styles-c10674c1-94cbde3f.js} +1 -1
  355. rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-d667fac1.js → svgDrawCommon-08f97a94-453ae764.js} +1 -1
  356. rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-e3205144.js → timeline-definition-85554ec2-8dcb88a4.js} +1 -1
  357. rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-4abeb0e2.js → xychartDiagram-e933f94c-376af5f0.js} +1 -1
  358. rasa/core/channels/inspector/dist/index.html +2 -2
  359. rasa/core/channels/inspector/index.html +1 -1
  360. rasa/core/channels/inspector/src/App.tsx +42 -44
  361. rasa/core/channels/inspector/src/components/Chat.tsx +2 -3
  362. rasa/core/channels/inspector/src/components/DialogueAgentStack.tsx +108 -0
  363. rasa/core/channels/inspector/src/components/{DialogueStack.tsx → DialogueHistoryStack.tsx} +8 -8
  364. rasa/core/channels/inspector/src/components/DialogueInformation.tsx +20 -3
  365. rasa/core/channels/inspector/src/components/LatencyDisplay.tsx +63 -35
  366. rasa/core/channels/inspector/src/helpers/audio/audiostream.ts +14 -0
  367. rasa/core/channels/inspector/src/helpers/formatters.test.ts +4 -0
  368. rasa/core/channels/inspector/src/helpers/utils.test.ts +127 -0
  369. rasa/core/channels/inspector/src/helpers/utils.ts +66 -1
  370. rasa/core/channels/inspector/src/types.ts +49 -7
  371. rasa/core/channels/socketio.py +212 -51
  372. rasa/core/channels/studio_chat.py +59 -57
  373. rasa/core/channels/voice_stream/asr/asr_event.py +1 -1
  374. rasa/core/channels/voice_stream/asr/azure.py +6 -3
  375. rasa/core/channels/voice_stream/asr/deepgram.py +1 -1
  376. rasa/core/channels/voice_stream/audiocodes.py +3 -0
  377. rasa/core/channels/voice_stream/browser_audio.py +53 -3
  378. rasa/core/channels/voice_stream/genesys.py +2 -1
  379. rasa/core/channels/voice_stream/jambonz.py +9 -1
  380. rasa/core/channels/voice_stream/twilio_media_streams.py +16 -0
  381. rasa/core/channels/voice_stream/voice_channel.py +66 -3
  382. rasa/core/constants.py +6 -0
  383. rasa/core/iam_credentials_providers/__init__.py +0 -0
  384. rasa/core/iam_credentials_providers/aws_iam_credentials_providers.py +66 -0
  385. rasa/core/iam_credentials_providers/credentials_provider_protocol.py +89 -0
  386. rasa/core/policies/enterprise_search_policy.py +4 -7
  387. rasa/core/policies/flows/flow_executor.py +66 -36
  388. rasa/core/policies/ted_policy.py +7 -5
  389. rasa/core/processor.py +32 -0
  390. rasa/core/redis_connection_factory.py +411 -0
  391. rasa/core/run.py +13 -3
  392. rasa/core/tracker_stores/redis_tracker_store.py +32 -14
  393. rasa/core/tracker_stores/sql_tracker_store.py +57 -1
  394. rasa/dialogue_understanding/commands/cancel_flow_command.py +2 -81
  395. rasa/dialogue_understanding/commands/start_flow_command.py +18 -113
  396. rasa/dialogue_understanding/commands/utils.py +118 -0
  397. rasa/dialogue_understanding/generator/flow_retrieval.py +10 -9
  398. rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v2_claude_3_5_sonnet_20240620_template.jinja2 +10 -5
  399. rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v2_gpt_4o_2024_11_20_template.jinja2 +10 -5
  400. rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v3_claude_3_5_sonnet_20240620_template.jinja2 +20 -12
  401. rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v3_gpt_4o_2024_11_20_template.jinja2 +19 -12
  402. rasa/dialogue_understanding/generator/single_step/single_step_based_llm_command_generator.py +6 -35
  403. rasa/dialogue_understanding/patterns/cancel.py +27 -6
  404. rasa/dialogue_understanding/patterns/clarify.py +3 -14
  405. rasa/dialogue_understanding/patterns/continue_interrupted.py +185 -114
  406. rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +18 -24
  407. rasa/dialogue_understanding/processor/command_processor.py +35 -0
  408. rasa/dialogue_understanding/stack/utils.py +43 -4
  409. rasa/dialogue_understanding/utils.py +24 -4
  410. rasa/engine/graph.py +5 -1
  411. rasa/engine/recipes/default_components.py +78 -10
  412. rasa/engine/recipes/default_recipe.py +41 -1
  413. rasa/engine/storage/local_model_storage.py +83 -3
  414. rasa/graph_components/validators/default_recipe_validator.py +153 -135
  415. rasa/model_manager/model_api.py +4 -5
  416. rasa/model_manager/runner_service.py +1 -1
  417. rasa/model_manager/socket_bridge.py +20 -15
  418. rasa/model_manager/trainer_service.py +12 -9
  419. rasa/model_manager/utils.py +1 -29
  420. rasa/model_manager/warm_rasa_process.py +1 -1
  421. rasa/model_training.py +22 -6
  422. rasa/nlu/classifiers/diet_classifier.py +22 -6
  423. rasa/nlu/classifiers/logistic_regression_classifier.py +18 -0
  424. rasa/nlu/extractors/extractor.py +1 -2
  425. rasa/shared/agents/auth/__init__.py +0 -0
  426. rasa/shared/agents/auth/agent_auth_factory.py +74 -0
  427. rasa/shared/agents/auth/agent_auth_manager.py +86 -0
  428. rasa/shared/agents/auth/auth_strategy/__init__.py +19 -0
  429. rasa/shared/agents/auth/auth_strategy/agent_auth_strategy.py +52 -0
  430. rasa/shared/agents/auth/auth_strategy/api_key_auth_strategy.py +42 -0
  431. rasa/shared/agents/auth/auth_strategy/bearer_token_auth_strategy.py +28 -0
  432. rasa/shared/agents/auth/auth_strategy/oauth2_auth_strategy.py +159 -0
  433. rasa/shared/agents/auth/constants.py +11 -0
  434. rasa/shared/agents/auth/types.py +11 -0
  435. rasa/shared/constants.py +3 -0
  436. rasa/shared/core/constants.py +6 -6
  437. rasa/shared/core/domain.py +58 -11
  438. rasa/shared/core/events.py +2 -0
  439. rasa/shared/core/flows/constants.py +5 -0
  440. rasa/shared/core/flows/flow_step.py +7 -1
  441. rasa/shared/core/flows/flows_list.py +6 -0
  442. rasa/shared/core/flows/steps/call.py +15 -12
  443. rasa/shared/core/flows/validation.py +238 -44
  444. rasa/shared/core/flows/yaml_flows_io.py +15 -6
  445. rasa/shared/core/slots.py +4 -0
  446. rasa/shared/exceptions.py +12 -0
  447. rasa/shared/importers/importer.py +6 -0
  448. rasa/shared/importers/utils.py +77 -1
  449. rasa/shared/nlu/training_data/schemas/responses.yml +3 -0
  450. rasa/shared/providers/_utils.py +60 -44
  451. rasa/shared/providers/embedding/default_litellm_embedding_client.py +2 -0
  452. rasa/shared/providers/llm/_base_litellm_client.py +2 -2
  453. rasa/shared/providers/llm/default_litellm_llm_client.py +2 -0
  454. rasa/shared/providers/llm/llm_response.py +4 -4
  455. rasa/shared/utils/common.py +24 -0
  456. rasa/shared/utils/health_check/health_check.py +7 -3
  457. rasa/shared/utils/llm.py +2 -1
  458. rasa/shared/utils/mcp/server_connection.py +108 -27
  459. rasa/shared/utils/mcp/utils.py +20 -0
  460. rasa/studio/upload.py +16 -47
  461. rasa/telemetry.py +97 -23
  462. rasa/tracing/config.py +38 -12
  463. rasa/tracing/instrumentation/attribute_extractors.py +5 -1
  464. rasa/tracing/instrumentation/instrumentation.py +85 -8
  465. rasa/utils/common.py +1 -1
  466. rasa/utils/io.py +27 -9
  467. rasa/utils/json_utils.py +6 -1
  468. rasa/utils/log_utils.py +5 -1
  469. rasa/utils/openapi.py +144 -0
  470. rasa/utils/tensorflow/__init__.py +29 -0
  471. rasa/utils/tensorflow/callback.py +1 -1
  472. rasa/utils/tensorflow/crf.py +1 -1
  473. rasa/utils/tensorflow/data_generator.py +21 -8
  474. rasa/utils/tensorflow/layers.py +11 -4
  475. rasa/utils/tensorflow/metrics.py +7 -3
  476. rasa/utils/tensorflow/models.py +41 -6
  477. rasa/utils/tensorflow/rasa_layers.py +6 -4
  478. rasa/utils/tensorflow/transformer.py +2 -3
  479. rasa/utils/train_utils.py +68 -38
  480. rasa/validator.py +18 -16
  481. rasa/version.py +1 -1
  482. rasa_pro-3.14.0.dev8.dist-info/METADATA +199 -0
  483. {rasa_pro-3.14.0.dev6.dist-info → rasa_pro-3.14.0.dev8.dist-info}/RECORD +486 -173
  484. rasa/core/channels/inspector/dist/assets/channel-0cd70adf.js +0 -1
  485. rasa/core/channels/inspector/dist/assets/clone-a0f9c4ed.js +0 -1
  486. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-de9cc4aa.js +0 -1
  487. rasa/core/channels/inspector/dist/assets/index-3e293924.js +0 -1353
  488. rasa_pro-3.14.0.dev6.dist-info/METADATA +0 -190
  489. {rasa_pro-3.14.0.dev6.dist-info → rasa_pro-3.14.0.dev8.dist-info}/NOTICE +0 -0
  490. {rasa_pro-3.14.0.dev6.dist-info → rasa_pro-3.14.0.dev8.dist-info}/WHEEL +0 -0
  491. {rasa_pro-3.14.0.dev6.dist-info → rasa_pro-3.14.0.dev8.dist-info}/entry_points.txt +0 -0
@@ -13,13 +13,13 @@ Use the following structured data:
13
13
 
14
14
  ## Available Actions:
15
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.
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. ONLY use slots that are explicitly defined in the flow's slot list.
17
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
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
19
  * `cancel flow`: Cancel the current flow if the user requests it.
20
20
  * `repeat message`: Repeat the last bot message.
21
- {% if active_agent %} * `continue agent`: Continue the currently active agent {{ active_agent.name }}.{% endif %}
22
- {% if completed_agents %}* `restart agent agent_name`: Restart the agent with the given name, in case the user wants to change some answer to a previous question asked by the agent. For example, `restart agent car_research_agent` if the user chnaged his mind about the car he wants to buy.{% endif %}
21
+ {% if active_agent %} * `continue agent`: Continue the currently active agent {{ active_agent.name }}. This has HIGHEST PRIORITY when an agent is active and the user is responding to agent questions.{% endif %}
22
+ {% if completed_agents %}* `restart agent agent_name`: Restart the agent with the given name, in case the user wants to change some answer to a previous question asked by the agent. For example, `restart agent car_research_agent` if the user changed his mind about the car he wants to buy. ONLY use agents that are listed in the `completed_agents` section.{% endif %}
23
23
 
24
24
  ---
25
25
 
@@ -32,6 +32,7 @@ Use the following structured data:
32
32
  * For categorical slots try to match the user message with allowed slot values. Use "other" if you cannot match it.
33
33
  * Set the boolean slots based on the user response. Map positive responses to `True`, and negative to `False`.
34
34
  * Extract text slot values exactly as provided by the user. Avoid assumptions, format changes, or partial extractions.
35
+ * ONLY use `set slot` with slots that are explicitly defined in the current flow's slot list. Do NOT create or assume slots that don't exist.
35
36
  ### Disambiguate Flows
36
37
  * Use `disambiguate flows` when the user's message matches multiple flows and you cannot decide which flow is most appropriate.
37
38
  * If the user message is short and not precise enough to start a flow or `search and reply`, disambiguate.
@@ -42,29 +43,35 @@ Use the following structured data:
42
43
  * Flow Priority: If you are unsure between starting a flow or `search and reply`, always prioritize starting a flow.
43
44
  ### Cancel Flow
44
45
  * Do not cancel any flow unless the user explicitly requests it.
45
- * Multiple flows can be started without cancelling the previous, if the user wants to pursue multiple processes.
46
- ### General Tips
46
+ * Multiple flows can be started without cancelling the previous, if the user wants to pursue multiple processes.{% if active_agent or completed_agents %}
47
+ ### Agents{% if active_agent %}
48
+ * When an agent is active, ALWAYS prioritize `continue agent` over `search and reply` unless the user is clearly asking something unrelated to the agent's task.{% endif %}{% if completed_agents %}
49
+ * ONLY use `restart agent` with agents that are listed in the `completed_agents` section. Do NOT restart non-existent agents.{% endif %}
50
+ * If you're unsure about agent names, refer to the structured data provided in the `Current State` section.
51
+ {% endif %}### General Tips
47
52
  * Only use information provided by the user.
48
53
  * Strictly adhere to the provided action format.
54
+ * ONLY use the exact actions listed above. Do NOT invent new actions like "respond <message>" or any other variations.
49
55
  * Focus on the last message and take it one step at a time.
50
56
  * Use the previous conversation steps only to aid understanding.
51
57
 
52
58
  ---
53
59
 
54
60
  ## Decision Rule Table
55
- | Condition | Action |
56
- |-------------------------------------------------------|--------------------|
57
- | Flow perfectly matches user's message | start flow |
58
- | Multiple flows are equally strong, relevant matches | disambiguate flows |
59
- | User's message is unclear or imprecise | disambiguate flows |
60
- | No flow fits at all, but knowledge base may help | search and reply |
61
+ | Condition | Action |
62
+ |---------------------------------------------------------------|--------------------|{% if active_agent %}
63
+ | Agent is active and the user is responding to agent questions | continue agent |{% endif %}
64
+ | Flow perfectly matches user's message | start flow |
65
+ | Multiple flows are equally strong, relevant matches | disambiguate flows |
66
+ | User's message is unclear or imprecise | disambiguate flows |
67
+ | No flow fits at all, but knowledge base may help | search and reply |
61
68
 
62
69
  ---
63
70
 
64
71
  ## Current State
65
72
  {% if current_flow != None %}Use the following structured data:
66
73
  ```json
67
- {"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 or slot.allowed_values else "" }}{% if slot.description %}"description": {{ slot.description | to_json_escaped_string }}{{ "," if slot.allowed_values else "" }}{% endif %}{% if slot.allowed_values %}"allowed_values": "{{ slot.allowed_values }}"{% endif %}}{% if not loop.last %},{% endif %}{% endfor %}]{% if active_agent or completed_agents %},{% endif %}{% if active_agent %}"active_agent": {"name": "{{ active_agent.name }}","description": "{{ active_agent.description }}"}{% if completed_agents %},{% endif %}{% endif %}{% if completed_agents %}"completed_agents": [{% for agent in completed_agents %}{"name": "{{ agent.name }}","description": "{{ agent.description }}"}{% if not loop.last %},{% endif %}{% endfor %}]{% endif %}}
74
+ {"active_flow":{"name":"{{ 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 %}]}{% if active_agent %},"active_agent":{"name":"{{ active_agent.name }}","description":{{ active_agent.description | to_json_escaped_string }}}{% endif %}{% if completed_agents %},"completed_agents":[{% for agent in completed_agents %}{"name":"{{ agent.name }}","description":{{ agent.description | to_json_escaped_string }}}{% if not loop.last %},{% endif %}{% endfor %}]{% endif %}}
68
75
  ```{% else %}
69
76
  You are currently not inside any flow.{% endif %}
70
77
 
@@ -5,7 +5,10 @@ from typing import Any, Dict, List, Literal, Optional, Text
5
5
  import structlog
6
6
 
7
7
  import rasa.shared.utils.io
8
- from rasa.core.available_agents import AvailableAgents
8
+ from rasa.agents.utils import (
9
+ get_active_agent_info,
10
+ get_completed_agents_info,
11
+ )
9
12
  from rasa.dialogue_understanding.commands import (
10
13
  CannotHandleCommand,
11
14
  Command,
@@ -45,7 +48,6 @@ from rasa.shared.constants import (
45
48
  PROMPT_TEMPLATE_CONFIG_KEY,
46
49
  ROUTE_TO_CALM_SLOT,
47
50
  )
48
- from rasa.shared.core.events import AgentCompleted
49
51
  from rasa.shared.core.flows import FlowsList
50
52
  from rasa.shared.core.trackers import DialogueStateTracker
51
53
  from rasa.shared.exceptions import ProviderClientAPIException
@@ -416,10 +418,10 @@ class SingleStepBasedLLMCommandGenerator(LLMBasedCommandGenerator, ABC):
416
418
  "current_slot_type": current_slot_type,
417
419
  "current_slot_allowed_values": current_slot_allowed_values,
418
420
  "user_message": latest_user_message,
419
- "active_agent": self._get_active_agent(tracker, top_flow.id)
421
+ "active_agent": get_active_agent_info(tracker, top_flow.id)
420
422
  if top_flow
421
423
  else None,
422
- "completed_agents": self._get_completed_agents(tracker),
424
+ "completed_agents": get_completed_agents_info(tracker),
423
425
  }
424
426
 
425
427
  return self.compile_template(self.prompt_template).render(**inputs)
@@ -467,34 +469,3 @@ class SingleStepBasedLLMCommandGenerator(LLMBasedCommandGenerator, ABC):
467
469
  ) -> Optional[str]:
468
470
  """Get the prompt template from the config or the default prompt template."""
469
471
  pass
470
-
471
- def _get_active_agent(
472
- self, tracker: DialogueStateTracker, active_flow_id: str
473
- ) -> Optional[Dict[str, Any]]:
474
- agent_frame = tracker.stack.find_active_agent_stack_frame_for_flow(
475
- active_flow_id
476
- )
477
- if agent_frame:
478
- return self._get_agent_info(agent_frame.agent_id)
479
- return None
480
-
481
- def _get_completed_agents(
482
- self, tracker: DialogueStateTracker
483
- ) -> List[Dict[str, Any]]:
484
- completed_agents: List[Dict[str, Any]] = []
485
- for event in reversed(tracker.events):
486
- if isinstance(event, AgentCompleted):
487
- agent_info = self._get_agent_info(event.agent_id)
488
- if agent_info:
489
- completed_agents.append(agent_info)
490
- return completed_agents
491
-
492
- def _get_agent_info(self, agent_id: str) -> Optional[Dict[str, Any]]:
493
- agent_config = AvailableAgents.get_agent_config(agent_id)
494
- if agent_config is None:
495
- return None
496
-
497
- return {
498
- "name": agent_config.agent.name,
499
- "description": agent_config.agent.description,
500
- }
@@ -8,10 +8,12 @@ import structlog
8
8
  from rasa.core.actions import action
9
9
  from rasa.core.channels.channel import OutputChannel
10
10
  from rasa.core.nlg.generator import NaturalLanguageGenerator
11
+ from rasa.dialogue_understanding.stack.dialogue_stack import DialogueStack
11
12
  from rasa.dialogue_understanding.stack.frames import (
12
13
  BaseFlowStackFrame,
13
14
  PatternFlowStackFrame,
14
15
  )
16
+ from rasa.dialogue_understanding.stack.frames.flow_stack_frame import AgentStackFrame
15
17
  from rasa.shared.constants import RASA_DEFAULT_FLOW_PATTERN_PREFIX
16
18
  from rasa.shared.core.constants import ACTION_CANCEL_FLOW
17
19
  from rasa.shared.core.domain import Domain
@@ -30,7 +32,8 @@ class CancelPatternFlowStackFrame(PatternFlowStackFrame):
30
32
  """A pattern flow stack frame which cancels a flow.
31
33
 
32
34
  The frame contains the information about the stack frames that should
33
- be canceled."""
35
+ be canceled.
36
+ """
34
37
 
35
38
  flow_id: str = FLOW_PATTERN_CANCEL
36
39
  """The ID of the flow."""
@@ -93,19 +96,37 @@ class ActionCancelFlow(action.Action):
93
96
  structlogger.warning("action.cancel_flow.no_cancel_frame")
94
97
  return []
95
98
 
99
+ agent_frame_ids_to_cancel = []
96
100
  for canceled_frame_id in top.canceled_frames:
97
101
  for frame in stack.frames:
98
102
  if frame.frame_id == canceled_frame_id and isinstance(
99
103
  frame, BaseFlowStackFrame
100
104
  ):
101
- # Setting the stack frame to the end step so it is properly
102
- # wrapped up by the flow policy
103
- frame.step_id = ContinueFlowStep.continue_step_for_id(END_STEP)
104
- break
105
+ if isinstance(frame, AgentStackFrame):
106
+ # When an AgentStackFrame needs to be canceled, we can
107
+ # remove it directly from the stack. No extra logic is
108
+ # required in the flow executor, since
109
+ # the AgentCanceled event has already been created by
110
+ # ActionCancelInterruptedFlows or CancelFlowCommand, and the
111
+ # steps following the agentic call step should not be executed.
112
+ agent_frame_ids_to_cancel.append(frame.frame_id)
113
+ break
114
+ else:
115
+ # Setting the stack frame to the end step so it is
116
+ # properly wrapped up by the flow policy
117
+ frame.step_id = ContinueFlowStep.continue_step_for_id(END_STEP)
118
+ break
105
119
  else:
106
120
  structlogger.warning(
107
121
  "action.cancel_flow.frame_not_found",
108
122
  frame_id=canceled_frame_id,
109
123
  )
110
124
 
111
- return tracker.create_stack_updated_events(stack)
125
+ # Create a copy of the stack without the agentic frames that should
126
+ # be canceled
127
+ new_stack = DialogueStack.empty()
128
+ for frame in stack.frames:
129
+ if frame.frame_id not in agent_frame_ids_to_cancel:
130
+ new_stack.push(frame)
131
+
132
+ return tracker.create_stack_updated_events(new_stack)
@@ -61,19 +61,6 @@ class ActionClarifyFlows(action.Action):
61
61
  """Return the flow name."""
62
62
  return ACTION_CLARIFY_FLOWS
63
63
 
64
- @staticmethod
65
- def assemble_options_string(names: List[str]) -> str:
66
- """Concatenate options to a human-readable string."""
67
- clarification_message = ""
68
- for i, name in enumerate(names):
69
- if i == 0:
70
- clarification_message += name
71
- elif i == len(names) - 1:
72
- clarification_message += f" or {name}"
73
- else:
74
- clarification_message += f", {name}"
75
- return clarification_message
76
-
77
64
  async def run(
78
65
  self,
79
66
  output_channel: "OutputChannel",
@@ -83,6 +70,8 @@ class ActionClarifyFlows(action.Action):
83
70
  metadata: Optional[Dict[str, Any]] = None,
84
71
  ) -> List[Event]:
85
72
  """Correct the slots."""
73
+ from rasa.dialogue_understanding.utils import assemble_options_string
74
+
86
75
  stack = tracker.stack
87
76
  if not (top := stack.top()):
88
77
  structlogger.warning("action.clarify_flows.no_active_flow")
@@ -92,7 +81,7 @@ class ActionClarifyFlows(action.Action):
92
81
  structlogger.warning("action.clarify_flows.no_clarification_frame")
93
82
  return []
94
83
 
95
- options_string = self.assemble_options_string(top.names)
84
+ options_string = assemble_options_string(top.names, conjunction="or")
96
85
  top.clarification_options = options_string
97
86
  # since we modified the stack frame, we need to update the stack
98
87
  return tracker.create_stack_updated_events(stack)
@@ -1,31 +1,47 @@
1
1
  from __future__ import annotations
2
2
 
3
- from dataclasses import dataclass
4
- from typing import Any, Dict, List, Optional, Text
3
+ from dataclasses import dataclass, field
4
+ from typing import Any, Dict, List, Optional, Text, Tuple
5
+
6
+ import structlog
5
7
 
6
8
  from rasa.core.actions.action import Action
7
9
  from rasa.core.channels import OutputChannel
8
10
  from rasa.core.nlg import NaturalLanguageGenerator
11
+ from rasa.dialogue_understanding.commands.utils import (
12
+ resume_flow,
13
+ )
14
+ from rasa.dialogue_understanding.patterns.cancel import CancelPatternFlowStackFrame
15
+ from rasa.dialogue_understanding.stack.dialogue_stack import DialogueStack
9
16
  from rasa.dialogue_understanding.stack.frames import PatternFlowStackFrame
10
- from rasa.dialogue_understanding.stack.utils import top_user_flow_frame
17
+ from rasa.dialogue_understanding.stack.frames.dialogue_stack_frame import (
18
+ DialogueStackFrame,
19
+ )
20
+ from rasa.dialogue_understanding.stack.frames.flow_stack_frame import (
21
+ AgentStackFrame,
22
+ FlowStackFrameType,
23
+ UserFlowStackFrame,
24
+ )
25
+ from rasa.dialogue_understanding.stack.utils import (
26
+ get_active_continue_interrupted_pattern_frame,
27
+ )
11
28
  from rasa.shared.constants import RASA_DEFAULT_FLOW_PATTERN_PREFIX
12
29
  from rasa.shared.core.constants import (
13
- ACTION_ASK_INTERRUPTED_FLOW_TO_CONTINUE,
14
- ACTION_CANCEL_INTERRUPTED_FLOW,
30
+ ACTION_CANCEL_INTERRUPTED_FLOWS,
15
31
  ACTION_CONTINUE_INTERRUPTED_FLOW,
16
- ACTION_SET_INTERRUPTED_FLOWS,
17
32
  )
18
33
  from rasa.shared.core.domain import Domain
19
- from rasa.shared.core.events import Event, SlotSet
34
+ from rasa.shared.core.events import AgentCancelled, Event, FlowCancelled, SlotSet
20
35
  from rasa.shared.core.trackers import DialogueStateTracker
21
36
 
22
37
  FLOW_PATTERN_CONTINUE_INTERRUPTED = (
23
38
  RASA_DEFAULT_FLOW_PATTERN_PREFIX + "continue_interrupted"
24
39
  )
25
- INTERRUPTED_FLOWS_SLOT = "interrupted_flows"
26
40
  INTERRUPTED_FLOW_TO_CONTINUE_SLOT = "interrupted_flow_to_continue"
27
- MULTIPLE_FLOWS_INTERRUPTED_SLOT = "multiple_flows_interrupted"
28
- CONFIRMATION_CONTINUE_INTERRUPTED_FLOW_SLOT = "confirmation_continue_interrupted_flow"
41
+ CONTINUE_INTERRUPTED_FLOW_CONFIRMATION_SLOT = "continue_interrupted_flow_confirmation"
42
+
43
+
44
+ structlogger = structlog.get_logger()
29
45
 
30
46
 
31
47
  @dataclass
@@ -34,8 +50,14 @@ class ContinueInterruptedPatternFlowStackFrame(PatternFlowStackFrame):
34
50
 
35
51
  flow_id: str = FLOW_PATTERN_CONTINUE_INTERRUPTED
36
52
  """The ID of the flow."""
37
- previous_flow_name: str = ""
38
- """The name of the flow that was interrupted."""
53
+ interrupted_flow_names: List[str] = field(default_factory=list)
54
+ """The names of the previous flows that were interrupted."""
55
+ interrupted_flow_ids: List[str] = field(default_factory=list)
56
+ """The ids of the previous flows that were interrupted."""
57
+ interrupted_flow_options: str = ""
58
+ """The options that the user can choose from as a string."""
59
+ multiple_flows_interrupted: bool = False
60
+ """Whether the user has interrupted multiple flows."""
39
61
 
40
62
  @classmethod
41
63
  def type(cls) -> str:
@@ -55,7 +77,10 @@ class ContinueInterruptedPatternFlowStackFrame(PatternFlowStackFrame):
55
77
  return ContinueInterruptedPatternFlowStackFrame(
56
78
  frame_id=data["frame_id"],
57
79
  step_id=data["step_id"],
58
- previous_flow_name=data["previous_flow_name"],
80
+ interrupted_flow_names=data["interrupted_flow_names"],
81
+ interrupted_flow_ids=data["interrupted_flow_ids"],
82
+ interrupted_flow_options=data["interrupted_flow_options"],
83
+ multiple_flows_interrupted=len(data["interrupted_flow_names"]) > 1,
59
84
  )
60
85
 
61
86
  def __eq__(self, other: Any) -> bool:
@@ -64,13 +89,15 @@ class ContinueInterruptedPatternFlowStackFrame(PatternFlowStackFrame):
64
89
  return (
65
90
  self.flow_id == other.flow_id
66
91
  and self.step_id == other.step_id
67
- and self.previous_flow_name == other.previous_flow_name
92
+ and self.interrupted_flow_names == other.interrupted_flow_names
93
+ and self.interrupted_flow_ids == other.interrupted_flow_ids
94
+ and self.interrupted_flow_options == other.interrupted_flow_options
68
95
  )
69
96
 
70
97
 
71
- class ActionSetInterruptedFlows(Action):
98
+ class ActionContinueInterruptedFlow(Action):
72
99
  def name(self) -> str:
73
- return ACTION_SET_INTERRUPTED_FLOWS
100
+ return ACTION_CONTINUE_INTERRUPTED_FLOW
74
101
 
75
102
  async def run(
76
103
  self,
@@ -79,25 +106,62 @@ class ActionSetInterruptedFlows(Action):
79
106
  tracker: DialogueStateTracker,
80
107
  domain: Domain,
81
108
  metadata: Optional[Dict[Text, Any]] = None,
82
- ) -> list[Event]:
83
- interrupted_flows_set = set()
84
- interrupted_user_flow_stack_frames = tracker.stack.get_all_user_flow_frames()
109
+ ) -> List[Event]:
110
+ # get the pattern frame from the stack
111
+ pattern_frame = get_active_continue_interrupted_pattern_frame(tracker.stack)
112
+
113
+ if pattern_frame is None:
114
+ structlogger.warning(
115
+ "action.continue_interrupted_flows.no_continue_interrupted_frame"
116
+ )
117
+ return []
85
118
 
86
- for frame in interrupted_user_flow_stack_frames:
87
- interrupted_flows_set.add(frame.flow_id)
119
+ interrupted_flow_ids = pattern_frame.interrupted_flow_ids
120
+ interrupted_flow_names = pattern_frame.interrupted_flow_names
121
+ multiple_flows_interrupted = pattern_frame.multiple_flows_interrupted
122
+
123
+ flow_to_continue = None
124
+ if not multiple_flows_interrupted:
125
+ # the user confirmed that they want to continue the flow
126
+ # as only one flow was interrupted, we can just continue the first one
127
+ flow_to_continue = interrupted_flow_ids[0]
128
+ else:
129
+ # the user mentioned the flow they want to continue
130
+ # check if the flow is in the list of interrupted flows
131
+ selected_flow = tracker.get_slot(INTERRUPTED_FLOW_TO_CONTINUE_SLOT)
132
+ if selected_flow in interrupted_flow_ids:
133
+ flow_to_continue = selected_flow
134
+ elif selected_flow in interrupted_flow_names:
135
+ # the user mentioned the flow by name
136
+ # find the flow id for the flow name
137
+ # the list of names and ids are in the same order
138
+ flow_to_continue = interrupted_flow_ids[
139
+ interrupted_flow_names.index(selected_flow)
140
+ ]
141
+
142
+ # if the user did not select a valid flow,
143
+ # we need to ask them to select a valid flow
144
+ if flow_to_continue is None:
145
+ await output_channel.send_text_message(
146
+ tracker.sender_id,
147
+ "You haven't selected a valid task to resume. "
148
+ "Please specify the task you would like to continue. "
149
+ "The options are: {{context.interrupted_flow_options}}",
150
+ )
151
+ return []
88
152
 
89
- interrupted_flows = list(interrupted_flows_set)
90
- multiple_flows_interrupted = len(interrupted_flows) > 1
153
+ # resume the flow the user selected
154
+ events = resume_flow(flow_to_continue, tracker, tracker.stack)
91
155
 
92
- return [
93
- SlotSet(INTERRUPTED_FLOWS_SLOT, interrupted_flows),
94
- SlotSet(MULTIPLE_FLOWS_INTERRUPTED_SLOT, multiple_flows_interrupted),
156
+ return events + [
157
+ SlotSet(INTERRUPTED_FLOW_TO_CONTINUE_SLOT, None),
158
+ SlotSet(CONTINUE_INTERRUPTED_FLOW_CONFIRMATION_SLOT, None),
95
159
  ]
96
160
 
97
161
 
98
- class ActionAskInterruptedFlowToContinue(Action):
162
+ class ActionCancelInterruptedFlows(Action):
99
163
  def name(self) -> str:
100
- return ACTION_ASK_INTERRUPTED_FLOW_TO_CONTINUE
164
+ return ACTION_CANCEL_INTERRUPTED_FLOWS
101
165
 
102
166
  async def run(
103
167
  self,
@@ -107,107 +171,114 @@ class ActionAskInterruptedFlowToContinue(Action):
107
171
  domain: Domain,
108
172
  metadata: Optional[Dict[Text, Any]] = None,
109
173
  ) -> List[Event]:
110
- interrupted_flows = tracker.get_slot(INTERRUPTED_FLOWS_SLOT) or []
111
-
112
- buttons = [
113
- {
114
- "title": flow_id,
115
- "payload": f'/SetSlots{{"{INTERRUPTED_FLOW_TO_CONTINUE_SLOT}": '
116
- f'"{flow_id}"}}',
117
- }
118
- for flow_id in interrupted_flows or []
119
- ]
120
- buttons.append(
121
- {
122
- "title": "None of them",
123
- "payload": f'/SetSlots{{"{INTERRUPTED_FLOW_TO_CONTINUE_SLOT}": '
124
- f'"none"}}',
125
- }
126
- )
174
+ # get the pattern frame from the stack
175
+ pattern_frame = get_active_continue_interrupted_pattern_frame(tracker.stack)
127
176
 
128
- await output_channel.send_text_with_buttons(
129
- tracker.sender_id,
130
- "You previously started several other tasks. "
131
- "Would you like to resume any of them?",
132
- buttons=buttons,
133
- )
177
+ if pattern_frame is None:
178
+ structlogger.warning(
179
+ "action.continue_interrupted_flows.no_continue_interrupted_frame"
180
+ )
181
+ return []
134
182
 
135
- return []
183
+ interrupted_flow_ids = pattern_frame.interrupted_flow_ids
136
184
 
185
+ event_list: List[Event] = []
137
186
 
138
- class ActionContinueInterruptedFlow(Action):
139
- def name(self) -> str:
140
- return ACTION_CONTINUE_INTERRUPTED_FLOW
187
+ # cancel all interrupted flows
188
+ for flow_id in interrupted_flow_ids:
189
+ event_list.extend(self.cancel_flow(tracker, tracker.stack, flow_id))
141
190
 
142
- async def run(
191
+ return event_list + [
192
+ SlotSet(INTERRUPTED_FLOW_TO_CONTINUE_SLOT, None),
193
+ SlotSet(CONTINUE_INTERRUPTED_FLOW_CONFIRMATION_SLOT, None),
194
+ ]
195
+
196
+ def cancel_flow(
143
197
  self,
144
- output_channel: OutputChannel,
145
- nlg: NaturalLanguageGenerator,
146
198
  tracker: DialogueStateTracker,
147
- domain: Domain,
148
- metadata: Optional[Dict[Text, Any]] = None,
199
+ stack: DialogueStack,
200
+ flow_id: str,
149
201
  ) -> List[Event]:
150
- from rasa.dialogue_understanding.commands import StartFlowCommand
151
-
152
- # get all necessary slot values
153
- multiple = tracker.get_slot(MULTIPLE_FLOWS_INTERRUPTED_SLOT)
154
- selected_flow = tracker.get_slot(INTERRUPTED_FLOW_TO_CONTINUE_SLOT)
155
- interrupted_flows = tracker.get_slot(INTERRUPTED_FLOWS_SLOT) or []
202
+ """Cancels a flow by flow id."""
203
+ applied_events: List[Event] = []
156
204
 
157
- original_user_frame = top_user_flow_frame(tracker.stack)
205
+ frames_to_cancel, user_frame_to_cancel = self._collect_frames_to_cancel(
206
+ stack, flow_id
207
+ )
158
208
 
159
- # case of multiple interrupted flows, where the user selected a flow to continue
160
- if multiple:
161
- flow_id = selected_flow if selected_flow else None
162
- # case of single interrupted flow, so there is only one flow to continue
163
- else:
164
- flow_id = interrupted_flows[0] if interrupted_flows else None
165
-
166
- event_list = []
167
- if flow_id:
168
- # TODO: refactor to avoid creating a StartFlowCommand first
169
- # resume the flow with the provided flow id
170
- start_flow_command = StartFlowCommand(flow_id)
171
- event_list = start_flow_command.resume_flow(
172
- tracker, tracker.stack, original_user_frame
173
- )
174
- else:
175
- await output_channel.send_text_message(
176
- tracker.sender_id,
177
- "You haven't selected a valid task to resume. "
178
- "Please specify the task you would like to continue.",
209
+ # if the flow is not on the stack, do nothing
210
+ if user_frame_to_cancel is None:
211
+ structlogger.error(
212
+ "cancel_flow.no_user_frame_to_cancel",
213
+ flow_id=flow_id,
179
214
  )
215
+ return []
180
216
 
181
- return event_list
217
+ frames_ids_to_cancel = [frame.frame_id for frame in frames_to_cancel]
182
218
 
219
+ stack.push(
220
+ CancelPatternFlowStackFrame(
221
+ canceled_name=flow_id,
222
+ canceled_frames=frames_ids_to_cancel,
223
+ )
224
+ )
183
225
 
184
- class ActionCancelInterruptedFlow(Action):
185
- def name(self) -> str:
186
- return ACTION_CANCEL_INTERRUPTED_FLOW
226
+ # create flow cancelled event
227
+ applied_events.extend(
228
+ [
229
+ FlowCancelled(
230
+ user_frame_to_cancel.flow_id, user_frame_to_cancel.step_id
231
+ ),
232
+ ]
233
+ )
234
+ # create agent cancelled events for any agent frames that are on the stack
235
+ for frame in frames_to_cancel:
236
+ if isinstance(frame, AgentStackFrame):
237
+ applied_events.append(
238
+ AgentCancelled(
239
+ frame.agent_id, frame.flow_id, reason="Flow was cancelled"
240
+ )
241
+ )
187
242
 
188
- async def run(
189
- self,
190
- output_channel: OutputChannel,
191
- nlg: NaturalLanguageGenerator,
192
- tracker: DialogueStateTracker,
193
- domain: Domain,
194
- metadata: Optional[Dict[Text, Any]] = None,
195
- ) -> List[Event]:
196
- from rasa.dialogue_understanding.commands import CancelFlowCommand
243
+ update_stack_events = tracker.create_stack_updated_events(stack)
197
244
 
198
- interrupted_flows = tracker.get_slot(INTERRUPTED_FLOWS_SLOT) or []
245
+ return applied_events + update_stack_events
199
246
 
200
- event_list = []
201
- for flow_id in interrupted_flows:
202
- # TODO: refactor to avoid creating a CancelFlowCommand first
203
- cancel_flow_command = CancelFlowCommand()
204
- event_list.extend(
205
- cancel_flow_command.cancel_flow(tracker, tracker.stack, flow_id)
206
- )
247
+ def _collect_frames_to_cancel(
248
+ self, stack: DialogueStack, target_flow_id: str
249
+ ) -> Tuple[List[DialogueStackFrame], Optional[UserFlowStackFrame]]:
250
+ """Collect frames that need to be cancelled.
207
251
 
208
- return event_list + [
209
- SlotSet(INTERRUPTED_FLOWS_SLOT, None),
210
- SlotSet(INTERRUPTED_FLOW_TO_CONTINUE_SLOT, None),
211
- SlotSet(MULTIPLE_FLOWS_INTERRUPTED_SLOT, None),
212
- SlotSet(CONFIRMATION_CONTINUE_INTERRUPTED_FLOW_SLOT, None),
213
- ]
252
+ Args:
253
+ stack: The stack to collect frames from.
254
+ target_flow_id: The ID of the flow to cancel.
255
+
256
+ Returns:
257
+ A tuple containing (frames_to_cancel, frame_to_cancel).
258
+ """
259
+ frames_to_cancel: List[DialogueStackFrame] = []
260
+ frame_found = False
261
+ frame_to_cancel = None
262
+
263
+ # collect all frames that belong to the target flow
264
+ # i.e. we want to cancel all frames that are on the stack and between
265
+ # the user flow frame that belongs to the target flow and the next user
266
+ # flow frame that belongs to a different flow
267
+ # this includes any pattern frames or agent frames as well
268
+ for frame in stack.frames:
269
+ if isinstance(frame, UserFlowStackFrame) and (
270
+ frame.frame_type == FlowStackFrameType.REGULAR
271
+ or frame.frame_type == FlowStackFrameType.INTERRUPT
272
+ ):
273
+ if frame.flow_id == target_flow_id:
274
+ frames_to_cancel.append(frame)
275
+ frame_to_cancel = frame
276
+ frame_found = True
277
+ continue
278
+ elif frame_found:
279
+ break
280
+
281
+ if frame_found:
282
+ frames_to_cancel.append(frame)
283
+
284
+ return list(frames_to_cancel), frame_to_cancel