rasa-pro 3.13.1a17__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 (267) 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/actions/direct_custom_actions_executor.py +8 -15
  5. rasa/core/channels/studio_chat.py +10 -34
  6. rasa/core/policies/enterprise_search_policy.py +8 -7
  7. rasa/core/policies/flows/flow_executor.py +1 -8
  8. rasa/dialogue_understanding/generator/flow_retrieval.py +9 -10
  9. rasa/dialogue_understanding/generator/llm_based_command_generator.py +15 -4
  10. rasa/dialogue_understanding/generator/llm_command_generator.py +3 -1
  11. rasa/dialogue_understanding/generator/multi_step/multi_step_llm_command_generator.py +48 -3
  12. rasa/dialogue_understanding/generator/single_step/single_step_based_llm_command_generator.py +15 -1
  13. rasa/hooks.py +55 -0
  14. rasa/llm_fine_tuning/utils.py +4 -2
  15. rasa/model_manager/model_api.py +3 -2
  16. rasa/model_manager/runner_service.py +1 -1
  17. rasa/model_manager/trainer_service.py +9 -12
  18. rasa/model_manager/utils.py +29 -1
  19. rasa/monkey_patches.py +91 -0
  20. rasa/shared/constants.py +6 -0
  21. rasa/shared/core/domain.py +15 -62
  22. rasa/shared/core/flows/flow_step.py +1 -7
  23. rasa/shared/core/flows/yaml_flows_io.py +8 -16
  24. rasa/shared/core/slots.py +0 -4
  25. rasa/shared/importers/importer.py +0 -6
  26. rasa/shared/importers/utils.py +1 -77
  27. rasa/shared/providers/constants.py +10 -0
  28. rasa/shared/providers/llm/_base_litellm_client.py +14 -4
  29. rasa/shared/providers/llm/litellm_router_llm_client.py +23 -12
  30. rasa/shared/providers/llm/llm_client.py +19 -15
  31. rasa/shared/providers/llm/self_hosted_llm_client.py +23 -18
  32. rasa/studio/upload.py +45 -10
  33. rasa/telemetry.py +1 -2
  34. rasa/tracing/instrumentation/attribute_extractors.py +1 -0
  35. rasa/utils/io.py +9 -27
  36. rasa/utils/json_utils.py +1 -6
  37. rasa/utils/log_utils.py +1 -5
  38. rasa/utils/plotting.py +1 -1
  39. rasa/validator.py +3 -7
  40. rasa/version.py +1 -1
  41. {rasa_pro-3.13.1a17.dist-info → rasa_pro-3.13.1.dev1.dist-info}/METADATA +9 -9
  42. {rasa_pro-3.13.1a17.dist-info → rasa_pro-3.13.1.dev1.dist-info}/RECORD +45 -266
  43. rasa/builder/README.md +0 -120
  44. rasa/builder/__init__.py +0 -0
  45. rasa/builder/config.py +0 -79
  46. rasa/builder/create_openai_vector_store.py +0 -228
  47. rasa/builder/exceptions.py +0 -55
  48. rasa/builder/inkeep-rag-response-schema.json +0 -64
  49. rasa/builder/inkeep_document_retrieval.py +0 -212
  50. rasa/builder/llm-helper-schema.json +0 -69
  51. rasa/builder/llm_context.py +0 -81
  52. rasa/builder/llm_helper_prompt.jinja2 +0 -245
  53. rasa/builder/llm_service.py +0 -317
  54. rasa/builder/logging_utils.py +0 -51
  55. rasa/builder/main.py +0 -147
  56. rasa/builder/models.py +0 -225
  57. rasa/builder/project_generator.py +0 -282
  58. rasa/builder/scrape_rasa_docs.py +0 -97
  59. rasa/builder/service.py +0 -742
  60. rasa/builder/skill_to_bot_prompt.jinja2 +0 -164
  61. rasa/builder/training_service.py +0 -132
  62. rasa/builder/validation_service.py +0 -93
  63. rasa/cli/project_templates/finance/actions/__init__.py +0 -0
  64. rasa/cli/project_templates/finance/actions/action_add_payee.py +0 -47
  65. rasa/cli/project_templates/finance/actions/action_ask_account.py +0 -50
  66. rasa/cli/project_templates/finance/actions/action_ask_account_from.py +0 -50
  67. rasa/cli/project_templates/finance/actions/action_ask_card.py +0 -47
  68. rasa/cli/project_templates/finance/actions/action_check_balance.py +0 -40
  69. rasa/cli/project_templates/finance/actions/action_check_card_existence.py +0 -35
  70. rasa/cli/project_templates/finance/actions/action_check_payee_existence.py +0 -40
  71. rasa/cli/project_templates/finance/actions/action_check_sufficient_funds.py +0 -41
  72. rasa/cli/project_templates/finance/actions/action_list_payees.py +0 -45
  73. rasa/cli/project_templates/finance/actions/action_process_immediate_payment.py +0 -18
  74. rasa/cli/project_templates/finance/actions/action_remove_payee.py +0 -49
  75. rasa/cli/project_templates/finance/actions/action_schedule_payment.py +0 -19
  76. rasa/cli/project_templates/finance/actions/action_session_start.py +0 -69
  77. rasa/cli/project_templates/finance/actions/action_update_card_status.py +0 -45
  78. rasa/cli/project_templates/finance/actions/action_validate_payment_date.py +0 -36
  79. rasa/cli/project_templates/finance/actions/database.py +0 -276
  80. rasa/cli/project_templates/finance/config.yml +0 -32
  81. rasa/cli/project_templates/finance/credentials.yml +0 -33
  82. rasa/cli/project_templates/finance/csvs/accounts.csv +0 -8
  83. rasa/cli/project_templates/finance/csvs/advisors.csv +0 -7
  84. rasa/cli/project_templates/finance/csvs/appointments.csv +0 -211
  85. rasa/cli/project_templates/finance/csvs/branches.csv +0 -10
  86. rasa/cli/project_templates/finance/csvs/cards.csv +0 -11
  87. rasa/cli/project_templates/finance/csvs/payees.csv +0 -10
  88. rasa/cli/project_templates/finance/csvs/transactions.csv +0 -71
  89. rasa/cli/project_templates/finance/csvs/users.csv +0 -4
  90. rasa/cli/project_templates/finance/data/flows/add_payee.yml +0 -29
  91. rasa/cli/project_templates/finance/data/flows/block_card.yml +0 -66
  92. rasa/cli/project_templates/finance/data/flows/check_balance.yml +0 -9
  93. rasa/cli/project_templates/finance/data/flows/list_payees.yml +0 -5
  94. rasa/cli/project_templates/finance/data/flows/remove_payee.yml +0 -21
  95. rasa/cli/project_templates/finance/data/flows/select_card.yml +0 -12
  96. rasa/cli/project_templates/finance/data/flows/transfer_money.yml +0 -67
  97. rasa/cli/project_templates/finance/data/flows/welcome.yml +0 -14
  98. rasa/cli/project_templates/finance/data/nlu.yml +0 -29
  99. rasa/cli/project_templates/finance/data/patterns/pattern_chitchat.yml +0 -7
  100. rasa/cli/project_templates/finance/data/patterns/pattern_completed.yml +0 -6
  101. rasa/cli/project_templates/finance/data/patterns/pattern_search.yml +0 -5
  102. rasa/cli/project_templates/finance/data/patterns/pattern_session_start.yml +0 -9
  103. rasa/cli/project_templates/finance/data/source/accounts.json +0 -51
  104. rasa/cli/project_templates/finance/data/source/advisors.json +0 -44
  105. rasa/cli/project_templates/finance/data/source/appointments.json +0 -1474
  106. rasa/cli/project_templates/finance/data/source/branches.json +0 -47
  107. rasa/cli/project_templates/finance/data/source/cards.json +0 -72
  108. rasa/cli/project_templates/finance/data/source/payees.json +0 -74
  109. rasa/cli/project_templates/finance/data/source/transactions.json +0 -492
  110. rasa/cli/project_templates/finance/data/source/users.json +0 -29
  111. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/consequences_of_blocking_card.txt +0 -8
  112. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/reasons_to_block_card.txt +0 -8
  113. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/recovering_from_card_fraud.txt +0 -8
  114. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/tips_for_card_security.txt +0 -8
  115. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/what_to_do_if_card_is_lost.txt +0 -8
  116. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/account_balance_security.txt +0 -7
  117. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/common_balance_inquiries.txt +0 -8
  118. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/methods_to_check_balance.txt +0 -8
  119. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/understanding_balance_updates.txt +0 -8
  120. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/what_to_do_if_balance_is_incorrect.txt +0 -8
  121. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/benefits_of_authorised_payees.txt +0 -8
  122. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/common_issues_with_payees.txt +0 -8
  123. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/general_payee_information.txt +0 -8
  124. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/payee_management_tips.txt +0 -8
  125. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/understanding_payee_types.txt +0 -8
  126. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/common_transfer_errors.txt +0 -8
  127. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/fees_for_transfers.txt +0 -8
  128. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/general_transfer_information.txt +0 -8
  129. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/security_tips_for_transfers.txt +0 -8
  130. rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/transfer_processing_times.txt +0 -8
  131. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part1.txt +0 -50
  132. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part10.txt +0 -50
  133. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part11.txt +0 -48
  134. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part12.txt +0 -50
  135. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part13.txt +0 -50
  136. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part14.txt +0 -47
  137. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part15.txt +0 -50
  138. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part16.txt +0 -50
  139. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part17.txt +0 -47
  140. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part18.txt +0 -50
  141. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part19.txt +0 -50
  142. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part2.txt +0 -50
  143. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part20.txt +0 -47
  144. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part21.txt +0 -50
  145. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part22.txt +0 -50
  146. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part23.txt +0 -47
  147. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part24.txt +0 -50
  148. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part25.txt +0 -50
  149. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part26.txt +0 -47
  150. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part27.txt +0 -50
  151. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part28.txt +0 -50
  152. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part29.txt +0 -47
  153. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part3.txt +0 -47
  154. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part30.txt +0 -50
  155. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part31.txt +0 -50
  156. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part32.txt +0 -47
  157. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part33.txt +0 -50
  158. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part34.txt +0 -50
  159. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part35.txt +0 -47
  160. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part36.txt +0 -50
  161. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part37.txt +0 -50
  162. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part38.txt +0 -47
  163. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part39.txt +0 -50
  164. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part4.txt +0 -50
  165. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part40.txt +0 -50
  166. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part41.txt +0 -47
  167. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part42.txt +0 -50
  168. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part43.txt +0 -50
  169. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part44.txt +0 -47
  170. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part45.txt +0 -50
  171. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part46.txt +0 -50
  172. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part47.txt +0 -47
  173. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part48.txt +0 -50
  174. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part49.txt +0 -50
  175. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part5.txt +0 -50
  176. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part50.txt +0 -47
  177. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part51.txt +0 -50
  178. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part52.txt +0 -50
  179. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part53.txt +0 -47
  180. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part54.txt +0 -50
  181. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part55.txt +0 -50
  182. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part56.txt +0 -47
  183. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part57.txt +0 -50
  184. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part58.txt +0 -50
  185. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part59.txt +0 -47
  186. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part6.txt +0 -47
  187. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part60.txt +0 -50
  188. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part61.txt +0 -50
  189. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part7.txt +0 -50
  190. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part8.txt +0 -50
  191. rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part9.txt +0 -47
  192. rasa/cli/project_templates/finance/domain/add_payee.yml +0 -47
  193. rasa/cli/project_templates/finance/domain/block_card.yml +0 -101
  194. rasa/cli/project_templates/finance/domain/check_balance.yml +0 -9
  195. rasa/cli/project_templates/finance/domain/default_actions.yml +0 -16
  196. rasa/cli/project_templates/finance/domain/default_flows.yml +0 -33
  197. rasa/cli/project_templates/finance/domain/list_payees.yml +0 -4
  198. rasa/cli/project_templates/finance/domain/remove_payee.yml +0 -16
  199. rasa/cli/project_templates/finance/domain/select_card.yml +0 -12
  200. rasa/cli/project_templates/finance/domain/transfer_money.yml +0 -79
  201. rasa/cli/project_templates/finance/endpoints.yml +0 -62
  202. rasa/cli/project_templates/finance/prompts/command-generator.jinja2 +0 -57
  203. rasa/cli/project_templates/finance/prompts/rephraser_demo_personality_prompt.jinja2 +0 -19
  204. rasa/cli/project_templates/finance/tests/conversation_repair/cancellations.yml +0 -12
  205. rasa/cli/project_templates/finance/tests/conversation_repair/cannot_handle.yml +0 -7
  206. rasa/cli/project_templates/finance/tests/conversation_repair/chitchat.yml +0 -7
  207. rasa/cli/project_templates/finance/tests/conversation_repair/clarification.yml +0 -9
  208. rasa/cli/project_templates/finance/tests/conversation_repair/completion.yml +0 -18
  209. rasa/cli/project_templates/finance/tests/conversation_repair/corrections.yml +0 -17
  210. rasa/cli/project_templates/finance/tests/conversation_repair/digressions.yml +0 -32
  211. rasa/cli/project_templates/finance/tests/conversation_repair/human_handoff.yml +0 -21
  212. rasa/cli/project_templates/finance/tests/conversation_repair/skipping_collect_steps.yml +0 -16
  213. rasa/cli/project_templates/finance/tests/demo_scripts/main.yml +0 -16
  214. rasa/cli/project_templates/finance/tests/happy_paths/balance_verification.yml +0 -15
  215. rasa/cli/project_templates/finance/tests/happy_paths/banking_questions.yml +0 -12
  216. rasa/cli/project_templates/finance/tests/happy_paths/card_blocking.yml +0 -52
  217. rasa/cli/project_templates/finance/tests/happy_paths/money_transfer.yml +0 -136
  218. rasa/cli/project_templates/finance/tests/happy_paths/payee_management.yml +0 -27
  219. rasa/cli/project_templates/finance/tests/happy_paths/user_greeted.yml +0 -5
  220. rasa/cli/project_templates/plain/actions/__init__.py +0 -0
  221. rasa/cli/project_templates/plain/config.yml +0 -17
  222. rasa/cli/project_templates/plain/credentials.yml +0 -33
  223. rasa/cli/project_templates/plain/data/patterns/pattern_session_start.yml +0 -7
  224. rasa/cli/project_templates/plain/domain.yml +0 -5
  225. rasa/cli/project_templates/plain/endpoints.yml +0 -58
  226. rasa/cli/project_templates/telco/actions/__init__.py +0 -0
  227. rasa/cli/project_templates/telco/actions/actions_billing.py +0 -197
  228. rasa/cli/project_templates/telco/actions/actions_get_data_from_db.py +0 -43
  229. rasa/cli/project_templates/telco/actions/actions_run_diagnostics.py +0 -23
  230. rasa/cli/project_templates/telco/actions/actions_session_start.py +0 -13
  231. rasa/cli/project_templates/telco/config.yml +0 -25
  232. rasa/cli/project_templates/telco/credentials.yml +0 -33
  233. rasa/cli/project_templates/telco/csvs/billing.csv +0 -10
  234. rasa/cli/project_templates/telco/csvs/customers.csv +0 -5
  235. rasa/cli/project_templates/telco/data/flows/flow_global.yml +0 -5
  236. rasa/cli/project_templates/telco/data/flows/flow_reboot_router.yml +0 -8
  237. rasa/cli/project_templates/telco/data/flows/flow_reset_router.yml +0 -7
  238. rasa/cli/project_templates/telco/data/flows/flow_solve_internet_issue.yml +0 -73
  239. rasa/cli/project_templates/telco/data/flows/flow_undertand_bill.yml +0 -45
  240. rasa/cli/project_templates/telco/data/patterns/pattern_completed.yml +0 -7
  241. rasa/cli/project_templates/telco/data/patterns/pattern_human_handoff.yml +0 -6
  242. rasa/cli/project_templates/telco/data/patterns/pattern_search.yml +0 -7
  243. rasa/cli/project_templates/telco/data/patterns/pattern_session_start.yml +0 -9
  244. rasa/cli/project_templates/telco/docs/reset_vs_rboot_router.txt +0 -1
  245. rasa/cli/project_templates/telco/docs/restart_router.txt +0 -6
  246. rasa/cli/project_templates/telco/docs/run_speed_test.txt +0 -6
  247. rasa/cli/project_templates/telco/domain/domain_global.yml +0 -29
  248. rasa/cli/project_templates/telco/domain/domain_patterns.yml +0 -17
  249. rasa/cli/project_templates/telco/domain/domain_reboot_router.yml +0 -20
  250. rasa/cli/project_templates/telco/domain/domain_reset_router.yml +0 -11
  251. rasa/cli/project_templates/telco/domain/domain_run_speed_test.yml +0 -24
  252. rasa/cli/project_templates/telco/domain/domain_solve_internet_issue.yml +0 -74
  253. rasa/cli/project_templates/telco/domain/domain_undertand_bill.yml +0 -102
  254. rasa/cli/project_templates/telco/endpoints.yml +0 -60
  255. rasa/cli/project_templates/telco/prompts/command-generator.jinja2 +0 -57
  256. rasa/cli/project_templates/telco/tests/e2e_results_failed.yml +0 -62
  257. rasa/cli/project_templates/telco/tests/e2e_results_passed.yml +0 -130
  258. rasa/cli/project_templates/telco/tests/e2e_test_cases/billing_test_cases.yml +0 -68
  259. rasa/cli/project_templates/telco/tests/e2e_test_cases/global_test_cases.yml +0 -13
  260. rasa/cli/project_templates/telco/tests/e2e_test_cases/internet_slow_test_case.yml +0 -47
  261. rasa/cli/project_templates/telco/tests/e2e_test_cases/out_of_scope_test_case.yml +0 -21
  262. rasa/cli/project_templates/telco/tests/e2e_test_cases/patterns_test_cases.yml +0 -15
  263. rasa/shared/importers/static.py +0 -63
  264. rasa/utils/openapi.py +0 -144
  265. {rasa_pro-3.13.1a17.dist-info → rasa_pro-3.13.1.dev1.dist-info}/NOTICE +0 -0
  266. {rasa_pro-3.13.1a17.dist-info → rasa_pro-3.13.1.dev1.dist-info}/WHEEL +0 -0
  267. {rasa_pro-3.13.1a17.dist-info → rasa_pro-3.13.1.dev1.dist-info}/entry_points.txt +0 -0
