rasa-pro 3.22.0.dev3__py3-none-any.whl → 3.22.0.dev4__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.
Files changed (457) hide show
  1. rasa/api/__init__.py +8 -0
  2. rasa/api/brokers/__init__.py +6 -0
  3. rasa/api/brokers/_conversation_key.py +29 -0
  4. rasa/api/brokers/_factory.py +173 -0
  5. rasa/api/brokers/_sql.py +36 -0
  6. rasa/api/brokers/v1/__init__.py +28 -0
  7. rasa/api/brokers/v1/base.py +56 -0
  8. rasa/api/brokers/v1/file.py +70 -0
  9. rasa/{core/brokers → api/brokers/v1}/http.py +59 -42
  10. rasa/api/brokers/v1/kafka.py +578 -0
  11. rasa/api/brokers/v1/pika.py +436 -0
  12. rasa/api/brokers/v1/sql.py +98 -0
  13. rasa/api/brokers/v1/types.py +49 -0
  14. rasa/api/channels/__init__.py +6 -0
  15. rasa/api/channels/_auth.py +105 -0
  16. rasa/api/channels/_collector.py +11 -0
  17. rasa/api/channels/_credentials.py +39 -0
  18. rasa/api/channels/_factory.py +237 -0
  19. rasa/api/channels/_response.py +188 -0
  20. rasa/api/channels/_runtime.py +113 -0
  21. rasa/api/channels/v1/__init__.py +33 -0
  22. rasa/api/channels/v1/base.py +320 -0
  23. rasa/api/channels/v1/botframework.py +348 -0
  24. rasa/api/channels/v1/collector.py +99 -0
  25. rasa/api/channels/v1/facebook.py +441 -0
  26. rasa/api/channels/v1/hangouts.py +336 -0
  27. rasa/api/channels/v1/mattermost.py +240 -0
  28. rasa/api/channels/v1/rocketchat.py +187 -0
  29. rasa/api/channels/v1/slack.py +714 -0
  30. rasa/api/channels/v1/socketio.py +579 -0
  31. rasa/api/channels/v1/telegram.py +375 -0
  32. rasa/api/channels/v1/twilio.py +225 -0
  33. rasa/api/channels/v1/twilio_utils.py +29 -0
  34. rasa/api/channels/v1/types.py +100 -0
  35. rasa/api/channels/v1/vier_cvg.py +419 -0
  36. rasa/api/channels/v1/voice_ready/__init__.py +1 -0
  37. rasa/api/channels/v1/voice_ready/audiocodes.py +457 -0
  38. rasa/api/channels/v1/voice_ready/jambonz.py +144 -0
  39. rasa/api/channels/v1/voice_ready/twilio_voice.py +494 -0
  40. rasa/api/channels/v1/voice_stream/__init__.py +1 -0
  41. rasa/api/channels/v1/voice_stream/audiocodes.py +397 -0
  42. rasa/api/channels/v1/voice_stream/chirp.py +334 -0
  43. rasa/api/channels/v1/voice_stream/genesys.py +475 -0
  44. rasa/api/channels/v1/voice_stream/jambonz.py +283 -0
  45. rasa/api/channels/v1/voice_stream/signalwire.py +504 -0
  46. rasa/api/channels/v1/voice_stream/twilio_media_streams.py +381 -0
  47. rasa/api/channels/v1/voice_stream/voice_channel.py +2515 -0
  48. rasa/api/channels/v1/voice_stream/vonage.py +440 -0
  49. rasa/api/channels/v1/webexteams.py +146 -0
  50. rasa/api/endpoints/__init__.py +7 -0
  51. rasa/api/endpoints/v1/__init__.py +14 -0
  52. rasa/api/knowledge/__init__.py +6 -0
  53. rasa/api/knowledge/_factory.py +111 -0
  54. rasa/api/knowledge/v1/__init__.py +40 -0
  55. rasa/api/knowledge/v1/base.py +33 -0
  56. rasa/api/knowledge/v1/embeddings.py +24 -0
  57. rasa/api/knowledge/v1/exceptions.py +16 -0
  58. rasa/api/knowledge/v1/faiss/__init__.py +49 -0
  59. rasa/api/knowledge/v1/faiss/constants.py +32 -0
  60. rasa/api/knowledge/v1/faiss/exceptions.py +25 -0
  61. rasa/api/knowledge/v1/faiss/knowledge.py +423 -0
  62. rasa/api/knowledge/v1/milvus/__init__.py +32 -0
  63. rasa/api/knowledge/v1/milvus/constants.py +15 -0
  64. rasa/api/knowledge/v1/milvus/knowledge.py +173 -0
  65. rasa/api/knowledge/v1/qdrant/__init__.py +35 -0
  66. rasa/api/knowledge/v1/qdrant/constants.py +11 -0
  67. rasa/api/knowledge/v1/qdrant/exceptions.py +13 -0
  68. rasa/api/knowledge/v1/qdrant/knowledge.py +118 -0
  69. rasa/api/knowledge/v1/types.py +74 -0
  70. rasa/api/locks/__init__.py +6 -0
  71. rasa/api/locks/_factory.py +114 -0
  72. rasa/api/locks/_ticket_lock.py +183 -0
  73. rasa/api/locks/v1/__init__.py +35 -0
  74. rasa/api/locks/v1/base.py +57 -0
  75. rasa/api/locks/v1/concurrent.py +303 -0
  76. rasa/api/locks/v1/exceptions.py +12 -0
  77. rasa/api/locks/v1/in_memory.py +34 -0
  78. rasa/api/locks/v1/redis.py +206 -0
  79. rasa/api/locks/v1/types.py +123 -0
  80. rasa/api/timers/__init__.py +6 -0
  81. rasa/api/timers/_factory.py +120 -0
  82. rasa/api/timers/v1/__init__.py +27 -0
  83. rasa/api/timers/v1/_helpers.py +33 -0
  84. rasa/api/timers/v1/base.py +63 -0
  85. rasa/api/timers/v1/in_memory.py +74 -0
  86. rasa/api/timers/v1/redis.py +353 -0
  87. rasa/api/timers/v1/types.py +68 -0
  88. rasa/api/tracker/__init__.py +6 -0
  89. rasa/api/tracker/_exceptions.py +12 -0
  90. rasa/api/tracker/_factory.py +213 -0
  91. rasa/api/tracker/_lifecycle.py +416 -0
  92. rasa/api/tracker/_serialisation.py +147 -0
  93. rasa/api/tracker/_storage_context.py +87 -0
  94. rasa/api/tracker/v1/__init__.py +57 -0
  95. rasa/api/tracker/v1/base.py +58 -0
  96. rasa/api/tracker/v1/dynamo.py +702 -0
  97. rasa/api/tracker/v1/exceptions.py +7 -0
  98. rasa/api/tracker/v1/in_memory.py +126 -0
  99. rasa/api/tracker/v1/mongo.py +467 -0
  100. rasa/api/tracker/v1/redis.py +579 -0
  101. rasa/api/tracker/v1/sql.py +1718 -0
  102. rasa/api/tracker/v1/types.py +21 -0
  103. rasa/api/versioning/__init__.py +45 -0
  104. rasa/api/versioning/discover.py +176 -0
  105. rasa/api/versioning/exceptions.py +25 -0
  106. rasa/api/versioning/resolve.py +152 -0
  107. rasa/api/voice/__init__.py +6 -0
  108. rasa/api/voice/_speech_api_key.py +113 -0
  109. rasa/api/voice/asr/__init__.py +6 -0
  110. rasa/api/voice/asr/_builtins.py +46 -0
  111. rasa/api/voice/asr/_factory.py +35 -0
  112. rasa/api/voice/asr/v1/__init__.py +66 -0
  113. rasa/api/voice/asr/v1/azure/__init__.py +21 -0
  114. rasa/api/voice/asr/v1/azure/config.py +43 -0
  115. rasa/{core/channels/voice_stream/asr → api/voice/asr/v1}/azure/engine.py +7 -7
  116. rasa/api/voice/asr/v1/base.py +469 -0
  117. rasa/api/voice/asr/v1/deepgram/__init__.py +39 -0
  118. rasa/{core/channels/voice_stream/asr → api/voice/asr/v1}/deepgram/base.py +23 -7
  119. rasa/api/voice/asr/v1/deepgram/config.py +60 -0
  120. rasa/{core/channels/voice_stream/asr → api/voice/asr/v1}/deepgram/constants.py +2 -1
  121. rasa/{core/channels/voice_stream/asr → api/voice/asr/v1}/deepgram/flux.py +5 -5
  122. rasa/{core/channels/voice_stream/asr → api/voice/asr/v1}/deepgram/nova.py +3 -3
  123. rasa/api/voice/asr/v1/deepgram_flux.py +17 -0
  124. rasa/api/voice/asr/v1/elevenlabs.py +246 -0
  125. rasa/api/voice/asr/v1/events.py +23 -0
  126. rasa/api/voice/asr/v1/speechmatics.py +311 -0
  127. rasa/api/voice/tts/__init__.py +6 -0
  128. rasa/api/voice/tts/_builtins.py +53 -0
  129. rasa/api/voice/tts/_factory.py +35 -0
  130. rasa/api/voice/tts/v1/__init__.py +65 -0
  131. rasa/api/voice/tts/v1/azure.py +565 -0
  132. rasa/api/voice/tts/v1/base.py +844 -0
  133. rasa/api/voice/tts/v1/cartesia.py +279 -0
  134. rasa/api/voice/tts/v1/config.py +12 -0
  135. rasa/api/voice/tts/v1/deepgram.py +242 -0
  136. rasa/api/voice/tts/v1/deepgram_flux.py +301 -0
  137. rasa/api/voice/tts/v1/elevenlabs.py +502 -0
  138. rasa/api/voice/tts/v1/rime.py +406 -0
  139. rasa/api/voice/v1/__init__.py +31 -0
  140. rasa/api/voice/v1/audio.py +120 -0
  141. rasa/builder/agent_skills.py +42 -16
  142. rasa/builder/branches.py +278 -16
  143. rasa/builder/config.py +1 -1
  144. rasa/builder/copilot/constants.py +3 -0
  145. rasa/builder/copilot/file_operations.py +295 -0
  146. rasa/builder/copilot/mcp_server/models.py +8 -0
  147. rasa/builder/copilot/mcp_server/tools/event_ledger.py +54 -10
  148. rasa/builder/copilot/mcp_server/tools/llm_judge_models.py +1 -1
  149. rasa/builder/copilot/modes/AGENTS.md +1 -1
  150. rasa/builder/copilot/modes/eval/AGENTS.md +15 -0
  151. rasa/builder/copilot/modes/eval/__init__.py +0 -0
  152. rasa/builder/copilot/modes/eval/actions.py +169 -0
  153. rasa/builder/copilot/modes/eval/capability.py +44 -0
  154. rasa/builder/copilot/modes/eval/cards.py +161 -0
  155. rasa/builder/copilot/modes/eval/job.py +232 -0
  156. rasa/builder/copilot/modes/eval/models.py +5 -0
  157. rasa/builder/copilot/modes/eval/sessions.py +36 -0
  158. rasa/builder/copilot/modes/plan/AGENTS.md +1 -1
  159. rasa/builder/copilot/modes/plan/build_job.py +109 -109
  160. rasa/builder/copilot/modes/plan/build_steps.py +12 -1
  161. rasa/builder/copilot/modes/plan/capability.py +14 -4
  162. rasa/builder/copilot/modes/registry.py +9 -2
  163. rasa/builder/copilot/prompts/evaluation_criteria_judge_prompt.jinja2 +2 -1
  164. rasa/builder/copilot/pydantic_ai/agent.py +10 -41
  165. rasa/builder/copilot/pydantic_ai/branch_tool.py +3 -3
  166. rasa/builder/copilot/pydantic_ai/config.py +1 -1
  167. rasa/builder/copilot/pydantic_ai/file_tools.py +87 -1
  168. rasa/builder/copilot/pydantic_ai/mcp_calls.py +53 -0
  169. rasa/builder/copilot/pydantic_ai/model_registry.py +86 -78
  170. rasa/builder/copilot/pydantic_ai/prompt_loader.py +36 -27
  171. rasa/builder/copilot/skill_catalog.py +15 -0
  172. rasa/builder/copilot/skills/mantle/building-from-conversations/SKILL.md +5 -3
  173. rasa/builder/copilot/skills/mantle/building-skills/SKILL.md +24 -9
  174. rasa/builder/copilot/skills/mantle/building-skills/references/control-levers.md +2 -2
  175. rasa/builder/copilot/skills/mantle/building-skills/references/responses.md +2 -2
  176. rasa/builder/copilot/skills/mantle/building-skills/references/tools.md +6 -2
  177. rasa/builder/copilot/skills/mantle/configuring-agent/SKILL.md +7 -5
  178. rasa/builder/copilot/skills/mantle/configuring-agent/references/agent-yml.md +1 -1
  179. rasa/builder/copilot/skills/mantle/configuring-agent/references/integrations-yml.md +9 -5
  180. rasa/builder/copilot/skills/mantle/migrating-from-calm/SKILL.md +6 -5
  181. rasa/builder/copilot/skills/mantle/simulating-evaluating/SKILL.md +8 -7
  182. rasa/builder/copilot/skills/mantle/simulating-evaluating/references/assertions.md +1 -1
  183. rasa/builder/copilot/subagents/AGENTS.md +4 -1
  184. rasa/builder/copilot/subagents/base.py +5 -0
  185. rasa/builder/copilot/subagents/builder/agent.py +15 -97
  186. rasa/builder/copilot/subagents/evaluation.py +40 -0
  187. rasa/builder/copilot/subagents/evaluator/__init__.py +0 -0
  188. rasa/builder/copilot/subagents/evaluator/agent.py +289 -0
  189. rasa/builder/copilot/subagents/model_choice.py +2 -2
  190. rasa/builder/copilot/subagents/planner/agent.py +40 -4
  191. rasa/builder/copilot/subagents/project_validation.py +110 -0
  192. rasa/builder/copilot/subagents/registry.py +6 -1
  193. rasa/builder/document_retrieval/local/data/docs_vectors.parquet +0 -0
  194. rasa/builder/document_retrieval/local/data/mantle_docs_vectors.parquet +0 -0
  195. rasa/builder/exceptions.py +10 -2
  196. rasa/builder/job_runner.py +31 -1
  197. rasa/builder/models.py +36 -4
  198. rasa/builder/project_generator/project_generator.py +2 -2
  199. rasa/builder/service.py +69 -1
  200. rasa/builder/validation_service.py +32 -2
  201. rasa/cli/export.py +41 -9
  202. rasa/cli/project_templates/mantle/AGENTS.md +16 -0
  203. rasa/cli/project_templates/mantle/skills/view_transactions/skill.md +4 -4
  204. rasa/cli/run.py +1 -1
  205. rasa/cli/scaffold.py +1 -1
  206. rasa/cli/tools/skills_data/mantle/mantle-building-from-conversations/SKILL.md +8 -1
  207. rasa/cli/tools/skills_data/mantle/mantle-building-skills/SKILL.md +35 -11
  208. rasa/cli/tools/skills_data/mantle/mantle-configuring-agent/SKILL.md +18 -10
  209. rasa/cli/tools/skills_data/mantle/mantle-simulating-evaluating/SKILL.md +6 -5
  210. rasa/cli/tools/skills_data/mantle/mantle-testing-debugging/SKILL.md +2 -1
  211. rasa/cli/train.py +1 -1
  212. rasa/core/a2a_server/rasa_a2a_agent_executor.py +11 -5
  213. rasa/core/agent.py +88 -28
  214. rasa/core/brokers/broker.py +45 -16
  215. rasa/core/brokers/broker_only_metadata.py +38 -0
  216. rasa/core/brokers/file.py +11 -34
  217. rasa/core/brokers/kafka.py +59 -543
  218. rasa/core/brokers/pika.py +34 -351
  219. rasa/core/brokers/sql.py +19 -62
  220. rasa/core/channels/__init__.py +181 -120
  221. rasa/core/channels/botframework.py +11 -330
  222. rasa/core/channels/callback.py +8 -6
  223. rasa/core/channels/channel.py +89 -1066
  224. rasa/core/channels/console.py +6 -3
  225. rasa/core/channels/development_inspector.py +10 -8
  226. rasa/core/channels/facebook.py +11 -421
  227. rasa/core/channels/hangouts.py +11 -323
  228. rasa/core/channels/inspector-nextgen/dist/assets/{index--9qSkQVO.js → index-B9poI8Mv.js} +66 -66
  229. rasa/core/channels/inspector-nextgen/dist/index.html +1 -1
  230. rasa/core/channels/inspector-nextgen/e2e/agents/mantle/skills/card_disambiguation/skill.md +1 -1
  231. rasa/core/channels/inspector-nextgen/e2e/agents/mantle/skills/card_replace/skill.md +13 -13
  232. rasa/core/channels/inspector-nextgen/e2e/agents/mantle/skills/card_replace/tools.py +5 -5
  233. rasa/core/channels/inspector-nextgen/e2e/agents/mantle/skills/close_savings_account/tools.py +1 -1
  234. rasa/core/channels/inspector-nextgen/e2e/agents/mantle/skills/travel_notice/skill.md +2 -2
  235. rasa/core/channels/inspector-nextgen/src/Icon/index.ts +2 -0
  236. rasa/core/channels/inspector-nextgen/src/assets/images/index.ts +1 -3
  237. rasa/core/channels/inspector-nextgen/src/components/EventInfo/BargeInEventInfo.test.tsx +4 -5
  238. rasa/core/channels/inspector-nextgen/src/components/EventInfo/BargeInEventInfo.tsx +7 -22
  239. rasa/core/channels/inspector-nextgen/src/components/EventInfo/LlmCallEventInfo.test.tsx +3 -3
  240. rasa/core/channels/inspector-nextgen/src/components/EventInfo/OrderedBlockEventInfo.test.tsx +1 -0
  241. rasa/core/channels/inspector-nextgen/src/components/EventInfo/SkillEventInfo.test.tsx +20 -1
  242. rasa/core/channels/inspector-nextgen/src/components/EventInfo/SkillEventInfo.tsx +21 -13
  243. rasa/core/channels/inspector-nextgen/src/hooks/useBotConnection.test.ts +1 -0
  244. rasa/core/channels/inspector-nextgen/src/store/selectors.test.ts +2 -0
  245. rasa/core/channels/inspector-nextgen/src/try-assistant/ConversationLog/Event/BargeInEvent.test.tsx +50 -8
  246. rasa/core/channels/inspector-nextgen/src/try-assistant/ConversationLog/Event/BargeInEvent.tsx +3 -13
  247. rasa/core/channels/inspector-nextgen/src/try-assistant/ConversationLog/Event/FlowEvent.test.tsx +1 -0
  248. rasa/core/channels/inspector-nextgen/src/try-assistant/ConversationLog/Event/OrderedBlockEvent.test.tsx +1 -0
  249. rasa/core/channels/inspector-nextgen/src/try-assistant/ConversationLog/Event/SkillEvent.test.tsx +1 -0
  250. rasa/core/channels/inspector-nextgen/src/try-assistant/ConversationLog/Message/MessageMarkup.test.tsx +12 -0
  251. rasa/core/channels/inspector-nextgen/src/try-assistant/ConversationLog/Message/MessageMarkup.tsx +3 -2
  252. rasa/core/channels/inspector-nextgen/src/try-assistant/ConversationLog/groupEventsByToolCall.test.ts +61 -17
  253. rasa/core/channels/inspector-nextgen/src/try-assistant/ConversationLog/groupEventsByToolCall.ts +24 -17
  254. rasa/core/channels/inspector-nextgen/src/try-assistant/MiddlePane.test.tsx +1 -0
  255. rasa/core/channels/inspector-nextgen/src/try-assistant/SkillMemoryDetails.test.tsx +1 -0
  256. rasa/core/channels/inspector-nextgen/src/try-assistant/SkillSection/ReferenceTag.tsx +5 -1
  257. rasa/core/channels/inspector-nextgen/src/try-assistant/SkillSection/SkillSection.test.tsx +30 -0
  258. rasa/core/channels/inspector-nextgen/src/try-assistant/SkillSection/SkillSection.tsx +10 -2
  259. rasa/core/channels/inspector-nextgen/src/try-assistant/SkillSection/deriveSkillStateAt.test.ts +1 -0
  260. rasa/core/channels/inspector-nextgen/src/try-assistant/SkillSection/references.test.ts +1 -0
  261. rasa/core/channels/inspector-nextgen/src/try-assistant/SkillSection/references.ts +5 -2
  262. rasa/core/channels/inspector-nextgen/src/try-assistant/deriveLlmCallView.test.ts +4 -4
  263. rasa/core/channels/inspector-nextgen/src/types/conversation.ts +1 -0
  264. rasa/core/channels/inspector-nextgen/src/types/skill.test.ts +23 -0
  265. rasa/core/channels/inspector-nextgen/src/types/skill.ts +3 -0
  266. rasa/core/channels/inspector-nextgen/src/utils/barge-in.ts +12 -12
  267. rasa/core/channels/inspector.py +20 -5
  268. rasa/core/channels/mattermost.py +11 -221
  269. rasa/core/channels/rasa_chat.py +6 -9
  270. rasa/core/channels/rest.py +63 -146
  271. rasa/core/channels/rocketchat.py +11 -167
  272. rasa/core/channels/slack.py +11 -690
  273. rasa/core/channels/socketio.py +14 -564
  274. rasa/core/channels/telegram.py +11 -335
  275. rasa/core/channels/twilio.py +11 -210
  276. rasa/core/channels/twilio_utils.py +8 -27
  277. rasa/core/channels/vier_cvg.py +11 -401
  278. rasa/core/channels/voice_ready/audiocodes.py +11 -439
  279. rasa/core/channels/voice_ready/jambonz.py +13 -132
  280. rasa/core/channels/voice_ready/twilio_voice.py +13 -482
  281. rasa/core/channels/voice_stream/asr/__init__.py +11 -42
  282. rasa/core/channels/voice_stream/asr/asr_engine.py +17 -466
  283. rasa/core/channels/voice_stream/asr/asr_event.py +14 -23
  284. rasa/core/channels/voice_stream/asr/azure/__init__.py +8 -21
  285. rasa/core/channels/voice_stream/asr/azure/config.py +3 -41
  286. rasa/core/channels/voice_stream/asr/deepgram/__init__.py +46 -36
  287. rasa/core/channels/voice_stream/asr/deepgram/config.py +12 -58
  288. rasa/core/channels/voice_stream/asr/deepgram_flux.py +11 -7
  289. rasa/core/channels/voice_stream/asr/elevenlabs.py +10 -242
  290. rasa/core/channels/voice_stream/asr/speechmatics.py +13 -307
  291. rasa/core/channels/voice_stream/audio_bytes.py +32 -120
  292. rasa/core/channels/voice_stream/audiocodes.py +13 -388
  293. rasa/core/channels/voice_stream/browser_audio.py +17 -14
  294. rasa/core/channels/voice_stream/chirp.py +11 -325
  295. rasa/core/channels/voice_stream/genesys.py +11 -466
  296. rasa/core/channels/voice_stream/jambonz.py +13 -271
  297. rasa/core/channels/voice_stream/json_audio.py +15 -12
  298. rasa/core/channels/voice_stream/marker_scheduler.py +121 -48
  299. rasa/core/channels/voice_stream/signalwire.py +13 -470
  300. rasa/core/channels/voice_stream/speech_api_key.py +8 -113
  301. rasa/core/channels/voice_stream/speech_model/README.md +51 -0
  302. rasa/core/channels/voice_stream/speech_model/__init__.py +8 -0
  303. rasa/core/channels/voice_stream/speech_model/constants.py +13 -0
  304. rasa/core/channels/voice_stream/speech_model/engine.py +452 -0
  305. rasa/core/channels/voice_stream/speech_model/factory.py +89 -0
  306. rasa/core/channels/voice_stream/speech_model/openai.py +53 -0
  307. rasa/core/channels/voice_stream/speech_model/openai_live.py +482 -0
  308. rasa/core/channels/voice_stream/speech_model/output_channel.py +150 -0
  309. rasa/core/channels/voice_stream/speech_model/polyai.py +95 -0
  310. rasa/core/channels/voice_stream/speech_model/rime_prism.py +402 -0
  311. rasa/core/channels/voice_stream/tts/__init__.py +31 -55
  312. rasa/core/channels/voice_stream/tts/azure.py +10 -562
  313. rasa/core/channels/voice_stream/tts/cartesia.py +5 -276
  314. rasa/core/channels/voice_stream/tts/config.py +4 -11
  315. rasa/core/channels/voice_stream/tts/deepgram.py +5 -239
  316. rasa/core/channels/voice_stream/tts/deepgram_flux.py +5 -298
  317. rasa/core/channels/voice_stream/tts/elevenlabs.py +16 -472
  318. rasa/core/channels/voice_stream/tts/rime.py +5 -403
  319. rasa/core/channels/voice_stream/tts/tts_engine.py +27 -839
  320. rasa/core/channels/voice_stream/twilio_media_streams.py +15 -372
  321. rasa/core/channels/voice_stream/util.py +2 -0
  322. rasa/core/channels/voice_stream/voice_channel.py +29 -2196
  323. rasa/core/channels/voice_stream/vonage.py +10 -416
  324. rasa/core/channels/voice_stream/websockets.py +17 -14
  325. rasa/core/channels/webexteams.py +11 -125
  326. rasa/core/concurrent_lock_store.py +28 -308
  327. rasa/core/constants.py +32 -21
  328. rasa/core/exporter.py +1 -1
  329. rasa/core/iam_credentials_providers/aws_iam_credentials_providers.py +17 -326
  330. rasa/core/iam_credentials_providers/credentials_provider_protocol.py +19 -92
  331. rasa/core/information_retrieval/_results.py +25 -0
  332. rasa/core/information_retrieval/faiss.py +50 -448
  333. rasa/core/information_retrieval/milvus.py +24 -157
  334. rasa/core/information_retrieval/qdrant.py +28 -98
  335. rasa/core/lock.py +3 -136
  336. rasa/core/lock_store.py +26 -412
  337. rasa/core/nlg/contextual_response_rephraser.py +12 -15
  338. rasa/core/policies/enterprise_search_policy.py +11 -14
  339. rasa/core/processor.py +3 -3
  340. rasa/core/redis_connection_factory.py +19 -472
  341. rasa/core/run.py +45 -4
  342. rasa/core/timer_managers/persistent_timer_manager.py +372 -0
  343. rasa/core/timer_managers/redis_timer_manager.py +19 -337
  344. rasa/core/timer_managers/timer_manager.py +22 -8
  345. rasa/core/timer_stores/in_memory_timer_store.py +7 -66
  346. rasa/core/timer_stores/redis_timer_store.py +20 -326
  347. rasa/core/timer_stores/timer_store.py +22 -171
  348. rasa/core/tracker_stores/auth_retry_tracker_store.py +126 -46
  349. rasa/core/tracker_stores/dynamo_tracker_store.py +23 -656
  350. rasa/core/tracker_stores/mongo_tracker_store.py +24 -377
  351. rasa/core/tracker_stores/redis_tracker_store.py +36 -510
  352. rasa/core/tracker_stores/sql_tracker_store.py +46 -1635
  353. rasa/core/tracker_stores/tracker_store.py +203 -802
  354. rasa/core/voice/event_composition/events/composite_events.py +1 -0
  355. rasa/core/voice/event_composition/events/constants.py +0 -3
  356. rasa/core/voice/event_composition/handlers/barge_in/backchannel/__init__.py +5 -0
  357. rasa/core/voice/event_composition/handlers/barge_in/backchannel/classifiers/__init__.py +5 -0
  358. rasa/core/voice/event_composition/handlers/barge_in/backchannel/classifiers/constants.py +54 -0
  359. rasa/core/voice/event_composition/handlers/barge_in/backchannel/classifiers/deberta.py +65 -0
  360. rasa/core/voice/event_composition/handlers/barge_in/backchannel/classifiers/deberta_hypothesis.jinja2 +1 -0
  361. rasa/core/voice/event_composition/handlers/barge_in/backchannel/classifiers/deberta_premise.jinja2 +5 -0
  362. rasa/core/voice/event_composition/handlers/barge_in/backchannel/classifiers/loader.py +116 -0
  363. rasa/core/voice/event_composition/handlers/barge_in/backchannel/classifiers/nli_model.py +104 -0
  364. rasa/core/voice/event_composition/handlers/barge_in/backchannel/classifiers/protocol.py +18 -0
  365. rasa/core/voice/event_composition/handlers/barge_in/backchannel/detector.py +103 -0
  366. rasa/core/voice/event_composition/handlers/barge_in/backchannel/runtime.py +75 -0
  367. rasa/core/voice/event_composition/handlers/barge_in/barge_in_handler.py +10 -5
  368. rasa/core/voice/event_composition/handlers/playback_tracking_handler.py +0 -21
  369. rasa/core/voice/interruptions.py +4 -2
  370. rasa/dialogue_understanding/stack/frames/mantle_stack_frames.py +21 -1
  371. rasa/dialogue_understanding/utils.py +34 -8
  372. rasa/{api.py → entrypoint.py} +2 -6
  373. rasa/mantle/config/_tracker_auth_retry.py +214 -0
  374. rasa/mantle/config/agent_spec.py +3 -1
  375. rasa/mantle/config/builtin_tool_constraints.py +2 -2
  376. rasa/mantle/config/channels.py +1 -1
  377. rasa/mantle/config/integrations.py +23 -10
  378. rasa/mantle/config/runtime_endpoints.py +240 -48
  379. rasa/mantle/config/validation.py +4 -4
  380. rasa/mantle/content/responses.py +44 -7
  381. rasa/mantle/content/static_buttons.py +3 -3
  382. rasa/mantle/content/validation.py +23 -2
  383. rasa/mantle/decorator_contract.py +492 -0
  384. rasa/mantle/inspector.py +26 -1
  385. rasa/mantle/llm/client.py +5 -4
  386. rasa/mantle/llm/tool_schemas.py +238 -78
  387. rasa/mantle/memory/coercion.py +90 -0
  388. rasa/mantle/memory/field.py +2 -2
  389. rasa/mantle/memory/validation.py +2 -2
  390. rasa/mantle/model_archive/training_telemetry.py +13 -4
  391. rasa/mantle/orchestration/collect_ask_state.py +16 -9
  392. rasa/mantle/orchestration/contracts.py +0 -6
  393. rasa/mantle/orchestration/correction/coercion.py +2 -29
  394. rasa/mantle/orchestration/correction/executor.py +4 -1
  395. rasa/mantle/orchestration/hybrid_link.py +161 -0
  396. rasa/mantle/orchestration/memory_validation_tools.py +2 -2
  397. rasa/mantle/orchestration/orchestrator.py +207 -367
  398. rasa/mantle/orchestration/pending_hold.py +225 -0
  399. rasa/mantle/orchestration/precondition_stack.py +95 -37
  400. rasa/mantle/orchestration/set_memory_button.py +1 -1
  401. rasa/mantle/orchestration/settable_write.py +81 -3
  402. rasa/mantle/orchestration/skill_digression.py +0 -18
  403. rasa/mantle/orchestration/skill_executor.py +1185 -439
  404. rasa/mantle/orchestration/skill_utils.py +72 -1
  405. rasa/mantle/orchestration/stated_fields.py +416 -0
  406. rasa/mantle/orchestration/tool_call_batch.py +77 -0
  407. rasa/mantle/orchestration/turn_context.py +15 -13
  408. rasa/mantle/prompts/constructor.py +9 -17
  409. rasa/mantle/prompts/messages.py +1 -1
  410. rasa/mantle/prompts/renderer.py +22 -0
  411. rasa/mantle/prompts/state.py +70 -17
  412. rasa/mantle/prompts/system_prompt.py +34 -23
  413. rasa/mantle/prompts/templates/__init__.py +0 -4
  414. rasa/mantle/prompts/templates/active_skill.jinja2 +18 -11
  415. rasa/mantle/prompts/templates/knowledge_answering.jinja2 +5 -0
  416. rasa/mantle/prompts/templates/lifecycle_tools.jinja2 +17 -16
  417. rasa/mantle/prompts/templates/pending_tool_confirmation.jinja2 +32 -7
  418. rasa/mantle/prompts/templates/routing_catalog.jinja2 +1 -2
  419. rasa/mantle/skills/catalog.py +61 -9
  420. rasa/mantle/skills/prose_scoping.py +29 -19
  421. rasa/mantle/skills/steps.py +3 -3
  422. rasa/mantle/state/tracker_handle.py +4 -4
  423. rasa/mantle/tools/constants.py +9 -0
  424. rasa/mantle/tools/decorator.py +8 -3
  425. rasa/mantle/tools/inventory.py +6 -4
  426. rasa/mantle/tools/loader.py +11 -11
  427. rasa/mantle/tools/mcp_import_spec.py +34 -19
  428. rasa/mantle/tools/validation.py +11 -1
  429. rasa/privacy/event_broker_utils.py +24 -3
  430. rasa/privacy/privacy_filter.py +282 -77
  431. rasa/privacy/privacy_manager.py +25 -7
  432. rasa/server.py +25 -7
  433. rasa/shared/constants.py +2 -0
  434. rasa/shared/core/playback_marker.py +50 -16
  435. rasa/shared/infrastructure/__init__.py +1 -0
  436. rasa/shared/infrastructure/constants.py +22 -0
  437. rasa/shared/infrastructure/iam/__init__.py +1 -0
  438. rasa/shared/infrastructure/iam/aws_iam_credentials_providers.py +328 -0
  439. rasa/shared/infrastructure/iam/credentials_provider_protocol.py +92 -0
  440. rasa/shared/infrastructure/redis_connection_factory.py +474 -0
  441. rasa/shared/nlu/constants.py +2 -0
  442. rasa/shared/utils/llm.py +17 -21
  443. rasa/studio/train.py +1 -1
  444. rasa/tracing/engine_token_usage.py +0 -1
  445. rasa/version.py +1 -1
  446. {rasa_pro-3.22.0.dev3.dist-info → rasa_pro-3.22.0.dev4.dist-info}/METADATA +8 -8
  447. {rasa_pro-3.22.0.dev3.dist-info → rasa_pro-3.22.0.dev4.dist-info}/RECORD +452 -272
  448. rasa/core/channels/inspector-nextgen/src/assets/images/tya-bot.png +0 -0
  449. rasa/core/channels/inspector-nextgen/src/assets/images/tya-user.png +0 -0
  450. rasa/core/voice/event_composition/handlers/barge_in/backchannel.py +0 -245
  451. rasa/mantle/prompts/templates/set_fields_fill_instruction.jinja2 +0 -2
  452. rasa/mantle/prompts/templates/set_fields_fill_task.jinja2 +0 -11
  453. /rasa/{core/channels/voice_stream/asr → api/voice/asr/v1}/azure/constants.py +0 -0
  454. /rasa/{core/channels/voice_stream/tts → api/voice/tts/v1}/_client_session.py +0 -0
  455. {rasa_pro-3.22.0.dev3.dist-info → rasa_pro-3.22.0.dev4.dist-info}/WHEEL +0 -0
  456. {rasa_pro-3.22.0.dev3.dist-info → rasa_pro-3.22.0.dev4.dist-info}/entry_points.txt +0 -0
  457. {rasa_pro-3.22.0.dev3.dist-info → rasa_pro-3.22.0.dev4.dist-info}/licenses/NOTICE +0 -0
