rasa-pro 3.13.1a18__py3-none-any.whl → 3.13.1.dev1__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 (266) hide show
  1. rasa/__init__.py +6 -0
  2. rasa/cli/scaffold.py +3 -22
  3. rasa/core/actions/action.py +3 -5
  4. rasa/core/channels/studio_chat.py +10 -34
  5. rasa/core/policies/enterprise_search_policy.py +8 -7
  6. rasa/core/policies/flows/flow_executor.py +1 -8
  7. rasa/dialogue_understanding/generator/flow_retrieval.py +9 -10
  8. rasa/dialogue_understanding/generator/llm_based_command_generator.py +15 -4
  9. rasa/dialogue_understanding/generator/llm_command_generator.py +3 -1
  10. rasa/dialogue_understanding/generator/multi_step/multi_step_llm_command_generator.py +48 -3
  11. rasa/dialogue_understanding/generator/single_step/single_step_based_llm_command_generator.py +15 -1
  12. rasa/hooks.py +55 -0
  13. rasa/llm_fine_tuning/utils.py +4 -2
  14. rasa/model_manager/model_api.py +3 -2
  15. rasa/model_manager/runner_service.py +1 -1
  16. rasa/model_manager/trainer_service.py +9 -12
  17. rasa/model_manager/utils.py +29 -1
  18. rasa/monkey_patches.py +91 -0
  19. rasa/shared/constants.py +6 -0
  20. rasa/shared/core/domain.py +15 -62
  21. rasa/shared/core/flows/flow_step.py +1 -7
  22. rasa/shared/core/flows/yaml_flows_io.py +8 -16
  23. rasa/shared/core/slots.py +0 -4
  24. rasa/shared/importers/importer.py +0 -6
  25. rasa/shared/importers/utils.py +1 -77
  26. rasa/shared/providers/constants.py +10 -0
  27. rasa/shared/providers/llm/_base_litellm_client.py +14 -4
  28. rasa/shared/providers/llm/litellm_router_llm_client.py +23 -12
  29. rasa/shared/providers/llm/llm_client.py +19 -15
  30. rasa/shared/providers/llm/self_hosted_llm_client.py +23 -18
  31. rasa/studio/upload.py +45 -10
  32. rasa/telemetry.py +1 -2
  33. rasa/tracing/instrumentation/attribute_extractors.py +1 -0
  34. rasa/utils/io.py +9 -27
  35. rasa/utils/json_utils.py +1 -6
  36. rasa/utils/log_utils.py +1 -5
  37. rasa/utils/plotting.py +1 -1
  38. rasa/validator.py +3 -7
  39. rasa/version.py +1 -1
  40. {rasa_pro-3.13.1a18.dist-info → rasa_pro-3.13.1.dev1.dist-info}/METADATA +9 -9
  41. {rasa_pro-3.13.1a18.dist-info → rasa_pro-3.13.1.dev1.dist-info}/RECORD +44 -265
  42. rasa/builder/README.md +0 -120
  43. rasa/builder/__init__.py +0 -0
  44. rasa/builder/config.py +0 -79
  45. rasa/builder/create_openai_vector_store.py +0 -228
  46. rasa/builder/exceptions.py +0 -55
  47. rasa/builder/inkeep-rag-response-schema.json +0 -64
  48. rasa/builder/inkeep_document_retrieval.py +0 -212
  49. rasa/builder/llm-helper-schema.json +0 -69
  50. rasa/builder/llm_context.py +0 -81
  51. rasa/builder/llm_helper_prompt.jinja2 +0 -245
  52. rasa/builder/llm_service.py +0 -317
  53. rasa/builder/logging_utils.py +0 -51
  54. rasa/builder/main.py +0 -147
  55. rasa/builder/models.py +0 -225
  56. rasa/builder/project_generator.py +0 -282
  57. rasa/builder/scrape_rasa_docs.py +0 -97
  58. rasa/builder/service.py +0 -742
  59. rasa/builder/skill_to_bot_prompt.jinja2 +0 -164
  60. rasa/builder/training_service.py +0 -132
  61. rasa/builder/validation_service.py +0 -93
  62. rasa/cli/project_templates/finance/actions/__init__.py +0 -0
  63. rasa/cli/project_templates/finance/actions/action_add_payee.py +0 -47
  64. rasa/cli/project_templates/finance/actions/action_ask_account.py +0 -50
  65. rasa/cli/project_templates/finance/actions/action_ask_account_from.py +0 -50
  66. rasa/cli/project_templates/finance/actions/action_ask_card.py +0 -47
  67. rasa/cli/project_templates/finance/actions/action_check_balance.py +0 -40
  68. rasa/cli/project_templates/finance/actions/action_check_card_existence.py +0 -35
  69. rasa/cli/project_templates/finance/actions/action_check_payee_existence.py +0 -40
  70. rasa/cli/project_templates/finance/actions/action_check_sufficient_funds.py +0 -41
  71. rasa/cli/project_templates/finance/actions/action_list_payees.py +0 -45
  72. rasa/cli/project_templates/finance/actions/action_process_immediate_payment.py +0 -18
  73. rasa/cli/project_templates/finance/actions/action_remove_payee.py +0 -49
  74. rasa/cli/project_templates/finance/actions/action_schedule_payment.py +0 -19
  75. rasa/cli/project_templates/finance/actions/action_session_start.py +0 -69
  76. rasa/cli/project_templates/finance/actions/action_update_card_status.py +0 -45
  77. rasa/cli/project_templates/finance/actions/action_validate_payment_date.py +0 -36
  78. rasa/cli/project_templates/finance/actions/database.py +0 -276
  79. rasa/cli/project_templates/finance/config.yml +0 -32
  80. rasa/cli/project_templates/finance/credentials.yml +0 -33
  81. rasa/cli/project_templates/finance/csvs/accounts.csv +0 -8
  82. rasa/cli/project_templates/finance/csvs/advisors.csv +0 -7
  83. rasa/cli/project_templates/finance/csvs/appointments.csv +0 -211
  84. rasa/cli/project_templates/finance/csvs/branches.csv +0 -10
  85. rasa/cli/project_templates/finance/csvs/cards.csv +0 -11
  86. rasa/cli/project_templates/finance/csvs/payees.csv +0 -10
  87. rasa/cli/project_templates/finance/csvs/transactions.csv +0 -71
  88. rasa/cli/project_templates/finance/csvs/users.csv +0 -4
  89. rasa/cli/project_templates/finance/data/flows/add_payee.yml +0 -29
  90. rasa/cli/project_templates/finance/data/flows/block_card.yml +0 -66
  91. rasa/cli/project_templates/finance/data/flows/check_balance.yml +0 -9
  92. rasa/cli/project_templates/finance/data/flows/list_payees.yml +0 -5
  93. rasa/cli/project_templates/finance/data/flows/remove_payee.yml +0 -21
  94. rasa/cli/project_templates/finance/data/flows/select_card.yml +0 -12
  95. rasa/cli/project_templates/finance/data/flows/transfer_money.yml +0 -67
  96. rasa/cli/project_templates/finance/data/flows/welcome.yml +0 -14
  97. rasa/cli/project_templates/finance/data/nlu.yml +0 -29
  98. rasa/cli/project_templates/finance/data/patterns/pattern_chitchat.yml +0 -7
  99. rasa/cli/project_templates/finance/data/patterns/pattern_completed.yml +0 -6
  100. rasa/cli/project_templates/finance/data/patterns/pattern_search.yml +0 -5
  101. rasa/cli/project_templates/finance/data/patterns/pattern_session_start.yml +0 -9
  102. rasa/cli/project_templates/finance/data/source/accounts.json +0 -51
  103. rasa/cli/project_templates/finance/data/source/advisors.json +0 -44
  104. rasa/cli/project_templates/finance/data/source/appointments.json +0 -1474
  105. rasa/cli/project_templates/finance/data/source/branches.json +0 -47
  106. rasa/cli/project_templates/finance/data/source/cards.json +0 -72
  107. rasa/cli/project_templates/finance/data/source/payees.json +0 -74
  108. rasa/cli/project_templates/finance/data/source/transactions.json +0 -492
  109. rasa/cli/project_templates/finance/data/source/users.json +0 -29
  110. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/consequences_of_blocking_card.txt +0 -8
  111. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/reasons_to_block_card.txt +0 -8
  112. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/recovering_from_card_fraud.txt +0 -8
  113. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/tips_for_card_security.txt +0 -8
  114. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/what_to_do_if_card_is_lost.txt +0 -8
  115. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/account_balance_security.txt +0 -7
  116. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/common_balance_inquiries.txt +0 -8
  117. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/methods_to_check_balance.txt +0 -8
  118. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/understanding_balance_updates.txt +0 -8
  119. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/what_to_do_if_balance_is_incorrect.txt +0 -8
  120. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/benefits_of_authorised_payees.txt +0 -8
  121. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/common_issues_with_payees.txt +0 -8
  122. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/general_payee_information.txt +0 -8
  123. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/payee_management_tips.txt +0 -8
  124. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/understanding_payee_types.txt +0 -8
  125. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/common_transfer_errors.txt +0 -8
  126. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/fees_for_transfers.txt +0 -8
  127. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/general_transfer_information.txt +0 -8
  128. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/security_tips_for_transfers.txt +0 -8
  129. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/transfer_processing_times.txt +0 -8
  130. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part1.txt +0 -50
  131. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part10.txt +0 -50
  132. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part11.txt +0 -48
  133. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part12.txt +0 -50
  134. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part13.txt +0 -50
  135. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part14.txt +0 -47
  136. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part15.txt +0 -50
  137. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part16.txt +0 -50
  138. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part17.txt +0 -47
  139. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part18.txt +0 -50
  140. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part19.txt +0 -50
  141. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part2.txt +0 -50
  142. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part20.txt +0 -47
  143. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part21.txt +0 -50
  144. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part22.txt +0 -50
  145. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part23.txt +0 -47
  146. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part24.txt +0 -50
  147. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part25.txt +0 -50
  148. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part26.txt +0 -47
  149. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part27.txt +0 -50
  150. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part28.txt +0 -50
  151. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part29.txt +0 -47
  152. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part3.txt +0 -47
  153. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part30.txt +0 -50
  154. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part31.txt +0 -50
  155. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part32.txt +0 -47
  156. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part33.txt +0 -50
  157. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part34.txt +0 -50
  158. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part35.txt +0 -47
  159. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part36.txt +0 -50
  160. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part37.txt +0 -50
  161. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part38.txt +0 -47
  162. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part39.txt +0 -50
  163. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part4.txt +0 -50
  164. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part40.txt +0 -50
  165. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part41.txt +0 -47
  166. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part42.txt +0 -50
  167. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part43.txt +0 -50
  168. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part44.txt +0 -47
  169. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part45.txt +0 -50
  170. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part46.txt +0 -50
  171. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part47.txt +0 -47
  172. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part48.txt +0 -50
  173. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part49.txt +0 -50
  174. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part5.txt +0 -50
  175. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part50.txt +0 -47
  176. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part51.txt +0 -50
  177. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part52.txt +0 -50
  178. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part53.txt +0 -47
  179. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part54.txt +0 -50
  180. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part55.txt +0 -50
  181. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part56.txt +0 -47
  182. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part57.txt +0 -50
  183. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part58.txt +0 -50
  184. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part59.txt +0 -47
  185. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part6.txt +0 -47
  186. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part60.txt +0 -50
  187. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part61.txt +0 -50
  188. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part7.txt +0 -50
  189. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part8.txt +0 -50
  190. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part9.txt +0 -47
  191. rasa/cli/project_templates/finance/domain/add_payee.yml +0 -47
  192. rasa/cli/project_templates/finance/domain/block_card.yml +0 -101
  193. rasa/cli/project_templates/finance/domain/check_balance.yml +0 -9
  194. rasa/cli/project_templates/finance/domain/default_actions.yml +0 -16
  195. rasa/cli/project_templates/finance/domain/default_flows.yml +0 -33
  196. rasa/cli/project_templates/finance/domain/list_payees.yml +0 -4
  197. rasa/cli/project_templates/finance/domain/remove_payee.yml +0 -16
  198. rasa/cli/project_templates/finance/domain/select_card.yml +0 -12
  199. rasa/cli/project_templates/finance/domain/transfer_money.yml +0 -79
  200. rasa/cli/project_templates/finance/endpoints.yml +0 -62
  201. rasa/cli/project_templates/finance/prompts/command-generator.jinja2 +0 -57
  202. rasa/cli/project_templates/finance/prompts/rephraser_demo_personality_prompt.jinja2 +0 -19
  203. rasa/cli/project_templates/finance/tests/conversation_repair/cancellations.yml +0 -12
  204. rasa/cli/project_templates/finance/tests/conversation_repair/cannot_handle.yml +0 -7
  205. rasa/cli/project_templates/finance/tests/conversation_repair/chitchat.yml +0 -7
  206. rasa/cli/project_templates/finance/tests/conversation_repair/clarification.yml +0 -9
  207. rasa/cli/project_templates/finance/tests/conversation_repair/completion.yml +0 -18
  208. rasa/cli/project_templates/finance/tests/conversation_repair/corrections.yml +0 -17
  209. rasa/cli/project_templates/finance/tests/conversation_repair/digressions.yml +0 -32
  210. rasa/cli/project_templates/finance/tests/conversation_repair/human_handoff.yml +0 -21
  211. rasa/cli/project_templates/finance/tests/conversation_repair/skipping_collect_steps.yml +0 -16
  212. rasa/cli/project_templates/finance/tests/demo_scripts/main.yml +0 -16
  213. rasa/cli/project_templates/finance/tests/happy_paths/balance_verification.yml +0 -15
  214. rasa/cli/project_templates/finance/tests/happy_paths/banking_questions.yml +0 -12
  215. rasa/cli/project_templates/finance/tests/happy_paths/card_blocking.yml +0 -52
  216. rasa/cli/project_templates/finance/tests/happy_paths/money_transfer.yml +0 -136
  217. rasa/cli/project_templates/finance/tests/happy_paths/payee_management.yml +0 -27
  218. rasa/cli/project_templates/finance/tests/happy_paths/user_greeted.yml +0 -5
  219. rasa/cli/project_templates/plain/actions/__init__.py +0 -0
  220. rasa/cli/project_templates/plain/config.yml +0 -17
  221. rasa/cli/project_templates/plain/credentials.yml +0 -33
  222. rasa/cli/project_templates/plain/data/patterns/pattern_session_start.yml +0 -7
  223. rasa/cli/project_templates/plain/domain.yml +0 -5
  224. rasa/cli/project_templates/plain/endpoints.yml +0 -58
  225. rasa/cli/project_templates/telco/actions/__init__.py +0 -0
  226. rasa/cli/project_templates/telco/actions/actions_billing.py +0 -197
  227. rasa/cli/project_templates/telco/actions/actions_get_data_from_db.py +0 -43
  228. rasa/cli/project_templates/telco/actions/actions_run_diagnostics.py +0 -23
  229. rasa/cli/project_templates/telco/actions/actions_session_start.py +0 -13
  230. rasa/cli/project_templates/telco/config.yml +0 -25
  231. rasa/cli/project_templates/telco/credentials.yml +0 -33
  232. rasa/cli/project_templates/telco/csvs/billing.csv +0 -10
  233. rasa/cli/project_templates/telco/csvs/customers.csv +0 -5
  234. rasa/cli/project_templates/telco/data/flows/flow_global.yml +0 -5
  235. rasa/cli/project_templates/telco/data/flows/flow_reboot_router.yml +0 -8
  236. rasa/cli/project_templates/telco/data/flows/flow_reset_router.yml +0 -7
  237. rasa/cli/project_templates/telco/data/flows/flow_solve_internet_issue.yml +0 -73
  238. rasa/cli/project_templates/telco/data/flows/flow_undertand_bill.yml +0 -45
  239. rasa/cli/project_templates/telco/data/patterns/pattern_completed.yml +0 -7
  240. rasa/cli/project_templates/telco/data/patterns/pattern_human_handoff.yml +0 -6
  241. rasa/cli/project_templates/telco/data/patterns/pattern_search.yml +0 -7
  242. rasa/cli/project_templates/telco/data/patterns/pattern_session_start.yml +0 -9
  243. rasa/cli/project_templates/telco/docs/reset_vs_rboot_router.txt +0 -1
  244. rasa/cli/project_templates/telco/docs/restart_router.txt +0 -6
  245. rasa/cli/project_templates/telco/docs/run_speed_test.txt +0 -6
  246. rasa/cli/project_templates/telco/domain/domain_global.yml +0 -29
  247. rasa/cli/project_templates/telco/domain/domain_patterns.yml +0 -17
  248. rasa/cli/project_templates/telco/domain/domain_reboot_router.yml +0 -20
  249. rasa/cli/project_templates/telco/domain/domain_reset_router.yml +0 -11
  250. rasa/cli/project_templates/telco/domain/domain_run_speed_test.yml +0 -24
  251. rasa/cli/project_templates/telco/domain/domain_solve_internet_issue.yml +0 -74
  252. rasa/cli/project_templates/telco/domain/domain_undertand_bill.yml +0 -102
  253. rasa/cli/project_templates/telco/endpoints.yml +0 -60
  254. rasa/cli/project_templates/telco/prompts/command-generator.jinja2 +0 -57
  255. rasa/cli/project_templates/telco/tests/e2e_results_failed.yml +0 -62
  256. rasa/cli/project_templates/telco/tests/e2e_results_passed.yml +0 -130
  257. rasa/cli/project_templates/telco/tests/e2e_test_cases/billing_test_cases.yml +0 -68
  258. rasa/cli/project_templates/telco/tests/e2e_test_cases/global_test_cases.yml +0 -13
  259. rasa/cli/project_templates/telco/tests/e2e_test_cases/internet_slow_test_case.yml +0 -47
  260. rasa/cli/project_templates/telco/tests/e2e_test_cases/out_of_scope_test_case.yml +0 -21
  261. rasa/cli/project_templates/telco/tests/e2e_test_cases/patterns_test_cases.yml +0 -15
  262. rasa/shared/importers/static.py +0 -63
  263. rasa/utils/openapi.py +0 -144
  264. {rasa_pro-3.13.1a18.dist-info → rasa_pro-3.13.1.dev1.dist-info}/NOTICE +0 -0
  265. {rasa_pro-3.13.1a18.dist-info → rasa_pro-3.13.1.dev1.dist-info}/WHEEL +0 -0
  266. {rasa_pro-3.13.1a18.dist-info → rasa_pro-3.13.1.dev1.dist-info}/entry_points.txt +0 -0
