rasa-pro 3.14.0.dev20250922__py3-none-any.whl → 3.14.0rc2__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 (304) hide show
  1. rasa/__main__.py +15 -3
  2. rasa/agents/__init__.py +0 -0
  3. rasa/agents/agent_factory.py +122 -0
  4. rasa/agents/agent_manager.py +211 -0
  5. rasa/agents/constants.py +43 -0
  6. rasa/agents/core/__init__.py +0 -0
  7. rasa/agents/core/agent_protocol.py +107 -0
  8. rasa/agents/core/types.py +81 -0
  9. rasa/agents/exceptions.py +38 -0
  10. rasa/agents/protocol/__init__.py +5 -0
  11. rasa/agents/protocol/a2a/__init__.py +0 -0
  12. rasa/agents/protocol/a2a/a2a_agent.py +879 -0
  13. rasa/agents/protocol/mcp/__init__.py +0 -0
  14. rasa/agents/protocol/mcp/mcp_base_agent.py +726 -0
  15. rasa/agents/protocol/mcp/mcp_open_agent.py +327 -0
  16. rasa/agents/protocol/mcp/mcp_task_agent.py +522 -0
  17. rasa/agents/schemas/__init__.py +13 -0
  18. rasa/agents/schemas/agent_input.py +38 -0
  19. rasa/agents/schemas/agent_output.py +26 -0
  20. rasa/agents/schemas/agent_tool_result.py +65 -0
  21. rasa/agents/schemas/agent_tool_schema.py +186 -0
  22. rasa/agents/templates/__init__.py +0 -0
  23. rasa/agents/templates/mcp_open_agent_prompt_template.jinja2 +20 -0
  24. rasa/agents/templates/mcp_task_agent_prompt_template.jinja2 +22 -0
  25. rasa/agents/utils.py +206 -0
  26. rasa/agents/validation.py +485 -0
  27. rasa/api.py +24 -9
  28. rasa/builder/config.py +6 -2
  29. rasa/builder/copilot/constants.py +4 -1
  30. rasa/builder/copilot/copilot.py +155 -79
  31. rasa/builder/copilot/models.py +304 -108
  32. rasa/builder/copilot/prompts/copilot_training_error_handler_prompt.jinja2 +53 -0
  33. rasa/builder/guardrails/{lakera.py → clients.py} +55 -5
  34. rasa/builder/guardrails/constants.py +3 -0
  35. rasa/builder/guardrails/models.py +45 -10
  36. rasa/builder/guardrails/policy_checker.py +324 -0
  37. rasa/builder/guardrails/utils.py +42 -276
  38. rasa/builder/jobs.py +182 -12
  39. rasa/builder/llm_service.py +32 -5
  40. rasa/builder/models.py +13 -3
  41. rasa/builder/project_generator.py +6 -1
  42. rasa/builder/service.py +31 -15
  43. rasa/builder/training_service.py +18 -24
  44. rasa/builder/validation_service.py +1 -1
  45. rasa/cli/arguments/default_arguments.py +12 -0
  46. rasa/cli/arguments/run.py +2 -0
  47. rasa/cli/arguments/train.py +2 -0
  48. rasa/cli/data.py +10 -8
  49. rasa/cli/dialogue_understanding_test.py +10 -7
  50. rasa/cli/e2e_test.py +9 -6
  51. rasa/cli/evaluate.py +4 -2
  52. rasa/cli/export.py +5 -2
  53. rasa/cli/inspect.py +8 -4
  54. rasa/cli/interactive.py +5 -4
  55. rasa/cli/llm_fine_tuning.py +11 -6
  56. rasa/cli/project_templates/finance/domain/general/help.yml +0 -0
  57. rasa/cli/project_templates/tutorial/credentials.yml +10 -0
  58. rasa/cli/run.py +12 -10
  59. rasa/cli/scaffold.py +4 -4
  60. rasa/cli/shell.py +9 -5
  61. rasa/cli/studio/studio.py +1 -1
  62. rasa/cli/test.py +34 -14
  63. rasa/cli/train.py +41 -28
  64. rasa/cli/utils.py +1 -393
  65. rasa/cli/validation/__init__.py +0 -0
  66. rasa/cli/validation/bot_config.py +223 -0
  67. rasa/cli/validation/config_path_validation.py +257 -0
  68. rasa/cli/x.py +8 -4
  69. rasa/constants.py +7 -1
  70. rasa/core/actions/action.py +51 -10
  71. rasa/core/actions/grpc_custom_action_executor.py +1 -1
  72. rasa/core/agent.py +19 -2
  73. rasa/core/available_agents.py +229 -0
  74. rasa/core/brokers/kafka.py +5 -1
  75. rasa/core/channels/__init__.py +82 -35
  76. rasa/core/channels/development_inspector.py +3 -3
  77. rasa/core/channels/inspector/README.md +25 -13
  78. rasa/core/channels/inspector/dist/assets/{arc-35222594.js → arc-6177260a.js} +1 -1
  79. rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-a0efbfd3.js → blockDiagram-38ab4fdb-b054f038.js} +1 -1
  80. rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-0584c0f2.js → c4Diagram-3d4e48cf-f25427d5.js} +1 -1
  81. rasa/core/channels/inspector/dist/assets/channel-bf9cbb34.js +1 -0
  82. rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-39f40dbe.js → classDiagram-70f12bd4-c7a2af53.js} +1 -1
  83. rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-1ad755f3.js → classDiagram-v2-f2320105-58db65c0.js} +1 -1
  84. rasa/core/channels/inspector/dist/assets/clone-8f9083bb.js +1 -0
  85. rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-b0f4f0fe.js → createText-2e5e7dd3-088372e2.js} +1 -1
  86. rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-9039bff9.js → edges-e0da2a9e-58676240.js} +1 -1
  87. rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-65c9b127.js → erDiagram-9861fffd-0c14d7c6.js} +1 -1
  88. rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-4f08b38e.js → flowDb-956e92f1-ea63f85c.js} +1 -1
  89. rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-e95c362a.js → flowDiagram-66a62f08-a2af48cd.js} +1 -1
  90. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-9ecd5b59.js +1 -0
  91. rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-703c3015.js → flowchart-elk-definition-4a651766-6937abe7.js} +1 -1
  92. rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-699328ea.js → ganttDiagram-c361ad54-7473f357.js} +1 -1
  93. rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-04cf4b05.js → gitGraphDiagram-72cf32ee-d0c9405e.js} +1 -1
  94. rasa/core/channels/inspector/dist/assets/{graph-ee94449e.js → graph-0a6f8466.js} +1 -1
  95. rasa/core/channels/inspector/dist/assets/{index-3862675e-940162b4.js → index-3862675e-7610671a.js} +1 -1
  96. rasa/core/channels/inspector/dist/assets/index-74e01d94.js +1354 -0
  97. rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-c79c2866.js → infoDiagram-f8f76790-be397dc7.js} +1 -1
  98. rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-84489d30.js → journeyDiagram-49397b02-4cefbf62.js} +1 -1
  99. rasa/core/channels/inspector/dist/assets/{layout-a9aa9858.js → layout-e7fbc2bf.js} +1 -1
  100. rasa/core/channels/inspector/dist/assets/{line-eb73cf26.js → line-a8aa457c.js} +1 -1
  101. rasa/core/channels/inspector/dist/assets/{linear-b3399f9a.js → linear-3351e0d2.js} +1 -1
  102. rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-b095bf1a.js → mindmap-definition-fc14e90a-b8cbf605.js} +1 -1
  103. rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-07644b66.js → pieDiagram-8a3498a8-f327f774.js} +1 -1
  104. rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-573a3f9c.js → quadrantDiagram-120e2f19-2854c591.js} +1 -1
  105. rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-d457e1e1.js → requirementDiagram-deff3bca-964985d5.js} +1 -1
  106. rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-9d26e1a2.js → sankeyDiagram-04a897e0-edeb4f33.js} +1 -1
  107. rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-3a9cde10.js → sequenceDiagram-704730f1-fcf70125.js} +1 -1
  108. rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-4f3e8cec.js → stateDiagram-587899a1-0e770395.js} +1 -1
  109. rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-e617e5bf.js → stateDiagram-v2-d93cdb3a-af8dcd22.js} +1 -1
  110. rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-eab30d2f.js → styles-6aaf32cf-36a9e70d.js} +1 -1
  111. rasa/core/channels/inspector/dist/assets/{styles-9a916d00-09994be2.js → styles-9a916d00-884a8b5b.js} +1 -1
  112. rasa/core/channels/inspector/dist/assets/{styles-c10674c1-b7110364.js → styles-c10674c1-dc097813.js} +1 -1
  113. rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-3ebc92ad.js → svgDrawCommon-08f97a94-5a2c7eed.js} +1 -1
  114. rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-7d13d2f2.js → timeline-definition-85554ec2-e89c4f6e.js} +1 -1
  115. rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-488385e1.js → xychartDiagram-e933f94c-afb6fe56.js} +1 -1
  116. rasa/core/channels/inspector/dist/index.html +1 -1
  117. rasa/core/channels/inspector/package.json +18 -18
  118. rasa/core/channels/inspector/src/App.tsx +29 -4
  119. rasa/core/channels/inspector/src/components/DialogueAgentStack.tsx +108 -0
  120. rasa/core/channels/inspector/src/components/{DialogueStack.tsx → DialogueHistoryStack.tsx} +4 -2
  121. rasa/core/channels/inspector/src/helpers/audio/audiostream.ts +7 -4
  122. rasa/core/channels/inspector/src/helpers/formatters.test.ts +4 -0
  123. rasa/core/channels/inspector/src/helpers/formatters.ts +24 -3
  124. rasa/core/channels/inspector/src/helpers/utils.test.ts +127 -0
  125. rasa/core/channels/inspector/src/helpers/utils.ts +66 -1
  126. rasa/core/channels/inspector/src/theme/base/styles.ts +19 -1
  127. rasa/core/channels/inspector/src/types.ts +21 -0
  128. rasa/core/channels/inspector/yarn.lock +336 -189
  129. rasa/core/channels/studio_chat.py +6 -6
  130. rasa/core/channels/telegram.py +4 -9
  131. rasa/core/channels/voice_stream/genesys.py +1 -1
  132. rasa/core/channels/voice_stream/tts/deepgram.py +140 -0
  133. rasa/core/channels/voice_stream/twilio_media_streams.py +5 -1
  134. rasa/core/channels/voice_stream/voice_channel.py +3 -0
  135. rasa/core/concurrent_lock_store.py +38 -21
  136. rasa/core/config/__init__.py +0 -0
  137. rasa/core/{available_endpoints.py → config/available_endpoints.py} +51 -16
  138. rasa/core/config/configuration.py +260 -0
  139. rasa/core/config/credentials.py +19 -0
  140. rasa/core/config/message_procesing_config.py +34 -0
  141. rasa/core/constants.py +10 -0
  142. rasa/core/iam_credentials_providers/aws_iam_credentials_providers.py +69 -4
  143. rasa/core/iam_credentials_providers/credentials_provider_protocol.py +2 -1
  144. rasa/core/lock_store.py +4 -0
  145. rasa/core/policies/enterprise_search_policy.py +5 -3
  146. rasa/core/policies/flow_policy.py +4 -4
  147. rasa/core/policies/flows/agent_executor.py +632 -0
  148. rasa/core/policies/flows/flow_executor.py +136 -75
  149. rasa/core/policies/flows/mcp_tool_executor.py +298 -0
  150. rasa/core/policies/intentless_policy.py +1 -1
  151. rasa/core/policies/ted_policy.py +20 -12
  152. rasa/core/policies/unexpected_intent_policy.py +6 -0
  153. rasa/core/processor.py +68 -44
  154. rasa/core/redis_connection_factory.py +7 -2
  155. rasa/core/run.py +37 -8
  156. rasa/core/test.py +4 -0
  157. rasa/core/tracker_stores/redis_tracker_store.py +4 -0
  158. rasa/core/tracker_stores/sql_tracker_store.py +3 -1
  159. rasa/core/tracker_stores/tracker_store.py +3 -7
  160. rasa/core/train.py +1 -1
  161. rasa/core/training/interactive.py +20 -18
  162. rasa/core/training/story_conflict.py +5 -5
  163. rasa/core/utils.py +22 -23
  164. rasa/dialogue_understanding/commands/__init__.py +8 -0
  165. rasa/dialogue_understanding/commands/cancel_flow_command.py +19 -5
  166. rasa/dialogue_understanding/commands/chit_chat_answer_command.py +21 -2
  167. rasa/dialogue_understanding/commands/clarify_command.py +20 -2
  168. rasa/dialogue_understanding/commands/continue_agent_command.py +91 -0
  169. rasa/dialogue_understanding/commands/knowledge_answer_command.py +21 -2
  170. rasa/dialogue_understanding/commands/restart_agent_command.py +162 -0
  171. rasa/dialogue_understanding/commands/start_flow_command.py +68 -7
  172. rasa/dialogue_understanding/commands/utils.py +124 -2
  173. rasa/dialogue_understanding/generator/command_parser.py +4 -0
  174. rasa/dialogue_understanding/generator/llm_based_command_generator.py +50 -12
  175. rasa/dialogue_understanding/generator/llm_command_generator.py +1 -1
  176. rasa/dialogue_understanding/generator/multi_step/multi_step_llm_command_generator.py +1 -1
  177. rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v2_claude_3_5_sonnet_20240620_template.jinja2 +66 -0
  178. rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v2_gpt_4o_2024_11_20_template.jinja2 +66 -0
  179. rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v3_claude_3_5_sonnet_20240620_template.jinja2 +89 -0
  180. rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v3_gpt_4o_2024_11_20_template.jinja2 +88 -0
  181. rasa/dialogue_understanding/generator/single_step/compact_llm_command_generator.py +42 -7
  182. rasa/dialogue_understanding/generator/single_step/search_ready_llm_command_generator.py +40 -3
  183. rasa/dialogue_understanding/generator/single_step/single_step_based_llm_command_generator.py +20 -3
  184. rasa/dialogue_understanding/patterns/cancel.py +27 -6
  185. rasa/dialogue_understanding/patterns/clarify.py +3 -14
  186. rasa/dialogue_understanding/patterns/continue_interrupted.py +239 -6
  187. rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +46 -8
  188. rasa/dialogue_understanding/processor/command_processor.py +136 -15
  189. rasa/dialogue_understanding/stack/dialogue_stack.py +98 -2
  190. rasa/dialogue_understanding/stack/frames/flow_stack_frame.py +57 -0
  191. rasa/dialogue_understanding/stack/utils.py +57 -3
  192. rasa/dialogue_understanding/utils.py +24 -4
  193. rasa/dialogue_understanding_test/du_test_runner.py +8 -3
  194. rasa/e2e_test/e2e_test_runner.py +13 -3
  195. rasa/engine/caching.py +2 -2
  196. rasa/engine/constants.py +1 -1
  197. rasa/engine/recipes/default_components.py +138 -49
  198. rasa/engine/recipes/default_recipe.py +108 -11
  199. rasa/engine/runner/dask.py +8 -5
  200. rasa/engine/validation.py +19 -6
  201. rasa/graph_components/validators/default_recipe_validator.py +86 -28
  202. rasa/hooks.py +5 -5
  203. rasa/llm_fine_tuning/utils.py +2 -2
  204. rasa/model_training.py +60 -47
  205. rasa/nlu/classifiers/diet_classifier.py +198 -98
  206. rasa/nlu/classifiers/logistic_regression_classifier.py +1 -4
  207. rasa/nlu/classifiers/mitie_intent_classifier.py +3 -0
  208. rasa/nlu/classifiers/sklearn_intent_classifier.py +1 -3
  209. rasa/nlu/extractors/crf_entity_extractor.py +9 -10
  210. rasa/nlu/extractors/mitie_entity_extractor.py +3 -0
  211. rasa/nlu/extractors/spacy_entity_extractor.py +3 -0
  212. rasa/nlu/featurizers/dense_featurizer/convert_featurizer.py +4 -0
  213. rasa/nlu/featurizers/dense_featurizer/lm_featurizer.py +5 -0
  214. rasa/nlu/featurizers/dense_featurizer/mitie_featurizer.py +2 -0
  215. rasa/nlu/featurizers/dense_featurizer/spacy_featurizer.py +3 -0
  216. rasa/nlu/featurizers/sparse_featurizer/count_vectors_featurizer.py +4 -2
  217. rasa/nlu/featurizers/sparse_featurizer/lexical_syntactic_featurizer.py +4 -0
  218. rasa/nlu/selectors/response_selector.py +10 -2
  219. rasa/nlu/tokenizers/jieba_tokenizer.py +3 -4
  220. rasa/nlu/tokenizers/mitie_tokenizer.py +3 -2
  221. rasa/nlu/tokenizers/spacy_tokenizer.py +3 -2
  222. rasa/nlu/utils/mitie_utils.py +3 -0
  223. rasa/nlu/utils/spacy_utils.py +3 -2
  224. rasa/plugin.py +8 -8
  225. rasa/privacy/privacy_manager.py +12 -3
  226. rasa/server.py +15 -3
  227. rasa/shared/agents/__init__.py +0 -0
  228. rasa/shared/agents/auth/__init__.py +0 -0
  229. rasa/shared/agents/auth/agent_auth_factory.py +105 -0
  230. rasa/shared/agents/auth/agent_auth_manager.py +92 -0
  231. rasa/shared/agents/auth/auth_strategy/__init__.py +19 -0
  232. rasa/shared/agents/auth/auth_strategy/agent_auth_strategy.py +52 -0
  233. rasa/shared/agents/auth/auth_strategy/api_key_auth_strategy.py +42 -0
  234. rasa/shared/agents/auth/auth_strategy/bearer_token_auth_strategy.py +28 -0
  235. rasa/shared/agents/auth/auth_strategy/oauth2_auth_strategy.py +167 -0
  236. rasa/shared/agents/auth/constants.py +12 -0
  237. rasa/shared/agents/auth/types.py +12 -0
  238. rasa/shared/agents/utils.py +35 -0
  239. rasa/shared/constants.py +8 -0
  240. rasa/shared/core/constants.py +16 -1
  241. rasa/shared/core/domain.py +0 -7
  242. rasa/shared/core/events.py +327 -0
  243. rasa/shared/core/flows/constants.py +5 -0
  244. rasa/shared/core/flows/flows_list.py +21 -5
  245. rasa/shared/core/flows/flows_yaml_schema.json +119 -184
  246. rasa/shared/core/flows/steps/call.py +49 -5
  247. rasa/shared/core/flows/steps/collect.py +98 -13
  248. rasa/shared/core/flows/validation.py +372 -8
  249. rasa/shared/core/flows/yaml_flows_io.py +3 -2
  250. rasa/shared/core/slots.py +2 -2
  251. rasa/shared/core/trackers.py +5 -2
  252. rasa/shared/exceptions.py +16 -0
  253. rasa/shared/importers/rasa.py +1 -1
  254. rasa/shared/importers/utils.py +9 -3
  255. rasa/shared/providers/llm/_base_litellm_client.py +41 -9
  256. rasa/shared/providers/llm/litellm_router_llm_client.py +8 -4
  257. rasa/shared/providers/llm/llm_client.py +7 -3
  258. rasa/shared/providers/llm/llm_response.py +66 -0
  259. rasa/shared/providers/llm/self_hosted_llm_client.py +8 -4
  260. rasa/shared/utils/common.py +24 -0
  261. rasa/shared/utils/health_check/health_check.py +7 -3
  262. rasa/shared/utils/llm.py +39 -16
  263. rasa/shared/utils/mcp/__init__.py +0 -0
  264. rasa/shared/utils/mcp/server_connection.py +247 -0
  265. rasa/shared/utils/mcp/utils.py +20 -0
  266. rasa/shared/utils/schemas/events.py +42 -0
  267. rasa/shared/utils/yaml.py +3 -1
  268. rasa/studio/pull/pull.py +3 -2
  269. rasa/studio/train.py +8 -7
  270. rasa/studio/upload.py +3 -6
  271. rasa/telemetry.py +69 -5
  272. rasa/tracing/config.py +45 -12
  273. rasa/tracing/constants.py +14 -0
  274. rasa/tracing/instrumentation/attribute_extractors.py +142 -9
  275. rasa/tracing/instrumentation/instrumentation.py +626 -21
  276. rasa/tracing/instrumentation/intentless_policy_instrumentation.py +4 -4
  277. rasa/tracing/instrumentation/metrics.py +32 -0
  278. rasa/tracing/metric_instrument_provider.py +68 -0
  279. rasa/utils/common.py +92 -1
  280. rasa/utils/endpoints.py +11 -2
  281. rasa/utils/log_utils.py +96 -5
  282. rasa/utils/ml_utils.py +1 -1
  283. rasa/utils/tensorflow/__init__.py +7 -0
  284. rasa/utils/tensorflow/callback.py +136 -101
  285. rasa/utils/tensorflow/crf.py +1 -1
  286. rasa/utils/tensorflow/data_generator.py +21 -8
  287. rasa/utils/tensorflow/layers.py +21 -11
  288. rasa/utils/tensorflow/metrics.py +7 -3
  289. rasa/utils/tensorflow/models.py +56 -8
  290. rasa/utils/tensorflow/rasa_layers.py +8 -6
  291. rasa/utils/tensorflow/transformer.py +2 -3
  292. rasa/utils/train_utils.py +54 -24
  293. rasa/validator.py +5 -5
  294. rasa/version.py +1 -1
  295. {rasa_pro-3.14.0.dev20250922.dist-info → rasa_pro-3.14.0rc2.dist-info}/METADATA +47 -41
  296. {rasa_pro-3.14.0.dev20250922.dist-info → rasa_pro-3.14.0rc2.dist-info}/RECORD +299 -238
  297. rasa/builder/scrape_rasa_docs.py +0 -97
  298. rasa/core/channels/inspector/dist/assets/channel-8e08bed9.js +0 -1
  299. rasa/core/channels/inspector/dist/assets/clone-78c82dea.js +0 -1
  300. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-2b08f601.js +0 -1
  301. rasa/core/channels/inspector/dist/assets/index-c941dcb3.js +0 -1336
  302. {rasa_pro-3.14.0.dev20250922.dist-info → rasa_pro-3.14.0rc2.dist-info}/NOTICE +0 -0
  303. {rasa_pro-3.14.0.dev20250922.dist-info → rasa_pro-3.14.0rc2.dist-info}/WHEEL +0 -0
  304. {rasa_pro-3.14.0.dev20250922.dist-info → rasa_pro-3.14.0rc2.dist-info}/entry_points.txt +0 -0
