rasa-pro 3.8.18__py3-none-any.whl → 3.9.15__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 (278) hide show
  1. README.md +6 -42
  2. rasa/__main__.py +14 -9
  3. rasa/anonymization/anonymization_pipeline.py +0 -1
  4. rasa/anonymization/anonymization_rule_executor.py +3 -3
  5. rasa/anonymization/utils.py +4 -3
  6. rasa/api.py +2 -2
  7. rasa/cli/arguments/default_arguments.py +1 -1
  8. rasa/cli/arguments/run.py +2 -2
  9. rasa/cli/arguments/test.py +1 -1
  10. rasa/cli/arguments/train.py +10 -10
  11. rasa/cli/e2e_test.py +27 -7
  12. rasa/cli/export.py +0 -1
  13. rasa/cli/license.py +3 -3
  14. rasa/cli/project_templates/calm/actions/action_template.py +1 -1
  15. rasa/cli/project_templates/calm/config.yml +1 -1
  16. rasa/cli/project_templates/calm/credentials.yml +1 -1
  17. rasa/cli/project_templates/calm/data/flows/add_contact.yml +1 -1
  18. rasa/cli/project_templates/calm/data/flows/remove_contact.yml +1 -1
  19. rasa/cli/project_templates/calm/domain/add_contact.yml +8 -2
  20. rasa/cli/project_templates/calm/domain/list_contacts.yml +3 -0
  21. rasa/cli/project_templates/calm/domain/remove_contact.yml +9 -2
  22. rasa/cli/project_templates/calm/domain/shared.yml +5 -0
  23. rasa/cli/project_templates/calm/endpoints.yml +4 -4
  24. rasa/cli/project_templates/default/actions/actions.py +1 -1
  25. rasa/cli/project_templates/default/config.yml +5 -5
  26. rasa/cli/project_templates/default/credentials.yml +1 -1
  27. rasa/cli/project_templates/default/endpoints.yml +4 -4
  28. rasa/cli/project_templates/default/tests/test_stories.yml +1 -1
  29. rasa/cli/project_templates/tutorial/config.yml +1 -1
  30. rasa/cli/project_templates/tutorial/credentials.yml +1 -1
  31. rasa/cli/project_templates/tutorial/data/patterns.yml +6 -0
  32. rasa/cli/project_templates/tutorial/domain.yml +4 -0
  33. rasa/cli/project_templates/tutorial/endpoints.yml +6 -6
  34. rasa/cli/run.py +0 -1
  35. rasa/cli/scaffold.py +3 -2
  36. rasa/cli/studio/download.py +11 -0
  37. rasa/cli/studio/studio.py +180 -24
  38. rasa/cli/studio/upload.py +0 -8
  39. rasa/cli/telemetry.py +18 -6
  40. rasa/cli/utils.py +21 -10
  41. rasa/cli/x.py +3 -2
  42. rasa/constants.py +1 -1
  43. rasa/core/actions/action.py +90 -315
  44. rasa/core/actions/action_exceptions.py +24 -0
  45. rasa/core/actions/constants.py +3 -0
  46. rasa/core/actions/custom_action_executor.py +188 -0
  47. rasa/core/actions/forms.py +11 -7
  48. rasa/core/actions/grpc_custom_action_executor.py +251 -0
  49. rasa/core/actions/http_custom_action_executor.py +140 -0
  50. rasa/core/actions/loops.py +3 -0
  51. rasa/core/actions/two_stage_fallback.py +1 -1
  52. rasa/core/agent.py +2 -4
  53. rasa/core/brokers/pika.py +1 -2
  54. rasa/core/channels/audiocodes.py +1 -1
  55. rasa/core/channels/botframework.py +0 -1
  56. rasa/core/channels/callback.py +0 -1
  57. rasa/core/channels/console.py +6 -8
  58. rasa/core/channels/development_inspector.py +1 -1
  59. rasa/core/channels/facebook.py +0 -3
  60. rasa/core/channels/hangouts.py +0 -6
  61. rasa/core/channels/inspector/dist/assets/{arc-5623b6dc.js → arc-b6e548fe.js} +1 -1
  62. rasa/core/channels/inspector/dist/assets/{c4Diagram-d0fbc5ce-685c106a.js → c4Diagram-d0fbc5ce-fa03ac9e.js} +1 -1
  63. rasa/core/channels/inspector/dist/assets/{classDiagram-936ed81e-8cbed007.js → classDiagram-936ed81e-ee67392a.js} +1 -1
  64. rasa/core/channels/inspector/dist/assets/{classDiagram-v2-c3cb15f1-5889cf12.js → classDiagram-v2-c3cb15f1-9b283fae.js} +1 -1
  65. rasa/core/channels/inspector/dist/assets/{createText-62fc7601-24c249d7.js → createText-62fc7601-8b6fcc2a.js} +1 -1
  66. rasa/core/channels/inspector/dist/assets/{edges-f2ad444c-7dd06a75.js → edges-f2ad444c-22e77f4f.js} +1 -1
  67. rasa/core/channels/inspector/dist/assets/{erDiagram-9d236eb7-62c1e54c.js → erDiagram-9d236eb7-60ffc87f.js} +1 -1
  68. rasa/core/channels/inspector/dist/assets/{flowDb-1972c806-ce49b86f.js → flowDb-1972c806-9dd802e4.js} +1 -1
  69. rasa/core/channels/inspector/dist/assets/{flowDiagram-7ea5b25a-4067e48f.js → flowDiagram-7ea5b25a-5fa1912f.js} +1 -1
  70. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-855bc5b3-1844e5a5.js +1 -0
  71. rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-abe16c3d-59fe4051.js → flowchart-elk-definition-abe16c3d-622a1fd2.js} +1 -1
  72. rasa/core/channels/inspector/dist/assets/{ganttDiagram-9b5ea136-47e3a43b.js → ganttDiagram-9b5ea136-e285a63a.js} +1 -1
  73. rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-99d0ae7c-5a2ac0d9.js → gitGraphDiagram-99d0ae7c-f237bdca.js} +1 -1
  74. rasa/core/channels/inspector/dist/assets/{index-2c4b9a3b-dfb8efc4.js → index-2c4b9a3b-4b03d70e.js} +1 -1
  75. rasa/core/channels/inspector/dist/assets/{index-268a75c0.js → index-a5d3e69d.js} +4 -4
  76. rasa/core/channels/inspector/dist/assets/{infoDiagram-736b4530-b0c470f2.js → infoDiagram-736b4530-72a0fa5f.js} +1 -1
  77. rasa/core/channels/inspector/dist/assets/{journeyDiagram-df861f2b-2edb829a.js → journeyDiagram-df861f2b-82218c41.js} +1 -1
  78. rasa/core/channels/inspector/dist/assets/{layout-b6873d69.js → layout-78cff630.js} +1 -1
  79. rasa/core/channels/inspector/dist/assets/{line-1efc5781.js → line-5038b469.js} +1 -1
  80. rasa/core/channels/inspector/dist/assets/{linear-661e9b94.js → linear-c4fc4098.js} +1 -1
  81. rasa/core/channels/inspector/dist/assets/{mindmap-definition-beec6740-2d2e727f.js → mindmap-definition-beec6740-c33c8ea6.js} +1 -1
  82. rasa/core/channels/inspector/dist/assets/{pieDiagram-dbbf0591-9d3ea93d.js → pieDiagram-dbbf0591-a8d03059.js} +1 -1
  83. rasa/core/channels/inspector/dist/assets/{quadrantDiagram-4d7f4fd6-06a178a2.js → quadrantDiagram-4d7f4fd6-6a0e56b2.js} +1 -1
  84. rasa/core/channels/inspector/dist/assets/{requirementDiagram-6fc4c22a-0bfedffc.js → requirementDiagram-6fc4c22a-2dc7c7bd.js} +1 -1
  85. rasa/core/channels/inspector/dist/assets/{sankeyDiagram-8f13d901-d76d0a04.js → sankeyDiagram-8f13d901-2360fe39.js} +1 -1
  86. rasa/core/channels/inspector/dist/assets/{sequenceDiagram-b655622a-37bb4341.js → sequenceDiagram-b655622a-41b9f9ad.js} +1 -1
  87. rasa/core/channels/inspector/dist/assets/{stateDiagram-59f0c015-f52f7f57.js → stateDiagram-59f0c015-0aad326f.js} +1 -1
  88. rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-2b26beab-4a986a20.js → stateDiagram-v2-2b26beab-9847d984.js} +1 -1
  89. rasa/core/channels/inspector/dist/assets/{styles-080da4f6-7dd9ae12.js → styles-080da4f6-564d890e.js} +1 -1
  90. rasa/core/channels/inspector/dist/assets/{styles-3dcbcfbf-46e1ca14.js → styles-3dcbcfbf-38957613.js} +1 -1
  91. rasa/core/channels/inspector/dist/assets/{styles-9c745c82-4a97439a.js → styles-9c745c82-f0fc6921.js} +1 -1
  92. rasa/core/channels/inspector/dist/assets/{svgDrawCommon-4835440b-823917a3.js → svgDrawCommon-4835440b-ef3c5a77.js} +1 -1
  93. rasa/core/channels/inspector/dist/assets/{timeline-definition-5b62e21b-9ea72896.js → timeline-definition-5b62e21b-bf3e91c1.js} +1 -1
  94. rasa/core/channels/inspector/dist/assets/{xychartDiagram-2b33534f-b631a8b6.js → xychartDiagram-2b33534f-4d4026c0.js} +1 -1
  95. rasa/core/channels/inspector/dist/index.html +1 -1
  96. rasa/core/channels/inspector/src/components/DiagramFlow.tsx +10 -0
  97. rasa/core/channels/inspector/src/helpers/formatters.test.ts +4 -7
  98. rasa/core/channels/inspector/src/helpers/formatters.ts +3 -2
  99. rasa/core/channels/rest.py +36 -21
  100. rasa/core/channels/rocketchat.py +0 -1
  101. rasa/core/channels/socketio.py +1 -1
  102. rasa/core/channels/telegram.py +3 -3
  103. rasa/core/channels/webexteams.py +0 -1
  104. rasa/core/concurrent_lock_store.py +1 -1
  105. rasa/core/evaluation/marker_base.py +1 -3
  106. rasa/core/evaluation/marker_stats.py +1 -2
  107. rasa/core/featurizers/single_state_featurizer.py +3 -26
  108. rasa/core/featurizers/tracker_featurizers.py +18 -122
  109. rasa/core/information_retrieval/__init__.py +7 -0
  110. rasa/core/information_retrieval/faiss.py +9 -4
  111. rasa/core/information_retrieval/information_retrieval.py +64 -7
  112. rasa/core/information_retrieval/milvus.py +7 -14
  113. rasa/core/information_retrieval/qdrant.py +8 -15
  114. rasa/core/lock_store.py +0 -1
  115. rasa/core/migrate.py +1 -2
  116. rasa/core/nlg/callback.py +3 -4
  117. rasa/core/policies/enterprise_search_policy.py +86 -22
  118. rasa/core/policies/enterprise_search_prompt_template.jinja2 +4 -41
  119. rasa/core/policies/enterprise_search_prompt_with_citation_template.jinja2 +60 -0
  120. rasa/core/policies/flows/flow_executor.py +104 -2
  121. rasa/core/policies/intentless_policy.py +7 -9
  122. rasa/core/policies/memoization.py +3 -3
  123. rasa/core/policies/policy.py +18 -9
  124. rasa/core/policies/rule_policy.py +8 -11
  125. rasa/core/policies/ted_policy.py +61 -88
  126. rasa/core/policies/unexpected_intent_policy.py +8 -17
  127. rasa/core/processor.py +136 -47
  128. rasa/core/run.py +41 -25
  129. rasa/core/secrets_manager/endpoints.py +2 -2
  130. rasa/core/secrets_manager/vault.py +6 -8
  131. rasa/core/test.py +3 -5
  132. rasa/core/tracker_store.py +49 -14
  133. rasa/core/train.py +1 -3
  134. rasa/core/training/interactive.py +9 -6
  135. rasa/core/utils.py +5 -10
  136. rasa/dialogue_understanding/coexistence/intent_based_router.py +11 -4
  137. rasa/dialogue_understanding/coexistence/llm_based_router.py +2 -3
  138. rasa/dialogue_understanding/commands/__init__.py +4 -0
  139. rasa/dialogue_understanding/commands/can_not_handle_command.py +9 -0
  140. rasa/dialogue_understanding/commands/cancel_flow_command.py +9 -0
  141. rasa/dialogue_understanding/commands/change_flow_command.py +38 -0
  142. rasa/dialogue_understanding/commands/chit_chat_answer_command.py +9 -0
  143. rasa/dialogue_understanding/commands/clarify_command.py +9 -0
  144. rasa/dialogue_understanding/commands/correct_slots_command.py +9 -0
  145. rasa/dialogue_understanding/commands/error_command.py +12 -0
  146. rasa/dialogue_understanding/commands/handle_code_change_command.py +9 -0
  147. rasa/dialogue_understanding/commands/human_handoff_command.py +9 -0
  148. rasa/dialogue_understanding/commands/knowledge_answer_command.py +9 -0
  149. rasa/dialogue_understanding/commands/noop_command.py +9 -0
  150. rasa/dialogue_understanding/commands/set_slot_command.py +38 -3
  151. rasa/dialogue_understanding/commands/skip_question_command.py +9 -0
  152. rasa/dialogue_understanding/commands/start_flow_command.py +9 -0
  153. rasa/dialogue_understanding/generator/__init__.py +16 -1
  154. rasa/dialogue_understanding/generator/command_generator.py +92 -6
  155. rasa/dialogue_understanding/generator/constants.py +18 -0
  156. rasa/dialogue_understanding/generator/flow_retrieval.py +7 -5
  157. rasa/dialogue_understanding/generator/llm_based_command_generator.py +467 -0
  158. rasa/dialogue_understanding/generator/llm_command_generator.py +39 -609
  159. rasa/dialogue_understanding/generator/multi_step/__init__.py +0 -0
  160. rasa/dialogue_understanding/generator/multi_step/fill_slots_prompt.jinja2 +62 -0
  161. rasa/dialogue_understanding/generator/multi_step/handle_flows_prompt.jinja2 +38 -0
  162. rasa/dialogue_understanding/generator/multi_step/multi_step_llm_command_generator.py +827 -0
  163. rasa/dialogue_understanding/generator/nlu_command_adapter.py +69 -8
  164. rasa/dialogue_understanding/generator/single_step/__init__.py +0 -0
  165. rasa/dialogue_understanding/generator/single_step/single_step_llm_command_generator.py +345 -0
  166. rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +36 -31
  167. rasa/dialogue_understanding/processor/command_processor.py +112 -3
  168. rasa/e2e_test/constants.py +1 -0
  169. rasa/e2e_test/e2e_test_case.py +44 -0
  170. rasa/e2e_test/e2e_test_runner.py +114 -11
  171. rasa/e2e_test/e2e_test_schema.yml +18 -0
  172. rasa/engine/caching.py +0 -1
  173. rasa/engine/graph.py +18 -6
  174. rasa/engine/recipes/config_files/default_config.yml +3 -3
  175. rasa/engine/recipes/default_components.py +1 -1
  176. rasa/engine/recipes/default_recipe.py +4 -5
  177. rasa/engine/recipes/recipe.py +1 -1
  178. rasa/engine/runner/dask.py +3 -9
  179. rasa/engine/storage/local_model_storage.py +0 -2
  180. rasa/engine/validation.py +179 -145
  181. rasa/exceptions.py +2 -2
  182. rasa/graph_components/validators/default_recipe_validator.py +3 -5
  183. rasa/hooks.py +0 -1
  184. rasa/model.py +1 -1
  185. rasa/model_training.py +1 -0
  186. rasa/nlu/classifiers/diet_classifier.py +33 -52
  187. rasa/nlu/classifiers/logistic_regression_classifier.py +9 -22
  188. rasa/nlu/classifiers/sklearn_intent_classifier.py +16 -37
  189. rasa/nlu/extractors/crf_entity_extractor.py +54 -97
  190. rasa/nlu/extractors/duckling_entity_extractor.py +1 -1
  191. rasa/nlu/featurizers/dense_featurizer/convert_featurizer.py +1 -5
  192. rasa/nlu/featurizers/dense_featurizer/lm_featurizer.py +0 -4
  193. rasa/nlu/featurizers/featurizer.py +1 -1
  194. rasa/nlu/featurizers/sparse_featurizer/count_vectors_featurizer.py +18 -49
  195. rasa/nlu/featurizers/sparse_featurizer/lexical_syntactic_featurizer.py +26 -64
  196. rasa/nlu/featurizers/sparse_featurizer/regex_featurizer.py +3 -5
  197. rasa/nlu/persistor.py +68 -26
  198. rasa/nlu/selectors/response_selector.py +7 -10
  199. rasa/nlu/test.py +0 -3
  200. rasa/nlu/utils/hugging_face/registry.py +1 -1
  201. rasa/nlu/utils/spacy_utils.py +1 -3
  202. rasa/server.py +22 -7
  203. rasa/shared/constants.py +12 -1
  204. rasa/shared/core/command_payload_reader.py +109 -0
  205. rasa/shared/core/constants.py +4 -5
  206. rasa/shared/core/domain.py +57 -56
  207. rasa/shared/core/events.py +4 -7
  208. rasa/shared/core/flows/flow.py +9 -0
  209. rasa/shared/core/flows/flows_list.py +12 -0
  210. rasa/shared/core/flows/steps/action.py +7 -2
  211. rasa/shared/core/generator.py +12 -11
  212. rasa/shared/core/slot_mappings.py +315 -24
  213. rasa/shared/core/slots.py +4 -2
  214. rasa/shared/core/trackers.py +32 -14
  215. rasa/shared/core/training_data/loading.py +0 -1
  216. rasa/shared/core/training_data/story_reader/story_reader.py +3 -3
  217. rasa/shared/core/training_data/story_reader/yaml_story_reader.py +11 -11
  218. rasa/shared/core/training_data/story_writer/yaml_story_writer.py +5 -3
  219. rasa/shared/core/training_data/structures.py +1 -1
  220. rasa/shared/core/training_data/visualization.py +1 -1
  221. rasa/shared/data.py +58 -1
  222. rasa/shared/exceptions.py +36 -2
  223. rasa/shared/importers/importer.py +1 -2
  224. rasa/shared/importers/rasa.py +0 -1
  225. rasa/shared/nlu/constants.py +2 -0
  226. rasa/shared/nlu/training_data/entities_parser.py +1 -2
  227. rasa/shared/nlu/training_data/features.py +2 -120
  228. rasa/shared/nlu/training_data/formats/dialogflow.py +3 -2
  229. rasa/shared/nlu/training_data/formats/rasa_yaml.py +3 -5
  230. rasa/shared/nlu/training_data/formats/readerwriter.py +0 -1
  231. rasa/shared/nlu/training_data/message.py +13 -0
  232. rasa/shared/nlu/training_data/training_data.py +0 -2
  233. rasa/shared/providers/openai/session_handler.py +2 -2
  234. rasa/shared/utils/constants.py +3 -0
  235. rasa/shared/utils/io.py +11 -1
  236. rasa/shared/utils/llm.py +1 -2
  237. rasa/shared/utils/pykwalify_extensions.py +1 -0
  238. rasa/shared/utils/schemas/domain.yml +3 -0
  239. rasa/shared/utils/yaml.py +44 -35
  240. rasa/studio/auth.py +26 -10
  241. rasa/studio/constants.py +2 -0
  242. rasa/studio/data_handler.py +114 -107
  243. rasa/studio/download.py +160 -27
  244. rasa/studio/results_logger.py +137 -0
  245. rasa/studio/train.py +6 -7
  246. rasa/studio/upload.py +159 -134
  247. rasa/telemetry.py +188 -34
  248. rasa/tracing/config.py +18 -3
  249. rasa/tracing/constants.py +26 -2
  250. rasa/tracing/instrumentation/attribute_extractors.py +50 -41
  251. rasa/tracing/instrumentation/instrumentation.py +290 -44
  252. rasa/tracing/instrumentation/intentless_policy_instrumentation.py +7 -5
  253. rasa/tracing/instrumentation/metrics.py +109 -21
  254. rasa/tracing/metric_instrument_provider.py +83 -3
  255. rasa/utils/cli.py +2 -1
  256. rasa/utils/common.py +1 -1
  257. rasa/utils/endpoints.py +1 -2
  258. rasa/utils/io.py +72 -6
  259. rasa/utils/licensing.py +246 -31
  260. rasa/utils/ml_utils.py +1 -1
  261. rasa/utils/tensorflow/data_generator.py +1 -1
  262. rasa/utils/tensorflow/environment.py +1 -1
  263. rasa/utils/tensorflow/model_data.py +201 -12
  264. rasa/utils/tensorflow/model_data_utils.py +499 -500
  265. rasa/utils/tensorflow/models.py +5 -6
  266. rasa/utils/tensorflow/rasa_layers.py +15 -15
  267. rasa/utils/train_utils.py +1 -1
  268. rasa/utils/url_tools.py +53 -0
  269. rasa/validator.py +305 -3
  270. rasa/version.py +1 -1
  271. {rasa_pro-3.8.18.dist-info → rasa_pro-3.9.15.dist-info}/METADATA +25 -61
  272. {rasa_pro-3.8.18.dist-info → rasa_pro-3.9.15.dist-info}/RECORD +276 -259
  273. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-855bc5b3-85583a23.js +0 -1
  274. rasa/utils/tensorflow/feature_array.py +0 -370
  275. /rasa/dialogue_understanding/generator/{command_prompt_template.jinja2 → single_step/command_prompt_template.jinja2} +0 -0
  276. {rasa_pro-3.8.18.dist-info → rasa_pro-3.9.15.dist-info}/NOTICE +0 -0
  277. {rasa_pro-3.8.18.dist-info → rasa_pro-3.9.15.dist-info}/WHEEL +0 -0
  278. {rasa_pro-3.8.18.dist-info → rasa_pro-3.9.15.dist-info}/entry_points.txt +0 -0