rasa/__init__.py CHANGED
@@ -5,5 +5,11 @@ from rasa import version
5
5
  # define the version before the other imports since these need it
6
6
  __version__ = version.__version__
7
7
 
8
+ from litellm.integrations.langfuse.langfuse import LangFuseLogger
9
+
10
+ from rasa.monkey_patches import litellm_langfuse_logger_init_fixed
11
+
12
+ # Monkey-patch the init method as early as possible before the class is used
13
+ LangFuseLogger.__init__ = litellm_langfuse_logger_init_fixed # type: ignore
8
14
 
9
15
  logging.getLogger(__name__).addHandler(logging.NullHandler())
rasa/cli/scaffold.py CHANGED
@@ -24,21 +24,10 @@ class ProjectTemplateName(Enum):
24
24
 
25
25
  DEFAULT = "default"
26
26
  TUTORIAL = "tutorial"
27
- PLAIN = "plain"
28
- FINANCE = "finance"
29
- TELCO = "telco"
30
27
 
31
28
  def __str__(self) -> str:
32
29
  return self.value
33
30
 
34
- @classmethod
35
- def get_all_values(cls) -> List[str]:
36
- return [name.value for name in cls]
37
-
38
- @classmethod
39
- def supported_values(cls) -> str:
40
- return ", ".join(cls.get_all_values())
41
-
42
31
 
