rasa-pro 3.13.1a18__py3-none-any.whl → 3.13.1a20__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 (273) hide show
  1. rasa/__main__.py +8 -0
  2. rasa/builder/auth.py +71 -0
  3. rasa/builder/config.py +16 -0
  4. rasa/builder/copilot/constants.py +15 -0
  5. rasa/builder/copilot/copilot.py +342 -0
  6. rasa/builder/copilot/copilot_response_handler.py +471 -0
  7. rasa/builder/copilot/exceptions.py +20 -0
  8. rasa/builder/copilot/models.py +344 -0
  9. rasa/builder/copilot/prompts/copilot_system_prompt.jinja2 +495 -0
  10. rasa/builder/copilot/telemetry.py +195 -0
  11. rasa/builder/document_retrieval/__init__.py +0 -0
  12. rasa/builder/document_retrieval/constants.py +16 -0
  13. rasa/builder/{inkeep_document_retrieval.py → document_retrieval/inkeep_document_retrieval.py} +53 -44
  14. rasa/builder/document_retrieval/models.py +62 -0
  15. rasa/builder/download.py +140 -0
  16. rasa/builder/guardrails/__init__.py +1 -0
  17. rasa/builder/guardrails/constants.py +4 -0
  18. rasa/builder/guardrails/exceptions.py +4 -0
  19. rasa/builder/guardrails/lakera.py +188 -0
  20. rasa/builder/guardrails/models.py +199 -0
  21. rasa/builder/guardrails/utils.py +305 -0
  22. rasa/builder/job_manager.py +87 -0
  23. rasa/builder/jobs.py +232 -0
  24. rasa/builder/llm_service.py +89 -173
  25. rasa/builder/logging_utils.py +162 -4
  26. rasa/builder/main.py +29 -16
  27. rasa/builder/models.py +93 -121
  28. rasa/builder/project_generator.py +91 -7
  29. rasa/builder/scrape_rasa_docs.py +1 -1
  30. rasa/builder/service.py +650 -452
  31. rasa/builder/shared/tracker_context.py +212 -0
  32. rasa/builder/validation_service.py +4 -4
  33. rasa/cli/data.py +8 -3
  34. rasa/cli/project_templates/basic/actions/action_api.py +15 -0
  35. rasa/cli/project_templates/basic/actions/action_human_handoff.py +44 -0
  36. rasa/cli/project_templates/basic/config.yml +23 -0
  37. rasa/cli/project_templates/{plain → basic}/credentials.yml +8 -7
  38. rasa/cli/project_templates/basic/data/general/feedback.yml +20 -0
  39. rasa/cli/project_templates/basic/data/general/goodbye.yml +6 -0
  40. rasa/cli/project_templates/basic/data/general/hello.yml +7 -0
  41. rasa/cli/project_templates/basic/data/general/help.yml +6 -0
  42. rasa/cli/project_templates/basic/data/general/human_handoff.yml +16 -0
  43. rasa/cli/project_templates/basic/data/general/welcome.yml +9 -0
  44. rasa/cli/project_templates/{finance/data/patterns → basic/data/system}/pattern_completed.yml +2 -1
  45. rasa/cli/project_templates/basic/data/system/pattern_correction.yml +7 -0
  46. rasa/cli/project_templates/basic/data/system/pattern_search.yml +8 -0
  47. rasa/cli/project_templates/basic/data/system/pattern_session_start.yml +8 -0
  48. rasa/cli/project_templates/basic/docs/rasa_assistant_qa.txt +65 -0
  49. rasa/cli/project_templates/basic/docs/template.txt +7 -0
  50. rasa/cli/project_templates/basic/domain/general/assistant_details.yml +12 -0
  51. rasa/cli/project_templates/basic/domain/general/bot_identity.yml +5 -0
  52. rasa/cli/project_templates/basic/domain/general/cannot_handle.yml +5 -0
  53. rasa/cli/project_templates/basic/domain/general/feedback.yml +28 -0
  54. rasa/cli/project_templates/basic/domain/general/goodbye.yml +7 -0
  55. rasa/cli/project_templates/basic/domain/general/help.yml +5 -0
  56. rasa/cli/project_templates/basic/domain/general/human_handoff_domain.yml +35 -0
  57. rasa/cli/project_templates/{finance/domain/default_actions.yml → basic/domain/general/utils.yml} +0 -3
  58. rasa/cli/project_templates/basic/domain/general/welcome.yml +7 -0
  59. rasa/cli/project_templates/{plain → basic}/endpoints.yml +42 -27
  60. rasa/cli/project_templates/basic/prompts/rephraser_demo_personality_prompt.jinja2 +19 -0
  61. rasa/cli/project_templates/defaults.py +25 -3
  62. rasa/cli/project_templates/finance/actions/__init__.py +46 -0
  63. rasa/cli/project_templates/finance/actions/accounts/__init__.py +0 -0
  64. rasa/cli/project_templates/finance/actions/{action_ask_account.py → accounts/action_ask_account.py} +6 -9
  65. rasa/cli/project_templates/finance/actions/{action_check_balance.py → accounts/action_check_balance.py} +4 -4
  66. rasa/cli/project_templates/finance/actions/action_session_start.py +11 -6
  67. rasa/cli/project_templates/finance/actions/cards/__init__.py +0 -0
  68. rasa/cli/project_templates/finance/actions/{action_ask_card.py → cards/action_ask_card.py} +4 -3
  69. rasa/cli/project_templates/finance/actions/{action_check_card_existence.py → cards/action_check_card_existence.py} +4 -3
  70. rasa/cli/project_templates/finance/actions/{action_update_card_status.py → cards/action_update_card_status.py} +18 -9
  71. rasa/cli/project_templates/finance/actions/database.py +1 -0
  72. rasa/cli/project_templates/finance/actions/transfers/__init__.py +0 -0
  73. rasa/cli/project_templates/finance/actions/{action_add_payee.py → transfers/action_add_payee.py} +8 -3
  74. rasa/cli/project_templates/finance/actions/{action_ask_account_from.py → transfers/action_ask_account_from.py} +5 -4
  75. rasa/cli/project_templates/finance/actions/{action_check_payee_existence.py → transfers/action_check_payee_existence.py} +3 -3
  76. rasa/cli/project_templates/finance/actions/{action_check_sufficient_funds.py → transfers/action_check_sufficient_funds.py} +3 -4
  77. rasa/cli/project_templates/finance/actions/{action_list_payees.py → transfers/action_list_payees.py} +4 -3
  78. rasa/cli/project_templates/finance/actions/{action_remove_payee.py → transfers/action_remove_payee.py} +4 -4
  79. rasa/cli/project_templates/finance/config.yml +8 -19
  80. rasa/cli/project_templates/finance/credentials.yml +6 -7
  81. rasa/cli/project_templates/finance/csvs/cards.csv +10 -10
  82. rasa/cli/project_templates/finance/csvs/payees.csv +10 -9
  83. rasa/cli/project_templates/finance/data/{flows → accounts}/check_balance.yml +2 -1
  84. rasa/cli/project_templates/finance/data/general/bot_identity.yml +6 -0
  85. rasa/cli/project_templates/finance/data/general/feedback.yml +20 -0
  86. rasa/cli/project_templates/finance/data/general/goodbye.yml +6 -0
  87. rasa/cli/project_templates/finance/data/general/hello.yml +7 -0
  88. rasa/cli/project_templates/finance/data/{flows/welcome.yml → general/help.yml} +2 -7
  89. rasa/cli/project_templates/finance/data/general/human_handoff.yml +16 -0
  90. rasa/cli/project_templates/finance/data/general/welcome.yml +9 -0
  91. rasa/cli/project_templates/finance/data/{patterns → system/patterns}/pattern_chitchat.yml +0 -2
  92. rasa/cli/project_templates/finance/data/system/patterns/pattern_completed.yml +7 -0
  93. rasa/cli/project_templates/finance/data/system/patterns/pattern_correction.yml +7 -0
  94. rasa/cli/project_templates/finance/data/system/patterns/pattern_search.yml +8 -0
  95. rasa/cli/project_templates/finance/data/{patterns → system/patterns}/pattern_session_start.yml +0 -1
  96. rasa/cli/project_templates/finance/domain/{check_balance.yml → accounts/check_balance.yml} +2 -0
  97. rasa/cli/project_templates/finance/domain/general/assistant_details.yml +12 -0
  98. rasa/cli/project_templates/finance/domain/general/bot_identity.yml +5 -0
  99. rasa/cli/project_templates/finance/domain/general/cannot_handle.yml +5 -0
  100. rasa/cli/project_templates/finance/domain/general/defaults.yml +24 -0
  101. rasa/cli/project_templates/finance/domain/general/feedback.yml +28 -0
  102. rasa/cli/project_templates/finance/domain/general/goodbye.yml +7 -0
  103. rasa/cli/project_templates/finance/domain/general/help.yml +5 -0
  104. rasa/cli/project_templates/finance/domain/general/human_handoff.yml +30 -0
  105. rasa/cli/project_templates/finance/domain/general/utils.yml +13 -0
  106. rasa/cli/project_templates/finance/domain/general/welcome.yml +8 -0
  107. rasa/cli/project_templates/finance/endpoints.yml +1 -0
  108. rasa/cli/project_templates/finance/prompts/rephraser_demo_personality_prompt.jinja2 +3 -3
  109. rasa/cli/project_templates/telco/actions/actions_billing.py +24 -17
  110. rasa/cli/project_templates/telco/actions/actions_get_data_from_db.py +6 -1
  111. rasa/cli/project_templates/telco/actions/actions_run_diagnostics.py +6 -1
  112. rasa/cli/project_templates/telco/actions/actions_session_start.py +6 -1
  113. rasa/cli/project_templates/tutorial/config.yml +2 -1
  114. rasa/cli/scaffold.py +27 -2
  115. rasa/cli/train.py +8 -0
  116. rasa/cli/utils.py +31 -15
  117. rasa/core/actions/action.py +28 -41
  118. rasa/core/actions/action_run_slot_rejections.py +1 -1
  119. rasa/core/channels/development_inspector.py +47 -14
  120. rasa/core/channels/inspector/dist/assets/{arc-371401b1.js → arc-1ddec37b.js} +1 -1
  121. rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-3f126156.js → blockDiagram-38ab4fdb-18af387c.js} +1 -1
  122. rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-12f22eb7.js → c4Diagram-3d4e48cf-250127a3.js} +1 -1
  123. rasa/core/channels/inspector/dist/assets/channel-59f6d54b.js +1 -0
  124. rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-03b1d386.js → classDiagram-70f12bd4-c3388b34.js} +1 -1
  125. rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-84f69d63.js → classDiagram-v2-f2320105-9c893a82.js} +1 -1
  126. rasa/core/channels/inspector/dist/assets/clone-26177ddb.js +1 -0
  127. rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-ca47fd38.js → createText-2e5e7dd3-c111213b.js} +1 -1
  128. rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-f837ca8a.js → edges-e0da2a9e-812a729d.js} +1 -1
  129. rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-8717ac54.js → erDiagram-9861fffd-fd5051bc.js} +1 -1
  130. rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-94f38b83.js → flowDb-956e92f1-3287ac02.js} +1 -1
  131. rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-b616f9fb.js → flowDiagram-66a62f08-692fb0b2.js} +1 -1
  132. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-29c03f5a.js +1 -0
  133. rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-f5d24bb8.js → flowchart-elk-definition-4a651766-008376f1.js} +1 -1
  134. rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-b43ba8d9.js → ganttDiagram-c361ad54-df330a69.js} +1 -1
  135. rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-c3aafaa5.js → gitGraphDiagram-72cf32ee-e03676fb.js} +1 -1
  136. rasa/core/channels/inspector/dist/assets/{graph-0d0a2c10.js → graph-46fad2ba.js} +1 -1
  137. rasa/core/channels/inspector/dist/assets/{index-3862675e-58ea0305.js → index-3862675e-a484ac55.js} +1 -1
  138. rasa/core/channels/inspector/dist/assets/{index-cce6f8a1.js → index-a003633f.js} +179 -179
  139. rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-b8f60461.js → infoDiagram-f8f76790-3f9e6ec2.js} +1 -1
  140. rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-95be5545.js → journeyDiagram-49397b02-79f72383.js} +1 -1
  141. rasa/core/channels/inspector/dist/assets/{layout-da885b9b.js → layout-aad098e5.js} +1 -1
  142. rasa/core/channels/inspector/dist/assets/{line-f1c817d3.js → line-219ab7ae.js} +1 -1
  143. rasa/core/channels/inspector/dist/assets/{linear-d42801e6.js → linear-2cddbe62.js} +1 -1
  144. rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-a38923a6.js → mindmap-definition-fc14e90a-1d41ed99.js} +1 -1
  145. rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-ca6e71e9.js → pieDiagram-8a3498a8-cc496ee8.js} +1 -1
  146. rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-b290dae9.js → quadrantDiagram-120e2f19-84d32884.js} +1 -1
  147. rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-03f02ceb.js → requirementDiagram-deff3bca-c0deb984.js} +1 -1
  148. rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-c49eee40.js → sankeyDiagram-04a897e0-b9d7fd62.js} +1 -1
  149. rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-b2cd6a3d.js → sequenceDiagram-704730f1-7d517565.js} +1 -1
  150. rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-e53a2028.js → stateDiagram-587899a1-98ef9b27.js} +1 -1
  151. rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-e1982a03.js → stateDiagram-v2-d93cdb3a-cee70748.js} +1 -1
  152. rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-d0226ca5.js → styles-6aaf32cf-3f9d1c96.js} +1 -1
  153. rasa/core/channels/inspector/dist/assets/{styles-9a916d00-0e21dc00.js → styles-9a916d00-67471923.js} +1 -1
  154. rasa/core/channels/inspector/dist/assets/{styles-c10674c1-9588494e.js → styles-c10674c1-bd093fb7.js} +1 -1
  155. rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-be478d4f.js → svgDrawCommon-08f97a94-675794e8.js} +1 -1
  156. rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-74631749.js → timeline-definition-85554ec2-0ac67617.js} +1 -1
  157. rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-a043552f.js → xychartDiagram-e933f94c-c018dc37.js} +1 -1
  158. rasa/core/channels/inspector/dist/index.html +2 -2
  159. rasa/core/channels/inspector/index.html +1 -1
  160. rasa/core/channels/inspector/package.json +4 -3
  161. rasa/core/channels/inspector/src/App.tsx +53 -7
  162. rasa/core/channels/inspector/src/components/Chat.tsx +3 -2
  163. rasa/core/channels/inspector/src/components/DiagramFlow.tsx +1 -1
  164. rasa/core/channels/inspector/src/components/LatencyDisplay.tsx +268 -0
  165. rasa/core/channels/inspector/src/components/LoadingSpinner.tsx +6 -2
  166. rasa/core/channels/inspector/src/helpers/audio/audiostream.ts +8 -3
  167. rasa/core/channels/inspector/src/types.ts +8 -0
  168. rasa/core/channels/inspector/yarn.lock +12 -12
  169. rasa/core/channels/studio_chat.py +119 -34
  170. rasa/core/channels/voice_ready/twilio_voice.py +1 -1
  171. rasa/core/channels/voice_stream/asr/asr_engine.py +5 -1
  172. rasa/core/channels/voice_stream/asr/deepgram.py +5 -0
  173. rasa/core/channels/voice_stream/audiocodes.py +16 -8
  174. rasa/core/channels/voice_stream/browser_audio.py +39 -4
  175. rasa/core/channels/voice_stream/call_state.py +13 -2
  176. rasa/core/channels/voice_stream/genesys.py +16 -13
  177. rasa/core/channels/voice_stream/jambonz.py +14 -12
  178. rasa/core/channels/voice_stream/twilio_media_streams.py +14 -13
  179. rasa/core/channels/voice_stream/util.py +11 -1
  180. rasa/core/channels/voice_stream/voice_channel.py +108 -29
  181. rasa/core/nlg/callback.py +1 -1
  182. rasa/core/nlg/contextual_response_rephraser.py +19 -9
  183. rasa/core/nlg/generator.py +21 -5
  184. rasa/core/nlg/response.py +43 -6
  185. rasa/core/nlg/translate.py +8 -0
  186. rasa/core/policies/enterprise_search_policy.py +16 -21
  187. rasa/dialogue_understanding/commands/correct_slots_command.py +38 -10
  188. rasa/dialogue_understanding/generator/command_generator.py +5 -5
  189. rasa/dialogue_understanding/generator/command_parser.py +9 -13
  190. rasa/dialogue_understanding/processor/command_processor.py +149 -55
  191. rasa/dialogue_understanding/stack/utils.py +13 -3
  192. rasa/dialogue_understanding_test/du_test_schema.yml +3 -3
  193. rasa/dialogue_understanding_test/validation.py +9 -10
  194. rasa/e2e_test/e2e_config.py +18 -11
  195. rasa/e2e_test/e2e_test_schema.yml +3 -3
  196. rasa/e2e_test/utils/validation.py +17 -19
  197. rasa/engine/validation.py +86 -91
  198. rasa/exceptions.py +26 -1
  199. rasa/model_manager/model_api.py +2 -2
  200. rasa/model_manager/socket_bridge.py +8 -2
  201. rasa/shared/providers/_configs/default_litellm_client_config.py +3 -7
  202. rasa/shared/utils/cli.py +2 -0
  203. rasa/shared/utils/common.py +2 -1
  204. rasa/shared/utils/health_check/health_check.py +10 -14
  205. rasa/studio/upload.py +6 -2
  206. rasa/studio/utils.py +33 -22
  207. rasa/telemetry.py +95 -22
  208. rasa/utils/licensing.py +21 -10
  209. rasa/utils/log_utils.py +1 -1
  210. rasa/utils/tensorflow/transformer.py +3 -3
  211. rasa/validator.py +7 -5
  212. rasa/version.py +1 -1
  213. {rasa_pro-3.13.1a18.dist-info → rasa_pro-3.13.1a20.dist-info}/METADATA +7 -7
  214. {rasa_pro-3.13.1a18.dist-info → rasa_pro-3.13.1a20.dist-info}/RECORD +242 -203
  215. rasa/builder/create_openai_vector_store.py +0 -228
  216. rasa/builder/llm-helper-schema.json +0 -69
  217. rasa/builder/llm_context.py +0 -81
  218. rasa/builder/llm_helper_prompt.jinja2 +0 -245
  219. rasa/cli/project_templates/finance/data/nlu.yml +0 -29
  220. rasa/cli/project_templates/finance/data/patterns/pattern_search.yml +0 -5
  221. rasa/cli/project_templates/finance/domain/default_flows.yml +0 -33
  222. rasa/cli/project_templates/finance/prompts/command-generator.jinja2 +0 -57
  223. rasa/cli/project_templates/finance/tests/conversation_repair/cancellations.yml +0 -12
  224. rasa/cli/project_templates/finance/tests/conversation_repair/cannot_handle.yml +0 -7
  225. rasa/cli/project_templates/finance/tests/conversation_repair/chitchat.yml +0 -7
  226. rasa/cli/project_templates/finance/tests/conversation_repair/clarification.yml +0 -9
  227. rasa/cli/project_templates/finance/tests/conversation_repair/completion.yml +0 -18
  228. rasa/cli/project_templates/finance/tests/conversation_repair/corrections.yml +0 -17
  229. rasa/cli/project_templates/finance/tests/conversation_repair/digressions.yml +0 -32
  230. rasa/cli/project_templates/finance/tests/conversation_repair/human_handoff.yml +0 -21
  231. rasa/cli/project_templates/finance/tests/conversation_repair/skipping_collect_steps.yml +0 -16
  232. rasa/cli/project_templates/finance/tests/demo_scripts/main.yml +0 -16
  233. rasa/cli/project_templates/finance/tests/happy_paths/balance_verification.yml +0 -15
  234. rasa/cli/project_templates/finance/tests/happy_paths/banking_questions.yml +0 -12
  235. rasa/cli/project_templates/finance/tests/happy_paths/card_blocking.yml +0 -52
  236. rasa/cli/project_templates/finance/tests/happy_paths/money_transfer.yml +0 -136
  237. rasa/cli/project_templates/finance/tests/happy_paths/payee_management.yml +0 -27
  238. rasa/cli/project_templates/finance/tests/happy_paths/user_greeted.yml +0 -5
  239. rasa/cli/project_templates/plain/config.yml +0 -17
  240. rasa/cli/project_templates/plain/data/patterns/pattern_session_start.yml +0 -7
  241. rasa/cli/project_templates/plain/domain.yml +0 -5
  242. rasa/core/channels/inspector/dist/assets/channel-f1efda17.js +0 -1
  243. rasa/core/channels/inspector/dist/assets/clone-fdf164e2.js +0 -1
  244. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-7d7a1629.js +0 -1
  245. rasa/shared/importers/static.py +0 -63
  246. /rasa/{cli/project_templates/plain/actions → builder/copilot}/__init__.py +0 -0
  247. /rasa/builder/{inkeep-rag-response-schema.json → document_retrieval/inkeep-rag-response-schema.json} +0 -0
  248. /rasa/cli/project_templates/finance/actions/{action_process_immediate_payment.py → transfers/action_process_immediate_payment.py} +0 -0
  249. /rasa/cli/project_templates/finance/actions/{action_schedule_payment.py → transfers/action_schedule_payment.py} +0 -0
  250. /rasa/cli/project_templates/finance/actions/{action_validate_payment_date.py → transfers/action_validate_payment_date.py} +0 -0
  251. /rasa/cli/project_templates/finance/data/{flows → cards}/block_card.yml +0 -0
  252. /rasa/cli/project_templates/finance/data/{flows → cards}/select_card.yml +0 -0
  253. /rasa/cli/project_templates/finance/data/{source → system/source}/accounts.json +0 -0
  254. /rasa/cli/project_templates/finance/data/{source → system/source}/advisors.json +0 -0
  255. /rasa/cli/project_templates/finance/data/{source → system/source}/appointments.json +0 -0
  256. /rasa/cli/project_templates/finance/data/{source → system/source}/branches.json +0 -0
  257. /rasa/cli/project_templates/finance/data/{source → system/source}/cards.json +0 -0
  258. /rasa/cli/project_templates/finance/data/{source → system/source}/payees.json +0 -0
  259. /rasa/cli/project_templates/finance/data/{source → system/source}/transactions.json +0 -0
  260. /rasa/cli/project_templates/finance/data/{source → system/source}/users.json +0 -0
  261. /rasa/cli/project_templates/finance/data/{flows → transfers}/add_payee.yml +0 -0
  262. /rasa/cli/project_templates/finance/data/{flows → transfers}/list_payees.yml +0 -0
  263. /rasa/cli/project_templates/finance/data/{flows → transfers}/remove_payee.yml +0 -0
  264. /rasa/cli/project_templates/finance/data/{flows → transfers}/transfer_money.yml +0 -0
  265. /rasa/cli/project_templates/finance/domain/{block_card.yml → cards/block_card.yml} +0 -0
  266. /rasa/cli/project_templates/finance/domain/{select_card.yml → cards/select_card.yml} +0 -0
  267. /rasa/cli/project_templates/finance/domain/{add_payee.yml → transfers/add_payee.yml} +0 -0
  268. /rasa/cli/project_templates/finance/domain/{list_payees.yml → transfers/list_payees.yml} +0 -0
  269. /rasa/cli/project_templates/finance/domain/{remove_payee.yml → transfers/remove_payee.yml} +0 -0
  270. /rasa/cli/project_templates/finance/domain/{transfer_money.yml → transfers/transfer_money.yml} +0 -0
  271. {rasa_pro-3.13.1a18.dist-info → rasa_pro-3.13.1a20.dist-info}/NOTICE +0 -0
  272. {rasa_pro-3.13.1a18.dist-info → rasa_pro-3.13.1a20.dist-info}/WHEEL +0 -0
  273. {rasa_pro-3.13.1a18.dist-info → rasa_pro-3.13.1a20.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,344 @@
1
+ import json
2
+ from abc import ABC, abstractmethod
3
+ from enum import Enum
4
+ from typing import Any, Dict, List, Literal, Optional, Union
5
+
6
+ import structlog
7
+ from openai.types.chat.chat_completion_chunk import ChatCompletionChunk
8
+ from pydantic import BaseModel, Field, model_validator
9
+
10
+ from rasa.builder.copilot.constants import ROLE_ASSISTANT, ROLE_COPILOT, ROLE_USER
11
+ from rasa.builder.models import ServerSentEvent
12
+ from rasa.builder.shared.tracker_context import TrackerContext
13
+
14
+ structlogger = structlog.get_logger()
15
+
16
+
17
+ class ResponseCompleteness(Enum):
18
+ """Enum for response completeness levels."""
19
+
20
+ TOKEN = "token" # Streaming token/chunk
21
+ COMPLETE = "complete" # Complete response (e.g., templated responses)
22
+
23
+
24
+ class ResponseCategory(Enum):
25
+ """Enum for different categories of responses."""
26
+
27
+ COPILOT = "copilot"
28
+ ROLEPLAY_DETECTION = "roleplay_detection"
29
+ OUT_OF_SCOPE_DETECTION = "out_of_scope_detection"
30
+ GUARDRAILS_POLICY_VIOLATION = "guardrails_policy_violation"
31
+ REFERENCE = "reference"
32
+ REFERENCE_ENTRY = "reference_entry"
33
+
34
+
35
+ class BaseContent(BaseModel):
36
+ type: str
37
+
38
+
39
+ class TextContent(BaseContent):
40
+ type: Literal["text"]
41
+ text: str
42
+
43
+
44
+ class CodeContent(BaseContent):
45
+ type: Literal["code"]
46
+ text: str
47
+
48
+
49
+ class FileContent(BaseContent):
50
+ type: Literal["file"]
51
+ file_path: str
52
+ file_content: str
53
+
54
+
55
+ class EventContent(BaseModel):
56
+ type: Literal["event"]
57
+ event: str = Field(..., description="The event's type_name")
58
+
59
+ event_data: Dict[str, Any] = Field(
60
+ default_factory=dict, description="Contains event-specific data fields."
61
+ )
62
+
63
+ @model_validator(mode="before")
64
+ @classmethod
65
+ def _collect_event_data(cls, data: Dict[str, Any]) -> Dict[str, Any]:
66
+ generic = {"type", "event"}
67
+ data["event_data"] = {
68
+ key: data.pop(key) for key in list(data.keys()) if key not in generic
69
+ }
70
+ return data
71
+
72
+ class Config:
73
+ extra = "forbid"
74
+
75
+
76
+ class CopilotChatMessage(BaseModel):
77
+ """Model for a single chat messages between the user and the copilot."""
78
+
79
+ role: str = Field(..., pattern=f"^({ROLE_USER}|{ROLE_COPILOT})$")
80
+ content: List[Union[TextContent, CodeContent, FileContent, EventContent]] = Field(
81
+ ...,
82
+ description=(
83
+ "The content of the message. "
84
+ "The content is expected to be a list of content blocks. "
85
+ "The content blocks are expected to be one of the following types: "
86
+ "text, link, code, or file."
87
+ ),
88
+ )
89
+ response_category: Optional[ResponseCategory] = Field(
90
+ None,
91
+ description=(
92
+ "The category/source of this message. For user role messages, only `None` "
93
+ "or `GUARDRAILS_POLICY_VIOLATION` are allowed. For copilot role messages, "
94
+ "any category is permitted."
95
+ ),
96
+ )
97
+
98
+ @model_validator(mode="after")
99
+ def validate_response_category_for_role(self) -> "CopilotChatMessage":
100
+ """Validate value of response_category for the role of the message.
101
+
102
+ For user role messages, only None or GUARDRAILS_POLICY_VIOLATION are allowed.
103
+ For copilot role messages, any category is permitted.
104
+ """
105
+ if (
106
+ self.role == ROLE_USER
107
+ and self.response_category is not None
108
+ and self.response_category != ResponseCategory.GUARDRAILS_POLICY_VIOLATION
109
+ ):
110
+ message = (
111
+ f"User role messages can only have response_category of `None` or "
112
+ f"`{ResponseCategory.GUARDRAILS_POLICY_VIOLATION}`, "
113
+ f"got `{self.response_category}`."
114
+ )
115
+ structlogger.error(
116
+ "copilot_chat_message.validate_response_category_for_role"
117
+ ".invalid_response_category",
118
+ event_info=message,
119
+ response_category=self.response_category,
120
+ role=self.role,
121
+ )
122
+ raise ValueError(message)
123
+
124
+ return self
125
+
126
+ def get_text_content(self) -> str:
127
+ """Concatenate all 'text' content blocks into a single string."""
128
+ return "\n".join(
129
+ content_block.text
130
+ for content_block in self.content
131
+ if isinstance(content_block, TextContent)
132
+ )
133
+
134
+ def to_openai_format(self) -> Dict[str, Any]:
135
+ """Convert to OpenAI message format for API calls."""
136
+ role = self._map_role_to_openai()
137
+
138
+ if role == ROLE_USER:
139
+ content = self.get_text_content()
140
+ else:
141
+ content_blocks = [block.model_dump() for block in self.content]
142
+ content = json.dumps(content_blocks)
143
+
144
+ return {"role": role, "content": content}
145
+
146
+ def _map_role_to_openai(self) -> str:
147
+ """Map internal roles to OpenAI-compatible roles."""
148
+ role_mapping = {
149
+ ROLE_USER: ROLE_USER,
150
+ ROLE_COPILOT: ROLE_ASSISTANT,
151
+ }
152
+ if self.role not in [ROLE_USER, ROLE_COPILOT]:
153
+ structlogger.error(
154
+ "copilot_chat_message.to_openai_format.invalid_role",
155
+ event_info=(
156
+ f"Invalid role: `{self.role}`. "
157
+ "Only `user` and `copilot` roles are supported."
158
+ ),
159
+ role=self.role,
160
+ )
161
+ raise ValueError(f"Invalid role: {self.role}")
162
+
163
+ return role_mapping[self.role]
164
+
165
+
166
+ class CopilotRequest(BaseModel):
167
+ """Request model for the copilot endpoint."""
168
+
169
+ copilot_chat_history: List[CopilotChatMessage] = Field(
170
+ ...,
171
+ description=(
172
+ "The chat history between the user and the copilot. "
173
+ "Used to generate a new response based on the previous conversation."
174
+ ),
175
+ )
176
+ session_id: str = Field(
177
+ ...,
178
+ description=(
179
+ "The session ID of chat session with the assistant. "
180
+ "Used to fetch the conversation from the tracker."
181
+ ),
182
+ )
183
+
184
+ @property
185
+ def last_message(self) -> Optional[CopilotChatMessage]:
186
+ """Get the last message from the copilot chat history."""
187
+ if not self.copilot_chat_history:
188
+ return None
189
+ return self.copilot_chat_history[-1]
190
+
191
+
192
+ class CopilotOutput(BaseModel, ABC):
193
+ """Base class for response events."""
194
+
195
+ response_completeness: ResponseCompleteness = Field(
196
+ description=(
197
+ "Indicates whether this is a streaming token (TOKEN) or a complete "
198
+ "response (COMPLETE)"
199
+ ),
200
+ )
201
+ response_category: ResponseCategory = Field(
202
+ description=(
203
+ "The category/source of this response. Each response type has a fixed "
204
+ "category that cannot be changed. "
205
+ ),
206
+ frozen=True,
207
+ )
208
+
209
+ @abstractmethod
210
+ def to_sse_event(self) -> ServerSentEvent:
211
+ """Convert to SSE event format."""
212
+ pass
213
+
214
+
215
+ class GeneratedContent(CopilotOutput):
216
+ """Represents generated content from the LLM to be streamed."""
217
+
218
+ content: str
219
+ response_category: ResponseCategory = Field(frozen=True)
220
+ response_completeness: ResponseCompleteness = ResponseCompleteness.TOKEN
221
+
222
+ def to_sse_event(self) -> ServerSentEvent:
223
+ """Convert to SSE event format."""
224
+ return ServerSentEvent(
225
+ event="copilot_response",
226
+ data={
227
+ "content": self.content,
228
+ "response_category": self.response_category.value,
229
+ "completeness": self.response_completeness.value,
230
+ },
231
+ )
232
+
233
+
234
+ class ReferenceEntry(CopilotOutput):
235
+ """Represents a reference entry with title and url."""
236
+
237
+ index: int
238
+ title: str
239
+ url: str
240
+ response_category: ResponseCategory = Field(
241
+ default=ResponseCategory.REFERENCE_ENTRY,
242
+ frozen=True,
243
+ )
244
+ response_completeness: ResponseCompleteness = ResponseCompleteness.COMPLETE
245
+
246
+ @model_validator(mode="after")
247
+ def validate_response_category(self) -> "ReferenceEntry":
248
+ """Validate that response_category has the correct default value."""
249
+ if self.response_category != ResponseCategory.REFERENCE_ENTRY:
250
+ raise ValueError(
251
+ f"ReferenceEntry response_category must be "
252
+ f"{ResponseCategory.REFERENCE_ENTRY}, got `{self.response_category}`."
253
+ )
254
+ return self
255
+
256
+ def to_sse_event(self) -> ServerSentEvent:
257
+ """Convert to SSE event format."""
258
+ return ServerSentEvent(
259
+ event="copilot_response",
260
+ data={
261
+ "index": self.index,
262
+ "title": self.title,
263
+ "url": self.url,
264
+ "response_category": self.response_category.value,
265
+ "completeness": self.response_completeness.value,
266
+ },
267
+ )
268
+
269
+
270
+ class ReferenceSection(CopilotOutput):
271
+ """Represents a reference section with documentation links."""
272
+
273
+ references: list[ReferenceEntry]
274
+ response_category: ResponseCategory = Field(
275
+ default=ResponseCategory.REFERENCE,
276
+ frozen=True,
277
+ )
278
+ response_completeness: ResponseCompleteness = ResponseCompleteness.COMPLETE
279
+
280
+ @model_validator(mode="after")
281
+ def validate_response_category(self) -> "ReferenceSection":
282
+ """Validate that response_category has the correct default value."""
283
+ if self.response_category != ResponseCategory.REFERENCE:
284
+ raise ValueError(
285
+ f"ReferenceSection response_category must be "
286
+ f"{ResponseCategory.REFERENCE}, got `{self.response_category}`."
287
+ )
288
+ return self
289
+
290
+ def to_sse_event(self) -> ServerSentEvent:
291
+ """Convert to SSE event format."""
292
+ return ServerSentEvent(
293
+ event="copilot_response",
294
+ data={
295
+ "references": [
296
+ reference.model_dump(include={"index", "title", "url"})
297
+ for reference in self.references
298
+ ],
299
+ "response_category": self.response_category.value,
300
+ "completeness": self.response_completeness.value,
301
+ },
302
+ )
303
+
304
+
305
+ class CopilotContext(BaseModel):
306
+ """Model containing the context used by the copilot to generate a response."""
307
+
308
+ assistant_logs: str = Field("")
309
+ assistant_files: Dict[str, str] = Field({})
310
+ copilot_chat_history: List["CopilotChatMessage"] = Field([])
311
+ tracker_context: Optional[TrackerContext] = Field(None)
312
+
313
+ class Config:
314
+ """Config for LLMBuilderContext."""
315
+
316
+ arbitrary_types_allowed = True
317
+
318
+
319
+ class UsageStatistics(BaseModel):
320
+ prompt_tokens: Optional[int] = None
321
+ completion_tokens: Optional[int] = None
322
+ total_tokens: Optional[int] = None
323
+ model: Optional[str] = None
324
+
325
+ def reset(self) -> None:
326
+ """Reset usage statistics to their default values."""
327
+ self.prompt_tokens = None
328
+ self.completion_tokens = None
329
+ self.total_tokens = None
330
+ self.model = None
331
+
332
+ def update_from_stream_chunk(self, chunk: ChatCompletionChunk) -> None:
333
+ """Update usage statistics from an OpenAI stream chunk.
334
+
335
+ Args:
336
+ chunk: The OpenAI stream chunk containing usage statistics.
337
+ """
338
+ if not (usage := getattr(chunk, "usage", None)):
339
+ return
340
+
341
+ self.prompt_tokens = usage.prompt_tokens
342
+ self.completion_tokens = usage.completion_tokens
343
+ self.total_tokens = usage.total_tokens
344
+ self.model = getattr(chunk, "model", None)