@@ -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:
@@ -5,11 +5,15 @@ from typing import Optional
5
5
  import structlog
6
6
 
7
7
  from rasa.model_manager import config
8
- from rasa.utils.io import subpath
8
+ from rasa.shared.exceptions import RasaException
9
9
 
10
10
  structlogger = structlog.get_logger()
11
11
 
12
12
 
13
+ class InvalidPathException(RasaException):
14
+ """Raised if a path is invalid - e.g. path traversal is detected."""
15
+
16
+
13
17
  def write_encoded_data_to_file(encoded_data: bytes, file: str) -> None:
14
18
  """Write base64 encoded data to a file."""
15
19
  # create the directory if it does not exist of the parent directory
@@ -49,6 +53,30 @@ def logs_path(action_id: str) -> str:
49
53
  return subpath(logs_base_path(), f"{action_id}.txt")
50
54
 
51
55
 
56
+ def subpath(parent: str, child: str) -> str:
57
+ """Return the path to the child directory of the parent directory.
58
+
59
+ Ensures, that child doesn't navigate to parent directories. Prevents
60
+ path traversal. Raises an InvalidPathException if the path is invalid.
61
+
62
+ Based on Snyk's directory traversal mitigation:
63
+ https://learn.snyk.io/lesson/directory-traversal/
64
+ """
65
+ safe_path = os.path.abspath(os.path.join(parent, child))
66
+ parent = os.path.abspath(parent)
67
+
68
+ common_base = os.path.commonpath([parent, safe_path])
69
+ if common_base != parent:
70
+ raise InvalidPathException(f"Invalid path: {safe_path}")
71
+
72
+ if os.path.basename(safe_path) != child:
73
+ raise InvalidPathException(
74
+ f"Invalid path - path traversal detected: {safe_path}"
75
+ )
76
+
77
+ return safe_path
78
+
79
+
52
80
  def get_logs_content(action_id: str) -> Optional[str]:
53
81
  """Return the content of the log file for a given action id."""
54
82
  try:
rasa/monkey_patches.py ADDED
@@ -0,0 +1,91 @@
1
+ import os
2
+ import traceback
3
+ from typing import Any, Optional
4
+
5
+ from litellm.secret_managers.main import str_to_bool
6
+ from packaging.version import Version
7
+
8
+
9
+ def litellm_langfuse_logger_init_fixed(
10
+ self: Any, # we should not import LangfuseLogger class before we patch it
11
+ langfuse_public_key: Optional[str] = None,
12
+ langfuse_secret: Optional[str] = None,
13
+ langfuse_host: str = "https://cloud.langfuse.com",
14
+ flush_interval: int = 1,
15
+ ) -> None:
16
+ """Monkeypatched version of LangfuseLogger.__init__ from the LiteLLM library.
17
+
18
+ This patched version removes a call that fetched the `project_id` from
19
+ Langfuse Cloud even when it was already set via environment variables.
20
+ In the original implementation, this call was made *before* initializing
21
+ the LangfuseClient, which caused the application to freeze for up to 60 seconds.
22
+
23
+ By removing this premature call, the monkeypatch avoids the unnecessary network
24
+ request and prevents the timeout/freeze issue.
25
+
26
+ This workaround can be removed once the underlying bug is resolved in LiteLLM:
27
+ https://github.com/BerriAI/litellm/issues/7732
28
+ """
29
+ try:
30
+ import langfuse
31
+ from langfuse import Langfuse
32
+ except Exception as e:
33
+ raise Exception(
34
+ f"\033[91mLangfuse not installed, try running 'pip install langfuse' "
35
+ f"to fix this error: {e}\n{traceback.format_exc()}\033[0m"
36
+ )
37
+ # Instance variables
38
+ self.secret_key = langfuse_secret or os.getenv("LANGFUSE_SECRET_KEY", "")
39
+ self.public_key = langfuse_public_key or os.getenv("LANGFUSE_PUBLIC_KEY", "")
40
+
41
+ self.langfuse_host = langfuse_host or os.getenv(
42
+ "LANGFUSE_HOST", "https://cloud.langfuse.com"
43
+ )
44
+ self.langfuse_host.replace("http://", "https://")
45
+ if not self.langfuse_host.startswith("https://"):
46
+ self.langfuse_host = "https://" + self.langfuse_host
47
+
48
+ self.langfuse_release = os.getenv("LANGFUSE_RELEASE")
49
+ self.langfuse_debug = os.getenv("LANGFUSE_DEBUG")
50
+ self.langfuse_flush_interval = (
51
+ os.getenv("LANGFUSE_FLUSH_INTERVAL") or flush_interval
52
+ )
53
+
54
+ parameters = {
55
+ "public_key": self.public_key,
56
+ "secret_key": self.secret_key,
57
+ "host": self.langfuse_host,
58
+ "release": self.langfuse_release,
59
+ "debug": self.langfuse_debug,
60
+ "flush_interval": self.langfuse_flush_interval, # flush interval in seconds
61
+ }
62
+
63
+ if Version(langfuse.version.__version__) >= Version("2.6.0"):
64
+ parameters["sdk_integration"] = "litellm"
65
+
66
+ self.Langfuse = Langfuse(**parameters)
67
+
68
+ if os.getenv("UPSTREAM_LANGFUSE_SECRET_KEY") is not None:
69
+ upstream_langfuse_debug = (
70
+ str_to_bool(self.upstream_langfuse_debug)
71
+ if self.upstream_langfuse_debug is not None
72
+ else None
73
+ )
74
+ self.upstream_langfuse_secret_key = os.getenv("UPSTREAM_LANGFUSE_SECRET_KEY")
75
+ self.upstream_langfuse_public_key = os.getenv("UPSTREAM_LANGFUSE_PUBLIC_KEY")
76
+ self.upstream_langfuse_host = os.getenv("UPSTREAM_LANGFUSE_HOST")
77
+ self.upstream_langfuse_release = os.getenv("UPSTREAM_LANGFUSE_RELEASE")
78
+ self.upstream_langfuse_debug = os.getenv("UPSTREAM_LANGFUSE_DEBUG")
79
+ self.upstream_langfuse = Langfuse(
80
+ public_key=self.upstream_langfuse_public_key,
81
+ secret_key=self.upstream_langfuse_secret_key,
82
+ host=self.upstream_langfuse_host,
83
+ release=self.upstream_langfuse_release,
84
+ debug=(
85
+ upstream_langfuse_debug
86
+ if upstream_langfuse_debug is not None
87
+ else False
88
+ ),
89
+ )
90
+ else:
91
+ self.upstream_langfuse = None
rasa/shared/constants.py CHANGED
@@ -350,6 +350,12 @@ ROLE_SYSTEM = "system"
350
350
  REFILL_UTTER = "refill_utter"