rasa/telemetry.py CHANGED
@@ -32,6 +32,7 @@ from rasa.constants import (
32
32
  CONFIG_TELEMETRY_ENABLED,
33
33
  CONFIG_TELEMETRY_ID,
34
34
  )
35
+ from rasa.shared.constants import PROMPT_CONFIG_KEY, PROMPT_TEMPLATE_CONFIG_KEY
35
36
  from rasa.engine.storage.local_model_storage import LocalModelStorage
36
37
  from rasa.shared.constants import DOCS_URL_TELEMETRY, UTTER_ASK_PREFIX
37
38
  from rasa.shared.core.flows import Flow
@@ -43,7 +44,6 @@ from rasa.shared.core.flows.steps import (
43
44
  )
44
45
  from rasa.shared.exceptions import RasaException
45
46
  from rasa.utils import common as rasa_utils
46
- from rasa.utils.licensing import property_of_active_license, get_license_hash
47
47
 
48
48
  if typing.TYPE_CHECKING:
49
49
  from rasa.core.brokers.broker import EventBroker
@@ -53,7 +53,7 @@ if typing.TYPE_CHECKING:
53
53
  from rasa.shared.nlu.training_data.training_data import TrainingData
54
54
  from rasa.shared.importers.importer import TrainingDataImporter
