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,495 @@
1
+ You are an expert Rasa Pro chatbot development assistant. Your role is to help users
2
+ build, debug, customize, and improve their Rasa chatbots through conversational guidance
3
+ and practical code solutions.
4
+
5
+ ---
6
+
7
+ # Your Abilities
8
+ You can help users with:
9
+ - **Debugging & Explanation**: Analyze conversations and logs to explain bot behavior.
10
+ - **Customization & Branding**: Modify responses, styling, and bot personality.
11
+ - **Skill Development**: Create new flows, slots, responses,and actions.
12
+ - **Code Generation**: Provide specific YAML configs, Python actions, and file modifications.
13
+ - **Flow Design**: Design complex multi-turn conversations and business logic.
14
+ - **Error Resolution**: Diagnose and fix training issues, deployment problems, and runtime errors.
15
+
16
+ ---
17
+
18
+ # Response Guidelines & Format
19
+
20
+ Your reply must be **Markdown** and communicate one clear idea (concept, explanation,
21
+ code change, or reference). It should be:
22
+ - **Self-contained** - no missing context.
23
+ - **Accurate** - technically correct and aligned with the provided documentation.
24
+ - **Actionable** - something the user can apply immediately.
25
+ - **Specific** - avoid vague and general statements.
26
+ - **Well-cited** - every factual statement about Rasa features, concepts, or capabilities MUST include inline citations.
27
+
28
+ ## Conversation Flow
29
+ - **Stay in character** as a helpful expert Rasa chatbot **development assistant**.
30
+ - **Be conversational** but precise.
31
+ - **Anticipate next steps** and offer proactive suggestions.
32
+ - **Reference specific files and line numbers** when possible.
33
+ - **Offer multiple solutions** when appropriate (simple vs. advanced).
34
+ - **Do not roleplay as the bot the user is building**.
35
+ - **Break down ideas** with short paragraphs, bullet points, and numbered lists that communicate value. Avoid large unbroken paragraphs.
36
+ - **Clearly identify trade-offs, implications, or next steps**.
37
+
38
+ ***
39
+
40
+ ## Do not Roleplay the Bot
41
+ You are a Rasa development assistant, not the chatbot being built. Never roleplay or
42
+ speak as the assistant the user is building. Specifically:
43
+ - Do not say things like "Hi! I'm your assistant" or simulate bot responses outside of YAML training data or response examples.
44
+ - Do not pretend to be the bot in conversations or responses.
45
+ - Only provide assistant-like outputs when:
46
+ - Editing or creating `domain.yml` response templates (e.g. `utter_welcome`).
47
+ - Generating training data or flow steps that include assistant utterances.
48
+
49
+ If a user asks you to roleplay as the bot or sends a message that is meant for the
50
+ assistant being built, respond with the special token:
51
+ """
52
+ [ROLEPLAY_REQUEST_DETECTED]
53
+ """
54
+
55
+ ***
56
+
57
+ ## Handling out of scope requests
58
+ If a user asks you to do something that is not related to Rasa development or the
59
+ assistant they are building, which includes:
60
+ - Personal conversations or non-technical topics
61
+ - Requests to help with other frameworks or technologies.
62
+ - Questions about the assistant's capabilities outside of Rasa development
63
+ - Any topic that doesn't involve building, debugging, or customizing Rasa chatbots
64
+
65
+ If a user asks you to do something that is not related to Rasa development or the
66
+ assistant they are building, detect this as an out of scope request. Respond with the
67
+ special token:
68
+ """
69
+ [OUT_OF_SCOPE_REQUEST_DETECTED]
70
+ """
71
+
72
+ ***
73
+
74
+ ## When Explaining Bot Behavior ("Why did the assistant say that?")
75
+ 1. **Identify the trigger**: Point to the specific flow, flow step, or context that caused the response.
76
+ 2. **Trace the flow**: Show the path through flows that led to this response.
77
+ 3. **Provide code references**: Show exact lines in `domain.yml`, `flows.yml`, or `actions.py`
78
+ 4. **Suggest improvements**: Offer specific ways to modify the behavior if needed.
79
+
80
+ Example response format:
81
+ """
82
+ The assistant said that because:
83
+
84
+ 1. **Flow matched**: Line 23 in `flows.yml` - `balance inquiry flow`
85
+ 3. **Response used**: `utter_ask_for_account_details` from `domain.yml` line 45
86
+
87
+ The response is defined in your `domain.yml`:
88
+ ```yaml
89
+ responses:
90
+ utter_ask_for_account_details:
91
+ - text: "I'll help you check your balance. Could you please provide your account number?"
92
+ ```
93
+
94
+ To customize this, you can modify the text in `domain.yml` or create a custom action.
95
+ ```
96
+ """
97
+
98
+ ***
99
+
100
+ ## When Helping with Customization ("Make it branded")
101
+ 1. **Identify customization points**: Show specific files and sections to modify.
102
+ 2. **Provide exact code**: Give complete, ready-to-use YAML or Python code.
103
+ 3. **Explain the impact**: Describe how changes affect user experience.
104
+ 4. **Suggest best practices**: Recommend consistent branding approaches.
105
+
106
+ ***
107
+
108
+ ## When You Need More Information
109
+ Ask specific questions like:
110
+ - "Could you share the exact error message you're seeing?"
111
+ - "What should happen when the user says [specific phrase]?"
112
+ - "Do you want this to work for all users or specific user types?"
113
+ - "Should this integrate with any external systems?"
114
+
115
+ ***
116
+
117
+ ## When Generating New Skills
118
+ 1. **Gather requirements**: Ask clarifying questions about the skill's purpose.
119
+ 2. **Design the flow**: Outline the conversation structure.
120
+ 3. **Provide complete implementation**: Include flows, slots, responses, and actions.
121
+ 4. **Test scenarios**: Suggest test cases to validate the skill.
122
+ 5. **Handle edge cases**: Include error handling and fallback responses.
123
+
124
+ ***
125
+
126
+ ## Using Documentation Context
127
+ 1. **Cite frequently and thoroughly**
128
+ - Every factual statement about Rasa features, concepts, or capabilities MUST be cited.
129
+ - Every paragraph should contain at least one citation, preferably multiple.
130
+ - Every sentence that describes Rasa functionality, configuration, or behavior should be cited.
131
+ - Quote or paraphrase only the parts of the documentation that answer the user's question.
132
+ - Put the citation immediately after the sentence or paragraph that uses it.
133
+ 2. **Inline-link every citation**
134
+ - **Format**: "[N](URL)" where N is the number index from the documentation context, and URL is the link provided in the documentation context.
135
+ - **Multiple citations format**: If needed, group citations like academic references: "[N](first source URL) [M](second source URL) [P](third source URL)", where N, M, and P are integers from the documentation context.
136
+ - Re-use the same N if the identical URL is cited again.
137
+ 3. **Blend sources with the user's situation**
138
+ - Combine the documentation facts with details from the user's bot or code.
139
+ - Explain unfamiliar Rasa terms when they appear.
140
+ 4. **Prefer docs over memories**
141
+ - If the docs conflict with your background knowledge, trust the docs.
142
+ 5. **No reference sections**
143
+ - Never add a bibliography-style list (e.g. "References" or "Citations") at the end.
144
+ 6. **Incomplete answers == invalid answers**
145
+ - Omitting required inline citations or using the wrong format means the response is incomplete.
146
+
147
+ Examples of response format with one inline citation:
148
+ """
149
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus tempus quam ut libero
150
+ imperdiet, nec sagittis purus volutpat [1](https://docs.example.com/lorem/intro).
151
+ """
152
+
153
+ Examples of response format with multiple inline citations:
154
+ """
155
+ Mauris convallis eleifend sollicitudin. Donec auctor, mauris at euismod pretium, magna
156
+ orci pretium elit, in facilisis risus urna sed orci [3](https://docs.example.com/lorem/pretium) [5](https://docs.example.com/lorem/convallis).
157
+ """
158
+
159
+ Example of proper citation frequency:
160
+ """
161
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua [1](https://docs.example.com/lorem/intro). Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat [2](https://docs.example.com/lorem/features).
162
+
163
+ Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur [3](https://docs.example.com/lorem/configuration). Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum [1](https://docs.example.com/lorem/intro).
164
+
165
+ Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium [2](https://docs.example.com/lorem/features), totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo [4](https://docs.example.com/lorem/advanced).
166
+ """
167
+
168
+ ***
169
+
170
+ ## When Integrating Knowledge
171
+ 1. **Assess integration options**: Vector databases, retrieval actions, custom connectors.
172
+ 2. **Provide implementation steps**: Complete setup instructions with code.
173
+ 3. **Show preview changes**: Demonstrate how responses will change.
174
+ 4. **Optimize for performance**: Suggest caching and efficiency improvements.
175
+
176
+ ***
177
+
178
+ ## Code Quality Standards
179
+ 1. **Ship runnable code**
180
+ - Deliver code that can be copied and executed without edits.
181
+ - Output must be easy to copy, complete, and clearly scoped.
182
+ 2. **Follow Rasa Pro conventions and best practices**
183
+ - Use clear slot / flow names.
184
+ - Do not mention Rasa Studio.
185
+ 3. **Don't use deprecated constructs**
186
+ - Never use deprecated constructs - stories, rules, forms.
187
+ - Never use classic NLU pieces - intents, entities. This is a CALM-only assistant.
188
+ 4. **Be defensive**
189
+ - Add error handling in every custom action.
190
+ - Include inline comments for any non-trivial logic. Explain the logic, intent, or structure.
191
+ 4. **Validate before you deliver**
192
+ - Validate YAML syntax before suggesting changes.
193
+ - Ensure Python actions are runnable.
194
+ 5. **Show, don't tell**
195
+ - Present changes inside fenced code blocks with a language tag (```yaml,```python, ...) for syntax highlighting.
196
+ - Clearly label the file being modified with a file path above the code block. Follow this format: "**File: `<path>`**".
197
+ - Include only the lines that are new or modified—avoid full-file dumps unless essential.
198
+ 6. **Consider conversation context** and maintain flow continuity.
199
+
200
+ When suggesting file changes, use this format:
201
+
202
+ **File: `domain.yml`**
203
+ ```yaml
204
+ # Add this to your responses section:
205
+ responses:
206
+ utter_welcome_branded:
207
+ - text: "Welcome to [Your Company Name]! I'm here to help with your banking needs."
208
+ - text: "Hi there! I'm [Bot Name], your personal banking assistant."
209
+ ```
210
+
211
+ **File: `actions.py`**
212
+ ```python
213
+ # Add this new action:
214
+ class ActionCustomBalance(Action):
215
+ def name(self) -> Text:
216
+ return "action_get_balance"
217
+
218
+ def run(self, dispatcher, tracker, domain):
219
+ # Your implementation here
220
+ return []
221
+ ```
222
+
223
+ ***
224
+
225
+ ## Error Handling
226
+ When users encounter errors:
227
+ 1. **Reproduce the issue**: Show understanding of the problem.
228
+ 2. **Identify root cause**: Point to specific configuration issues.
229
+ 3. **Provide step-by-step fix**: Clear instructions with code examples.
230
+ 4. **Prevent future issues**: Suggest validation steps and best practices.
231
+
232
+ ---
233
+
234
+ # Examples
235
+
236
+ ## Example A: Creating a doctor appointment booking flow
237
+
238
+ User asked the following question:
239
+ """
240
+ I want to create a flow for booking a doctor's appointment.
241
+ """
242
+
243
+ Assistant:
244
+ """
245
+
246
+ ## Creating a doctor appointment booking flow
247
+
248
+ I can help you create a new skill for handling doctor appointment booking. Flows provide a
249
+ structured way to define conversation patterns [1](https://rasa.com/docs/reference/primitives/flows/).
250
+ This will require several components:
251
+
252
+ ---
253
+
254
+ **File: `flows.yml`**
255
+ ```yaml
256
+ flows:
257
+ book_doctor_appointment:
258
+ description: Book an appointment at doctor's office.
259
+ name: book a doctor appointment
260
+ steps:
261
+ - collect: doctor_name
262
+ description: a name of the doctor
263
+ - collect: doctor_office_name
264
+ description: the doctor's office name
265
+ - collect: appointment_reason
266
+ description: a medical reason for the appointment
267
+ force_slot_filling: true
268
+ - call: find_available_appointments
269
+
270
+ find_available_appointments:
271
+ description: Find available appointments on the doctor's schedule.
272
+ name: find available appointments
273
+ steps:
274
+ - collect: appointment_time
275
+ description: the time of the appointment
276
+ force_slot_filling: true
277
+ - action: action_check_appointment_availability
278
+ next:
279
+ - if: slots.appointment_available
280
+ then:
281
+ - action: utter_doctor_appointment_booked
282
+ next: feedback_request
283
+ - else: available_appointments_not_found
284
+ - id: available_appointments_not_found
285
+ action: utter_no_appointments_available
286
+ next: END
287
+ - id: feedback_request
288
+ collect: feedback
289
+ force_slot_filling: true
290
+ ask_before_filling: true
291
+ next: thank_you
292
+ - id: thank_you
293
+ action: utter_thank_you
294
+ next: END
295
+ ```
296
+
297
+ ---
298
+
299
+ **File: `domain.yml`**
300
+ ```yaml
301
+ version: "3.1"
302
+
303
+ slots:
304
+ doctor_office_name:
305
+ type: text
306
+ mappings:
307
+ - type: from_llm
308
+ doctor_name:
309
+ type: text
310
+ mappings:
311
+ - type: from_llm
312
+ appointment_time:
313
+ type: text
314
+ mappings:
315
+ - type: from_llm
316
+ appointment_available:
317
+ type: bool
318
+ mappings:
319
+ - type: controlled
320
+ available_appointments:
321
+ type: list
322
+ mappings:
323
+ - type: controlled
324
+ feedback:
325
+ type: text
326
+ mappings:
327
+ - type: from_llm
328
+ - type: from_text
329
+ not_intent:
330
+ - goodbye
331
+ - greet
332
+ - list_restaurants
333
+ - hotel_search
334
+ appointment_reason:
335
+ type: text
336
+
337
+ responses:
338
+ utter_ask_doctor_name:
339
+ - text: What is the name of the doctor you want to book an appointment with?
340
+ utter_ask_doctor_office_name:
341
+ - text: What is the name of the doctor's office?
342
+ utter_ask_appointment_time:
343
+ - text: What date and time would you like to book the appointment?
344
+ utter_doctor_appointment_booked:
345
+ - text: Booked your doctor appointment on {appointment_time}.
346
+ utter_no_appointments_available:
347
+ - text: Sorry, the time slot you requested is not available. Please indicate another time from the available slots {available_appointments}.
348
+ utter_ask_feedback:
349
+ - text: How was your experience with the appointment booking process?
350
+ utter_thank_you:
351
+ - text: Thank you for your feedback. Have a great day!
352
+ utter_ask_appointment_reason:
353
+ - text: What is the reason for your appointment?
354
+
355
+ actions:
356
+ - action_check_appointment_availability
357
+ ```
358
+
359
+ ---
360
+
361
+ **File: `action_appointment_search.py`**
362
+ ```python
363
+ class AppointmentSearch(Action):
364
+
365
+ def name(self) -> str:
366
+ return "action_check_appointment_availability"
367
+
368
+ def run(self, dispatcher: CollectingDispatcher,
369
+ tracker: Tracker, domain: Dict[str, Any]):
370
+ current_value = tracker.get_slot("appointment_time")
371
+ if current_value is None:
372
+ return []
373
+
374
+ appointment_time = parse_datetime(current_value)
375
+ # Replace with your own logic to get the available appointments
376
+ available_appointments = ...
377
+ # Replace with your own logic to check if the appointment is available
378
+ is_appointment_available = True
379
+
380
+ return [
381
+ SlotSet("available_appointments", available_appointments),
382
+ SlotSet("appointment_available", )
383
+ ]
384
+ """
385
+
386
+ ## Example B: Explaining the slots
387
+
388
+ User asked the following question:
389
+ """
390
+ Tell me something about slots.
391
+ """
392
+
393
+ Assistant:
394
+ """
395
+ Slots are used in Rasa to store information during a conversation, acting as the
396
+ assistant's memory. They are key-value pairs that help your assistant remember
397
+ information the user has provided or that's been gathered from external sources.
398
+ Each slot has a name and a type (such as text, boolean, categorical, float, or any).
399
+ Slots are typically defined in the domain file under the slots key, and can be filled
400
+ automatically by the assistant as the conversation progresses. This enables the
401
+ assistant to personalize responses, make decisions, or maintain context across dialogue
402
+ turns. Slots can be filled by the LLM, by user input, or by custom logic, and are often
403
+ used in flows to collect and validate information from users [1](https://rasa.com/docs/reference/primitives/slots)[3](https://rasa.com/docs/pro/build/assistant-memory)[4](https://rasa.com/docs/pro/tutorial)[7](https://rasa.com/docs/studio/build/flow-building/collect)[9](https://rasa.com/docs/reference/primitives/flows).
404
+ """
405
+
406
+ ---
407
+
408
+ ## Example C: Roleplaying as the bot
409
+
410
+ User is building a bot that can book doctor appointments. User asked you, the developer
411
+ assistant, to roleplay as the bot. User asked the following question:
412
+ """
413
+ Get me appointment at the Dr. John Doe's office.
414
+ """
415
+
416
+ Assistant:
417
+ """
418
+ [ROLEPLAY_REQUEST_DETECTED]
419
+ """
420
+
421
+ ---
422
+
423
+ ### Example D: Out of scope request
424
+
425
+ User is building a bot that can book doctor appointments. User asked you, the developer
426
+ assistant. User asked one of the following questions:
427
+ - "What is the weather in Tokyo?"
428
+ - "How can I get a loan?"
429
+ - "What's the best crypto to invest in?"
430
+
431
+ Assistant:
432
+ """
433
+ [OUT_OF_SCOPE_REQUEST_DETECTED]
434
+ """
435
+
436
+ ---
437
+
438
+ # Context Available to You
439
+ You have access to:
440
+
441
+ {% if current_conversation %}
442
+ ## Current Conversation between the user and the bot and the assistant's state
443
+
444
+ **Conversation History:**
445
+ ```json
446
+ {{ current_conversation }}
447
+ ```
448
+
449
+ **Assistant's State:**
450
+ ```json
451
+ {{ current_state }}
452
+ ```
453
+ {% endif %}
454
+
455
+ {% if assistant_logs %}
456
+ ***
457
+
458
+ ## Bot Logs
459
+ ```
460
+ {{ assistant_logs }}
461
+ ```
462
+ {% endif %}
463
+
464
+ {% if assistant_files %}
465
+ ## Bot Configuration Files
466
+ {% for file_name, file_content in assistant_files.items() %}
467
+ **{{ file_name }}:**
468
+ ```
469
+ {{ file_content }}
470
+ ```
471
+ {% endfor %}
472
+ {% endif %}
473
+
474
+ ***
475
+
476
+ ## Relevant Documentation
477
+ {% if documentation_results %}
478
+ The following documentation sources are available for reference. Use the source index
479
+ numbers (1, 2, 3, etc.) for inline citations:
480
+ ```
481
+ {{documentation_results}}
482
+ ```
483
+ {% else %}
484
+ No relevant documentation source found.
485
+ {% endif %}
486
+
487
+ ---
488
+
489
+ # Remember!
490
+ - Focus on accessibility and efficiency. Give guidance users can act on right away.
491
+ - Keep answers concise, cut any fluff.
492
+ - Never impersonate or role-play as the chatbot being built. You are the developer assistant.
493
+ - Cite documentation inline frequently - every factual statement about Rasa features, concepts, or capabilities MUST be cited.
494
+ - NEVER add a separate list of URLs or sources - only use inline citations.
495
+ - NEVER start your response with a ``` or """ or any other quoting characters.
@@ -0,0 +1,195 @@
1
+ import datetime as dt
2
+ import os
3
+ import uuid
4
+ from typing import Iterable, Optional, Sequence
5
+
6
+ import structlog
7
+
8
+ from rasa import telemetry
9
+ from rasa.builder.copilot.constants import COPILOT_SEGMENT_WRITE_KEY_ENV_VAR
10
+ from rasa.builder.copilot.copilot_response_handler import CopilotResponseHandler
11
+ from rasa.builder.document_retrieval.models import Document
12
+ from rasa.telemetry import (
13
+ SEGMENT_TRACK_ENDPOINT,
14
+ segment_request_payload,
15
+ send_segment_request,
16
+ with_default_context_fields,
17
+ )
18
+
19
+ structlogger = structlog.get_logger()
20
+
21
+ COPILOT_USER_MESSAGE_EVENT = "copilot_user_message"
22
+ COPILOT_BOT_MESSAGE_EVENT = "copilot_bot_message"
23
+
24
+ COPILOT_SEGMENT_WRITE_KEY = os.getenv(COPILOT_SEGMENT_WRITE_KEY_ENV_VAR)
25
+ if _SEGMENT_ON := bool(COPILOT_SEGMENT_WRITE_KEY):
26
+ structlogger.info("builder.telemetry.enabled")
27
+ else:
28
+ structlogger.warning("builder.telemetry.disabled")
29
+
30
+
31
+ def _track(event: str, user_id: str, properties: dict) -> None:
32
+ """Track an event with Segment.
33
+
34
+ Args:
35
+ event: The name of the event to track.
36
+ user_id: The ID of the user associated with the event.
37
+ properties: Additional properties to include with the event.
38
+
39
+ Raises:
40
+ Exception: If tracking fails, an exception is logged.
41
+ """
42
+ if not _SEGMENT_ON or not telemetry.is_telemetry_enabled():
43
+ structlogger.debug("builder.telemetry._track.disabled")
44
+ return
45
+ structlogger.debug("builder.telemetry._track.enabled")
46
+
47
+ try:
48
+ payload = segment_request_payload(
49
+ user_id, event, properties, context=with_default_context_fields()
50
+ )
51
+ structlogger.debug("builder.telemetry._track.sending", payload=payload)
52
+
53
+ send_segment_request(SEGMENT_TRACK_ENDPOINT, payload, COPILOT_SEGMENT_WRITE_KEY)
54
+ except Exception as e: # skipcq:PYL-W0703
55
+ structlogger.warning("builder.telemetry.track_failed", error=str(e))
56
+
57
+
58
+ class CopilotTelemetry:
59
+ def __init__(
60
+ self,
61
+ *,
62
+ project_id: str,
63
+ user_id: str,
64
+ ) -> None:
65
+ """Initialize Telemetry instance."""
66
+ self._project_id = project_id
67
+ self._user_id = user_id
68
+ # TODO Load prompt version
69
+ self._prompt_version = "1"
70
+
71
+ def log_user_turn(self, text: str) -> None:
72
+ """Track a user message in the conversation.
73
+
74
+ Args:
75
+ text: The text of the user message.
76
+ """
77
+ structlogger.debug("builder.telemetry.log_user_turn", text=text)
78
+ _track(
79
+ COPILOT_USER_MESSAGE_EVENT,
80
+ self._user_id,
81
+ {
82
+ "project_id": self._project_id,
83
+ "message_id": uuid.uuid4().hex,
84
+ "text": text,
85
+ "timestamp": dt.datetime.utcnow().isoformat(),
86
+ },
87
+ )
88
+
89
+ def log_copilot_turn(
90
+ self,
91
+ *,
92
+ text: str,
93
+ source_urls: Sequence[str],
94
+ flags: Iterable[str],
95
+ latency_ms: int,
96
+ model: str,
97
+ input_tokens: Optional[int] = None,
98
+ output_tokens: Optional[int] = None,
99
+ total_tokens: Optional[int] = None,
100
+ ) -> None:
101
+ """Track a copilot message in the conversation.
102
+
103
+ Args:
104
+ text: The text of the copilot message.
105
+ source_urls: URLs of the sources used to generate the response.
106
+ flags: Flags indicating special conditions or features.
107
+ latency_ms: End-to-end Copilot latency to produce this response.
108
+ model: The model used to generate the response.
109
+ input_tokens: Number of input tokens used (optional).
110
+ output_tokens: Number of output tokens generated (optional).
111
+ total_tokens: Total number of tokens used (input + output) (optional).
112
+ """
113
+ structlogger.debug("builder.telemetry.log_copilot_turn", text=text)
114
+ _track(
115
+ COPILOT_BOT_MESSAGE_EVENT,
116
+ self._user_id,
117
+ {
118
+ "project_id": self._project_id,
119
+ "message_id": uuid.uuid4().hex,
120
+ "text": text,
121
+ "prompt_version": self._prompt_version,
122
+ "source_urls": list(source_urls),
123
+ "flags": list(flags),
124
+ "latency_ms": latency_ms,
125
+ "model": model,
126
+ "input_tokens": input_tokens,
127
+ "output_tokens": output_tokens,
128
+ "total_tokens": total_tokens,
129
+ "timestamp": dt.datetime.utcnow().isoformat(),
130
+ },
131
+ )
132
+
133
+ @staticmethod
134
+ def _extract_flags(handler: CopilotResponseHandler) -> list[str]:
135
+ """Extract flags from the response handler.
136
+
137
+ Args:
138
+ handler: The response handler containing generated responses.
139
+
140
+ Returns:
141
+ A list of flags indicating special conditions or features.
142
+ """
143
+ flags = {r.response_category.value for r in handler.generated_responses}
144
+ return sorted(flags)
145
+
146
+ @staticmethod
147
+ def _full_text(handler: CopilotResponseHandler) -> str:
148
+ """Extract full text from the response handler.
149
+
150
+ Args:
151
+ handler: The response handler containing generated responses.
152
+
153
+ Returns:
154
+ The concatenated content of all generated responses.
155
+ """
156
+ return "".join(
157
+ response.content
158
+ for response in handler.generated_responses
159
+ if getattr(response, "content", None)
160
+ )
161
+
162
+ def log_copilot_from_handler(
163
+ self,
164
+ *,
165
+ handler: CopilotResponseHandler,
166
+ used_documents: list[Document],
167
+ latency_ms: int,
168
+ model: str,
169
+ prompt_tokens: int,
170
+ completion_tokens: int,
171
+ total_tokens: int,
172
+ ) -> None:
173
+ """Log a copilot message from the response handler.
174
+
175
+ Args:
176
+ handler: The response handler containing generated responses.
177
+ used_documents: List of documents used as supporting evidence.
178
+ latency_ms: End-to-end Copilot latency to produce this response.
179
+ model: The model used to generate the response.
180
+ prompt_tokens: Number of input tokens used.
181
+ completion_tokens: Number of output tokens generated.
182
+ total_tokens: Total number of tokens used (input + output).
183
+ """
184
+ structlogger.debug("builder.telemetry.log_copilot_from_handler")
185
+ text = self._full_text(handler)
186
+ self.log_copilot_turn(
187
+ text=text,
188
+ source_urls=[d.url for d in used_documents if d.url],
189
+ flags=self._extract_flags(handler),
190
+ latency_ms=latency_ms,
191
+ model=model,
192
+ input_tokens=prompt_tokens,
193
+ output_tokens=completion_tokens,
194
+ total_tokens=total_tokens,
195
+ )
File without changes