rasa/api/__init__.py ADDED
@@ -0,0 +1,8 @@
1
+ """Mantle public API for versioned custom integrations.
2
+
3
+ Import a specific versioned component, for example::
4
+
5
+ from rasa.api.knowledge.v1 import KnowledgeStore
6
+
7
+ CLI train/run helpers are not part of this package; see ``rasa.entrypoint``.
8
+ """
@@ -0,0 +1,6 @@
1
+ """Mantle event-broker public API.
2
+
3
+ Versioned modules live under ``rasa.api.brokers.vN``. Prefer importing from a
4
+ specific version (for example ``rasa.api.brokers.v1``) rather than this
5
+ package root.
6
+ """
@@ -0,0 +1,29 @@
1
+ """Conversation field selection for brokers that key events by conversation.
2
+
3
+ Kafka and SQL need to know whether an event identifies its conversation as
4
+ ``sender_id`` or ``conversation_id``. That choice follows the loaded engine
5
+ and is not part of the published ``EventBroker`` port. A later broker version
6
+ can reuse this mixin without copying it onto the storage contract.
7
+
8
+ This module does not import a published version.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ from rasa.shared.engine_version import DEFAULT_ENGINE_VERSION, MANTLE_ENGINE_VERSION
14
+
15
+
16
+ class ConversationKeyMixin:
17
+ """Select the event field that identifies a conversation.
18
+
19
+ ``engine_version`` is set from the loaded model. Until then the default
20
+ engine version selects ``sender_id``.
21
+ """
22
+
23
+ engine_version: str = DEFAULT_ENGINE_VERSION
24
+
25
+ def conversation_key_name(self) -> str:
26
+ """Return the event field that identifies the conversation."""
27
+ if self.engine_version == MANTLE_ENGINE_VERSION:
28
+ return "conversation_id"
29
+ return "sender_id"
@@ -0,0 +1,173 @@
1
+ """Create Mantle event brokers from a type key or import path.
2
+
3
+ The leading underscore marks this module as private. Customers subclass
4
+ ``EventBroker`` from the published brokers API package. Rasa loads brokers
5
+ through this module.
6
+
7
+ Short names resolve to the builtins of the current published version. A custom
8
+ class may subclass the current or previous version; ``prepare_instance`` wraps
9
+ a previous version so callers receive the current interface.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ import importlib
15
+ from typing import Any
16
+
17
+ import structlog
18
+
19
+ from rasa.api.versioning import (
20
+ AmbiguousApiVersionError,
21
+ UnknownApiVersionError,
22
+ current_version,
23
+ prepare_instance,
24
+ resolve_version,
25
+ )
26
+ from rasa.shared.exceptions import ConnectionException, RasaException
27
+
28
+ structlogger = structlog.get_logger()
29
+
30
+ _BUILTIN_SPECS = {
31
+ "pika": ("pika", "PikaEventBroker"),
32
+ "sql": ("sql", "SQLEventBroker"),
33
+ "file": ("file", "FileEventBroker"),
34
+ "kafka": ("kafka", "KafkaEventBroker"),
35
+ "concurrent_kafka": ("kafka", "ConcurrentKafkaEventBroker"),
36
+ "http": ("http", "HttpEventBroker"),
37
+ }
38
+
39
+
40
+ def _version_base(version: str | None = None) -> Any:
41
+ resolved = version or current_version("brokers")
42
+ return importlib.import_module(f"rasa.api.brokers.{resolved}.base")
43
+
44
+
45
+ def _version_submodule(version: str, name: str) -> Any:
46
+ return importlib.import_module(f"rasa.api.brokers.{version}.{name}")
47
+
48
+
49
+ def builtin_types(version: str | None = None) -> dict[str, type]:
50
+ """Map builtin short names to event broker classes for ``version``."""
51
+ resolved = version or current_version("brokers")
52
+ return {
53
+ name: getattr(_version_submodule(resolved, module_name), class_name)
54
+ for name, (module_name, class_name) in _BUILTIN_SPECS.items()
55
+ }
56
+
57
+
58
+ async def create_event_broker(
59
+ config_type: str | None,
60
+ settings: Any,
61
+ ) -> Any:
62
+ """Instantiate a Mantle event broker and normalize it to the current API.
63
+
64
+ ``config_type`` is a builtin short name (``pika``, ``sql``, ``file``,
65
+ ``kafka``, ``concurrent_kafka``, ``http``), a ``module.path.ClassName``
66
+ import path, or omitted for the Pika default when a broker section is
67
+ present.
68
+
69
+ ``connect`` is awaited after preparation so this never returns an
70
+ unconfigured builtin.
71
+
72
+ Omitting the ``event_broker`` section entirely is handled by the Mantle
73
+ loader and yields ``None`` — this factory always builds a broker.
74
+ """
75
+ resolved_type = config_type or "pika"
76
+ structlogger.debug(
77
+ "rasa.api.brokers.create_event_broker", config_type=resolved_type
78
+ )
79
+ base = _version_base()
80
+ broker_cls = resolve_event_broker_class(resolved_type)
81
+ _validate_event_broker_class(broker_cls, resolved_type)
82
+ try:
83
+ broker = broker_cls()
84
+ except TypeError as error:
85
+ raise RasaException(
86
+ f"{resolved_type} must be constructible without arguments."
87
+ ) from error
88
+ prepared = prepare_instance(broker, "brokers")
89
+ if not isinstance(prepared, base.EventBroker):
90
+ raise RasaException(
91
+ f"Prepared event broker must implement EventBroker, got {type(prepared)!r}."
92
+ )
93
+ try:
94
+ await prepared.connect(settings)
95
+ except _connection_errors() as error:
96
+ raise ConnectionException("Cannot connect to event broker.") from error
97
+ return prepared
98
+
99
+
100
+ def resolve_event_broker_class(config_type: str) -> type:
101
+ """Resolve a builtin name or import path to an event broker class."""
102
+ builtin_spec = _BUILTIN_SPECS.get(config_type.lower())
103
+ if builtin_spec is not None and "." not in config_type:
104
+ module_name, class_name = builtin_spec
105
+ return getattr(
106
+ _version_submodule(current_version("brokers"), module_name), class_name
107
+ )
108
+
109
+ try:
110
+ module_name, class_name = config_type.rsplit(".", 1)
111
+ module = importlib.import_module(module_name)
112
+ except ValueError as error:
113
+ raise RasaException(
114
+ f"Invalid event broker type '{config_type}'. "
115
+ f"Expected a builtin name ({', '.join(sorted(_BUILTIN_SPECS))}) "
116
+ f"or module.path.ClassName."
117
+ ) from error
118
+ except ModuleNotFoundError as error:
119
+ raise RasaException(
120
+ f"Cannot retrieve class from path {config_type}."
121
+ ) from error
122
+
123
+ external_class = getattr(module, class_name, None)
124
+ if not isinstance(external_class, type):
125
+ raise RasaException(f"{config_type} did not resolve to a class.")
126
+ _validate_event_broker_class(external_class, config_type)
127
+ return external_class
128
+
129
+
130
+ def _validate_event_broker_class(broker_cls: type, config_type: str) -> None:
131
+ """Validate a broker contract before running customer construction code."""
132
+ try:
133
+ resolved = resolve_version(broker_cls, "brokers")
134
+ except (UnknownApiVersionError, AmbiguousApiVersionError) as error:
135
+ raise RasaException(
136
+ f"{config_type} must be a subclass of EventBroker."
137
+ ) from error
138
+
139
+ broker_base = _version_base(resolved.version).EventBroker
140
+ if not issubclass(broker_cls, broker_base):
141
+ raise RasaException(f"{config_type} must be a subclass of EventBroker.")
142
+
143
+ matched_base_index = broker_cls.__mro__.index(resolved.matched_base)
144
+ compatibility_bases = [
145
+ base
146
+ for base in broker_cls.__mro__[:matched_base_index]
147
+ if base.__module__.startswith("rasa.core.")
148
+ ]
149
+ if compatibility_bases:
150
+ raise RasaException(
151
+ f"{config_type} must subclass the published "
152
+ f"rasa.api.brokers.{resolved.version} EventBroker contract, "
153
+ "not an internal compatibility class."
154
+ )
155
+
156
+ if getattr(broker_cls, "connect", None) is broker_base.connect:
157
+ raise RasaException(f"{config_type} must implement connect().")
158
+ if getattr(broker_cls, "publish", None) is broker_base.publish:
159
+ raise RasaException(f"{config_type} must implement publish().")
160
+
161
+
162
+ def _connection_errors() -> tuple[type[BaseException], ...]:
163
+ """Return backend connection failures normalized by both runtime paths."""
164
+ import aio_pika.exceptions
165
+ import aiormq.exceptions
166
+ import sqlalchemy.exc
167
+
168
+ return (
169
+ sqlalchemy.exc.OperationalError,
170
+ aio_pika.exceptions.AMQPConnectionError,
171
+ aiormq.exceptions.ChannelNotFoundEntity,
172
+ *aio_pika.exceptions.CONNECTION_EXCEPTIONS,
173
+ )
@@ -0,0 +1,36 @@
1
+ """Private SQL helpers shared by published broker implementations."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+ from urllib import parse
7
+
8
+ from sqlalchemy.engine import URL
9
+
10
+
11
+ def build_db_url(
12
+ dialect: str = "sqlite",
13
+ host: str | None = None,
14
+ port: int | None = None,
15
+ db: str = "events.db",
16
+ username: str | None = None,
17
+ password: str | None = None,
18
+ query: dict[str, Any] | None = None,
19
+ ) -> str | URL:
20
+ """Build an SQLAlchemy URL without depending on a CALM tracker store."""
21
+ if host and "://" in host:
22
+ return host
23
+ if host:
24
+ parsed = parse.urlsplit(f"scheme://{host}")
25
+ port = parsed.port or port
26
+ host = parsed.hostname or host
27
+
28
+ return URL.create(
29
+ dialect,
30
+ username=username,
31
+ password=password,
32
+ host=host,
33
+ port=port,
34
+ database=db,
35
+ query=query or {},
36
+ )
@@ -0,0 +1,28 @@
1
+ """Mantle event broker contract — version 1.
2
+
3
+ Public surface for custom event brokers.
4
+
5
+ Publishing this package under ``rasa.api.brokers.v1`` is enough for the
6
+ versioning framework to discover it — no registration call is required.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from rasa.api.brokers.v1.base import EventBroker
12
+ from rasa.api.brokers.v1.file import FileEventBroker
13
+ from rasa.api.brokers.v1.http import HttpEventBroker
14
+ from rasa.api.brokers.v1.kafka import ConcurrentKafkaEventBroker, KafkaEventBroker
15
+ from rasa.api.brokers.v1.pika import PikaEventBroker
16
+ from rasa.api.brokers.v1.sql import SQLEventBroker
17
+ from rasa.api.brokers.v1.types import EventBrokerSettings
18
+
19
+ __all__ = [
20
+ "ConcurrentKafkaEventBroker",
21
+ "EventBroker",
22
+ "EventBrokerSettings",
23
+ "FileEventBroker",
24
+ "HttpEventBroker",
25
+ "KafkaEventBroker",
26
+ "PikaEventBroker",
27
+ "SQLEventBroker",
28
+ ]
@@ -0,0 +1,56 @@
1
+ """Mantle ``EventBroker`` abstract base (``rasa.api.brokers.v1``)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from abc import ABC, abstractmethod
6
+ from typing import Any, Optional
7
+
8
+ from rasa.api.brokers.v1.types import EventBrokerSettings
9
+
10
+
11
+ class EventBroker(ABC):
12
+ """Published Mantle contract for event broker backends.
13
+
14
+ Customers subclass this base, or a builtin from the same module, and import
15
+ it from ``rasa.api.brokers.v1``. YAML names the class only; the import names
16
+ the version.
17
+
18
+ A backend implements ``connect``, ``publish``, and may override ``is_ready``
19
+ and ``close``.
20
+ """
21
+
22
+ def __init__(self) -> None:
23
+ """Create an unconnected event broker."""
24
+
25
+ @abstractmethod
26
+ async def connect(self, settings: EventBrokerSettings) -> None:
27
+ """Connect or configure the broker using Mantle settings."""
28
+
29
+ @abstractmethod
30
+ def publish(self, event: dict[str, Any]) -> None:
31
+ """Publish a JSON-formatted Rasa event."""
32
+
33
+ def publish_batch(self, events: list[dict[str, Any]]) -> None:
34
+ """Publish the new events of one conversation, in order.
35
+
36
+ A transport that pays a per-request cost overrides this to send them
37
+ together. Publishing them one at a time is what the caller would do
38
+ otherwise, so a broker that has no use for the batch inherits exactly
39
+ the behaviour it had before.
40
+ """
41
+ for event in events:
42
+ self.publish(event)
43
+
44
+ def raise_if_engine_unsupported(self, engine_version: Optional[str]) -> None:
45
+ """Refuse a model whose events this broker cannot carry.
46
+
47
+ Brokers carry every engine by default. Engine-specific transports can
48
+ override this hook to reject an incompatible model before it is loaded.
49
+ """
50
+
51
+ def is_ready(self) -> bool:
52
+ """Return whether the broker is ready to publish."""
53
+ return True
54
+
55
+ async def close(self) -> None:
56
+ """Close the connection to the event broker."""
@@ -0,0 +1,70 @@
1
+ """File Mantle event broker builtin."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import logging
7
+ from typing import Any, Optional
8
+
9
+ from rasa.api.brokers.v1.base import EventBroker
10
+ from rasa.api.brokers.v1.types import EventBrokerSettings
11
+
12
+ logger = logging.getLogger(__name__)
13
+
14
+
15
+ class FileEventBroker(EventBroker):
16
+ """Log events to a file in json format.
17
+
18
+ There will be one event per line and each event is stored as json.
19
+ """
20
+
21
+ DEFAULT_LOG_FILE_NAME = "rasa_event.log"
22
+
23
+ def __init__(self) -> None:
24
+ """Create an unconnected file event broker."""
25
+ super().__init__()
26
+ self.path: str = self.DEFAULT_LOG_FILE_NAME
27
+ self.event_logger: logging.Logger | None = None
28
+
29
+ async def connect(self, settings: EventBrokerSettings) -> None:
30
+ """Configure the log file from Mantle settings."""
31
+ params = dict(settings.params)
32
+ self._configure(path=params.get("path"))
33
+
34
+ def publish(self, event: dict[str, Any]) -> None:
35
+ """Write event to file."""
36
+ if self.event_logger is None:
37
+ raise RuntimeError("FileEventBroker.connect must be called before publish.")
38
+ self.event_logger.info(json.dumps(event))
39
+ self.event_logger.handlers[0].flush()
40
+
41
+ async def close(self) -> None:
42
+ """Close this broker's file handlers."""
43
+ if self.event_logger is None:
44
+ return
45
+ for handler in list(self.event_logger.handlers):
46
+ self.event_logger.removeHandler(handler)
47
+ handler.close()
48
+ logging.Logger.manager.loggerDict.pop(self.event_logger.name, None)
49
+ self.event_logger = None
50
+
51
+ def _configure(self, path: Optional[str] = None) -> None:
52
+ self.path = path or self.DEFAULT_LOG_FILE_NAME
53
+ self.event_logger = self._event_logger()
54
+
55
+ def _event_logger(self) -> logging.Logger:
56
+ """Instantiate the file logger."""
57
+ logger_file = self.path
58
+ query_logger = logging.getLogger(f"event-logger.{id(self)}")
59
+ query_logger.setLevel(logging.INFO)
60
+ for existing_handler in list(query_logger.handlers):
61
+ query_logger.removeHandler(existing_handler)
62
+ existing_handler.close()
63
+ handler = logging.FileHandler(logger_file)
64
+ handler.setFormatter(logging.Formatter("%(message)s"))
65
+ query_logger.propagate = False
66
+ query_logger.addHandler(handler)
67
+
68
+ logger.info(f"Logging events to '{logger_file}'.")
69
+
70
+ return query_logger
@@ -1,3 +1,7 @@
1
+ """HTTP Mantle event broker builtin (Studio ingestion)."""
2
+
3
+ from __future__ import annotations
4
+
1
5
  import asyncio