@@ -4,6 +4,9 @@ import logging
4
4
  import typing
5
5
  from typing import Any, Dict, List, Optional, Text, Type
6
6
 
7
+ # importing mitie at module level to ensure error is raised if mitie is not installed
8
+ import mitie
9
+
7
10
  import rasa.shared.utils.io
8
11
  from rasa.engine.graph import ExecutionContext, GraphComponent
9
12
  from rasa.engine.recipes.default_recipe import DefaultV1Recipe
@@ -1,6 +1,9 @@
1
1
  import typing
2
2
  from typing import Any, Dict, List, Text, Type
3
3
 
4
+ # importing spacy at module level to ensure error is raised if spacy is not installed
5
+ import spacy # noqa: F401
6
+
4
7
  from rasa.engine.graph import ExecutionContext, GraphComponent
5
8
  from rasa.engine.recipes.default_recipe import DefaultV1Recipe
6
9
  from rasa.engine.storage.resource import Resource
@@ -28,6 +28,7 @@ from rasa.nlu.tokenizers.tokenizer import Token, Tokenizer
28
28
  from rasa.shared.nlu.constants import ACTION_TEXT, TEXT
29
29
  from rasa.shared.nlu.training_data.message import Message
30
30
  from rasa.shared.nlu.training_data.training_data import TrainingData