351
351
  REJECTIONS = "rejections"
352
352
 
353
+ # Used for Langfuse metadata
354
+ LANGFUSE_METADATA_USER_ID = "trace_user_id"
355
+ LANGFUSE_METADATA_SESSION_ID = "session_id"
356
+ LANGFUSE_CUSTOM_METADATA_DICT = "trace_metadata"
357
+ LANGFUSE_TAGS = "tags"
358
+
353
359
  # Constants for extractive search FAQ parsing (QA pairs from input documents)
354
360
  FAQ_DOCUMENT_METADATA_TITLE = "title"
355
361
  FAQ_DOCUMENT_METADATA_ANSWER = "answer"
@@ -98,8 +98,6 @@ IS_RETRIEVAL_INTENT_KEY = "is_retrieval_intent"
98
98
  ENTITY_ROLES_KEY = "roles"
99
99
  ENTITY_GROUPS_KEY = "groups"
100
100
  ENTITY_FEATURIZATION_KEY = "influence_conversation"
101
- STORE_ENTITIES_AS_SLOTS_KEY = "store_entities_as_slots"
102
- DOMAIN_CONFIG_KEY = "config"
103
101
 
104
102
  KEY_SLOTS = "slots"
105
103
  KEY_INTENTS = "intents"
@@ -148,8 +146,6 @@ MERGE_FUNC_MAPPING: Dict[Text, Callable[..., Any]] = {
148
146
  KEY_FORMS: rasa.shared.utils.common.merge_dicts,
149
147
  }