2
6
  import random
3
7
  import re
@@ -10,7 +14,8 @@ import aiohttp
10
14
  import structlog
11
15
  from pydantic import BaseModel, ConfigDict, ValidationError
12
16
 
13
- from rasa.core.brokers.broker import EventBroker
17
+ from rasa.api.brokers.v1.base import EventBroker
18
+ from rasa.api.brokers.v1.types import EventBrokerSettings
14
19
  from rasa.shared.engine_version import (
15
20
  DEFAULT_ENGINE_VERSION,
16
21
  MANTLE_ENGINE_VERSION,
@@ -93,7 +98,41 @@ class HttpEventBroker(EventBroker):
93
98
  on any other engine the events have no representation in the contract.
94
99
  """
95
100
 
96
- def __init__(
101
+ def __init__(self) -> None:
102
+ """Create an unconnected HTTP event broker."""
103
+ super().__init__()
104
+ self.url: Optional[Text] = None
105
+ self.timeout = DEFAULT_TIMEOUT_IN_SECONDS
106
+ self.retries = DEFAULT_RETRIES
107
+ self.retry_delay_in_seconds = DEFAULT_RETRY_DELAY_IN_SECONDS
108
+ self.max_retry_delay_in_seconds = DEFAULT_MAX_RETRY_DELAY_IN_SECONDS
109
+ self.max_in_flight_requests = DEFAULT_MAX_IN_FLIGHT_REQUESTS
110
+ self.endpoint: Optional[EndpointConfig] = None
111
+ self.stream_pii = True
112
+ self._ssl_context: Any = None
113
+ self._engine_version: Text = DEFAULT_ENGINE_VERSION
114
+ self._engine_refused = False
115
+ self._engine_refusal_logged = False
116
+ self._session: Optional[aiohttp.ClientSession] = None
117
+ self._session_loop: Optional[AbstractEventLoop] = None
118
+ # Maps each in-flight task to the number of events it carries, so a
119
+ # batch abandoned at shutdown can say what it cost.
120
+ self._in_flight: Dict[asyncio.Task, int] = {}
121
+ self._closing = asyncio.Event()
122
+ self._closed = False
123
+ self._shut_down = False
124
+
125
+ async def connect(self, settings: EventBrokerSettings) -> None:
126
+ """Configure the HTTP client from Mantle settings."""
127
+ params = dict(settings.params)
128
+ url = params.pop("url", None)
129
+ # Rebuild EndpointConfig so headers, auth, token and TLS settings land
130
+ # on the same object the send path already reads. Named HTTP tuning
131
+ # keys (timeout, retries, …) ride along in ``kwargs``.
132
+ endpoint = EndpointConfig(url=url, **params)
133
+ self._configure(url=url, endpoint=endpoint, **endpoint.kwargs)
134
+
135
+ def _configure(
97
136
  self,
98
137
  url: Optional[Text] = None,
99
138
  timeout: float = DEFAULT_TIMEOUT_IN_SECONDS,
@@ -104,7 +143,7 @@ class HttpEventBroker(EventBroker):
104
143
  endpoint: Optional[EndpointConfig] = None,
105
144
  **kwargs: Any,
106
145
  ) -> None:
107
- """Creates a broker that posts events to Studio's ingestion endpoint.
146
+ """Apply connection settings for Studio's ingestion endpoint.
108
147
 
109
148
  Args:
110
149
  url: Studio's ingestion endpoint, for example
@@ -116,9 +155,8 @@ class HttpEventBroker(EventBroker):
116
155
  max_retry_delay_in_seconds: Ceiling for the doubling delay.
117
156
  max_in_flight_requests: Requests allowed in flight before further
118
157
  batches are dropped rather than queued without limit.
119
- endpoint: Pre-built endpoint configuration. Supplied by
120
- `from_endpoint_config`; carries the headers, auth and SSL
121
- settings the user configured.
158
+ endpoint: Pre-built endpoint configuration. Carries the headers,
159
+ auth and SSL settings the user configured.
122
160
  kwargs: Remaining endpoint configuration, ignored.
123
161
 
124
162
  Raises:
@@ -200,37 +238,6 @@ class HttpEventBroker(EventBroker):
200
238
  # to repeat on every request.
201
239
  self._ssl_context = self.endpoint.create_ssl_context()
202
240
 
203
- # The base class declares this as a plain `str`, so the default
204
- # stands in until a model loads. It is never read before then.
205
- self._engine_version: Text = DEFAULT_ENGINE_VERSION
206
- self._engine_refused = False
207
- self._engine_refusal_logged = False
208
-
209
- self._session: Optional[aiohttp.ClientSession] = None
210
- self._session_loop: Optional[AbstractEventLoop] = None
211
- # Maps each in-flight task to the number of events it carries, so a
212
- # batch abandoned at shutdown can say what it cost.
213
- self._in_flight: Dict[asyncio.Task, int] = {}
214
- self._closing = asyncio.Event()
215
- self._closed = False
216
- self._shut_down = False
217
-
218
- @classmethod
219
- async def from_endpoint_config(
220
- cls,
221
- broker_config: Optional[EndpointConfig],
222
- event_loop: Optional[AbstractEventLoop] = None,
223
- ) -> Optional["HttpEventBroker"]:
224
- """Creates broker. See the parent class for more information."""
225
- if broker_config is None:
226
- return None
227
-
228
- return cls(
229
- url=broker_config.url,
230
- endpoint=broker_config,
231
- **broker_config.kwargs,
232
- )
233
-
234
241
  @property
235
242
  def _loggable_url(self) -> Text:
236
243
  """The configured url without the credentials it may embed.
@@ -239,8 +246,16 @@ class HttpEventBroker(EventBroker):
239
246
  both work, so the url as configured never goes into a log or an error
240
247
  message. Derived on each read so it follows `url` if that changes.
241
248
  """
249
+ if not self.url:
250
+ return ""
242
251
  return strip_url_credentials(self.url)
243
252
 
253
+ def _require_endpoint(self) -> EndpointConfig:
254
+ """Return the configured endpoint, or fail if connect was skipped."""
255
+ if self.endpoint is None or not self.url:
256
+ raise RuntimeError("HttpEventBroker.connect must be called before use.")
257
+ return self.endpoint
258
+
244
259
  def _batches(
245
260
  self, events: List[Dict[Text, Any]]
246
261
  ) -> Iterator[List[Dict[Text, Any]]]:
@@ -594,15 +609,16 @@ class HttpEventBroker(EventBroker):
594
609
  )
595
610
  raise PermanentDeliveryError("The event broker has been closed.")
596
611
 
612
+ endpoint = self._require_endpoint()
597
613
  auth = None
598
- if self.endpoint.basic_auth:
614
+ if endpoint.basic_auth:
599
615
  auth = aiohttp.BasicAuth(
600
- self.endpoint.basic_auth["username"],
601
- self.endpoint.basic_auth["password"],
616
+ endpoint.basic_auth["username"],
617
+ endpoint.basic_auth["password"],
602
618
  )
603
619
 
604
620
  self._session = aiohttp.ClientSession(
605
- headers=self.endpoint.headers,
621
+ headers=endpoint.headers,
606
622
  auth=auth,
607
623
  timeout=aiohttp.ClientTimeout(total=self.timeout),
608
624
  connector=aiohttp.TCPConnector(
@@ -647,13 +663,14 @@ class HttpEventBroker(EventBroker):
647
663
  Studio refused the request itself, or the broker is closed.
648
664
  """
649
665
  payload = self._payload(events)
666
+ endpoint = self._require_endpoint()
650
667
  session = self._client_session()
651
668
 
652
669
  try:
653
670
  async with session.post(
654
671
  self.url,
655
672
  json=payload,
656
- params=self.endpoint.combine_parameters(),
673
+ params=endpoint.combine_parameters(),
657
674
  # Correlates this attempt with the receiving end's own logs.
658
675
  headers={"X-Request-ID": request_id},
659
676
  # A 307 or 308 would re-post the whole batch, user text and