43
32
  template_domain_path = defaultdict(lambda: DEFAULT_DOMAIN_PATH)
44
33
  template_domain_path[ProjectTemplateName.DEFAULT] = "domain"
@@ -170,17 +159,9 @@ def create_initial_project(
170
159
  path: Text, template: ProjectTemplateName = ProjectTemplateName.DEFAULT
171
160
  ) -> None:
172
161
  """Creates directory structure and templates for initial project."""
173
- import distutils.dir_util as dir_util
174
-
175
- # clear the cache of the copy_tree function, this avoids issues if
176
- # a project directory existed before and we removed folders in it
177
- # with shutil.rmtree. see
178
- # https://stackoverflow.com/questions/9160227/dir-util-copy-tree-fails-after-shutil-rmtree
179
- if hasattr(dir_util, "_path_created"):
180
- dir_util._path_created.clear()
181
- else:
182
- dir_util.SkipRepeatAbsolutePaths.clear()
183
- dir_util.copy_tree(scaffold_path(template), path)
162
+ from distutils.dir_util import copy_tree
163
+
164
+ copy_tree(scaffold_path(template), path)
184
165
 
185
166
 
186
167
  def scaffold_path(template: ProjectTemplateName) -> Text:
@@ -908,12 +908,10 @@ class RemoteAction(Action):
908
908
  draft.setdefault("buttons", [])