150
148
 
151
- DEFAULT_STORE_ENTITIES_AS_SLOTS = True
152
-
153
149
  DICT_DATA_KEYS = [
154
150
  key
155
151
  for key, value in MERGE_FUNC_MAPPING.items()
@@ -322,7 +318,7 @@ class Domain:
322
318
  actions = cls._collect_action_names(domain_actions)
323
319
 
324
320
  additional_arguments = {
325
- **data.get(DOMAIN_CONFIG_KEY, {}),
321
+ **data.get("config", {}),
326
322
  "actions_which_explicitly_need_domain": (
327
323
  cls._collect_actions_which_explicitly_need_domain(domain_actions)
328
324
  ),
@@ -472,9 +468,9 @@ class Domain:
472
468
  return domain_dict
473
469
 
474
470
  if override:
475
- config = domain_dict.get(DOMAIN_CONFIG_KEY, {})
471
+ config = domain_dict.get("config", {})
476
472
  for key, val in config.items():
477
- combined[DOMAIN_CONFIG_KEY][key] = val
473
+ combined["config"][key] = val
478
474
 
479
475
  if (
480
476
  override
@@ -512,10 +508,10 @@ class Domain:
512
508
  return combined
513
509
 
514
510
  def partial_merge(self, other: Domain) -> Domain:
515
- """Returns a new Domain with intersection-based merging.
516
-
517
- For each domain section only overwrite items that already exist in self.
518
- Brand-new items in `other` are ignored.
511
+ """
512
+ Returns a new Domain with intersection-based merging:
513
+ - For each domain section only overwrite items that already exist in self.
514
+ - Brand-new items in `other` are ignored.
519
515
 
520
516
  Args:
521
517
  other: The domain to merge with.
@@ -547,9 +543,9 @@ class Domain:
547
543
  return Domain.from_dict(updated_self)
548
544
 
549
545
  def difference(self, other: Domain) -> Domain:
550
- """Returns a new Domain containing items in `self` that are NOT in `other`.
551
-
552
- Uses simple equality checks for dict/list items.
546
+ """
547
+ Returns a new Domain containing items in `self` that are NOT in `other`,
548
+ using simple equality checks for dict/list items.
553
549
 
554
550
  Args:
555
551
  other: The domain to compare with.
@@ -602,16 +598,9 @@ class Domain:
602
598
  ) -> Dict:
603
599
  # add the config, session_config and training data version defaults
604
600
  # if not included in the original domain dict
605
- if (
606
- DOMAIN_CONFIG_KEY not in data
607
- and store_entities_as_slots != DEFAULT_STORE_ENTITIES_AS_SLOTS
608
- ):
601
+ if "config" not in data and not store_entities_as_slots:
609
602
  data.update(
610
- {
611
- DOMAIN_CONFIG_KEY: {
612
- STORE_ENTITIES_AS_SLOTS_KEY: store_entities_as_slots
613
- }
614
- }
603
+ {"config": {"store_entities_as_slots": store_entities_as_slots}}
615
604
  )
616
605
 
617
606
  if SESSION_CONFIG_KEY not in data:
@@ -948,7 +937,7 @@ class Domain:
948
937
  forms: Union[Dict[Text, Any], List[Text]],
949
938
  data: Dict,
950
939
  action_texts: Optional[List[Text]] = None,
951
- store_entities_as_slots: bool = DEFAULT_STORE_ENTITIES_AS_SLOTS,
940
+ store_entities_as_slots: bool = True,
952
941
  session_config: SessionConfig = SessionConfig.default(),
953
942
  **kwargs: Any,
954
943
  ) -> None:
@@ -1722,45 +1711,9 @@ class Domain:
1722
1711
  else:
1723
1712
  return True
1724
1713
 
1725
- def _uses_custom_session_config(self) -> bool:
1726
- """Check if the domain uses a custom session config."""
1727
- return self._data.get(SESSION_CONFIG_KEY) != SessionConfig.default().as_dict()
1728
-
1729
- def _uses_custom_domain_config(self) -> bool:
1730
- """Check if the domain uses a custom domain config."""
1731
- return self._data.get(DOMAIN_CONFIG_KEY) != {
1732
- STORE_ENTITIES_AS_SLOTS_KEY: DEFAULT_STORE_ENTITIES_AS_SLOTS
1733
- }
1734
-
1735
- def _cleaned_json_data(self) -> Dict[Text, Any]:
1736
- """Remove default values from the domain data.
1737
-
1738
- Only retains data that was customized by the user.
1739
-
1740
- Returns:
1741
- A cleaned dictionary version of the domain.
1742
- """
1743
- cleaned_data = copy.deepcopy(self._data)
1744
-
1745
- # Remove default config if it only contains store_entities_as_slots: False
1746
- if DOMAIN_CONFIG_KEY in cleaned_data and not self._uses_custom_domain_config():
1747
- del cleaned_data[DOMAIN_CONFIG_KEY]
1748
-
1749
- # Remove default session config if it matches the default values
1750
- if (
1751
- SESSION_CONFIG_KEY in cleaned_data
1752
- and not self._uses_custom_session_config()
1753
- ):
1754
- del cleaned_data[SESSION_CONFIG_KEY]
1755
-
1756
- return cleaned_data
1757
-
1758
- def as_dict(self, should_clean_json: bool = False) -> Dict[Text, Any]:
1714
+ def as_dict(self) -> Dict[Text, Any]:
1759
1715
  """Return serialized `Domain`."""
1760
- if should_clean_json:
1761
- return self._cleaned_json_data()
1762
- else:
1763
- return self._data
1716
+ return self._data
1764
1717
 
1765
1718
  @staticmethod
1766
1719
  def get_responses_with_multilines(
@@ -52,13 +52,7 @@ def step_from_json(flow_id: Text, data: Dict[Text, Any]) -> FlowStep:
52
52
  return SetSlotsFlowStep.from_json(flow_id, data)
53
53
  if "noop" in data:
54
54
  return NoOperationFlowStep.from_json(flow_id, data)
55
-
56
- required_properties = ["action", "collect", "link", "call", "set_slots", "noop"]
57
- raise RasaException(
58
- f"Failed to parse step from json. Unknown type for {data}. "
59
- f"At lest one of the following properties is required: "
60
- f"{', '.join(required_properties)}"
61
- )
55
+ raise RasaException(f"Failed to parse step from json. Unknown type for {data}.")
62
56
 
63
57
 
64
58
  @dataclass
@@ -262,9 +262,12 @@ class YamlFlowsWriter:
262
262
  Returns:
263
263
  The dumped YAML.
264
264
  """
265
- return dump_obj_as_yaml_to_string(
266
- {KEY_FLOWS: get_flows_as_json(flows, should_clean_json)}
267
- )
265
+ dump = {}
266
+ for flow in flows:
267
+ dumped_flow = get_flow_as_json(flow, should_clean_json)
268
+ del dumped_flow["id"]
269
+ dump[flow.id] = dumped_flow
270
+ return dump_obj_as_yaml_to_string({KEY_FLOWS: dump})
268
271
 
269
272
  @staticmethod
270
273
  def dump(
@@ -421,20 +424,9 @@ def process_yaml_content(yaml_content: Dict[str, Any]) -> Dict[str, Any]:
421
424
  return yaml_content
422
425
 
423
426
 
424
- def get_flows_as_json(
425
- flows: FlowsList, should_clean_json: bool = False
426
- ) -> Dict[str, Any]:
427
- """Get the flows as a JSON dictionary."""
428
- dump = {}
429
- for flow in flows:
430
- dumped_flow = get_flow_as_json(flow, should_clean_json)
431
- del dumped_flow["id"]
432
- dump[flow.id] = dumped_flow
433
- return dump
434
-
435
-
436
427
  def get_flow_as_json(flow: Flow, should_clean_json: bool = False) -> Dict[str, Any]:
437
- """Clean the Flow JSON by removing default values and empty fields.
428
+ """
429
+ Clean the Flow JSON by removing default values and empty fields.
438
430
 
439
431
  Args:
440
432
  flow: The Flow object to clean.
rasa/shared/core/slots.py CHANGED
@@ -273,14 +273,10 @@ class Slot(ABC):
273
273
  try:
274
274
  return rasa.shared.utils.common.class_from_module_path(type_name)
275
275
  except (ImportError, AttributeError):
276
- known_types = [
277
- cls.type_name for cls in rasa.shared.utils.common.all_subclasses(Slot)
278
- ]
279
276
  raise InvalidSlotTypeException(
280
277
  f"Failed to find slot type, '{type_name}' is neither a known type nor "
281
278
  f"user-defined. If you are creating your own slot type, make "
282
279
  f"sure its module path is correct. "
283
- f"Known types: {', '.join(known_types)} "
284
280
  f"You can find all build in types at {DOCS_URL_SLOTS}"
285
281
  )
286
282
 
@@ -207,12 +207,6 @@ class TrainingDataImporter(ABC):
207
207
  )
208
208
  ]
209
209
 
210
- return TrainingDataImporter.wrap_in_builtins(importers)
211
-
212
- @staticmethod
213
- def wrap_in_builtins(
214
- importers: List["TrainingDataImporter"],
215
- ) -> "TrainingDataImporter":
216
210
  return LanguageImporter(
217
211
  E2EImporter(
218
212
  FlowSyncImporter(ResponsesSyncImporter(CombinedDataImporter(importers)))
@@ -1,37 +1,9 @@
1
- from typing import Any, Dict, Iterable, List, Optional, Text
2
-
3
- from pydantic import BaseModel, Field
1
+ from typing import Iterable, List, Optional, Text
4
2
 
5
3
  from rasa.shared.core.domain import Domain
6
4
  from rasa.shared.core.flows import FlowsList
7
- from rasa.shared.core.flows.yaml_flows_io import get_flows_as_json
8
5
  from rasa.shared.core.training_data.structures import StoryGraph
9
- from rasa.shared.importers.importer import TrainingDataImporter
10
- from rasa.shared.nlu.training_data.formats.rasa_yaml import RasaYAMLWriter
11
6
  from rasa.shared.nlu.training_data.training_data import TrainingData
12
- from rasa.utils.json_utils import extract_values
13
-
14
-
15
- class CALMUserData(BaseModel):
16
- """All pieces that will be uploaded to Rasa Studio."""
17
-
18
- flows: Dict[str, Any] = Field(default_factory=dict)
19
- domain: Dict[str, Any] = Field(default_factory=dict)
20
- config: Dict[str, Any] = Field(default_factory=dict)
21
- endpoints: Dict[str, Any] = Field(default_factory=dict)
22
- nlu: Dict[str, Any] = Field(default_factory=dict)
23
-
24
-
25
- DOMAIN_KEYS = [
26
- "version",
27
- "actions",
28
- "responses",
29
- "slots",
30
- "intents",
31
- "entities",
32
- "forms",
33
- "session_config",
34
- ]
35
7
 
36
8
 
37
9
  def training_data_from_paths(paths: Iterable[Text], language: Text) -> TrainingData:
@@ -62,51 +34,3 @@ def flows_from_paths(files: List[Text]) -> FlowsList:
62
34
  )
63
35
  flows.validate()
64
36
  return flows
65
-
66
-
67
- def extract_calm_import_parts_from_importer(
68
- importer: TrainingDataImporter,
69
- config: Optional[Dict[str, Any]] = None,
70
- endpoints: Optional[Dict[str, Any]] = None,
71
- ) -> CALMUserData:
72
- """Extracts CALMUserData from a TrainingDataImporter.
73
-
74
- Args:
75
- importer: The training data importer
76
- data_paths: The path(s) to the training data for flows
77
- config: Optional config dict, if not provided will use importer.get_config()
78
- endpoints: Optional endpoints dict, defaults to empty dict
79
-
80
- Returns:
81
- CALMUserData containing flows, domain, config, endpoints, and nlu data
82
- """
83
- # Extract config
84
- if config is None:
85
- config = importer.get_config()
86
-
87
- # Extract domain
88
- domain_from_files = importer.get_user_domain().as_dict()
89
- domain = extract_values(domain_from_files, DOMAIN_KEYS)
90
-
91
- # Extract flows
92
- flows = importer.get_user_flows()
93
- flows_dict = get_flows_as_json(flows)
94
-
95
- # Extract NLU data
96
- nlu_data = importer.get_nlu_data()
97
- nlu_examples = nlu_data.filter_training_examples(
98
- lambda ex: ex.get("intent") in nlu_data.intents
99
- )
100
- nlu_dict = RasaYAMLWriter().training_data_to_dict(nlu_examples)
101
-
102
- # Use provided endpoints or default to empty dict
103
- if endpoints is None:
104
- endpoints = {}
105
-
106
- return CALMUserData(
107
- flows=flows_dict or {},
108
- domain=domain or {},
109
- config=config or {},
110
- endpoints=endpoints or {},
111
- nlu=nlu_dict or {},
112
- )
@@ -4,3 +4,13 @@ LITE_LLM_API_KEY_FIELD = "api_key"
4
4
  LITE_LLM_API_VERSION_FIELD = "api_version"
5
5
  LITE_LLM_MODEL_FIELD = "model"
6
6
  LITE_LLM_AZURE_AD_TOKEN = "azure_ad_token"
7
+
8
+ # Enable or disable Langfuse integration
9
+ RASA_LANGFUSE_INTEGRATION_ENABLED_ENV_VAR = "RASA_LANGFUSE_INTEGRATION_ENABLED"
10
+
11
+ # Langfuse configuration
12
+ LANGFUSE_CALLBACK_NAME = "langfuse"
13
+ LANGFUSE_HOST_ENV_VAR = "LANGFUSE_HOST"
14
+ LANGFUSE_PROJECT_ID_ENV_VAR = "LANGFUSE_PROJECT_ID"
15
+ LANGFUSE_PUBLIC_KEY_ENV_VAR = "LANGFUSE_PUBLIC_KEY"
16
+ LANGFUSE_SECRET_KEY_ENV_VAR = "LANGFUSE_SECRET_KEY"
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  import logging
4
4
  from abc import abstractmethod
5
- from typing import Any, Dict, List, Union, cast
5
+ from typing import Any, Dict, List, Optional, Union, cast
6
6
 
7
7
  import structlog
8
8
  from litellm import acompletion, completion, validate_environment
@@ -126,7 +126,11 @@ class _BaseLiteLLMClient:
126
126
  raise ProviderClientValidationError(event_info)
127
127
 
128
128
  @suppress_logs(log_level=logging.WARNING)
129
- def completion(self, messages: Union[List[dict], List[str], str]) -> LLMResponse:
129
+ def completion(
130
+ self,
131
+ messages: Union[List[dict], List[str], str],
132
+ metadata: Optional[Dict[str, Any]] = None,
133
+ ) -> LLMResponse:
130
134
  """Synchronously generate completions for given list of messages.
131
135
 
132
136
  Args:
@@ -138,6 +142,7 @@ class _BaseLiteLLMClient:
138
142
  - a list of messages. Each message is a string and will be formatted
139
143
  as a user message.
140
144
  - a single message as a string which will be formatted as user message.
145
+ metadata: Optional metadata to be passed to the LLM call.
141
146
 
142
147
  Returns:
143
148
  List of message completions.
@@ -155,7 +160,9 @@ class _BaseLiteLLMClient:
155
160
 
156
161
  @suppress_logs(log_level=logging.WARNING)
157
162
  async def acompletion(
158
- self, messages: Union[List[dict], List[str], str]
163
+ self,
164
+ messages: Union[List[dict], List[str], str],
165
+ metadata: Optional[Dict[str, Any]] = None,
159
166
  ) -> LLMResponse:
160
167
  """Asynchronously generate completions for given list of messages.
161
168
 
@@ -168,6 +175,7 @@ class _BaseLiteLLMClient:
168
175
  - a list of messages. Each message is a string and will be formatted
169
176
  as a user message.
170
177
  - a single message as a string which will be formatted as user message.
178
+ metadata: Optional metadata to be passed to the LLM call.
171
179
 
172
180
  Returns:
173
181
  List of message completions.
@@ -178,7 +186,9 @@ class _BaseLiteLLMClient:
178
186
  try:
179
187
  formatted_messages = self._get_formatted_messages(messages)
180
188
  arguments = resolve_environment_variables(self._completion_fn_args)
181
- response = await acompletion(messages=formatted_messages, **arguments)
189
+ response = await acompletion(
190
+ messages=formatted_messages, metadata=metadata, **arguments
191
+ )
182
192
  return self._format_response(response)
183
193
  except Exception as e:
184
194
  message = ""