55
55
  from rasa.core.utils import AvailableEndpoints
56
- from rasa.e2e_test.e2e_test_case import TestCase, Fixture
56
+ from rasa.e2e_test.e2e_test_case import TestCase, Fixture, Metadata
57
57
 
58
58
  logger = logging.getLogger(__name__)
59
59
 
@@ -93,7 +93,8 @@ CI_ENVIRONMENT_TELL = [
93
93
  ]
94
94
 
95
95
  # If updating or creating a new event, remember to update
96
- # https://rasa.com/docs/rasa/telemetry
96
+ # https://rasa.com/docs/rasa-pro/telemetry/telemetry OR
97
+ # https://rasa.com/docs/rasa-pro/telemetry/reference
97
98
  TRAINING_STARTED_EVENT = "Training Started"
98
99
  TRAINING_COMPLETED_EVENT = "Training Completed"
99
100
  TELEMETRY_DISABLED_EVENT = "Telemetry Disabled"
@@ -124,6 +125,18 @@ TELEMETRY_INTENTLESS_POLICY_PREDICT_EVENT = "Intentless Policy Predicted"
124
125
  TELEMETRY_LLM_INTENT_PREDICT_EVENT = "LLM Intent Predicted"
125
126
  TELEMETRY_LLM_INTENT_TRAIN_COMPLETED_EVENT = "LLM Intent Training Completed"