31
+ from rasa.shared.utils.io import raise_deprecation_warning
31
32
 
32
33
  logger = logging.getLogger(__name__)
33
34
 
@@ -101,6 +102,9 @@ class ConveRTFeaturizer(DenseFeaturizer, GraphComponent):
101
102
  name: An identifier for this featurizer.
102
103
  config: The configuration.
103
104
  """
105
+ raise_deprecation_warning(
106
+ "ConveRTFeaturizer is deprecated and will be removed in a future version."
107
+ )
104
108
  super().__init__(name=name, config=config)
105
109
 
106
110
  model_url = self._config["model_url"]
@@ -23,6 +23,7 @@ from rasa.nlu.tokenizers.tokenizer import Token, Tokenizer
23
23
  from rasa.shared.nlu.constants import ACTION_TEXT, TEXT
24
24
  from rasa.shared.nlu.training_data.message import Message
25
25
  from rasa.shared.nlu.training_data.training_data import TrainingData
26
+ from rasa.shared.utils.io import raise_deprecation_warning
26
27
  from rasa.utils import train_utils
27
28
  from rasa.utils.tensorflow.model_data import ragged_array_to_ndarray
28
29
 
@@ -61,6 +62,10 @@ class LanguageModelFeaturizer(DenseFeaturizer, GraphComponent):
61
62
  self, config: Dict[Text, Any], execution_context: ExecutionContext
62
63
  ) -> None:
63
64
  """Initializes the featurizer with the model in the config."""
65
+ raise_deprecation_warning(
66
+ "LanguageModelFeaturizer is deprecated and "
67
+ "will be removed in a future version."
68
+ )
64
69
  super(LanguageModelFeaturizer, self).__init__(
65
70
  execution_context.node_name, config
66
71
  )
@@ -4,6 +4,8 @@ import logging
4
4
  import typing
5
5
  from typing import Any, Dict, List, Text, Tuple, Type
6
6
 
7
+ # importing mitie at module level to ensure error is raised if mitie is not installed
8
+ import mitie
7
9
  import numpy as np
8
10
 
9
11
  from rasa.engine.graph import ExecutionContext, GraphComponent
@@ -4,6 +4,9 @@ from typing import Any, Dict, List, Text, Type
4
4
 
5
5
  import numpy as np
6
6
 
7
+ # importing spacy at module level to ensure error is raised if spacy is not installed
8
+ import spacy # noqa: F401
9
+
7
10
  from rasa.engine.graph import ExecutionContext, GraphComponent
8
11
  from rasa.engine.recipes.default_recipe import DefaultV1Recipe
9
12
  from rasa.engine.storage.resource import Resource
@@ -21,12 +21,14 @@ from rasa.nlu.constants import (
21
21
  )
22
22
  from rasa.nlu.featurizers.sparse_featurizer.sparse_featurizer import SparseFeaturizer
23
23
  from rasa.nlu.tokenizers.tokenizer import Tokenizer
24
- from rasa.nlu.utils.spacy_utils import SpacyModel
25
24
  from rasa.shared.constants import DOCS_URL_COMPONENTS
26
25
  from rasa.shared.exceptions import FileIOException, RasaException
27
26
  from rasa.shared.nlu.constants import ACTION_NAME, INTENT, INTENT_RESPONSE_KEY, TEXT
28
27
  from rasa.shared.nlu.training_data.message import Message
29
28
  from rasa.shared.nlu.training_data.training_data import TrainingData
29
+ from rasa.shared.utils.common import conditional_import
30
+
31
+ SpacyModel, _ = conditional_import("rasa.nlu.utils.spacy_utils", "SpacyModel")
30
32
 
31
33
  BUFFER_SLOTS_PREFIX = "buf_"
32
34
 
@@ -603,7 +605,7 @@ class CountVectorsFeaturizer(SparseFeaturizer, GraphComponent):
603
605
  return [], []
604
606
 
605
607
  def train(
606
- self, training_data: TrainingData, model: Optional[SpacyModel] = None
608
+ self, training_data: TrainingData, model: Optional[Any] = None
607
609
  ) -> Resource:
608
610
  """Trains the featurizer.
