rasa-pro 3.14.0.dev10__py3-none-any.whl → 3.14.0.dev11__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 (291) hide show
  1. rasa/__main__.py +15 -3
  2. rasa/agents/agent_manager.py +50 -2
  3. rasa/agents/constants.py +3 -0
  4. rasa/agents/core/types.py +11 -0
  5. rasa/agents/protocol/a2a/a2a_agent.py +45 -5
  6. rasa/agents/protocol/mcp/mcp_base_agent.py +14 -5
  7. rasa/agents/protocol/mcp/mcp_open_agent.py +27 -13
  8. rasa/agents/protocol/mcp/mcp_task_agent.py +42 -31
  9. rasa/agents/schemas/agent_tool_result.py +0 -2
  10. rasa/agents/schemas/agent_tool_schema.py +55 -3
  11. rasa/agents/templates/mcp_open_agent_prompt_template.jinja2 +6 -6
  12. rasa/agents/templates/mcp_task_agent_prompt_template.jinja2 +5 -5
  13. rasa/agents/utils.py +42 -3
  14. rasa/builder/copilot/telemetry.py +35 -19
  15. rasa/builder/main.py +5 -14
  16. rasa/builder/project_generator.py +1 -1
  17. rasa/builder/service.py +5 -0
  18. rasa/builder/template_cache.py +9 -184
  19. rasa/cli/project_templates/basic/data/data.md +5 -6
  20. rasa/cli/project_templates/basic/domain/domain.md +5 -2
  21. rasa/cli/project_templates/finance/README.md +8 -7
  22. rasa/cli/project_templates/finance/actions/__init__.py +0 -46
  23. rasa/cli/project_templates/finance/actions/accounts/check_balance.py +18 -0
  24. rasa/cli/project_templates/finance/actions/{transfers/action_process_immediate_payment.py → cards/check_that_card_exists.py} +6 -3
  25. rasa/cli/project_templates/finance/actions/cards/list_cards.py +22 -0
  26. rasa/cli/project_templates/finance/actions/contacts/__init__.py +0 -0
  27. rasa/cli/project_templates/finance/actions/contacts/add_contact.py +30 -0
  28. rasa/cli/project_templates/finance/actions/contacts/list_contacts.py +22 -0
  29. rasa/cli/project_templates/finance/actions/contacts/remove_contact.py +35 -0
  30. rasa/cli/project_templates/finance/actions/db.py +117 -0
  31. rasa/cli/project_templates/finance/actions/transfers/check_transfer_funds.py +27 -0
  32. rasa/cli/project_templates/finance/actions/transfers/check_transfer_limit.py +36 -0
  33. rasa/cli/project_templates/finance/actions/transfers/execute_recurrent_payment.py +20 -0
  34. rasa/cli/project_templates/finance/actions/transfers/execute_transfer.py +45 -0
  35. rasa/cli/project_templates/finance/actions/transfers/list_transactions.py +32 -0
  36. rasa/cli/project_templates/finance/config.yml +6 -0
  37. rasa/cli/project_templates/finance/credentials.yml +7 -6
  38. rasa/cli/project_templates/finance/data/accounts/check_balance.yml +3 -4
  39. rasa/cli/project_templates/finance/data/accounts/download_statements.yml +26 -0
  40. rasa/cli/project_templates/finance/data/bills/bill_pay_reminder.yml +25 -0
  41. rasa/cli/project_templates/finance/data/cards/activate_card.yml +35 -0
  42. rasa/cli/project_templates/finance/data/cards/block_card.yml +37 -58
  43. rasa/cli/project_templates/finance/data/cards/list_cards.yml +14 -0
  44. rasa/cli/project_templates/finance/data/cards/replace_card.yml +16 -0
  45. rasa/cli/project_templates/finance/data/cards/replace_eligible_card.yml +29 -0
  46. rasa/cli/project_templates/finance/data/contacts/add_contact.yml +33 -0
  47. rasa/cli/project_templates/finance/data/contacts/list_contacts.yml +14 -0
  48. rasa/cli/project_templates/finance/data/contacts/remove_contact.yml +31 -0
  49. rasa/cli/project_templates/finance/data/data.md +6 -3
  50. rasa/cli/project_templates/finance/data/general/agent_details.yml +6 -0
  51. rasa/cli/project_templates/finance/data/general/hello.yml +1 -2
  52. rasa/cli/project_templates/finance/data/general/human_handoff.yml +1 -1
  53. rasa/cli/project_templates/finance/data/transfers/check_transfer_limit.yml +18 -0
  54. rasa/cli/project_templates/finance/data/transfers/list_transactions.yml +46 -0
  55. rasa/cli/project_templates/finance/data/transfers/move_money_between_accounts.yml +51 -0
  56. rasa/cli/project_templates/finance/data/transfers/transfer_money.yml +29 -62
  57. rasa/cli/project_templates/finance/data/transfers/transfer_money_to_a_third_party.yml +175 -0
  58. rasa/cli/project_templates/finance/db/cards.json +18 -0
  59. rasa/cli/project_templates/finance/db/contacts.json +10 -0
  60. rasa/cli/project_templates/finance/db/my_account.json +6 -0
  61. rasa/cli/project_templates/finance/db/transactions.json +22 -0
  62. rasa/cli/project_templates/finance/docs/docs.md +8 -0
  63. rasa/cli/project_templates/finance/docs/fenlo_banking_faq/account_features/budgeting_analytics.txt +22 -0
  64. rasa/cli/project_templates/finance/docs/fenlo_banking_faq/account_features/multi_currency_accounts.txt +19 -0
  65. rasa/cli/project_templates/finance/docs/fenlo_banking_faq/account_features/premium_benefits.txt +19 -0
  66. rasa/cli/project_templates/finance/docs/fenlo_banking_faq/card_management/contactless_limits.txt +16 -0
  67. rasa/cli/project_templates/finance/docs/fenlo_banking_faq/card_management/freeze_unfreeze_card.txt +16 -0
  68. rasa/cli/project_templates/finance/docs/fenlo_banking_faq/card_management/lost_stolen_card.txt +19 -0
  69. rasa/cli/project_templates/finance/docs/fenlo_banking_faq/money_transfers/instant_payments.txt +19 -0
  70. rasa/cli/project_templates/finance/docs/fenlo_banking_faq/money_transfers/international_transfers.txt +19 -0
  71. rasa/cli/project_templates/finance/docs/fenlo_banking_faq/security_fraud/fraud_protection.txt +22 -0
  72. rasa/cli/project_templates/finance/docs/fenlo_banking_faq/security_fraud/secure_payments.txt +22 -0
  73. rasa/cli/project_templates/finance/domain/_system/patterns/pattern_session_start.yml +11 -0
  74. rasa/cli/project_templates/finance/domain/accounts/check_balance.yml +9 -5
  75. rasa/cli/project_templates/finance/domain/accounts/download_statements.yml +40 -0
  76. rasa/cli/project_templates/finance/domain/bills/bill_pay_reminder.yml +49 -0
  77. rasa/cli/project_templates/finance/domain/cards/activate_card.yml +24 -0
  78. rasa/cli/project_templates/finance/domain/cards/block_card.yml +33 -90
  79. rasa/cli/project_templates/finance/domain/cards/list_cards.yml +16 -0
  80. rasa/cli/project_templates/finance/domain/cards/replace_card.yml +43 -0
  81. rasa/cli/project_templates/finance/domain/cards/shared.yml +15 -0
  82. rasa/cli/project_templates/finance/domain/contacts/add_contact.yml +37 -0
  83. rasa/cli/project_templates/finance/domain/contacts/list_contacts.yml +16 -0
  84. rasa/cli/project_templates/finance/domain/contacts/remove_contact.yml +32 -0
  85. rasa/cli/project_templates/finance/domain/domain.md +9 -1
  86. rasa/cli/project_templates/finance/domain/general/_shared.yml +53 -0
  87. rasa/cli/project_templates/finance/domain/general/agent_details.yml +19 -0
  88. rasa/cli/project_templates/finance/domain/general/cannot_handle.yml +5 -2
  89. rasa/cli/project_templates/finance/domain/general/feedback.yml +0 -3
  90. rasa/cli/project_templates/finance/domain/general/human_handoff.yml +7 -3
  91. rasa/cli/project_templates/finance/domain/general/welcome.yml +5 -2
  92. rasa/cli/project_templates/finance/domain/transfers/check_transfer_limit.yml +32 -0
  93. rasa/cli/project_templates/finance/domain/transfers/list_transactions.yml +44 -0
  94. rasa/cli/project_templates/finance/domain/transfers/shared.yml +17 -0
  95. rasa/cli/project_templates/finance/domain/transfers/transfer_money.yml +203 -61
  96. rasa/cli/project_templates/finance/endpoints.yml +3 -2
  97. rasa/cli/project_templates/finance/prompts/rephraser_demo_personality_prompt.jinja2 +31 -12
  98. rasa/cli/project_templates/telco/data/data.md +1 -1
  99. rasa/cli/project_templates/telco/docs/docs.md +3 -0
  100. rasa/cli/project_templates/telco/domain/domain.md +1 -2
  101. rasa/constants.py +1 -1
  102. rasa/core/actions/direct_custom_actions_executor.py +9 -2
  103. rasa/core/agent.py +2 -3
  104. rasa/core/available_agents.py +1 -1
  105. rasa/core/brokers/broker.py +1 -1
  106. rasa/core/brokers/kafka.py +52 -8
  107. rasa/core/channels/__init__.py +82 -35
  108. rasa/core/channels/inspector/README.md +1 -1
  109. rasa/core/channels/telegram.py +4 -9
  110. rasa/core/channels/voice_stream/twilio_media_streams.py +5 -1
  111. rasa/core/concurrent_lock_store.py +66 -16
  112. rasa/core/iam_credentials_providers/aws_iam_credentials_providers.py +76 -1
  113. rasa/core/iam_credentials_providers/credentials_provider_protocol.py +1 -1
  114. rasa/core/lock_store.py +41 -7
  115. rasa/core/policies/flows/agent_executor.py +632 -0
  116. rasa/core/policies/flows/flow_executor.py +3 -417
  117. rasa/core/policies/flows/mcp_tool_executor.py +32 -12
  118. rasa/core/processor.py +49 -28
  119. rasa/core/run.py +22 -0
  120. rasa/dialogue_understanding/commands/cancel_flow_command.py +1 -1
  121. rasa/dialogue_understanding/commands/chit_chat_answer_command.py +11 -3
  122. rasa/dialogue_understanding/commands/clarify_command.py +11 -3
  123. rasa/dialogue_understanding/commands/knowledge_answer_command.py +11 -3
  124. rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v2_claude_3_5_sonnet_20240620_template.jinja2 +3 -3
  125. rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v2_gpt_4o_2024_11_20_template.jinja2 +3 -3
  126. rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v3_claude_3_5_sonnet_20240620_template.jinja2 +3 -3
  127. rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v3_gpt_4o_2024_11_20_template.jinja2 +3 -3
  128. rasa/dialogue_understanding/generator/single_step/single_step_based_llm_command_generator.py +2 -0
  129. rasa/dialogue_understanding/processor/command_processor.py +70 -0
  130. rasa/dialogue_understanding/stack/dialogue_stack.py +0 -25
  131. rasa/engine/loader.py +12 -0
  132. rasa/engine/recipes/default_components.py +111 -82
  133. rasa/engine/recipes/default_recipe.py +79 -22
  134. rasa/engine/runner/dask.py +8 -5
  135. rasa/graph_components/validators/default_recipe_validator.py +59 -19
  136. rasa/model_manager/warm_rasa_process.py +13 -3
  137. rasa/model_training.py +0 -14
  138. rasa/nlu/classifiers/logistic_regression_classifier.py +1 -22
  139. rasa/nlu/classifiers/mitie_intent_classifier.py +3 -0
  140. rasa/nlu/classifiers/sklearn_intent_classifier.py +1 -3
  141. rasa/nlu/extractors/crf_entity_extractor.py +9 -10
  142. rasa/nlu/extractors/mitie_entity_extractor.py +3 -0
  143. rasa/nlu/extractors/spacy_entity_extractor.py +3 -0
  144. rasa/nlu/featurizers/dense_featurizer/mitie_featurizer.py +2 -0
  145. rasa/nlu/featurizers/dense_featurizer/spacy_featurizer.py +3 -0
  146. rasa/nlu/featurizers/sparse_featurizer/count_vectors_featurizer.py +4 -2
  147. rasa/nlu/featurizers/sparse_featurizer/lexical_syntactic_featurizer.py +4 -0
  148. rasa/nlu/tokenizers/jieba_tokenizer.py +3 -4
  149. rasa/nlu/tokenizers/mitie_tokenizer.py +3 -2
  150. rasa/nlu/tokenizers/spacy_tokenizer.py +3 -2
  151. rasa/nlu/utils/mitie_utils.py +3 -0
  152. rasa/nlu/utils/spacy_utils.py +3 -2
  153. rasa/telemetry.py +63 -0
  154. rasa/utils/log_utils.py +95 -4
  155. rasa/utils/tensorflow/__init__.py +0 -22
  156. rasa/utils/tensorflow/callback.py +17 -7
  157. rasa/utils/tensorflow/layers.py +10 -7
  158. rasa/utils/tensorflow/rasa_layers.py +1 -1
  159. rasa/version.py +1 -1
  160. {rasa_pro-3.14.0.dev10.dist-info → rasa_pro-3.14.0.dev11.dist-info}/METADATA +99 -89
  161. {rasa_pro-3.14.0.dev10.dist-info → rasa_pro-3.14.0.dev11.dist-info}/RECORD +164 -235
  162. rasa/cli/project_templates/finance/actions/accounts/action_ask_account.py +0 -47
  163. rasa/cli/project_templates/finance/actions/accounts/action_check_balance.py +0 -40
  164. rasa/cli/project_templates/finance/actions/action_session_start.py +0 -74
  165. rasa/cli/project_templates/finance/actions/cards/action_ask_card.py +0 -48
  166. rasa/cli/project_templates/finance/actions/cards/action_check_card_existence.py +0 -36
  167. rasa/cli/project_templates/finance/actions/cards/action_update_card_status.py +0 -54
  168. rasa/cli/project_templates/finance/actions/database.py +0 -277
  169. rasa/cli/project_templates/finance/actions/transfers/action_add_payee.py +0 -52
  170. rasa/cli/project_templates/finance/actions/transfers/action_ask_account_from.py +0 -51
  171. rasa/cli/project_templates/finance/actions/transfers/action_check_payee_existence.py +0 -40
  172. rasa/cli/project_templates/finance/actions/transfers/action_check_sufficient_funds.py +0 -40
  173. rasa/cli/project_templates/finance/actions/transfers/action_list_payees.py +0 -46
  174. rasa/cli/project_templates/finance/actions/transfers/action_remove_payee.py +0 -49
  175. rasa/cli/project_templates/finance/actions/transfers/action_schedule_payment.py +0 -19
  176. rasa/cli/project_templates/finance/actions/transfers/action_validate_payment_date.py +0 -36
  177. rasa/cli/project_templates/finance/csvs/accounts.csv +0 -8
  178. rasa/cli/project_templates/finance/csvs/advisors.csv +0 -7
  179. rasa/cli/project_templates/finance/csvs/appointments.csv +0 -211
  180. rasa/cli/project_templates/finance/csvs/branches.csv +0 -10
  181. rasa/cli/project_templates/finance/csvs/cards.csv +0 -11
  182. rasa/cli/project_templates/finance/csvs/payees.csv +0 -11
  183. rasa/cli/project_templates/finance/csvs/transactions.csv +0 -71
  184. rasa/cli/project_templates/finance/csvs/users.csv +0 -4
  185. rasa/cli/project_templates/finance/data/cards/select_card.yml +0 -12
  186. rasa/cli/project_templates/finance/data/general/bot_identity.yml +0 -6
  187. rasa/cli/project_templates/finance/data/system/patterns/pattern_chitchat.yml +0 -5
  188. rasa/cli/project_templates/finance/data/system/source/accounts.json +0 -51
  189. rasa/cli/project_templates/finance/data/system/source/advisors.json +0 -44
  190. rasa/cli/project_templates/finance/data/system/source/appointments.json +0 -1474
  191. rasa/cli/project_templates/finance/data/system/source/branches.json +0 -47
  192. rasa/cli/project_templates/finance/data/system/source/cards.json +0 -72
  193. rasa/cli/project_templates/finance/data/system/source/payees.json +0 -74
  194. rasa/cli/project_templates/finance/data/system/source/transactions.json +0 -492
  195. rasa/cli/project_templates/finance/data/system/source/users.json +0 -29
  196. rasa/cli/project_templates/finance/data/transfers/add_payee.yml +0 -29
  197. rasa/cli/project_templates/finance/data/transfers/list_payees.yml +0 -5
  198. rasa/cli/project_templates/finance/data/transfers/remove_payee.yml +0 -21
  199. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/consequences_of_blocking_card.txt +0 -8
  200. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/reasons_to_block_card.txt +0 -8
  201. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/recovering_from_card_fraud.txt +0 -8
  202. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/tips_for_card_security.txt +0 -8
  203. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/what_to_do_if_card_is_lost.txt +0 -8
  204. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/account_balance_security.txt +0 -7
  205. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/common_balance_inquiries.txt +0 -8
  206. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/methods_to_check_balance.txt +0 -8
  207. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/understanding_balance_updates.txt +0 -8
  208. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/what_to_do_if_balance_is_incorrect.txt +0 -8
  209. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/benefits_of_authorised_payees.txt +0 -8
  210. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/common_issues_with_payees.txt +0 -8
  211. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/general_payee_information.txt +0 -8
  212. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/payee_management_tips.txt +0 -8
  213. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/understanding_payee_types.txt +0 -8
  214. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/common_transfer_errors.txt +0 -8
  215. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/fees_for_transfers.txt +0 -8
  216. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/general_transfer_information.txt +0 -8
  217. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/security_tips_for_transfers.txt +0 -8
  218. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/transfer_processing_times.txt +0 -8
  219. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part1.txt +0 -50
  220. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part10.txt +0 -50
  221. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part11.txt +0 -48
  222. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part12.txt +0 -50
  223. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part13.txt +0 -50
  224. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part14.txt +0 -47
  225. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part15.txt +0 -50
  226. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part16.txt +0 -50
  227. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part17.txt +0 -47
  228. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part18.txt +0 -50
  229. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part19.txt +0 -50
  230. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part2.txt +0 -50
  231. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part20.txt +0 -47
  232. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part21.txt +0 -50
  233. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part22.txt +0 -50
  234. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part23.txt +0 -47
  235. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part24.txt +0 -50
  236. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part25.txt +0 -50
  237. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part26.txt +0 -47
  238. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part27.txt +0 -50
  239. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part28.txt +0 -50
  240. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part29.txt +0 -47
  241. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part3.txt +0 -47
  242. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part30.txt +0 -50
  243. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part31.txt +0 -50
  244. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part32.txt +0 -47
  245. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part33.txt +0 -50
  246. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part34.txt +0 -50
  247. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part35.txt +0 -47
  248. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part36.txt +0 -50
  249. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part37.txt +0 -50
  250. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part38.txt +0 -47
  251. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part39.txt +0 -50
  252. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part4.txt +0 -50
  253. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part40.txt +0 -50
  254. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part41.txt +0 -47
  255. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part42.txt +0 -50
  256. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part43.txt +0 -50
  257. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part44.txt +0 -47
  258. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part45.txt +0 -50
  259. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part46.txt +0 -50
  260. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part47.txt +0 -47
  261. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part48.txt +0 -50
  262. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part49.txt +0 -50
  263. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part5.txt +0 -50
  264. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part50.txt +0 -47
  265. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part51.txt +0 -50
  266. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part52.txt +0 -50
  267. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part53.txt +0 -47
  268. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part54.txt +0 -50
  269. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part55.txt +0 -50
  270. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part56.txt +0 -47
  271. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part57.txt +0 -50
  272. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part58.txt +0 -50
  273. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part59.txt +0 -47
  274. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part6.txt +0 -47
  275. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part60.txt +0 -50
  276. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part61.txt +0 -50
  277. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part7.txt +0 -50
  278. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part8.txt +0 -50
  279. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part9.txt +0 -47
  280. rasa/cli/project_templates/finance/domain/cards/select_card.yml +0 -12
  281. rasa/cli/project_templates/finance/domain/general/bot_identity.yml +0 -5
  282. rasa/cli/project_templates/finance/domain/general/defaults.yml +0 -24
  283. rasa/cli/project_templates/finance/domain/general/goodbye.yml +0 -7
  284. rasa/cli/project_templates/finance/domain/general/help.yml +0 -5
  285. rasa/cli/project_templates/finance/domain/general/utils.yml +0 -13
  286. rasa/cli/project_templates/finance/domain/transfers/add_payee.yml +0 -47
  287. rasa/cli/project_templates/finance/domain/transfers/list_payees.yml +0 -4
  288. rasa/cli/project_templates/finance/domain/transfers/remove_payee.yml +0 -16
  289. {rasa_pro-3.14.0.dev10.dist-info → rasa_pro-3.14.0.dev11.dist-info}/NOTICE +0 -0
  290. {rasa_pro-3.14.0.dev10.dist-info → rasa_pro-3.14.0.dev11.dist-info}/WHEEL +0 -0
  291. {rasa_pro-3.14.0.dev10.dist-info → rasa_pro-3.14.0.dev11.dist-info}/entry_points.txt +0 -0