126
127
  TELEMETRY_E2E_TEST_RUN_STARTED_EVENT = "E2E Test Run Started"
128
+ TELEMETRY_ENTERPRISE_SEARCH_POLICY_TRAINING_STARTED_EVENT = (
129
+ "Enterprise Search Policy Training Started"
130
+ )
131
+ TELEMETRY_ENTERPRISE_SEARCH_POLICY_TRAINING_COMPLETED_EVENT = (
132
+ "Enterprise Search Policy Training Completed"
133
+ )
134
+ TELEMETRY_ENTERPRISE_SEARCH_POLICY_PREDICT_EVENT = "Enterprise Search Policy Predicted"
135
+
136
+ # licensing events
137
+ TELEMETRY_CONVERSATION_COUNT = "Conversation Count"
138
+ TELEMETRY_CONVERSATION_SOFT_LIMIT_REACHED = "Conversation Soft Limit Reached"
139
+ TELEMETRY_CONVERSATION_HARD_LIMIT_REACHED = "Conversation Hard Limit Reached"
127
140
 
128
141
  # used to calculate the context on the first call and cache it afterwards
129
142
  TELEMETRY_CONTEXT = None
@@ -147,6 +160,12 @@ NUM_CALL_STEPS = "num_call_steps"
147
160
  NUM_SHARED_SLOTS_BETWEEN_FLOWS = "num_shared_slots_between_flows"
148
161
  LLM_COMMAND_GENERATOR_MODEL_NAME = "llm_command_generator_model_name"
149
162
  LLM_COMMAND_GENERATOR_CUSTOM_PROMPT_USED = "llm_command_generator_custom_prompt_used"
163
+ MULTI_STEP_LLM_COMMAND_GENERATOR_HANDLE_FLOWS_PROMPT_USED = (
164
+ "multi_step_llm_command_generator_custom_handle_flows_prompt_used"
165
+ )
166
+ MULTI_STEP_LLM_COMMAND_GENERATOR_FILL_SLOTS_PROMPT_USED = (
167
+ "multi_step_llm_command_generator_custom_fill_slots_prompt_used"
168
+ )
150
169
  FLOW_RETRIEVAL_ENABLED = "flow_retrieval_enabled"
151
170
  FLOW_RETRIEVAL_EMBEDDING_MODEL_NAME = "flow_retrieval_embedding_model_name"
152
171
  TRACING_BACKEND = "tracing_backend"
@@ -158,7 +177,7 @@ def print_telemetry_reporting_info() -> None:
158
177
  """Print telemetry information to std out."""