609
611
 
@@ -18,6 +18,10 @@ from typing import (
18
18
  import numpy as np
19
19
  import scipy.sparse
20
20
 
21
+ # importing spacy at module level to ensure error is raised if spacy is not installed
22
+ # spacy is needed when importing from rasa.nlu.tokenizers.spacy_tokenizer
23
+ import spacy # noqa: F401
24
+
21
25
  import rasa.shared.utils.io
22
26
  import rasa.utils.io
23
27
  from rasa.engine.graph import ExecutionContext, GraphComponent
@@ -45,6 +45,7 @@ from rasa.shared.nlu.constants import (
45
45
  from rasa.shared.nlu.training_data import util
46
46
  from rasa.shared.nlu.training_data.message import Message
47
47
  from rasa.shared.nlu.training_data.training_data import TrainingData
48
+ from rasa.shared.utils.io import raise_deprecation_warning
48
49
  from rasa.utils.tensorflow import rasa_layers
49
50
  from rasa.utils.tensorflow.constants import (
50
51
  AUTO,
@@ -295,6 +296,9 @@ class ResponseSelector(DIETClassifier):
295
296
  otherwise initializes it with random weights.
296
297
  sparse_feature_sizes: Sizes of the sparse features the model was trained on.
297
298
  """
299
+ raise_deprecation_warning(
300
+ "ResponseSelector is deprecated and will be removed in a future version."
301
+ )
298
302
  component_config = config
299
303
 
300
304
  # the following properties cannot be adapted for the ResponseSelector
@@ -963,8 +967,12 @@ class DIET2DIET(DIET):
963
967
 
964
968
  predictions = {
965
969
  DIAGNOSTIC_DATA: {
966
- "attention_weights": attention_weights,
967
- "text_transformed": text_transformed,
970
+ "attention_weights": attention_weights.numpy()
971
+ if hasattr(attention_weights, "numpy")
972
+ else attention_weights,
973
+ "text_transformed": text_transformed.numpy()
974
+ if hasattr(text_transformed, "numpy")
975
+ else text_transformed,
968
976
  }
969
977
  }
970
978
 
@@ -6,6 +6,9 @@ import os
6
6
  import shutil
7
7
  from typing import Any, Dict, List, Optional, Text
8
8
 
9
+ # importing jieba at module level to ensure error is raised if jieba is not installed
10
+ import jieba
11
+
9
12
  from rasa.engine.graph import ExecutionContext
10
13
  from rasa.engine.recipes.default_recipe import DefaultV1Recipe
11
14
  from rasa.engine.storage.resource import Resource
@@ -81,8 +84,6 @@ class JiebaTokenizer(Tokenizer):
81
84
  be found in the documentation of jieba.
82
85
  https://github.com/fxsjy/jieba#load-dictionary
83
86
  """
84
- import jieba
85
-
86
87
  jieba_userdicts = glob.glob(f"{path}/*")
87
88
  for jieba_userdict in jieba_userdicts:
88
89
  logger.info(f"Loading Jieba User Dictionary at {jieba_userdict}")
@@ -95,8 +96,6 @@ class JiebaTokenizer(Tokenizer):
95
96
 
96
97
  def tokenize(self, message: Message, attribute: Text) -> List[Token]:
97
98
  """Tokenizes the text of the provided attribute of the incoming message."""
98
- import jieba
99
-
100
99
  text = message.get(attribute)
101
100
 
102
101
  tokenized = jieba.tokenize(text)
@@ -2,6 +2,9 @@ from __future__ import annotations
2
2
 
3
3
  from typing import Any, Dict, List, Text
4
4
 
5
+ # importing mitie at module level to ensure error is raised if mitie is not installed
6
+ import mitie
7
+
5
8
  from rasa.engine.graph import ExecutionContext
6
9
  from rasa.engine.recipes.default_recipe import DefaultV1Recipe
7
10
  from rasa.engine.storage.resource import Resource
@@ -49,8 +52,6 @@ class MitieTokenizer(Tokenizer):
49
52
 
50
53
  def tokenize(self, message: Message, attribute: Text) -> List[Token]:
51
54
  """Tokenizes the text of the provided attribute of the incoming message."""
52
- import mitie
53
-
54
55
  text = message.get(attribute)
55
56
 
56
57
  encoded_sentence = text.encode(DEFAULT_ENCODING)
@@ -1,6 +1,9 @@
1
1
  import typing
2
2
  from typing import Any, Dict, List, Optional, Text, Type
3
3
 
4
+ # importing spacy at module level to ensure error is raised if spacy is not installed
5
+ import spacy
6
+
4
7
  from rasa.engine.recipes.default_recipe import DefaultV1Recipe
5
8
  from rasa.nlu.constants import SPACY_DOCS
6
9
  from rasa.nlu.tokenizers.tokenizer import Token, Tokenizer
@@ -64,8 +67,6 @@ class SpacyTokenizer(Tokenizer):
64
67
 
65
68
  @staticmethod
66
69
  def _tag_of_token(token: Any) -> Text:
67
- import spacy
68
-
69
70
  if spacy.about.__version__ > "2" and token._.has("tag"):
70
71
  return token._.get("tag")
71
72
  else:
@@ -4,6 +4,9 @@ import typing
4
4
  from pathlib import Path
5
5
  from typing import Any, Dict, List, Optional, Text
6
6
 
7
+ # importing mitie at module level to ensure error is raised if mitie is not installed
8
+ import mitie
9
+
7
10
  from rasa.engine.graph import ExecutionContext, GraphComponent
8
11
  from rasa.engine.recipes.default_recipe import DefaultV1Recipe
9
12
  from rasa.engine.storage.resource import Resource
@@ -5,6 +5,9 @@ import logging
5
5
  import typing
6
6
  from typing import Any, Dict, List, Optional, Text, Tuple
7
7
 
8
+ # importing spacy at module level to ensure error is raised if spacy is not installed
9
+ import spacy
10
+
8
11
  from rasa.engine.graph import ExecutionContext, GraphComponent
9
12
  from rasa.engine.recipes.default_recipe import DefaultV1Recipe
10
13
  from rasa.engine.storage.resource import Resource
@@ -76,8 +79,6 @@ class SpacyNLP(GraphComponent):
76
79
  @staticmethod
77
80
  def load_model(spacy_model_name: Text) -> SpacyModel:
78
81
  """Try loading the model, catching the OSError if missing."""
79
- import spacy
80
-
81
82
  if not spacy_model_name:
82
83
  raise InvalidModelError(
83
84
  f"Missing model configuration for `SpacyNLP` in `config.yml`.\n"
rasa/plugin.py CHANGED
@@ -37,7 +37,7 @@ def init_hooks(manager: pluggy.PluginManager) -> None:
37
37
  manager.register(hooks)
38
38
 
39
39
 
40
- @hookspec # type: ignore[misc]
40
+ @hookspec
41
41
  def refine_cli(
42
42
  subparsers: SubParsersAction,
43
43
  parent_parsers: List[argparse.ArgumentParser],
@@ -45,22 +45,22 @@ def refine_cli(
45
45
  """Customizable hook for adding CLI commands."""
46
46
 
47
47
 
48
- @hookspec # type: ignore[misc]
48
+ @hookspec
49
49
  def configure_commandline(cmdline_arguments: argparse.Namespace) -> Optional[Text]:
50
50
  """Hook specification for configuring plugin CLI."""
51
51
 
52
52
 
53
- @hookspec # type: ignore[misc]
53
+ @hookspec
54
54
  def init_telemetry(endpoints_file: Optional[Text]) -> None:
55
55
  """Hook specification for initialising plugin telemetry."""
56
56
 
57
57
 
58
- @hookspec # type: ignore[misc]
58
+ @hookspec
59
59
  def init_managers(endpoints_file: Optional[Text]) -> None:
60
60
  """Hook specification for initialising managers."""
61
61
 
62
62
 
63
- @hookspec(firstresult=True) # type: ignore[misc]
63
+ @hookspec(firstresult=True)
64
64
  def create_tracker_store( # type: ignore[empty-body]
65
65
  endpoint_config: Union["TrackerStore", "EndpointConfig"],
66
66
  domain: "Domain",
@@ -69,7 +69,7 @@ def create_tracker_store( # type: ignore[empty-body]
69
69
  """Hook specification for wrapping with AuthRetryTrackerStore."""
70
70
 
71
71
 
72
- @hookspec # type: ignore[misc]
72
+ @hookspec
73
73
  def after_server_stop() -> None:
74
74
  """Hook specification for stopping the server.
75
75
 
@@ -78,11 +78,11 @@ def after_server_stop() -> None:
78
78
  """
79
79
 
80
80
 
81
- @hookspec # type: ignore[misc]
81
+ @hookspec
82
82
  def after_new_user_message(tracker: "DialogueStateTracker") -> None:
83
83
  """Hook specification for after a new user message is received."""
84
84
 
85
85
 
86
- @hookspec # type: ignore[misc]
86
+ @hookspec
87
87
  def after_action_executed(tracker: "DialogueStateTracker") -> None:
88
88
  """Hook specification for after an action is executed."""
@@ -30,8 +30,8 @@ from rasa.shared.core.trackers import DialogueStateTracker, EventVerbosity
30
30
  if TYPE_CHECKING:
31
31
  from asyncio import AbstractEventLoop
32
32
 
33
- from rasa.core.available_endpoints import AvailableEndpoints
34
33
  from rasa.core.brokers.broker import EventBroker
34
+ from rasa.core.config.available_endpoints import AvailableEndpoints
35
35
  from rasa.shared.core.domain import Domain
36
36
 
37
37
 
@@ -264,10 +264,19 @@ class BackgroundPrivacyManager:
264
264
  )
265
265
  return None
266
266
 
267
- latest_user_message = tracker.get_last_event_for(
267
+ latest_user_message_event = tracker.get_last_event_for(
268
268
  UserUttered, event_verbosity=EventVerbosity.ALL
269
269
  )
270
- if latest_user_message is None or not latest_user_message.text:
270
+ if latest_user_message_event is None or not isinstance(
271
+ latest_user_message_event, UserUttered
272
+ ):
273
+ structlogger.debug(
274
+ "rasa.privacy_manager.no_user_message.skipping_processing",
275
+ )
276
+ return None
277
+
278
+ latest_user_message: UserUttered = latest_user_message_event
279
+ if not latest_user_message.text:
271
280
  structlogger.debug(
272
281
  "rasa.privacy_manager.no_user_message.skipping_processing",
273
282
  )
rasa/server.py CHANGED
@@ -44,12 +44,13 @@ import rasa.utils.endpoints
44
44
  import rasa.utils.io
45
45
  from rasa.constants import MINIMUM_COMPATIBLE_VERSION
46
46
  from rasa.core.agent import Agent
47
- from rasa.core.available_endpoints import AvailableEndpoints
47
+ from rasa.core.available_agents import AvailableAgents
48
48
  from rasa.core.channels.channel import (
49
49
  CollectingOutputChannel,
50
50
  OutputChannel,
51
51
  UserMessage,
52
52
  )
53
+ from rasa.core.config.available_endpoints import AvailableEndpoints
53
54
  from rasa.core.constants import DEFAULT_RESPONSE_TIMEOUT
54
55
  from rasa.core.persistor import parse_remote_storage
55
56
  from rasa.core.test import test
@@ -243,7 +244,7 @@ def requires_auth(
243
244
  @wraps(f)
244
245
  async def decorated(
245
246
  request: Request, *args: Any, **kwargs: Any
246
- ) -> response.HTTPResponse:
247
+ ) -> Union[response.HTTPResponse, Coroutine[Any, Any, response.HTTPResponse]]:
247
248
  provided = request.args.get("token", None)
248
249
 
249
250
  # noinspection PyProtectedMember
@@ -676,7 +677,9 @@ def inject_temp_dir(f: Callable[..., Coroutine]) -> Callable:
676
677
  """
677
678
 
678
679
  @wraps(f)
679
- async def decorated_function(*args: Any, **kwargs: Any) -> HTTPResponse:
680
+ async def decorated_function(
681
+ *args: Any, **kwargs: Any
682
+ ) -> Union[HTTPResponse, Coroutine[Any, Any, HTTPResponse]]:
680
683
  with TempDirectoryPath(get_temp_dir_name()) as directory:
681
684
  # Decorated request handles need to have a parameter `temporary_directory`
682
685
  return await f(*args, temporary_directory=Path(directory), **kwargs)
@@ -693,6 +696,7 @@ def create_app(
693
696
  jwt_private_key: Optional[Text] = None,
694
697
  jwt_method: Text = "HS256",
695
698
  endpoints: Optional[AvailableEndpoints] = None,
699
+ sub_agents: Optional[AvailableAgents] = None,
696
700
  is_inspector_enabled: bool = False,
697
701
  ) -> Sanic:
698
702
  """Class representing a Rasa HTTP server."""
@@ -728,6 +732,7 @@ def create_app(
728
732
  user_id="username",
729
733
  )
730
734
 
735
+ app.ctx.sub_agents = sub_agents
731
736
  app.ctx.agent = agent
732
737
  # Initialize shared object of type unsigned int for tracking
733
738
  # the number of active training processes
@@ -1463,6 +1468,13 @@ def create_app(
1463
1468
  flows = await processor.get_flows()
1464
1469
  return response.json(flows.as_json_list())
1465
1470
 
1471
+ @app.get("/sub-agents")
1472
+ @requires_auth(app, auth_token)
1473
+ async def get_sub_agents(request: Request) -> HTTPResponse:
1474
+ """Get all the sub-agents currently stored by the agent."""
1475
+ sub_agents = app.ctx.sub_agents
1476
+ return response.json(sub_agents.as_json_list())
1477
+
1466
1478
  @app.get("/domain")
1467
1479
  @requires_auth(app, auth_token)
1468
1480
  @ensure_loaded_agent(app)
File without changes
File without changes
@@ -0,0 +1,105 @@
1
+ """Factory for creating authentication strategy instances based on the strategy type."""
2
+
3
+ from typing import Any, ClassVar, Dict, Optional, Type
4
+
5
+ import structlog
6
+
7
+ from rasa.shared.agents.auth.auth_strategy import (
8
+ AgentAuthStrategy,
9
+ APIKeyAuthStrategy,
10
+ BearerTokenAuthStrategy,
11
+ OAuth2AuthStrategy,
12
+ )
13
+ from rasa.shared.agents.auth.constants import CONFIG_MODULE_KEY
14
+ from rasa.shared.agents.auth.types import AgentAuthType
15
+ from rasa.shared.utils.common import class_from_module_path
16
+
17
+ structlogger = structlog.get_logger()
18
+
19
+
20
+ class AgentAuthFactory:
21
+ """Factory for creating authentication strategy instances based on the
22
+ authentication strategy type.
23
+ """
24
+
25
+ _auth_strategies: ClassVar[Dict[AgentAuthType, Type[AgentAuthStrategy]]] = {
26
+ AgentAuthType.API_KEY: APIKeyAuthStrategy,
27
+ AgentAuthType.OAUTH2: OAuth2AuthStrategy,
28
+ AgentAuthType.BEARER_TOKEN: BearerTokenAuthStrategy,
29
+ }
30
+
31
+ @classmethod
32
+ def create_client(
33
+ cls, auth_type: AgentAuthType, config: Optional[Dict[str, Any]] = None
34
+ ) -> AgentAuthStrategy:
35
+ """Create an authentication strategy instance based on the strategy type.
36
+
37
+ Args:
38
+ auth_type: The type of the authentication strategy.
39
+ config: The configuration dictionary for the authentication.
40
+
41
+ Returns:
42
+ An instance of the authentication strategy.
43
+ """
44
+ config = config or {}
45
+
46
+ # If the auth type is custom, we need to create it from the module
47
+ if auth_type == AgentAuthType.CUSTOM:
48
+ auth_strategy_class: Type[AgentAuthStrategy] = class_from_module_path(
49
+ config[CONFIG_MODULE_KEY]
50
+ )
51
+ if not cls._is_valid_custom_auth_strategy(auth_strategy_class):
52
+ raise ValueError(
53
+ f"Authentication strategy class `{auth_strategy_class}` must "
54
+ f"subclass the "
55
+ f"`{cls.get_agent_auth_strategy_base_class().__name__}` class."
56
+ )
57
+ structlogger.debug(
58
+ "agent_auth_factory.create_client.custom_auth_strategy",
59
+ event_info=f"Initializing `{auth_strategy_class.__name__}`",
60
+ auth_type=auth_type.value,
61
+ auth_strategy_class=auth_strategy_class.__name__,
62
+ )
63
+ return auth_strategy_class.from_config(config)
64
+
65
+ # Get the strategy class for the specified type
66
+ auth_strategy_class = cls._get_auth_strategy_class(auth_type)
67
+ if auth_strategy_class is None:
68
+ raise ValueError(
69
+ f"Unsupported strategy type: {auth_type}. "
70
+ f"Supported types: {cls.get_supported_auth_strategy_types()}"
71
+ )
72
+ # Create instance based on strategy type
73
+ return auth_strategy_class.from_config(config)
74
+
75
+ @classmethod
76
+ def get_supported_auth_strategy_types(cls) -> list[AgentAuthType]:
77
+ """Get all supported authentication strategy types."""
78
+ return list(cls._auth_strategies.keys())
79
+
80
+ @classmethod
81
+ def _get_auth_strategy_class(
82
+ cls, auth_type: AgentAuthType
83
+ ) -> Type[AgentAuthStrategy]:
84
+ """Get the class that implements the authentication strategy."""
85
+ if not cls.is_auth_strategy_supported(auth_type):
86
+ raise ValueError(
87
+ f"Unsupported authentication strategy type: {auth_type}. "
88
+ f"Supported types: {cls.get_supported_auth_strategy_types()}"
89
+ )
90
+ return cls._auth_strategies[auth_type]
91
+
92
+ @classmethod
93
+ def is_auth_strategy_supported(cls, auth_type: AgentAuthType) -> bool:
94
+ """Check if the authentication strategy type is supported."""
95
+ return auth_type in cls._auth_strategies
96
+
97
+ @classmethod
98
+ def _is_valid_custom_auth_strategy(cls, strategy_class: Any) -> bool:
99
+ """Check if the authentication strategy class is valid."""
100
+ return issubclass(strategy_class, cls.get_agent_auth_strategy_base_class())
101
+
102
+ @staticmethod
103
+ def get_agent_auth_strategy_base_class() -> Type[AgentAuthStrategy]:
104
+ """Get the agent authentication strategy base class."""
105
+ return AgentAuthStrategy
@@ -0,0 +1,92 @@
1
+ """High-level authentication management with strategy abstraction."""
2
+
3
+ from typing import Any, Dict, Optional
4
+
5
+ import structlog
6
+
7
+ from rasa.shared.agents.auth.agent_auth_factory import AgentAuthFactory
8
+ from rasa.shared.agents.auth.auth_strategy import AgentAuthStrategy
9
+ from rasa.shared.agents.auth.constants import (
10
+ CONFIG_API_KEY_KEY,
11
+ CONFIG_MODULE_KEY,
12
+ CONFIG_OAUTH_KEY,
13
+ CONFIG_TOKEN_KEY,
14
+ )
15
+ from rasa.shared.agents.auth.types import AgentAuthType
16
+ from rasa.shared.exceptions import AgentAuthInitializationException
17
+
18
+ structlogger = structlog.get_logger()
19
+
20
+
21
+ class AgentAuthManager:
22
+ """High-level authentication management with strategy abstraction."""
23
+
24
+ def __init__(self, auth_strategy: Optional[AgentAuthStrategy] = None):
25
+ """Initialize a new authentication manager instance."""
26
+ self._auth_strategy: Optional[AgentAuthStrategy] = auth_strategy
27
+
28
+ def get_auth(self) -> AgentAuthStrategy:
29
+ """Retrieve the authentication instance.
30
+
31
+ Returns:
32
+ The authentication instance.
33
+
34
+ Raises:
35
+ ValueError: If no authentication is connected.
36
+ """
37
+ if self._auth_strategy is None:
38
+ raise ValueError("No authentication instance available")
39
+ return self._auth_strategy
40
+
41
+ @staticmethod
42
+ def detect_auth_type(config: Dict[str, Any]) -> AgentAuthType:
43
+ if CONFIG_MODULE_KEY in config:
44
+ return AgentAuthType.CUSTOM
45
+ if CONFIG_API_KEY_KEY in config:
46
+ return AgentAuthType.API_KEY
47
+ if CONFIG_TOKEN_KEY in config:
48
+ return AgentAuthType.BEARER_TOKEN
49
+ if CONFIG_OAUTH_KEY in config:
50
+ return AgentAuthType.OAUTH2
51
+ raise ValueError(
52
+ "Invalid authentication type. Supported types: "
53
+ + ", ".join([auth_type.value for auth_type in AgentAuthType])
54
+ )
55
+
56
+ @classmethod
57
+ def load_auth(
58
+ cls, config: Optional[Dict[str, Any]]
59
+ ) -> Optional["AgentAuthManager"]:
60
+ """Connect to authentication using specified strategy type and persist
61
+ the auth instance to the manager in a ready-to-use state.
62
+
63
+ Args:
64
+ config: The configuration dictionary for the authentication.
65
+
66
+ Raises:
67
+ AgentAuthInitializationException: If the authentication connection fails.
68
+ """
69
+ if not config:
70
+ return None
71
+ try:
72
+ auth_type = AgentAuthManager.detect_auth_type(config)
73
+
74
+ # Create the auth client
75
+ client = AgentAuthFactory.create_client(auth_type, config)
76
+
77
+ structlogger.debug(
78
+ "agent_auth_manager.load_auth.success",
79
+ auth_type=auth_type.value,
80
+ event_info=(
81
+ f"Loaded authentication client successfully for `{auth_type.value}`"
82
+ ),
83
+ )
84
+ return cls(client)
85
+ except Exception as e:
86
+ event_info = "Failed to load authentication client"
87
+ structlogger.error(
88
+ "agent_auth_manager.load_auth.failed_to_load",
89
+ event_info=event_info,
90
+ config=config,
91
+ )
92
+ raise AgentAuthInitializationException(e) from e
@@ -0,0 +1,19 @@
1
+ """Authentication strategy implementations."""
2
+
3
+ from rasa.shared.agents.auth.auth_strategy.agent_auth_strategy import AgentAuthStrategy
4
+ from rasa.shared.agents.auth.auth_strategy.api_key_auth_strategy import (
5
+ APIKeyAuthStrategy,
6
+ )
7
+ from rasa.shared.agents.auth.auth_strategy.bearer_token_auth_strategy import (
8
+ BearerTokenAuthStrategy,
9
+ )
10
+ from rasa.shared.agents.auth.auth_strategy.oauth2_auth_strategy import (
11
+ OAuth2AuthStrategy,
12
+ )
13
+
14
+ __all__ = [
15
+ "AgentAuthStrategy",
16
+ "APIKeyAuthStrategy",
17
+ "OAuth2AuthStrategy",
18
+ "BearerTokenAuthStrategy",
19
+ ]