@@ -35,8 +35,6 @@ class DirectCustomActionExecutor(CustomActionExecutor):
35
35
  self.action_name = action_name
36
36
  self.action_endpoint = action_endpoint
37
37
  self.action_executor = self._create_action_executor()
38
- self.register_actions_from_a_module()
39
- self.action_executor.reload()
40
38
 
41
39
  @staticmethod
42
40
  @lru_cache(maxsize=1)
@@ -88,12 +86,21 @@ class DirectCustomActionExecutor(CustomActionExecutor):
88
86
 
89
87
  Returns:
90
88
  The response from the execution of the custom action.
89
+
90
+ Raises:
91
+ RasaException: If the actions module specified does not exist.
91
92
  """
92
93
  structlogger.debug(
93
94
  "action.direct_custom_action_executor.run",
94
95
  action_name=self.action_name,
95
96
  )
96
97
 
98
+ # Register actions module if not already registered.
99
+ # This is done here instead of __init__ to allow proper
100
+ # exception handling and avoid hanging conversations.
101
+ self.register_actions_from_a_module()
102
+ self.action_executor.reload()
103
+
97
104
  tracker_state = tracker.current_state(EventVerbosity.ALL)
98
105
  action_call = {
99
106
  "next_action": self.action_name,
rasa/core/agent.py CHANGED
@@ -286,14 +286,13 @@ async def load_agent(
286
286
  "Agent loaded with no model!"
287
287
  )
288
288
 
289
- if agent.processor:
289
+ if agent.processor and sub_agents:
290
290
  flows = await agent.processor.get_flows()
291
- domain = agent.processor.domain
292
291
  # CLI commands that accept --sub-agents
293
292
  # all route through this entry point.
294
293
  # With all required data available,
295
294
  # this is the best spot to initialize the subagents.
296
- await initialize_agents(flows, domain, sub_agents)
295
+ await initialize_agents(flows, sub_agents)
297
296
 
298
297
  return agent
299
298
 
@@ -117,7 +117,7 @@ class AvailableAgents(metaclass=Singleton):
117
117
  else:
118
118
  # We are using the default folder, it may not be created yet
119
119
  # Init with an empty agents in this case
120
- structlogger.warning(
120
+ structlogger.info(
121
121
  f"Default agents config folder '{agent_folder}' does not exist. "
122
122
  f"Agent configurations won't be loaded."
123
123
  )
@@ -66,7 +66,7 @@ class EventBroker:
66
66
  raise NotImplementedError("Event broker must implement the `publish` method.")
67
67
 
68
68
  def is_ready(self) -> bool:
69
- """Determine whether or not the event broker is ready.
69
+ """Determine whether the event broker is ready.
70
70
 
71
71
  Returns:
72
72
  `True` by default, but this may be overridden by subclasses.
@@ -6,13 +6,18 @@ import threading
6
6
  import time
7
7
  from asyncio import AbstractEventLoop
8
8
  from functools import cached_property
9
- from typing import TYPE_CHECKING, Any, Dict, List, Optional, Text, Union
9
+ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Text, Tuple, Union
10
10
 
11
11
  import structlog
12
12
 
13
13
  import rasa.shared.utils.common
14
14
  from rasa.core.brokers.broker import EventBroker
15
15
  from rasa.core.exceptions import KafkaProducerInitializationError
16
+ from rasa.core.iam_credentials_providers.credentials_provider_protocol import (
17
+ IAMCredentialsProviderInput,
18
+ SupportedServiceType,
19
+ create_iam_credentials_provider,
20
+ )
16
21
  from rasa.shared.core.events import ErrorHandled
17
22
  from rasa.shared.utils.io import DEFAULT_ENCODING
18
23
  from rasa.utils.endpoints import EndpointConfig
@@ -93,6 +98,9 @@ class KafkaEventBroker(EventBroker):
93
98
  self.ssl_keyfile = ssl_keyfile
94
99
  self.queue_size = kwargs.get("queue_size")
95
100
  self.ssl_check_hostname = "https" if ssl_check_hostname else None
101
+ self.iam_credentials_provider = create_iam_credentials_provider(
102
+ IAMCredentialsProviderInput(service_name=SupportedServiceType.EVENT_BROKER)
103
+ )
96
104
 
97
105
  # PII management attributes
98
106
  self.stream_pii = kwargs.get("stream_pii", True)
@@ -134,8 +142,8 @@ class KafkaEventBroker(EventBroker):
134
142
  try:
135
143
  self._check_kafka_connection()
136
144
  logger.debug("Connection to kafka successful.")
137
- except KafkaException:
138
- logger.debug("Failed to connect kafka.")
145
+ except KafkaException as exc:
146
+ logger.debug(f"Failed to connect to kafka: {exc}")
139
147
  return
140
148
  while retries:
141
149
  try:
@@ -215,7 +223,31 @@ class KafkaEventBroker(EventBroker):
215
223
  KafkaException: if Kafka is disconnected.
216
224
  """
217
225
  if self.producer is not None:
218
- self.producer.list_topics(timeout=5)
226
+ structlogger.debug(
227
+ "rasa.core.brokers.kafka.KafkaEventBroker.check_kafka_connection",
228
+ )
229
+ # we have to poll to trigger the oauth_cb if using IAM authentication
230
+ self.producer.poll(0)
231
+ self.producer.list_topics(self.topic, timeout=5)
232
+
233
+ def get_aws_iam_token(
234
+ self, oauth_config: Any
235
+ ) -> Tuple[Optional[str], Optional[float]]:
236
+ """Callback function to fetch AWS IAM token for MSK authentication.
237
+
238
+ The callback function requires this specific signature to work correctly.
239
+
240
+ Args:
241
+ oauth_config: OAuth configuration.
242
+
243
+ Returns:
244
+ A tuple of auth token and expiry time in seconds.
245
+ """
246
+ if self.iam_credentials_provider is None:
247
+ return None, None
248
+
249
+ temp_credentials = self.iam_credentials_provider.get_credentials()
250
+ return temp_credentials.auth_token, temp_credentials.expiration
219
251
 
220
252
  def _get_kafka_config(self) -> Dict[Text, Any]:
221
253
  config = {
@@ -246,15 +278,27 @@ class KafkaEventBroker(EventBroker):
246
278
  }
247
279
  elif self.security_protocol == "SASL_SSL":
248
280
  authentication_params = {
249
- "sasl.username": self.sasl_username,
250
- "sasl.password": self.sasl_password,
251
281
  "ssl.ca.location": self.ssl_cafile,
252
- "ssl.certificate.location": self.ssl_certfile,
253
- "ssl.key.location": self.ssl_keyfile,
254
282
  "ssl.endpoint.identification.algorithm": self.ssl_check_hostname,
255
283
  "security.protocol": self.security_protocol,
256
284
  "sasl.mechanism": self.sasl_mechanism,
257
285
  }
286
+
287
+ if self.iam_credentials_provider is not None:
288
+ authentication_params.update(
289
+ {
290
+ "oauth_cb": self.get_aws_iam_token,
291
+ }
292
+ )
293
+ else:
294
+ authentication_params.update(
295
+ {
296
+ "sasl.username": self.sasl_username,
297
+ "sasl.password": self.sasl_password,
298
+ "ssl.certificate.location": self.ssl_certfile,
299
+ "ssl.key.location": self.ssl_keyfile,
300
+ }
301
+ )
258
302
  else:
259
303
  raise ValueError(
260
304
  f"Cannot initialise `KafkaEventBroker`: "
@@ -1,5 +1,5 @@
1
1
  # ruff: noqa: I001
2
- from typing import Text, Dict, List, Type
2
+ from typing import Text, Dict, List, Type, Optional
3
3
 
4
4
  from rasa.core.channels.channel import ( # noqa: F401
5
5
  InputChannel,
@@ -15,54 +15,101 @@ from rasa.core.channels.socketio import SocketIOInput
15
15
  from rasa.core.channels.botframework import BotFrameworkInput
16
16
  from rasa.core.channels.callback import CallbackInput
17
17
  from rasa.core.channels.console import CmdlineInput
18
- from rasa.core.channels.facebook import FacebookInput
19
18
  from rasa.core.channels.mattermost import MattermostInput
20
19
  from rasa.core.channels.rasa_chat import RasaChatInput
21
20
  from rasa.core.channels.rest import RestInput
22
21
  from rasa.core.channels.rocketchat import RocketChatInput
23
- from rasa.core.channels.slack import SlackInput
24
- from rasa.core.channels.telegram import TelegramInput
25
- from rasa.core.channels.twilio import TwilioInput
26
- from rasa.core.channels.voice_ready.twilio_voice import TwilioVoiceInput
27
22
  from rasa.core.channels.voice_ready.jambonz import JambonzVoiceReadyInput
28
23
  from rasa.core.channels.voice_ready.audiocodes import AudiocodesInput
29
24
  from rasa.core.channels.voice_stream.browser_audio import BrowserAudioInputChannel
30
- from rasa.core.channels.webexteams import WebexTeamsInput
31
25
  from rasa.core.channels.hangouts import HangoutsInput
32
- from rasa.core.channels.vier_cvg import CVGInput
33
- from rasa.core.channels.voice_stream.twilio_media_streams import (
34
- TwilioMediaStreamsInputChannel,
35
- )
36
26
  from rasa.core.channels.voice_stream.genesys import GenesysInputChannel
37
27
  from rasa.core.channels.studio_chat import StudioChatInput
38
28
  from rasa.core.channels.voice_stream.audiocodes import AudiocodesVoiceInputChannel
39
29
  from rasa.core.channels.voice_stream.jambonz import JambonzStreamInputChannel
40
30
 
31
+ # Type annotations for channels with optional dependencies
32
+ FacebookInput: Optional[Type[InputChannel]]
33
+ SlackInput: Optional[Type[InputChannel]]
34
+ TelegramInput: Optional[Type[InputChannel]]
35
+ TwilioInput: Optional[Type[InputChannel]]
36
+ TwilioVoiceInput: Optional[Type[InputChannel]]
37
+ TwilioMediaStreamsInputChannel: Optional[Type[InputChannel]]
38
+ WebexTeamsInput: Optional[Type[InputChannel]]
39
+ CVGInput: Optional[Type[InputChannel]]
40
+
41
+ # Channels with optional dependencies - import with try-except
42
+ try:
43
+ from rasa.core.channels.facebook import FacebookInput
44
+ except ImportError:
45
+ FacebookInput = None
46
+
47
+ try:
48
+ from rasa.core.channels.slack import SlackInput
49
+ except ImportError:
50
+ SlackInput = None
51
+
52
+ try:
53
+ from rasa.core.channels.telegram import TelegramInput
54
+ except ImportError:
55
+ TelegramInput = None
56
+
57
+ try:
58
+ from rasa.core.channels.twilio import TwilioInput
59
+ except ImportError:
60
+ TwilioInput = None
61
+
62
+ try:
63
+ from rasa.core.channels.voice_ready.twilio_voice import TwilioVoiceInput
64
+ except ImportError:
65
+ TwilioVoiceInput = None
66
+
67
+ try:
68
+ from rasa.core.channels.voice_stream.twilio_media_streams import (
69
+ TwilioMediaStreamsInputChannel,
70
+ )
71
+ except ImportError:
72
+ TwilioMediaStreamsInputChannel = None
73
+
74
+ try:
75
+ from rasa.core.channels.webexteams import WebexTeamsInput
76
+ except ImportError:
77
+ WebexTeamsInput = None
78
+
79
+ try:
80
+ from rasa.core.channels.vier_cvg import CVGInput
81
+ except ImportError:
82
+ CVGInput = None
83
+
41
84
  input_channel_classes: List[Type[InputChannel]] = [
42
- CmdlineInput,
43
- FacebookInput,
44
- SlackInput,
45
- TelegramInput,
46
- MattermostInput,
47
- TwilioInput,
48
- TwilioVoiceInput,
49
- RasaChatInput,
50
- BotFrameworkInput,
51
- RocketChatInput,
52
- CallbackInput,
53
- RestInput,
54
- SocketIOInput,
55
- WebexTeamsInput,
56
- HangoutsInput,
57
- AudiocodesInput,
58
- CVGInput,
59
- JambonzVoiceReadyInput,
60
- TwilioMediaStreamsInputChannel,
61
- BrowserAudioInputChannel,
62
- GenesysInputChannel,
63
- StudioChatInput,
64
- AudiocodesVoiceInputChannel,
65
- JambonzStreamInputChannel,
85
+ c
86
+ for c in [
87
+ CmdlineInput,
88
+ FacebookInput,
89
+ SlackInput,
90
+ TelegramInput,
91
+ MattermostInput,
92
+ TwilioInput,
93
+ TwilioVoiceInput,
94
+ RasaChatInput,
95
+ BotFrameworkInput,
96
+ RocketChatInput,
97
+ CallbackInput,
98
+ RestInput,
99
+ SocketIOInput,
100
+ WebexTeamsInput,
101
+ HangoutsInput,
102
+ AudiocodesInput,
103
+ CVGInput,
104
+ JambonzVoiceReadyInput,
105
+ TwilioMediaStreamsInputChannel,
106
+ BrowserAudioInputChannel,
107
+ GenesysInputChannel,
108
+ StudioChatInput,
109
+ AudiocodesVoiceInputChannel,
110
+ JambonzStreamInputChannel,
111
+ ]
112
+ if c is not None
66
113
  ]
67
114
 
68
115
  # Mapping from an input channel name to its class to allow name based lookup.
@@ -1,4 +1,4 @@
1
- nu# Rasa Inspector
1
+ # Rasa Inspector
2
2
 
3
3
  A rapid prototyping tool for enterprise developer personas working in Rasa Pro built with React + Typescript + Vite.
4
4
 
@@ -4,6 +4,9 @@ import typing
4
4
  from copy import deepcopy
5
5
  from typing import Any, Awaitable, Callable, Dict, List, Optional, Text
6
6
 
7
+ # Import aiogram at module level to raise error if not installed
8
+ from aiogram import Bot
9
+ from aiogram.types import Message, Update
7
10
  from sanic import Blueprint, response
8
11
  from sanic.request import Request
9
12
  from sanic.response import HTTPResponse
@@ -28,15 +31,7 @@ class TelegramOutput(OutputChannel):
28
31
  return "telegram"
29
32
 
30
33
  def __init__(self, access_token: Optional[Text]) -> None:
31
- try:
32
- from aiogram import Bot
33
-
34
- self.bot = Bot(access_token)
35
- except ImportError:
36
- raise ImportError(
37
- "To use the Telegram channel, please install the aiogram package "
38
- "with 'pip install aiogram'"
39
- )
34
+ self.bot = Bot(access_token)
40
35
 
41
36
  async def send_text_message(
42
37
  self, recipient_id: Text, text: Text, **kwargs: Any
@@ -14,6 +14,9 @@ from sanic import ( # type: ignore[attr-defined]
14
14
  response,
15
15
  )
16
16
 
17
+ # Import twilio at module level to raise error if not installed
18
+ from twilio.twiml.voice_response import VoiceResponse
19
+
17
20
  from rasa.core.channels import UserMessage
18
21
  from rasa.core.channels.channel import (
19
22
  create_auth_requested_response_provider,
@@ -145,7 +148,8 @@ class TwilioMediaStreamsInputChannel(VoiceInputChannel):
145
148
  """Get the sender ID for the channel.
146
149
 
147
150
  Twilio Media Streams uses the Stream ID as Sender ID because
148
- it is required in OutputChannel.send_text_message to send messages."""
151
+ it is required in OutputChannel.send_text_message to send messages.
152
+ """
149
153
  return call_parameters.stream_id # type: ignore[return-value]
150
154
 
151
155
  def channel_bytes_to_rasa_audio_bytes(self, input_bytes: bytes) -> RasaAudioBytes:
@@ -4,6 +4,7 @@ from collections import deque
4
4
  from typing import Deque, Optional, Text
5
5
 
6
6
  import structlog
7
+ from pydantic import ValidationError
7
8
 
8
9
  from rasa.core.lock import Ticket, TicketLock
9
10
  from rasa.core.lock_store import (
@@ -12,6 +13,12 @@ from rasa.core.lock_store import (
12
13
  LockError,
13
14
  LockStore,
14
15
  )
16
+ from rasa.core.redis_connection_factory import (
17
+ DeploymentMode,
18
+ RedisConfig,
19
+ RedisConnectionFactory,
20
+ )
21
+ from rasa.shared.exceptions import RasaException
15
22
  from rasa.utils.endpoints import EndpointConfig
16
23
 
17
24
  DEFAULT_REDIS_DB = 1
@@ -74,9 +81,10 @@ class ConcurrentRedisLockStore(LockStore):
74
81
  alphanumeric.
75
82
  socket_timeout - Timeout in seconds after which an exception will be raised
76
83
  in case Redis doesn't respond within `socket_timeout` seconds.
84
+ deployment_mode - Redis deployment mode: standard, cluster, or sentinel.
85
+ endpoints - List of endpoints for cluster/sentinel mode in host:port format.
86
+ sentinel_service - Sentinel service name.
77
87
  """
78
- import redis
79
-
80
88
  host = endpoint_config.kwargs.get("host", DEFAULT_HOSTNAME)
81
89
  port = endpoint_config.kwargs.get("port", DEFAULT_PORT)
82
90
  db = endpoint_config.kwargs.get("db", DEFAULT_REDIS_DB)
@@ -90,20 +98,33 @@ class ConcurrentRedisLockStore(LockStore):
90
98
  socket_timeout = endpoint_config.kwargs.get(
91
99
  "socket_timeout", DEFAULT_SOCKET_TIMEOUT_IN_SECONDS
92
100
  )
93
-
94
- self.red = redis.StrictRedis(
95
- host=host,
96
- port=int(port),
97
- db=int(db),
98
- username=username,
99
- password=password,
100
- ssl=use_ssl,
101
- ssl_certfile=ssl_certfile,
102
- ssl_keyfile=ssl_keyfile,
103
- ssl_ca_certs=ssl_ca_certs,
104
- socket_timeout=socket_timeout,
101
+ deployment_mode = endpoint_config.kwargs.get(
102
+ "deployment_mode", DeploymentMode.STANDARD.value
105
103
  )
104
+ endpoints = endpoint_config.kwargs.get("endpoints", [])
105
+ sentinel_service = endpoint_config.kwargs.get("sentinel_service")
106
106
 
107
+ try:
108
+ redis_config = RedisConfig(
109
+ host=host,
110
+ port=port,
111
+ db=db,
112
+ username=username,
113
+ password=password,
114
+ use_ssl=use_ssl,
115
+ ssl_certfile=ssl_certfile,
116
+ ssl_keyfile=ssl_keyfile,
117
+ ssl_ca_certs=ssl_ca_certs,
118
+ socket_timeout=socket_timeout,
119
+ deployment_mode=deployment_mode,
120
+ endpoints=endpoints,
121
+ sentinel_service=sentinel_service,
122
+ )
123
+ self.red = RedisConnectionFactory.create_connection(redis_config)
124
+ except ValidationError as e:
125
+ raise RasaException(f"Invalid Redis configuration: {e}")
126
+
127
+ self.deployment_mode = deployment_mode
107
128
  self.key_prefix = DEFAULT_CONCURRENT_REDIS_LOCK_STORE_KEY_PREFIX
108
129
  if key_prefix:
109
130
  structlogger.debug(
@@ -129,6 +150,32 @@ class ConcurrentRedisLockStore(LockStore):
129
150
  ),
130
151
  )
131
152
 
153
+ def _get_keys_by_pattern(self, pattern: Text) -> list:
154
+ """Get keys by pattern, using SCAN for cluster mode and KEYS for others."""
155
+ if self.deployment_mode == DeploymentMode.CLUSTER.value:
156
+ # In cluster mode, use SCAN to get keys more reliably
157
+ keys = []
158
+ cursor = 0
159
+
160
+ while True:
161
+ try:
162
+ cursor, batch_keys = self.red.scan(cursor, match=pattern, count=100)
163
+ keys.extend(batch_keys)
164
+ if cursor == 0:
165
+ break
166
+ except Exception as e:
167
+ structlogger.warning(
168
+ "concurrent_redis_lock_store._get_keys_by_pattern.scan_interrupted",
169
+ event_info=f"SCAN interrupted in cluster mode: {e}. "
170
+ f"Returning {len(keys)} keys found so far.",
171
+ )
172
+ break
173
+ else:
174
+ # Standard and sentinel modes use KEYS
175
+ keys = self.red.keys(pattern)
176
+
177
+ return keys
178
+
132
179
  def issue_ticket(
133
180
  self, conversation_id: Text, lock_lifetime: float = LOCK_LIFETIME
134
181
  ) -> int:
@@ -157,11 +204,14 @@ class ConcurrentRedisLockStore(LockStore):
157
204
  tickets: Deque[Ticket] = deque()
158
205
 
159
206
  pattern = self.key_prefix + conversation_id + ":" + "[0-9]*"
160
- redis_keys = self.red.keys(pattern)
207
+ redis_keys = self._get_keys_by_pattern(pattern)
161
208
 
162
209
  for key in redis_keys:
163
210
  serialised_ticket = self.red.get(key)
164
211
  if serialised_ticket:
212
+ # Handle bytes to string conversion for JSON parsing
213
+ if isinstance(serialised_ticket, bytes):
214
+ serialised_ticket = serialised_ticket.decode("utf-8")
165
215
  ticket = Ticket.from_dict(json.loads(serialised_ticket))
166
216
  tickets.appendleft(ticket)
167
217
 
@@ -172,7 +222,7 @@ class ConcurrentRedisLockStore(LockStore):
172
222
  def delete_lock(self, conversation_id: Text) -> None:
173
223
  """Deletes lock for conversation ID."""
174
224
  pattern = self.key_prefix + conversation_id + ":*"
175
- redis_keys = self.red.keys(pattern)
225
+ redis_keys = self._get_keys_by_pattern(pattern)
176
226
 
177
227
  if not redis_keys:
178
228
  structlogger.debug(
@@ -1,7 +1,11 @@
1
+ import os
2
+ import threading
3
+ import time
1
4
  from typing import Optional
2
5
 
3
6
  import boto3
4
7
  import structlog
8
+ from aws_msk_iam_sasl_signer import MSKAuthTokenProvider
5
9
  from botocore.exceptions import BotoCoreError
6
10
 
7
11
  from rasa.core.iam_credentials_providers.credentials_provider_protocol import (
@@ -10,6 +14,7 @@ from rasa.core.iam_credentials_providers.credentials_provider_protocol import (
10
14
  SupportedServiceType,
11
15
  TemporaryCredentials,
12
16
  )
17
+ from rasa.shared.exceptions import ConnectionException
13
18
 
14
19
  structlogger = structlog.get_logger(__name__)
15
20
 
@@ -17,7 +22,7 @@ structlogger = structlog.get_logger(__name__)
17
22
  class AWSRDSIAMCredentialsProvider(IAMCredentialsProvider):
18
23
  """Generates temporary credentials for AWS RDS using IAM roles."""
19
24
 
20
- def __init__(self, username: str, host: str, port: int):
25
+ def __init__(self, username: str, host: str, port: int) -> None:
21
26
  """Initializes the provider."""
22
27
  self.username = username
23
28
  self.host = host
@@ -52,6 +57,73 @@ class AWSRDSIAMCredentialsProvider(IAMCredentialsProvider):
52
57
  return TemporaryCredentials(auth_token=None)
53
58
 
54
59
 
60
+ class AWSMSKafkaIAMCredentialsProvider(IAMCredentialsProvider):
61
+ """Generates temporary credentials for AWS MSK using IAM roles."""
62
+
63
+ def __init__(self) -> None:
64
+ self.region = os.getenv("AWS_DEFAULT_REGION", os.getenv("AWS_REGION"))
65
+ self._token: Optional[str] = None
66
+ self._expires_at: float = 0
67
+ self.refresh_margin_seconds = 60 # Refresh 60 seconds before expiry
68
+ # ensure thread safety when refreshing token because the
69
+ # kafka client library we use (confluent-kafka) is multithreaded
70
+ self.lock = threading.Lock()
71
+
72
+ @property
73
+ def token(self) -> Optional[str]:
74
+ return self._token
75
+
76
+ @token.setter
77
+ def token(self, value: str) -> None:
78
+ self._token = value
79
+
80
+ @property
81
+ def expires_at(self) -> float:
82
+ return self._expires_at
83
+
84
+ @expires_at.setter
85
+ def expires_at(self, value: float) -> None:
86
+ self._expires_at = value
87
+
88
+ def get_credentials(self) -> TemporaryCredentials:
89
+ """Generates temporary credentials for AWS MSK."""
90
+ with self.lock:
91
+ current_time = time.time() # Current time in seconds
92
+ if (
93
+ not self.token
94
+ or current_time >= self.expires_at - self.refresh_margin_seconds
95
+ ):
96
+ try:
97
+ auth_token, expiry_ms = MSKAuthTokenProvider.generate_auth_token(
98
+ self.region
99
+ )
100
+ structlogger.debug(
101
+ "rasa.core.aws_msk_iam_credentials_provider.get_credentials",
102
+ event_info="Successfully generated AWS IAM token for "
103
+ "Kafka authentication.",
104
+ )
105
+ self.token = auth_token
106
+ self.expires_at = int(expiry_ms) / 1000 # Convert ms to seconds
107
+ return TemporaryCredentials(
108
+ auth_token=auth_token,
109
+ expiration=self.expires_at,
110
+ )
111
+ except Exception as exc:
112
+ raise ConnectionException(
113
+ f"Failed to generate AWS IAM token "
114
+ f"for MSK authentication. Original exception: {exc}"
115
+ ) from exc
116
+ else:
117
+ structlogger.debug(
118
+ "rasa.core.aws_msk_iam_credentials_provider.get_credentials",
119
+ event_info="Using cached AWS IAM token for Kafka authentication.",
120
+ )
121
+ return TemporaryCredentials(
122
+ auth_token=self.token,
123
+ expiration=self.expires_at,
124
+ )
125
+
126
+
55
127
  def create_aws_iam_credentials_provider(
56
128
  provider_input: "IAMCredentialsProviderInput",
57
129
  ) -> Optional["IAMCredentialsProvider"]:
@@ -63,4 +135,7 @@ def create_aws_iam_credentials_provider(
63
135
  port=provider_input.port,
64
136
  )
65
137
 
138
+ if provider_input.service_name == SupportedServiceType.EVENT_BROKER:
139
+ return AWSMSKafkaIAMCredentialsProvider()
140
+
66
141
  return None
@@ -16,7 +16,7 @@ class TemporaryCredentials(BaseModel):
16
16
  """Dataclass storing temporary credentials."""
17
17
 
18
18
  auth_token: Optional[str] = None
19
- expiration: Optional[int] = None
19
+ expiration: Optional[float] = None
20
20
  username: Optional[str] = None
21
21
  presigned_url: Optional[str] = None
22
22