159
178
  message = textwrap.dedent(
160
179
  f"""
161
- Rasa Open Source reports anonymous usage telemetry to help improve the product
180
+ Rasa Pro reports anonymous usage telemetry to help improve the product
162
181
  for all its users.
163
182
 
164
183
  If you'd like to opt-out, you can use `rasa telemetry disable`.
@@ -225,6 +244,12 @@ def is_telemetry_enabled() -> bool:
225
244
  Returns:
226
245
  `True`, if telemetry is enabled, `False` otherwise.
227
246
  """
247
+ from rasa.utils import licensing
248
+
249
+ if licensing.is_champion_server_license():
250
+ logger.debug("Telemetry is enabled for developer licenses.")
251
+ return True
252
+
228
253
  telemetry_environ = os.environ.get(TELEMETRY_ENABLED_ENVIRONMENT_VARIABLE)
229
254
 
230
255
  if telemetry_environ is not None:
@@ -336,7 +361,7 @@ def telemetry_write_key() -> Optional[Text]:
336
361
  """Read the Segment write key from the segment key text file.
337
362
 
338
363
  The segment key text file should by present only in wheel/sdist packaged
339
- versions of Rasa Open Source. This avoids running telemetry locally when
364
+ versions of Rasa Pro. This avoids running telemetry locally when
340
365
  developing on Rasa or when running CI builds.
341
366
 
342
367
  In local development, this should always return `None` to avoid logging telemetry.
@@ -542,7 +567,7 @@ def _is_docker() -> bool:
542
567
 
543
568
 
544
569
  def with_default_context_fields(
545
- context: Optional[Dict[Text, Any]] = None
570
+ context: Optional[Dict[Text, Any]] = None,
546
571
  ) -> Dict[Text, Any]:
547
572
  """Return a new context dictionary with default and provided field values merged.
548
573
 
@@ -565,6 +590,8 @@ def _default_context_fields() -> Dict[Text, Any]:
565
590
  Return:
566
591
  A new context containing information about the runtime environment.
567
592
  """
593
+ from rasa.utils.licensing import property_of_active_license, get_license_hash
594
+
568
595
  global TELEMETRY_CONTEXT
569
596
 
570
597
  if not TELEMETRY_CONTEXT:
@@ -600,7 +627,7 @@ def _track(
600
627
 
601
628
  It is OK to use this function from outside telemetry.py, but note that it
602
629
  is recommended to create a new track_xyz() function for complex telemetry
603
- events, or events that are generated from many parts of the Rasa Open Source code.
630
+ events, or events that are generated from many parts of the Rasa Pro code.
604
631
 
605
632
  Args:
606
633
  event_name: Name of the event.
@@ -714,6 +741,8 @@ def get_telemetry_id() -> Optional[Text]:
714
741
  Returns:
715
742
  The identifier, if it is configured correctly.
716
743
  """
744
+ from rasa.utils.licensing import property_of_active_license
745
+
717
746
  return property_of_active_license(lambda active_license: active_license.jti)
718
747
 
719
748
 
@@ -1043,12 +1072,25 @@ def _collect_flow_statistics(flows: List[Flow]) -> Dict[str, Any]:
1043
1072
 
1044
1073
 
1045
1074
  def _get_llm_command_generator_config(config: Dict[str, Any]) -> Optional[Dict]:
1046
- """Returns the configuration for the LLMCommandGenerator including the model name,
1047
- whether a custom prompt is used, whether flow retrieval is enabled, and flow
1048
- retrieval embedding model.
1075
+ """Returns the configuration for the LLMCommandGenerator.
1076
+
1077
+ Includes the model name, whether a custom prompt is used, whether flow
1078
+ retrieval is enabled, and flow retrieval embedding model.
1049
1079
  """
1050
- from rasa.dialogue_understanding.generator import LLMCommandGenerator
1051
- from rasa.dialogue_understanding.generator.llm_command_generator import (
1080
+ from rasa.shared.constants import (
1081
+ MODEL_CONFIG_KEY,
1082
+ MODEL_NAME_CONFIG_KEY,
1083
+ )
1084
+ from rasa.dialogue_understanding.generator import (
1085
+ LLMCommandGenerator,
1086
+ SingleStepLLMCommandGenerator,
1087
+ MultiStepLLMCommandGenerator,
1088
+ )
1089
+ from rasa.dialogue_understanding.generator.multi_step.multi_step_llm_command_generator import ( # noqa: E501
1090
+ HANDLE_FLOWS_KEY,
1091
+ FILL_SLOTS_KEY,
1092
+ )
1093
+ from rasa.dialogue_understanding.generator.constants import (
1052
1094
  LLM_CONFIG_KEY,
1053
1095
  DEFAULT_LLM_CONFIG,
1054
1096
  FLOW_RETRIEVAL_KEY,
@@ -1060,15 +1102,21 @@ def _get_llm_command_generator_config(config: Dict[str, Any]) -> Optional[Dict]:
1060
1102
  def find_command_generator_component(pipeline: List) -> Optional[Dict]:
1061
1103
  """Finds the LLMCommandGenerator component in the pipeline."""
1062
1104
  for component in pipeline:
1063
- if component["name"] == LLMCommandGenerator.__name__:
1105
+ if component["name"] in [
1106
+ LLMCommandGenerator.__name__,
1107
+ SingleStepLLMCommandGenerator.__name__,
1108
+ MultiStepLLMCommandGenerator.__name__,
1109
+ ]:
1064
1110
  return component
1065
1111
  return None
1066
1112
 
1067
1113
  def extract_settings(component: Dict) -> Dict:
1068
1114
  """Extracts the settings from the command generator component."""
1069
- custom_prompt_used = "prompt" in component
1070
- llm_model_name = component.get(LLM_CONFIG_KEY, {}).get(
1071
- "model_name", DEFAULT_LLM_CONFIG["model_name"]
1115
+ llm_config = component.get(LLM_CONFIG_KEY, {})
1116
+ llm_model_name = (
1117
+ llm_config.get(MODEL_CONFIG_KEY)
1118
+ or llm_config.get(MODEL_NAME_CONFIG_KEY)
1119
+ or DEFAULT_LLM_CONFIG[MODEL_NAME_CONFIG_KEY]
1072
1120
  )
1073
1121
  flow_retrieval_config = component.get(FLOW_RETRIEVAL_KEY, {})
1074
1122
  flow_retrieval_enabled = flow_retrieval_config.get("active", True)
@@ -1081,7 +1129,12 @@ def _get_llm_command_generator_config(config: Dict[str, Any]) -> Optional[Dict]:
1081
1129
  )
1082
1130
  return {
1083
1131
  LLM_COMMAND_GENERATOR_MODEL_NAME: llm_model_name,
1084
- LLM_COMMAND_GENERATOR_CUSTOM_PROMPT_USED: custom_prompt_used,
1132
+ LLM_COMMAND_GENERATOR_CUSTOM_PROMPT_USED: PROMPT_CONFIG_KEY in component
1133
+ or PROMPT_TEMPLATE_CONFIG_KEY in component,
1134
+ MULTI_STEP_LLM_COMMAND_GENERATOR_HANDLE_FLOWS_PROMPT_USED: HANDLE_FLOWS_KEY
1135
+ in component.get("prompt_templates", {}),
1136
+ MULTI_STEP_LLM_COMMAND_GENERATOR_FILL_SLOTS_PROMPT_USED: FILL_SLOTS_KEY
1137
+ in component.get("prompt_templates", {}),
1085
1138
  FLOW_RETRIEVAL_ENABLED: flow_retrieval_enabled,
1086
1139
  FLOW_RETRIEVAL_EMBEDDING_MODEL_NAME: flow_retrieval_embedding_model_name,
1087
1140
  }
@@ -1089,6 +1142,8 @@ def _get_llm_command_generator_config(config: Dict[str, Any]) -> Optional[Dict]:
1089
1142
  command_generator_config = {
1090
1143
  LLM_COMMAND_GENERATOR_MODEL_NAME: None,
1091
1144
  LLM_COMMAND_GENERATOR_CUSTOM_PROMPT_USED: None,
1145
+ MULTI_STEP_LLM_COMMAND_GENERATOR_HANDLE_FLOWS_PROMPT_USED: None,
1146
+ MULTI_STEP_LLM_COMMAND_GENERATOR_FILL_SLOTS_PROMPT_USED: None,
1092
1147
  FLOW_RETRIEVAL_ENABLED: None,
1093
1148
  FLOW_RETRIEVAL_EMBEDDING_MODEL_NAME: None,
1094
1149
  }
@@ -1230,19 +1285,19 @@ def track_server_start(
1230
1285
  "number_of_workers": number_of_workers,
1231
1286
  "endpoints_nlg": endpoints.nlg.type if endpoints.nlg else None,
1232
1287
  "endpoints_nlu": endpoints.nlu.type if endpoints.nlu else None,
1233
- "endpoints_action_server": (
1234
- endpoints.action.type if endpoints.action else None
1235
- ),
1288
+ "endpoints_action_server": endpoints.action.type
1289
+ if endpoints.action
1290
+ else None,
1236
1291
  "endpoints_model_server": endpoints.model.type if endpoints.model else None,
1237
- "endpoints_tracker_store": (
1238
- endpoints.tracker_store.type if endpoints.tracker_store else None
1239
- ),
1240
- "endpoints_lock_store": (
1241
- endpoints.lock_store.type if endpoints.lock_store else None
1242
- ),
1243
- "endpoints_event_broker": (
1244
- endpoints.event_broker.type if endpoints.event_broker else None
1245
- ),
1292
+ "endpoints_tracker_store": endpoints.tracker_store.type
1293
+ if endpoints.tracker_store
1294
+ else None,
1295
+ "endpoints_lock_store": endpoints.lock_store.type
1296
+ if endpoints.lock_store
1297
+ else None,
1298
+ "endpoints_event_broker": endpoints.event_broker.type
1299
+ if endpoints.event_broker
1300
+ else None,
1246
1301
  "project": project_fingerprint_from_model(model_directory),
1247
1302
  },
1248
1303
  )
@@ -1386,7 +1441,9 @@ def track_markers_parsed_count(
1386
1441
 
1387
1442
  @ensure_telemetry_enabled
1388
1443
  def track_e2e_test_run(
1389
- input_test_cases: List["TestCase"], input_fixtures: List["Fixture"]
1444
+ input_test_cases: List["TestCase"],
1445
+ input_fixtures: List["Fixture"],
1446
+ input_metadata: List["Metadata"],
1390
1447
  ) -> None:
1391
1448
  """Track an end-to-end test run."""
1392
1449
  _track(
@@ -1395,6 +1452,8 @@ def track_e2e_test_run(
1395
1452
  "number_of_test_cases": len(input_test_cases),
1396
1453
  "number_of_fixtures": len(input_fixtures),
1397
1454
  "uses_fixtures": len(input_fixtures) > 0,
1455
+ "uses_metadata": len(input_metadata) > 0,
1456
+ "number_of_metadata": len(input_metadata),
1398
1457
  },
1399
1458
  )
1400
1459
 
@@ -1574,10 +1633,105 @@ def append_anonymization_trait(
1574
1633
  endpoints_file, KEY_ANONYMIZATION_RULES
1575
1634
  )
1576
1635
 
1577
- traits[
1578
- KEY_ANONYMIZATION_RULES
1579
- ] = rasa.anonymization.utils.extract_anonymization_traits(
1580
- anonymization_config, KEY_ANONYMIZATION_RULES
1636
+ traits[KEY_ANONYMIZATION_RULES] = (
1637
+ rasa.anonymization.utils.extract_anonymization_traits(
1638
+ anonymization_config, KEY_ANONYMIZATION_RULES
1639
+ )
1581
1640
  )
1582
1641
 
1583
1642
  return traits
1643
+
1644
+
1645
+ @ensure_telemetry_enabled
1646
+ def track_enterprise_search_policy_train_started() -> None:
1647
+ """Track when a user starts training Enterprise Search policy."""
1648
+ _track(TELEMETRY_ENTERPRISE_SEARCH_POLICY_TRAINING_STARTED_EVENT)
1649
+
1650
+
1651
+ @ensure_telemetry_enabled
1652
+ def track_enterprise_search_policy_train_completed(
1653
+ vector_store_type: Optional[str],
1654
+ embeddings_type: Optional[str],
1655
+ embeddings_model: Optional[str],
1656
+ llm_type: Optional[str],
1657
+ llm_model: Optional[str],
1658
+ citation_enabled: Optional[bool],
1659
+ ) -> None:
1660
+ """Track when a user completes training Enterprise Search policy."""
1661
+ _track(
1662
+ TELEMETRY_ENTERPRISE_SEARCH_POLICY_TRAINING_COMPLETED_EVENT,
1663
+ {
1664
+ "vector_store_type": vector_store_type,
1665
+ "embeddings_type": embeddings_type,
1666
+ "embeddings_model": embeddings_model,
1667
+ "llm_type": llm_type,
1668
+ "llm_model": llm_model,
1669
+ "citation_enabled": citation_enabled,
1670
+ },
1671
+ )
1672
+
1673
+
1674
+ @ensure_telemetry_enabled
1675
+ def track_enterprise_search_policy_predict(
1676
+ vector_store_type: Optional[str],
1677
+ embeddings_type: Optional[str],
1678
+ embeddings_model: Optional[str],
1679
+ llm_type: Optional[str],
1680
+ llm_model: Optional[str],
1681
+ citation_enabled: Optional[bool],
1682
+ ) -> None:
1683
+ """Track when a user predicts the next action using Enterprise Search policy."""
1684
+ _track(
1685
+ TELEMETRY_ENTERPRISE_SEARCH_POLICY_PREDICT_EVENT,
1686
+ {
1687
+ "vector_store_type": vector_store_type,
1688
+ "embeddings_type": embeddings_type,
1689
+ "embeddings_model": embeddings_model,
1690
+ "llm_type": llm_type,
1691
+ "llm_model": llm_model,
1692
+ "citation_enabled": citation_enabled,
1693
+ },
1694
+ )
1695
+
1696
+
1697
+ @ensure_telemetry_enabled
1698
+ def track_conversation_count_hard_limit(
1699
+ conversation_count: int, tracked_month: datetime
1700
+ ) -> None:
1701
+ """Track when the number of conversations reaches the hard limit."""
1702
+ _track(
1703
+ TELEMETRY_CONVERSATION_HARD_LIMIT_REACHED,
1704
+ {
1705
+ "conversation_count": conversation_count,
1706
+ "year": tracked_month.year,
1707
+ "month": tracked_month.month,
1708
+ },
1709
+ )
1710
+
1711
+
1712
+ @ensure_telemetry_enabled
1713
+ def track_conversation_count_soft_limit(
1714
+ conversation_count: int, tracked_month: datetime
1715
+ ) -> None:
1716
+ """Track when the number of conversations reaches the soft limit."""
1717
+ _track(
1718
+ TELEMETRY_CONVERSATION_SOFT_LIMIT_REACHED,
1719
+ {
1720
+ "conversation_count": conversation_count,
1721
+ "year": tracked_month.year,
1722
+ "month": tracked_month.month,
1723
+ },
1724
+ )
1725
+
1726
+
1727
+ @ensure_telemetry_enabled
1728
+ def track_conversation_count(conversation_count: int, tracked_month: datetime) -> None:
1729
+ """Track the number of conversations."""
1730
+ _track(
1731
+ TELEMETRY_CONVERSATION_COUNT,
1732
+ {
1733
+ "conversation_count": conversation_count,
1734
+ "year": tracked_month.year,
1735
+ "month": tracked_month.month,
1736
+ },
1737
+ )
rasa/tracing/config.py CHANGED
@@ -16,6 +16,11 @@ from opentelemetry.sdk.resources import SERVICE_NAME, Resource
16
16
  from opentelemetry.sdk.trace import TracerProvider
17
17
  from opentelemetry.sdk.trace.export import BatchSpanProcessor
18
18
 
19
+ from rasa.core.actions.custom_action_executor import (
20
+ CustomActionExecutor,
21
+ RetryCustomActionExecutor,
22
+ )
23
+ from rasa.core.actions.grpc_custom_action_executor import GRPCCustomActionExecutor
19
24
  from rasa.core.agent import Agent
20
25
  from rasa.core.processor import MessageProcessor
21
26
  from rasa.core.tracker_store import TrackerStore
@@ -23,8 +28,10 @@ from rasa.dialogue_understanding.commands import (
23
28
  Command,
24
29
  FreeFormAnswerCommand,
25
30
  )
26
- from rasa.dialogue_understanding.generator.llm_command_generator import (
31
+ from rasa.dialogue_understanding.generator import (
27
32
  LLMCommandGenerator,
33
+ SingleStepLLMCommandGenerator,
34
+ MultiStepLLMCommandGenerator,
28
35
  )
29
36
  from rasa.dialogue_understanding.generator.nlu_command_adapter import NLUCommandAdapter
30
37
  from rasa.engine.graph import GraphNode
@@ -38,11 +45,10 @@ from rasa.tracing.constants import (
38
45
  ENDPOINTS_ROOT_CERTIFICATES_KEY,
39
46
  ENDPOINTS_METRICS_KEY,
40
47
  )
48
+ from rasa.tracing.instrumentation import instrumentation
41
49
  from rasa.tracing.metric_instrument_provider import MetricInstrumentProvider
42
50
  from rasa.utils.endpoints import EndpointConfig, read_endpoint_config
43
51
 
44
- from rasa.tracing.instrumentation import instrumentation
45
-
46
52
  TRACING_SERVICE_NAME = os.environ.get("TRACING_SERVICE_NAME", "rasa")
47
53
 
48
54
  logger = logging.getLogger(__name__)
@@ -82,6 +88,11 @@ def configure_tracing(tracer_provider: Optional[TracerProvider]) -> None:
82
88
  for vector_store_class in InformationRetrieval.__subclasses__()
83
89
  ]
84
90
 
91
+ custom_action_executor_subclasses = []
92
+ for custom_action_executor_class in CustomActionExecutor.__subclasses__():
93
+ if custom_action_executor_class != RetryCustomActionExecutor:
94
+ custom_action_executor_subclasses.append(custom_action_executor_class)
95
+
85
96
  instrumentation.instrument(
86
97
  tracer_provider=tracer_provider,
87
98
  agent_class=Agent,
@@ -96,6 +107,10 @@ def configure_tracing(tracer_provider: Optional[TracerProvider]) -> None:
96
107
  vector_store_subclasses=vector_store_subclasses,
97
108
  nlu_command_adapter_class=NLUCommandAdapter,
98
109
  endpoint_config_class=EndpointConfig,
110
+ grpc_custom_action_executor_class=GRPCCustomActionExecutor,
111
+ single_step_llm_command_generator_class=SingleStepLLMCommandGenerator,
112
+ multi_step_llm_command_generator_class=MultiStepLLMCommandGenerator,
113
+ custom_action_executor_subclasses=custom_action_executor_subclasses,
99
114
  )
100
115
 
101
116
 
rasa/tracing/constants.py CHANGED
@@ -9,7 +9,7 @@ ENDPOINTS_OTLP_BACKEND_TYPE = "otlp"
9
9
 
10
10
  # tracing attributes
11
11
  PROMPT_TOKEN_LENGTH_ATTRIBUTE_NAME = "len_prompt_tokens"
12
- ENDPOINT_REQUEST_BODY_SIZE_IN_BYTES_ATTRIBUTE_NAME = "request_body_size_in_bytes"
12
+ REQUEST_BODY_SIZE_IN_BYTES_ATTRIBUTE_NAME = "request_body_size_in_bytes"
13
13
 
14
14
  # metrics constants
15
15
  LLM_COMMAND_GENERATOR_CPU_USAGE_METRIC_NAME = "llm_command_generator_cpu_usage"
@@ -20,6 +20,30 @@ LLM_COMMAND_GENERATOR_PROMPT_TOKEN_USAGE_METRIC_NAME = (
20
20
  LLM_COMMAND_GENERATOR_LLM_RESPONSE_DURATION_METRIC_NAME = (
21
21
  "llm_command_generator_llm_response_duration"
22
22
  )
23
+ SINGLE_STEP_LLM_COMMAND_GENERATOR_CPU_USAGE_METRIC_NAME = (
24
+ "single_step_llm_command_generator_cpu_usage"
25
+ )
26
+ SINGLE_STEP_LLM_COMMAND_GENERATOR_MEMORY_USAGE_METRIC_NAME = (
27
+ "single_step_llm_command_generator_memory_usage"
28
+ )
29
+ SINGLE_STEP_LLM_COMMAND_GENERATOR_PROMPT_TOKEN_USAGE_METRIC_NAME = (
30
+ "single_step_llm_command_generator_prompt_token_usage"
31
+ )
32
+ SINGLE_STEP_LLM_COMMAND_GENERATOR_LLM_RESPONSE_DURATION_METRIC_NAME = (
33
+ "single_step_llm_command_generator_llm_response_duration"
34
+ )
35
+ MULTI_STEP_LLM_COMMAND_GENERATOR_CPU_USAGE_METRIC_NAME = (
36
+ "multi_step_llm_command_generator_cpu_usage"
37
+ )
38
+ MULTI_STEP_LLM_COMMAND_GENERATOR_MEMORY_USAGE_METRIC_NAME = (
39
+ "multi_step_llm_command_generator_memory_usage"
40
+ )
41
+ MULTI_STEP_LLM_COMMAND_GENERATOR_PROMPT_TOKEN_USAGE_METRIC_NAME = (
42
+ "multi_step_llm_command_generator_prompt_token_usage"
43
+ )
44
+ MULTI_STEP_LLM_COMMAND_GENERATOR_LLM_RESPONSE_DURATION_METRIC_NAME = (
45
+ "multi_step_llm_command_generator_llm_response_duration"
46
+ )
23
47
 
24
48
  ENTERPRISE_SEARCH_POLICY_LLM_RESPONSE_DURATION_METRIC_NAME = (
25
49
  "enterprise_search_policy_llm_response_duration"
@@ -34,5 +58,5 @@ CONTEXTUAL_RESPONSE_REPHRASER_LLM_RESPONSE_DURATION_METRIC_NAME = (
34
58
  RASA_CLIENT_REQUEST_DURATION_METRIC_NAME = "rasa_client_request_duration"
35
59
  RASA_CLIENT_REQUEST_BODY_SIZE_METRIC_NAME = "rasa_client_request_body_size"
36
60
 
37
- LLM_COMMAND_GENERATOR_CPU_MEMORY_USAGE_UNIT_NAME = "percentage"
61
+ LLM_BASED_COMMAND_GENERATOR_CPU_MEMORY_USAGE_UNIT_NAME = "percentage"
38
62
  DURATION_UNIT_NAME = "ms"
@@ -1,46 +1,48 @@
1
1
  import json
2
2
  import logging
3
3
  from pathlib import Path
4
- from typing import Any, Dict, List, Optional, TYPE_CHECKING, Text, Tuple
4
+ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Text, Tuple, Union
5
5
 
6
6
  import tiktoken
7
7
  from numpy import ndarray
8
+ from rasa_sdk.grpc_py import action_webhook_pb2
8
9
 
10
+ from rasa.core.actions.grpc_custom_action_executor import GRPCCustomActionExecutor
11
+ from rasa.core.actions.http_custom_action_executor import HTTPCustomActionExecutor
9
12
  from rasa.core.agent import Agent
10
13
  from rasa.core.brokers.broker import EventBroker
11
14
  from rasa.core.channels import UserMessage
12
- from rasa.core.nlg.contextual_response_rephraser import ContextualResponseRephraser
13
15
  from rasa.core.lock_store import LOCK_LIFETIME, LockStore
16
+ from rasa.core.nlg.contextual_response_rephraser import ContextualResponseRephraser
14
17
  from rasa.core.processor import MessageProcessor
15
18
  from rasa.core.tracker_store import TrackerStore
16
19
  from rasa.dialogue_understanding.commands import Command
17
- from rasa.dialogue_understanding.generator.llm_command_generator import (
18
- LLMCommandGenerator,
19
- )
20
20
  from rasa.dialogue_understanding.stack.dialogue_stack import DialogueStack
21
- from rasa.engine.graph import GraphModelConfiguration, GraphNode, ExecutionContext
21
+ from rasa.engine.graph import ExecutionContext, GraphModelConfiguration, GraphNode
22
22
  from rasa.engine.training.graph_trainer import GraphTrainer
23
23
  from rasa.shared.core.constants import REQUESTED_SLOT
24
24
  from rasa.shared.core.domain import Domain
25
25
  from rasa.shared.core.events import DialogueStackUpdated, Event
26
- from rasa.shared.core.flows import Flow, FlowStep, FlowsList
26
+ from rasa.shared.core.flows import Flow, FlowsList, FlowStep
27
27
  from rasa.shared.core.trackers import DialogueStateTracker
28
28
  from rasa.shared.importers.importer import TrainingDataImporter
29
- from rasa.shared.nlu.constants import INTENT_NAME_KEY
29
+ from rasa.shared.nlu.constants import INTENT_NAME_KEY, SET_SLOT_COMMAND
30
30
  from rasa.shared.utils.llm import combine_custom_and_default_config
31
31
  from rasa.tracing.constants import (
32
32
  PROMPT_TOKEN_LENGTH_ATTRIBUTE_NAME,
33
- ENDPOINT_REQUEST_BODY_SIZE_IN_BYTES_ATTRIBUTE_NAME,
33
+ REQUEST_BODY_SIZE_IN_BYTES_ATTRIBUTE_NAME,
34
34
  )
35
- from rasa.utils.endpoints import concat_url
36
35
 
37
36
  if TYPE_CHECKING:
38
37
  from langchain.llms.base import BaseLLM
38
+
39
39
  from rasa.core.policies.enterprise_search_policy import EnterpriseSearchPolicy
40
40
  from rasa.core.policies.intentless_policy import IntentlessPolicy
41
41
  from rasa.core.policies.policy import PolicyPrediction
42
- from rasa.dialogue_understanding.generator.command_generator import CommandGenerator
43
- from rasa.utils.endpoints import EndpointConfig
42
+ from rasa.dialogue_understanding.generator import (
43
+ CommandGenerator,
44
+ LLMBasedCommandGenerator,
45
+ )
44
46
 
45
47
  # This file contains all attribute extractors for tracing instrumentation.
46
48
  # These are functions that are applied to the arguments of the wrapped function to be
@@ -84,7 +86,7 @@ def extract_llm_command_generator_attrs(
84
86
  command_name = command.get("command")
85
87
  commands_list.append(command_name)
86
88
 
87
- if command_name == "set slot":
89
+ if command_name == SET_SLOT_COMMAND:
88
90
  attributes["slot_name"] = command.get("name")
89
91
 
90
92
  if command_name == "start flow":
@@ -247,7 +249,10 @@ def extract_attrs_for_graph_trainer(
247
249
  }
248
250
 
249
251
 
250
- def extract_headers(message: UserMessage, **kwargs: Any) -> Any:
252
+ def extract_headers(
253
+ message: UserMessage,
254
+ **kwargs: Any,
255
+ ) -> Any:
251
256
  """Extract the headers from the `UserMessage`."""
252
257
  if message.headers:
253
258
  return message.headers
@@ -269,7 +274,7 @@ def extract_intent_name_and_slots(
269
274
  slots[slot_name] = slot_value.value
270
275
  break
271
276
  return {
272
- "intent_name": str(tracker.latest_message.intent.get(INTENT_NAME_KEY)), # type: ignore[union-attr] # noqa: E501
277
+ "intent_name": str(tracker.latest_message.intent.get(INTENT_NAME_KEY)), # type: ignore[union-attr]
273
278
  **slots,
274
279
  }
275
280
 
@@ -315,11 +320,11 @@ def extract_llm_config(self: Any, default_llm_config: Dict[str, Any]) -> Dict[st
315
320
  return attributes
316
321
 
317
322
 
318
- def extract_attrs_for_llm_command_generator(
319
- self: LLMCommandGenerator,
323
+ def extract_attrs_for_llm_based_command_generator(
324
+ self: "LLMBasedCommandGenerator",
320
325
  prompt: str,
321
326
  ) -> Dict[str, Any]:
322
- from rasa.dialogue_understanding.generator.llm_command_generator import (
327
+ from rasa.dialogue_understanding.generator.constants import (
323
328
  DEFAULT_LLM_CONFIG,
324
329
  )
325
330
 
@@ -382,7 +387,7 @@ def extract_attrs_for_validate_state_of_commands(
382
387
  command_type = command.command()
383
388
  command_as_dict = command.as_dict()
384
389
 
385
- if command_type == "set slot":
390
+ if command_type == SET_SLOT_COMMAND:
386
391
  command_as_dict.pop("value", None)
387
392
 
388
393
  if command_type == "correct slot":
@@ -414,7 +419,7 @@ def extract_attrs_for_clean_up_commands(
414
419
  command_type = command.command()
415
420
  command_as_dict = command.as_dict()
416
421
 
417
- if command_type == "set slot":
422
+ if command_type == SET_SLOT_COMMAND:
418
423
  command_as_dict.pop("value", None)
419
424
 
420
425
  commands_list.append(command_as_dict)
@@ -467,7 +472,7 @@ def extract_attrs_for_check_commands_against_startable_flows(
467
472
  command_as_dict = command.as_dict()
468
473
  command_type = command.command()
469
474
 
470
- if command_type == "set slot":
475
+ if command_type == SET_SLOT_COMMAND:
471
476
  slot_value = command_as_dict.pop("value", None)
472
477
  command_as_dict["is_slot_value_missing_or_none"] = slot_value is None
473
478
 
@@ -523,7 +528,6 @@ def extract_attrs_for_policy_prediction(
523
528
  diagnostic_data: Optional[Dict[Text, Any]] = None,
524
529
  action_metadata: Optional[Dict[Text, Any]] = None,
525
530
  ) -> Dict[str, Any]:
526
-
527
531
  # diagnostic_data can contain ndarray type values which need to be converted
528
532
  # into a list since the returning values have to be JSON serializable.
529
533
  if isinstance(diagnostic_data, dict):
@@ -638,26 +642,31 @@ def extend_attributes_with_prompt_tokens_length(
638
642
  return attributes
639
643
 
640
644
 
641
- def extract_attrs_for_endpoint_config(
642
- self: "EndpointConfig",
643
- method: Text = "post",
644
- subpath: Optional[Text] = None,
645
- content_type: Optional[Text] = "application/json",
646
- compress: bool = False,
647
- **kwargs: Any,
645
+ def extract_attrs_for_custom_action_executor_run(
646
+ self: Union[HTTPCustomActionExecutor, GRPCCustomActionExecutor],
647
+ tracker: DialogueStateTracker,
648
+ domain: Domain,
649
+ include_domain: bool = False,
648
650
  ) -> Dict[str, Any]:
649
- request_body = kwargs.get("json")
650
- attrs: Dict[str, Any] = {"url": concat_url(self.url, subpath)}
651
+ attrs: Dict[str, Any] = {
652
+ "class_name": self.__class__.__name__,
653
+ "action_name": self.action_name if hasattr(self, "action_name") else "None",
654
+ "sender_id": tracker.sender_id,
655
+ "url": self.action_endpoint.url if hasattr(self, "action_endpoint") else "None",
656
+ }
657
+ return attrs
651
658
 
652
- if not request_body:
653
- attrs.update({ENDPOINT_REQUEST_BODY_SIZE_IN_BYTES_ATTRIBUTE_NAME: 0})
654
- else:
655
- attrs.update(
656
- {
657
- ENDPOINT_REQUEST_BODY_SIZE_IN_BYTES_ATTRIBUTE_NAME: len(
658
- json.dumps(request_body).encode("utf-8")
659
- )
660
- }
661
- )
659
+
660
+ def extract_attrs_for_grpc_custom_action_executor_request(
661
+ self: GRPCCustomActionExecutor,
662
+ request: action_webhook_pb2.WebhookRequest,
663
+ ) -> Dict[str, Any]:
664
+ attrs: Dict[str, Any] = {"url": self.action_endpoint.url}
665
+
666
+ attrs.update(
667
+ {
668
+ REQUEST_BODY_SIZE_IN_BYTES_ATTRIBUTE_NAME: request.ByteSize(),
669
+ }
670
+ )
662
671
 
663
672
  return attrs