909
909
  draft["buttons"].extend(buttons)
910
910
 
911
+ # Avoid overwriting `draft` values with empty values
911
912
  response = {k: v for k, v in response.items() if v}
912
-
913
- response.update(draft)
914
- bot_messages.append(
915
- create_bot_utterance(response, tracker.current_language)
916
- )
913
+ draft.update(response)
914
+ bot_messages.append(create_bot_utterance(draft, tracker.current_language))
917
915
 
918
916
  return bot_messages
919
917
 
@@ -42,14 +42,14 @@ if TYPE_CHECKING:
42
42
  from sanic import Sanic, Websocket # type: ignore[attr-defined]
43
43
  from socketio import AsyncServer
44
44
 
45
- from rasa.core.channels.channel import UserMessage
45
+ from rasa.core.channels.channel import InputChannel, UserMessage
46
46
  from rasa.shared.core.trackers import DialogueStateTracker
47
47
 
48
48
 
49
49
  structlogger = structlog.get_logger()
50
50
 
51
51
 
52
- def tracker_as_dump(tracker: "DialogueStateTracker") -> Dict[str, Any]:
52
+ def tracker_as_dump(tracker: "DialogueStateTracker") -> str:
53
53
  """Create a dump of the tracker state."""
54
54
  from rasa.shared.core.trackers import get_trackers_for_conversation_sessions
55
55
 
@@ -60,9 +60,8 @@ def tracker_as_dump(tracker: "DialogueStateTracker") -> Dict[str, Any]:
60
60
  else:
61
61
  last_tracker = multiple_tracker_sessions[-1]
62
62
 
63
- # TODO: this is a bug: the bridge converts this back to json, but it
64
- # should be json in the first place
65
- return last_tracker.current_state(EventVerbosity.AFTER_RESTART)
63
+ state = last_tracker.current_state(EventVerbosity.AFTER_RESTART)
64
+ return json.dumps(state)
66
65
 
67
66
 
68
67
  def does_need_action_prediction(tracker: "DialogueStateTracker") -> bool:
@@ -149,7 +148,6 @@ class StudioChatInput(SocketIOInput, VoiceInputChannel):
149
148
  from rasa.core.agent import Agent
150
149
 
151
150
  self.agent: Optional[Agent] = None
152
- self.latest_tracker_session_id = None
153
151
 
154
152
  # Initialize the SocketIO input channel
155
153
  SocketIOInput.__init__(
@@ -181,9 +179,7 @@ class StudioChatInput(SocketIOInput, VoiceInputChannel):
181
179
  self._register_tracker_update_hook()
182
180
 
183
181
  @classmethod
184
- def from_credentials(
185
- cls, credentials: Optional[Dict[Text, Any]]
186
- ) -> "StudioChatInput":
182
+ def from_credentials(cls, credentials: Optional[Dict[Text, Any]]) -> "InputChannel":
187
183
  """Creates a StudioChatInput channel from credentials."""
188
184
  credentials = credentials or {}
189
185
 
@@ -215,11 +211,6 @@ class StudioChatInput(SocketIOInput, VoiceInputChannel):
215
211
  if not self.sio:
216
212
  structlogger.error("studio_chat.on_tracker_updated.sio_not_initialized")
217
213
  return
218
-
219
- # we need the latest session id to use it for the llm helper to get the
220
- # most recent conversation the user had with the bot.
221
- self.latest_tracker_session_id = sender_id
222
-
223
214
  await self.sio.emit("tracker", tracker_dump, room=sender_id)
224
215
 
225
216
  async def on_message_proxy(
@@ -231,14 +222,7 @@ class StudioChatInput(SocketIOInput, VoiceInputChannel):
231
222
 
232
223
  Triggers a tracker update notification after processing the message.
233
224
  """
234
- try:
235
- await on_new_message(message)
236
- except Exception as e:
237
- structlogger.exception(
238
- "studio_chat.on_new_message.error",
239
- error=str(e),
240
- sender_id=message.sender_id,
241
- )
225
+ await on_new_message(message)
242
226
 
243
227
  if not self.agent:
244
228
  structlogger.error("studio_chat.on_message_proxy.agent_not_initialized")
@@ -291,7 +275,7 @@ class StudioChatInput(SocketIOInput, VoiceInputChannel):
291
275
  async def collect_call_parameters(
292
276
  self, channel_websocket: "Websocket"
293
277
  ) -> Optional[CallParameters]:
294
- """Voice method to collect call parameters."""
278
+ """Voice method to collect call parameters"""
295
279
  session_id = channel_websocket.session_id
296
280
  return CallParameters(session_id, "local", "local", stream_id=session_id)
297
281
 
@@ -321,7 +305,7 @@ class StudioChatInput(SocketIOInput, VoiceInputChannel):
321
305
  def create_output_channel(
322
306
  self, voice_websocket: "Websocket", tts_engine: TTSEngine
323
307
  ) -> VoiceOutputChannel:
324
- """Create a voice output channel."""
308
+ """Create a voice output channel"""
325
309
  return StudioVoiceOutputChannel(
326
310
  voice_websocket,
327
311
  tts_engine,
@@ -448,16 +432,8 @@ class StudioChatInput(SocketIOInput, VoiceInputChannel):
448
432
  ws.put_message(data)
449
433
  return
450
434
 
451
- try:
452
- # Handle text messages
453
- await self.handle_user_message(sid, data, on_new_message)
454
- except Exception as e:
455
- structlogger.exception(
456
- "studio_chat.sio.handle_message.error",
457
- error=str(e),
458
- sid=sid,
459
- )
460
- await self.sio.emit("error", str(e), room=sid)
435
+ # Handle text messages
436
+ await self.handle_user_message(sid, data, on_new_message)
461
437
 
462
438
  @self.sio.on("update_tracker", namespace=self.namespace)
463
439
  async def on_update_tracker(sid: Text, data: Dict) -> None:
@@ -784,19 +784,17 @@ class EnterpriseSearchPolicy(LLMHealthCheckMixin, EmbeddingsHealthCheckMixin, Po
784
784
  if not os.path.exists(docs_folder) or not os.path.isdir(docs_folder):
785
785
  error_message = (
786
786
  f"Document source directory does not exist or is not a "
787
- f"directory: '{os.path.abspath(docs_folder)}'. "
787
+ f"directory: '{docs_folder}'. "
788
788
  "Please specify a valid path to the documents source directory in the "
789
789
  "vector_store configuration."
790
790
  )
791
791
  structlogger.error(
792
792
  "enterprise_search_policy.train.faiss.invalid_source_directory",
793
793
  message=error_message,
794
- docs_folder={os.path.abspath(docs_folder)},
795
- configuration_value=docs_folder,
796
794
  )
797
795
  print_error_and_exit(error_message)
798
796
 
799
- docs = glob.glob(os.path.join(docs_folder, "**/*.txt"), recursive=True)
797
+ docs = glob.glob(os.path.join(docs_folder, "*.txt"), recursive=True)
800
798
  if not docs or len(docs) < 1:
801
799
  error_message = (
802
800
  f"Document source directory is empty: '{docs_folder}'. "
@@ -1135,7 +1133,8 @@ class EnterpriseSearchPolicy(LLMHealthCheckMixin, EmbeddingsHealthCheckMixin, Po
1135
1133
  embeddings_config: Dict[Text, Any],
1136
1134
  log_source_method: str,
1137
1135
  ) -> None:
1138
- """Perform the health checks using resolved LLM and embeddings configurations.
1136
+ """
1137
+ Perform the health checks using resolved LLM and embeddings configurations.
1139
1138
  Resolved means the configuration is either:
1140
1139
  - A reference to a model group that has already been expanded into
1141
1140
  its corresponding configuration using the information from
@@ -1164,7 +1163,8 @@ class EnterpriseSearchPolicy(LLMHealthCheckMixin, EmbeddingsHealthCheckMixin, Po
1164
1163
 
1165
1164
  @classmethod
1166
1165
  def get_system_default_prompt_based_on_config(cls, config: Dict[str, Any]) -> str:
1167
- """Resolves the default prompt template for Enterprise Search Policy based on
1166
+ """
1167
+ Resolves the default prompt template for Enterprise Search Policy based on
1168
1168
  the component's configuration.
1169
1169
 
1170
1170
  - The old prompt is selected when both citation and relevancy check are either
@@ -1195,7 +1195,8 @@ class EnterpriseSearchPolicy(LLMHealthCheckMixin, EmbeddingsHealthCheckMixin, Po
1195
1195
  relevancy_check_enabled: bool,
1196
1196
  citation_enabled: bool,
1197
1197
  ) -> str:
1198
- """Returns the appropriate default prompt template based on the feature flags.
1198
+ """
1199
+ Returns the appropriate default prompt template based on the feature flags.
1199
1200
 
1200
1201
  The selection follows this priority:
1201
1202
  1. If relevancy check is enabled, return the prompt that includes both relevancy
@@ -740,14 +740,7 @@ def _run_action_step(
740
740
  # do not log about non-existing validation actions of collect steps
741
741
  utter_action_name = render_template_variables("{{context.utter}}", context)
742
742
  if utter_action_name not in available_actions:
743
- structlogger.warning(
744
- "flow.step.run.action.unknown",
745
- action=action_name,
746
- event_info=(
747
- f"The action '{action_name}' is not defined in the domain but "
748
- f"getting triggered by the flow '{step.flow_id}'."
749
- ),
750
- )
743
+ structlogger.warning("flow.step.run.action.unknown", action=action_name)
751
744
  return ContinueFlowWithNextStep(events=initial_events)
752
745
 
753
746
 
@@ -219,6 +219,11 @@ class FlowRetrieval(EmbeddingsHealthCheckMixin):
219
219
  if self.vector_store is not None:
220
220
  with self._model_storage.write_to(self._resource) as model_path:
221
221
  self.vector_store.save_local(model_path)
222
+ else:
223
+ structlogger.warning(
224
+ "flow_retrieval.persist_vector_store.not_initialized",
225
+ event_info="Vector store is None, not persisted.",
226
+ )
222
227
 
223
228
  def _persist_config(self) -> None:
224
229
  with self._model_storage.write_to(self._resource) as path:
@@ -244,16 +249,6 @@ class FlowRetrieval(EmbeddingsHealthCheckMixin):
244
249
  )
245
250
 
246
251
  flows_to_embedd = flows.exclude_link_only_flows()
247
-
248
- if not flows_to_embedd:
249
- structlogger.debug(
250
- "flow_retrieval.populate_vector_store.no_flows_to_embed",
251
- event_info=(
252
- "No flows to embed in the vector store, skipping population."
253
- ),
254
- )
255
- return
256
-
257
252
  embeddings = self._create_embedder(self.config)
258
253
  documents = self._generate_flow_documents(flows_to_embedd, domain)
259
254
  try:
@@ -425,6 +420,10 @@ class FlowRetrieval(EmbeddingsHealthCheckMixin):
425
420
  The top k documents with similarity scores.
426
421
  """
427
422
  if self.vector_store is None:
423
+ structlogger.error(
424
+ "flow_retrieval.query_vector_store.vector_store_not_configured",
425
+ event_info="Vector store is not configured",
426
+ )
428
427
  return []
429
428
  try:
430
429
  documents_with_scores = (
@@ -1,6 +1,8 @@
1
1
  from abc import ABC, abstractmethod
2
+ from asyncio import Lock
2
3
  from functools import lru_cache
3
4
  from typing import Any, Dict, List, Optional, Set, Text, Tuple, Union
5
+ from uuid import UUID, uuid4
4
6
 
5
7
  import structlog
6
8
  from jinja2 import Environment, Template, select_autoescape
@@ -89,6 +91,9 @@ class LLMBasedCommandGenerator(
89
91
  else:
90
92
  self.flow_retrieval = None
91
93
 
94
+ self.sender_id_to_session_id_mapping: Dict[str, UUID] = {}
95
+ self._lock = Lock()
96
+
92
97
  ### Abstract methods
93
98
  @staticmethod
94
99
  @abstractmethod
@@ -225,8 +230,7 @@ class LLMBasedCommandGenerator(
225
230
 
226
231
  @lru_cache
227
232
  def compile_template(self, template: str) -> Template:
228
- """
229
- Compile the prompt template and register custom filters.
233
+ """Compile the prompt template and register custom filters.
230
234
 
231
235
  Compiling the template is an expensive operation,
232
236
  so we cache the result.
@@ -327,7 +331,9 @@ class LLMBasedCommandGenerator(
327
331
 
328
332
  @measure_llm_latency
329
333
  async def invoke_llm(
330
- self, prompt: Union[List[dict], List[str], str]
334
+ self,
335
+ prompt: Union[List[dict], List[str], str],
336
+ metadata: Optional[Dict[str, Any]] = None,
331
337
  ) -> Optional[LLMResponse]:
332
338
  """Use LLM to generate a response.
333
339
 
@@ -340,6 +346,7 @@ class LLMBasedCommandGenerator(
340
346
  - a list of messages. Each message is a string and will be formatted
341
347
  as a user message.
342
348
  - a single message as a string which will be formatted as user message.
349
+ metadata: Optional metadata to be passed to the LLM call.
343
350
 
344
351
  Returns:
345
352
  An LLMResponse object.
@@ -351,7 +358,7 @@ class LLMBasedCommandGenerator(
351
358
  self.config.get(LLM_CONFIG_KEY), self.get_default_llm_config()
352
359
  )
353
360
  try:
354
- return await llm.acompletion(prompt)
361
+ return await llm.acompletion(prompt, metadata)
355
362
  except Exception as e:
356
363
  # unfortunately, langchain does not wrap LLM exceptions which means
357
364
  # we have to catch all exceptions here
@@ -654,3 +661,7 @@ class LLMBasedCommandGenerator(
654
661
  def get_default_llm_config() -> Dict[str, Any]:
655
662
  """Get the default LLM config for the command generator."""
656
663
  return DEFAULT_LLM_CONFIG
664
+
665
+ async def _get_or_create_session_id(self, sender_id: str) -> UUID:
666
+ async with self._lock:
667
+ return self.sender_id_to_session_id_mapping.setdefault(sender_id, uuid4())
@@ -55,7 +55,9 @@ class LLMCommandGenerator(SingleStepLLMCommandGenerator):
55
55
  )
56
56
 
57
57
  async def invoke_llm(
58
- self, prompt: Union[List[dict], List[str], str]
58
+ self,
59
+ prompt: Union[List[dict], List[str], str],
60
+ metadata: Optional[Dict[str, Any]] = None,
59
61
  ) -> Optional[LLMResponse]:
60
62
  try:
61
63
  return await super().invoke_llm(prompt)
@@ -42,6 +42,9 @@ from rasa.engine.storage.resource import Resource
42
42
  from rasa.engine.storage.storage import ModelStorage
43
43
  from rasa.shared.constants import (
44
44
  EMBEDDINGS_CONFIG_KEY,
45
+ LANGFUSE_CUSTOM_METADATA_DICT,
46
+ LANGFUSE_METADATA_SESSION_ID,
47
+ LANGFUSE_TAGS,
45
48
  RASA_PATTERN_CANNOT_HANDLE_NOT_SUPPORTED,
46
49
  ROUTE_TO_CALM_SLOT,
47
50
  )
@@ -493,7 +496,21 @@ class MultiStepLLMCommandGenerator(LLMBasedCommandGenerator):
493
496
  prompt=prompt,
494
497
  )
495
498
 
496
- response = await self.invoke_llm(prompt)
499
+ if tracker:
500
+ session_id = str(await self._get_or_create_session_id(tracker.sender_id))
501
+ else:
502
+ session_id = "unknown"
503
+
504
+ metadata = {
505
+ LANGFUSE_METADATA_SESSION_ID: session_id,
506
+ LANGFUSE_CUSTOM_METADATA_DICT: {
507
+ "component": self.__class__.__name__,
508
+ "function": "_predict_commands_for_active_flow",
509
+ },
510
+ LANGFUSE_TAGS: [self.__class__.__name__],
511
+ }
512
+
513
+ response = await self.invoke_llm(prompt, metadata)
497
514
  llm_response = LLMResponse.ensure_llm_response(response)
498
515
  actions = None
499
516
  if llm_response and llm_response.choices:
@@ -548,7 +565,20 @@ class MultiStepLLMCommandGenerator(LLMBasedCommandGenerator):
548
565
  prompt=prompt,
549
566
  )
550
567
 
551
- response = await self.invoke_llm(prompt)
568
+ if tracker:
569
+ session_id = str(await self._get_or_create_session_id(tracker.sender_id))
570
+ else:
571
+ session_id = "unknown"
572
+
573
+ metadata = {
574
+ LANGFUSE_METADATA_SESSION_ID: session_id,
575
+ LANGFUSE_CUSTOM_METADATA_DICT: {
576
+ "component": self.__class__.__name__,
577
+ "function": "_predict_commands_for_handling_flows",
578
+ },
579
+ LANGFUSE_TAGS: [self.__class__.__name__],
580
+ }
581
+ response = await self.invoke_llm(prompt, metadata)
552
582
  llm_response = LLMResponse.ensure_llm_response(response)
553
583
  actions = None
554
584
  if llm_response and llm_response.choices:
@@ -638,7 +668,22 @@ class MultiStepLLMCommandGenerator(LLMBasedCommandGenerator):
638
668
  prompt=prompt,
639
669
  )
640
670
 
641
- response = await self.invoke_llm(prompt)
671
+ if tracker:
672
+ session_id = str(await self._get_or_create_session_id(tracker.sender_id))
673
+
674
+ else:
675
+ session_id = "unknown"
676
+
677
+ metadata = {
678
+ LANGFUSE_METADATA_SESSION_ID: session_id,
679
+ LANGFUSE_CUSTOM_METADATA_DICT: {
680
+ "component": self.__class__.__name__,
681
+ "function": "_predict_commands_for_newly_started_flow",
682
+ },
683
+ LANGFUSE_TAGS: [self.__class__.__name__],
684
+ }
685
+
686
+ response = await self.invoke_llm(prompt, metadata)
642
687
  llm_response = LLMResponse.ensure_llm_response(response)
643
688
  actions = None
644
689
  if llm_response and llm_response.choices:
@@ -41,6 +41,9 @@ from rasa.engine.storage.resource import Resource
41
41
  from rasa.engine.storage.storage import ModelStorage
42
42
  from rasa.shared.constants import (
43
43
  EMBEDDINGS_CONFIG_KEY,
44
+ LANGFUSE_CUSTOM_METADATA_DICT,
45
+ LANGFUSE_METADATA_SESSION_ID,
46
+ LANGFUSE_TAGS,
44
47
  PROMPT_TEMPLATE_CONFIG_KEY,
45
48
  ROUTE_TO_CALM_SLOT,
46
49
  )
@@ -269,7 +272,18 @@ class SingleStepBasedLLMCommandGenerator(LLMBasedCommandGenerator, ABC):
269
272
  prompt=flow_prompt,
270
273
  )
271
274
 
272
- response = await self.invoke_llm(flow_prompt)
275
+ if tracker:
276
+ session_id = str(await self._get_or_create_session_id(tracker.sender_id))
277
+ else:
278
+ session_id = "unknown"
279
+
280
+ metadata = {
281
+ LANGFUSE_METADATA_SESSION_ID: session_id,
282
+ LANGFUSE_CUSTOM_METADATA_DICT: {"component": self.__class__.__name__},
283
+ LANGFUSE_TAGS: [self.__class__.__name__],
284
+ }
285
+
286
+ response = await self.invoke_llm(flow_prompt, metadata)
273
287
  llm_response = LLMResponse.ensure_llm_response(response)
274
288
  # The check for 'None' maintains compatibility with older versions
275
289
  # of LLMCommandGenerator. In previous implementations, 'invoke_llm'
rasa/hooks.py CHANGED
@@ -1,8 +1,20 @@
1
1
  import argparse
2
2
  import logging
3
+ import os
3
4
  from typing import TYPE_CHECKING, List, Optional, Text, Union
4
5
 
6
+ import litellm
5
7
  import pluggy
8
+ import structlog
9
+
10
+ from rasa.shared.providers.constants import (
11
+ LANGFUSE_CALLBACK_NAME,
12
+ LANGFUSE_HOST_ENV_VAR,
13
+ LANGFUSE_PROJECT_ID_ENV_VAR,
14
+ LANGFUSE_PUBLIC_KEY_ENV_VAR,
15
+ LANGFUSE_SECRET_KEY_ENV_VAR,
16
+ RASA_LANGFUSE_INTEGRATION_ENABLED_ENV_VAR,
17
+ )
6
18
 
7
19
  # IMPORTANT: do not import anything from rasa here - use scoped imports
8
20
  # this avoids circular imports, as the hooks are used in different places
@@ -17,6 +29,7 @@ if TYPE_CHECKING:
17
29
 
18
30
  hookimpl = pluggy.HookimplMarker("rasa")
19
31
  logger = logging.getLogger(__name__)
32
+ structlogger = structlog.get_logger()
20
33
 
21
34
 
22
35
  @hookimpl # type: ignore[misc]
@@ -56,6 +69,8 @@ def configure_commandline(cmdline_arguments: argparse.Namespace) -> Optional[Tex
56
69
  config.configure_tracing(tracer_provider)
57
70
  config.configure_metrics(endpoints_file)
58
71
 
72
+ _init_langfuse_integration()
73
+
59
74
  return endpoints_file
60
75
 
61
76
 
@@ -87,3 +102,43 @@ def create_tracker_store(
87
102
  endpoint_config=endpoint_config, domain=domain, event_broker=event_broker
88
103
  )
89
104
  return endpoint_config
105
+
106
+
107
+ def _is_langfuse_integration_enabled() -> bool:
108
+ return (
109
+ os.environ.get(RASA_LANGFUSE_INTEGRATION_ENABLED_ENV_VAR, "false").lower()
110
+ == "true"
111
+ )
112
+
113
+
114
+ def _init_langfuse_integration() -> None:
115
+ if not _is_langfuse_integration_enabled():
116
+ structlogger.info(
117
+ "hooks._init_langfuse_integration.disabled",
118
+ event_info="Langfuse integration is disabled.",
119
+ )
120
+ return
121
+
122
+ if (
123
+ not os.environ.get(LANGFUSE_HOST_ENV_VAR)
124
+ or not os.environ.get(LANGFUSE_PROJECT_ID_ENV_VAR)
125
+ or not os.environ.get(LANGFUSE_PUBLIC_KEY_ENV_VAR)
126
+ or not os.environ.get(LANGFUSE_SECRET_KEY_ENV_VAR)
127
+ ):
128
+ structlogger.warning(
129
+ "hooks._init_langfuse_integration.missing_langfuse_keys",
130
+ event_info=(
131
+ "Langfuse integration is enabled, but some environment variables "
132
+ "are missing. Please set LANGFUSE_HOST, LANGFUSE_PROJECT_ID, "
133
+ "LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY environment "
134
+ "variables to use Langfuse integration."
135
+ ),
136
+ )
137
+ return
138
+
139
+ litellm.success_callback = [LANGFUSE_CALLBACK_NAME]
140
+ litellm.failure_callback = [LANGFUSE_CALLBACK_NAME]
141
+ structlogger.info(
142
+ "hooks.langfuse_callbacks_initialized",
143
+ event_info="Langfuse integration initialized.",
144
+ )
@@ -1,6 +1,6 @@
1
1
  from contextlib import contextmanager
2
2
  from datetime import datetime
3
- from typing import Callable, Generator, List, Union
3
+ from typing import Any, Callable, Dict, Generator, List, Optional, Union
4
4
 
5
5
  import structlog
6
6
 
@@ -24,7 +24,9 @@ def make_mock_invoke_llm(commands: str) -> Callable:
24
24
  """
25
25
 
26
26
  async def _mock_invoke_llm(
27
- self: LLMBasedCommandGenerator, prompt: Union[List[dict], List[str], str]
27
+ self: LLMBasedCommandGenerator,
28
+ prompt: Union[List[dict], List[str], str],
29
+ metadata: Optional[Dict[str, Any]] = None,
28
30
  ) -> LLMResponse:
29
31
  structlogger.debug(
30
32
  f"LLM call intercepted, response mocked. "
@@ -39,9 +39,11 @@ from rasa.model_manager.trainer_service import (
39
39
  update_training_status,
40
40
  )
41
41
  from rasa.model_manager.utils import (
42
+ InvalidPathException,
42
43
  get_logs_content,
43
44
  logs_base_path,
44
45
  models_base_path,
46
+ subpath,
45
47
  )
46
48
  from rasa.model_manager.warm_rasa_process import (
47
49
  initialize_warm_rasa_process,
@@ -51,7 +53,6 @@ from rasa.server import ErrorResponse
51
53
  from rasa.shared.exceptions import InvalidConfigException
52
54
  from rasa.shared.utils.yaml import dump_obj_as_yaml_to_string
53
55
  from rasa.studio.upload import build_calm_import_parts
54
- from rasa.utils.io import InvalidPathException, subpath
55
56
 
56
57
  dotenv.load_dotenv()
57
58
 
@@ -104,7 +105,7 @@ async def update_status_of_all_bots() -> None:
104
105
  await update_bot_status(bot)
105
106
 
106
107
 
107
- def base_server_url(request: Optional[Request]) -> str:
108
+ def base_server_url(request: Request) -> str:
108
109
  """Return the base URL of the server."""
109
110
  if SERVER_BASE_URL:
110
111
  return SERVER_BASE_URL.rstrip("/")
@@ -15,11 +15,11 @@ from rasa.model_manager import config
15
15
  from rasa.model_manager.utils import (
16
16
  logs_path,
17
17
  models_base_path,
18
+ subpath,
18
19
  write_encoded_data_to_file,
19
20
  )
20
21
  from rasa.model_manager.warm_rasa_process import start_rasa_process
21
22
  from rasa.studio.prompts import handle_prompts
22
- from rasa.utils.io import subpath
23
23
 
24
24
  structlogger = structlog.get_logger()
25
25
 
@@ -14,6 +14,7 @@ from rasa.model_manager.utils import (
14
14
  ensure_base_directory_exists,
15
15
  logs_path,
16
16
  models_base_path,
17
+ subpath,
17
18
  write_encoded_data_to_file,
18
19
  )
19
20
  from rasa.model_manager.warm_rasa_process import (
@@ -21,7 +22,6 @@ from rasa.model_manager.warm_rasa_process import (
21
22
  )
22
23
  from rasa.model_training import generate_random_model_name
23
24
  from rasa.studio.prompts import handle_prompts
24
- from rasa.utils.io import subpath
25
25
 
26
26
  structlogger = structlog.get_logger()
27
27
 
@@ -53,15 +53,6 @@ class TrainingSession(BaseModel):
53
53
  """Check if the training is running."""
54
54
  return self.status == TrainingSessionStatus.RUNNING
55
55
 
56
- def has_just_finished(self) -> bool:
57
- if not self.is_status_indicating_alive():
58
- # skip if the training is not running
59
- return False
60
- if self.process.poll() is None:
61
- # process is still running
62
- return False
63
- return True
64
-
65
56
  def model_path(self) -> str:
66
57
  """Return the path to the model."""
67
58
  return subpath(models_base_path(), f"{self.model_name}.tar.gz")
@@ -98,8 +89,14 @@ def terminate_training(training: TrainingSession) -> None:
98
89
 
99
90
 
100
91
  def update_training_status(training: TrainingSession) -> None:
101
- if training.has_just_finished():
102
- complete_training(training)
92
+ if not training.is_status_indicating_alive():
93
+ # skip if the training is not running
94
+ return
95
+ if training.process.poll() is None:
96
+ # process is still running
97
+ return
98
+
99
+ complete_training(training)
103
100
 
104
101
 
105
102
  def complete_training(training: TrainingSession) -> None: