rasa-pro 3.13.0.dev5__py3-none-any.whl → 3.13.0.dev7__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 (154) hide show
  1. rasa/api.py +4 -0
  2. rasa/cli/arguments/default_arguments.py +13 -1
  3. rasa/cli/arguments/train.py +2 -0
  4. rasa/cli/evaluate.py +1 -1
  5. rasa/cli/export.py +2 -2
  6. rasa/cli/train.py +1 -0
  7. rasa/constants.py +2 -0
  8. rasa/core/agent.py +2 -2
  9. rasa/core/brokers/kafka.py +4 -0
  10. rasa/core/brokers/pika.py +4 -0
  11. rasa/core/brokers/sql.py +1 -1
  12. rasa/core/channels/inspector/.eslintrc.cjs +12 -6
  13. rasa/core/channels/inspector/.prettierrc +5 -0
  14. rasa/core/channels/inspector/README.md +10 -4
  15. rasa/core/channels/inspector/dist/assets/{arc-9f75cc3b.js → arc-c4b064fc.js} +1 -1
  16. rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-7f34db23.js → blockDiagram-38ab4fdb-215b5026.js} +1 -1
  17. rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-948bab2c.js → c4Diagram-3d4e48cf-2b54a0a3.js} +1 -1
  18. rasa/core/channels/inspector/dist/assets/channel-3730f5fd.js +1 -0
  19. rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-53b0dd0e.js → classDiagram-70f12bd4-daacea5f.js} +1 -1
  20. rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-fdf789e7.js → classDiagram-v2-f2320105-930d4dc2.js} +1 -1
  21. rasa/core/channels/inspector/dist/assets/clone-e847561e.js +1 -0
  22. rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-87c4ece5.js → createText-2e5e7dd3-83c206ba.js} +1 -1
  23. rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-5a8b0749.js → edges-e0da2a9e-b0eb01d0.js} +1 -1
  24. rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-66da90e2.js → erDiagram-9861fffd-17586500.js} +1 -1
  25. rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-10044f05.js → flowDb-956e92f1-be2a1776.js} +1 -1
  26. rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-f338f66a.js → flowDiagram-66a62f08-c2120ebd.js} +1 -1
  27. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-efbbfe00.js +1 -0
  28. rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-b13140aa.js → flowchart-elk-definition-4a651766-a6ab5c48.js} +1 -1
  29. rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-f2b4a55a.js → ganttDiagram-c361ad54-ef613457.js} +1 -1
  30. rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-dedc298d.js → gitGraphDiagram-72cf32ee-d59185b3.js} +1 -1
  31. rasa/core/channels/inspector/dist/assets/{graph-4ede11ff.js → graph-0f155405.js} +1 -1
  32. rasa/core/channels/inspector/dist/assets/{index-3862675e-65549d37.js → index-3862675e-d5f1d1b7.js} +1 -1
  33. rasa/core/channels/inspector/dist/assets/{index-3a23e736.js → index-47737d3a.js} +123 -123
  34. rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-65439671.js → infoDiagram-f8f76790-b07d141f.js} +1 -1
  35. rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-56d03d98.js → journeyDiagram-49397b02-1936d429.js} +1 -1
  36. rasa/core/channels/inspector/dist/assets/{layout-dd48f7f4.js → layout-dde8d0f3.js} +1 -1
  37. rasa/core/channels/inspector/dist/assets/{line-1569ad2c.js → line-0c2c7ee0.js} +1 -1
  38. rasa/core/channels/inspector/dist/assets/{linear-48bf4935.js → linear-35dd89a4.js} +1 -1
  39. rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-688504c1.js → mindmap-definition-fc14e90a-56192851.js} +1 -1
  40. rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-78b6d7e6.js → pieDiagram-8a3498a8-fc21ed78.js} +1 -1
  41. rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-048b84b3.js → quadrantDiagram-120e2f19-25e98518.js} +1 -1
  42. rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-dd67f107.js → requirementDiagram-deff3bca-546ff1f5.js} +1 -1
  43. rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-8128436e.js → sankeyDiagram-04a897e0-02d8b82d.js} +1 -1
  44. rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-1a0d1461.js → sequenceDiagram-704730f1-3ca5a92e.js} +1 -1
  45. rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-46d388ed.js → stateDiagram-587899a1-128ea07c.js} +1 -1
  46. rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-ea42951a.js → stateDiagram-v2-d93cdb3a-95f290af.js} +1 -1
  47. rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-7427ed0c.js → styles-6aaf32cf-4984898a.js} +1 -1
  48. rasa/core/channels/inspector/dist/assets/{styles-9a916d00-ff5e5a16.js → styles-9a916d00-1bf266ba.js} +1 -1
  49. rasa/core/channels/inspector/dist/assets/{styles-c10674c1-7b3680cf.js → styles-c10674c1-60521c63.js} +1 -1
  50. rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-f860f2ad.js → svgDrawCommon-08f97a94-a25b6e12.js} +1 -1
  51. rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-2eebf0c8.js → timeline-definition-85554ec2-0fc086bf.js} +1 -1
  52. rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-5d7f4e96.js → xychartDiagram-e933f94c-44ee592e.js} +1 -1
  53. rasa/core/channels/inspector/dist/index.html +1 -1
  54. rasa/core/channels/inspector/package.json +3 -1
  55. rasa/core/channels/inspector/src/App.tsx +91 -90
  56. rasa/core/channels/inspector/src/components/Chat.tsx +45 -41
  57. rasa/core/channels/inspector/src/components/DiagramFlow.tsx +40 -40
  58. rasa/core/channels/inspector/src/components/DialogueInformation.tsx +57 -57
  59. rasa/core/channels/inspector/src/components/DialogueStack.tsx +36 -27
  60. rasa/core/channels/inspector/src/components/ExpandIcon.tsx +4 -4
  61. rasa/core/channels/inspector/src/components/FullscreenButton.tsx +7 -7
  62. rasa/core/channels/inspector/src/components/LoadingSpinner.tsx +28 -12
  63. rasa/core/channels/inspector/src/components/NoActiveFlow.tsx +9 -9
  64. rasa/core/channels/inspector/src/components/RasaLogo.tsx +5 -5
  65. rasa/core/channels/inspector/src/components/RecruitmentPanel.tsx +55 -60
  66. rasa/core/channels/inspector/src/components/SaraDiagrams.tsx +5 -5
  67. rasa/core/channels/inspector/src/components/Slots.tsx +22 -22
  68. rasa/core/channels/inspector/src/components/Welcome.tsx +28 -31
  69. rasa/core/channels/inspector/src/helpers/audio/audiostream.ts +245 -0
  70. rasa/core/channels/inspector/src/helpers/audio/microphone-processor.js +12 -0
  71. rasa/core/channels/inspector/src/helpers/audio/playback-processor.js +36 -0
  72. rasa/core/channels/inspector/src/helpers/conversation.ts +7 -7
  73. rasa/core/channels/inspector/src/helpers/formatters.test.ts +181 -181
  74. rasa/core/channels/inspector/src/helpers/formatters.ts +111 -111
  75. rasa/core/channels/inspector/src/helpers/utils.ts +78 -61
  76. rasa/core/channels/inspector/src/main.tsx +8 -8
  77. rasa/core/channels/inspector/src/theme/Button/Button.ts +8 -8
  78. rasa/core/channels/inspector/src/theme/Heading/Heading.ts +7 -7
  79. rasa/core/channels/inspector/src/theme/Input/Input.ts +9 -9
  80. rasa/core/channels/inspector/src/theme/Link/Link.ts +6 -6
  81. rasa/core/channels/inspector/src/theme/Modal/Modal.ts +13 -13
  82. rasa/core/channels/inspector/src/theme/Table/Table.tsx +10 -10
  83. rasa/core/channels/inspector/src/theme/Tooltip/Tooltip.ts +5 -5
  84. rasa/core/channels/inspector/src/theme/base/breakpoints.ts +7 -7
  85. rasa/core/channels/inspector/src/theme/base/colors.ts +64 -64
  86. rasa/core/channels/inspector/src/theme/base/fonts/fontFaces.css +21 -18
  87. rasa/core/channels/inspector/src/theme/base/radii.ts +8 -8
  88. rasa/core/channels/inspector/src/theme/base/shadows.ts +5 -5
  89. rasa/core/channels/inspector/src/theme/base/sizes.ts +5 -5
  90. rasa/core/channels/inspector/src/theme/base/space.ts +12 -12
  91. rasa/core/channels/inspector/src/theme/base/styles.ts +5 -5
  92. rasa/core/channels/inspector/src/theme/base/typography.ts +12 -12
  93. rasa/core/channels/inspector/src/theme/base/zIndices.ts +3 -3
  94. rasa/core/channels/inspector/src/theme/index.ts +38 -38
  95. rasa/core/channels/inspector/src/types.ts +56 -50
  96. rasa/core/channels/inspector/yarn.lock +5 -0
  97. rasa/core/channels/voice_ready/audiocodes.py +34 -17
  98. rasa/core/evaluation/marker_tracker_loader.py +1 -1
  99. rasa/core/exporter.py +1 -1
  100. rasa/core/nlg/contextual_response_rephraser.py +4 -2
  101. rasa/core/nlg/summarize.py +1 -1
  102. rasa/core/persistor.py +55 -20
  103. rasa/core/policies/enterprise_search_policy.py +7 -4
  104. rasa/core/policies/intentless_policy.py +15 -9
  105. rasa/core/processor.py +2 -2
  106. rasa/core/run.py +7 -2
  107. rasa/core/tracker_stores/__init__.py +0 -0
  108. rasa/core/{auth_retry_tracker_store.py → tracker_stores/auth_retry_tracker_store.py} +5 -1
  109. rasa/core/tracker_stores/dynamo_tracker_store.py +218 -0
  110. rasa/core/tracker_stores/mongo_tracker_store.py +206 -0
  111. rasa/core/tracker_stores/redis_tracker_store.py +219 -0
  112. rasa/core/tracker_stores/sql_tracker_store.py +555 -0
  113. rasa/core/tracker_stores/tracker_store.py +805 -0
  114. rasa/core/utils.py +6 -0
  115. rasa/dialogue_understanding/coexistence/llm_based_router.py +8 -3
  116. rasa/dialogue_understanding/commands/clarify_command.py +2 -2
  117. rasa/dialogue_understanding/commands/knowledge_answer_command.py +2 -2
  118. rasa/dialogue_understanding/generator/constants.py +2 -2
  119. rasa/dialogue_understanding/generator/llm_based_command_generator.py +1 -1
  120. rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v2_gpt_4o_2024_11_20_template.jinja2 +33 -12
  121. rasa/dialogue_understanding/generator/single_step/compact_llm_command_generator.py +2 -2
  122. rasa/hooks.py +2 -2
  123. rasa/keys +1 -0
  124. rasa/llm_fine_tuning/paraphrasing/conversation_rephraser.py +4 -2
  125. rasa/model_manager/config.py +3 -1
  126. rasa/model_manager/model_api.py +1 -2
  127. rasa/model_manager/runner_service.py +8 -4
  128. rasa/model_manager/trainer_service.py +1 -0
  129. rasa/model_training.py +12 -3
  130. rasa/nlu/extractors/crf_entity_extractor.py +66 -16
  131. rasa/plugin.py +1 -1
  132. rasa/server.py +6 -2
  133. rasa/shared/constants.py +3 -0
  134. rasa/shared/core/events.py +68 -2
  135. rasa/shared/providers/_configs/azure_openai_client_config.py +4 -0
  136. rasa/shared/providers/_configs/openai_client_config.py +4 -0
  137. rasa/shared/providers/embedding/_base_litellm_embedding_client.py +3 -0
  138. rasa/shared/providers/llm/_base_litellm_client.py +5 -2
  139. rasa/telemetry.py +2 -2
  140. rasa/tracing/config.py +1 -1
  141. rasa/tracing/instrumentation/attribute_extractors.py +1 -1
  142. rasa/tracing/instrumentation/instrumentation.py +1 -1
  143. rasa/utils/licensing.py +1 -2
  144. rasa/version.py +1 -1
  145. {rasa_pro-3.13.0.dev5.dist-info → rasa_pro-3.13.0.dev7.dist-info}/METADATA +4 -4
  146. {rasa_pro-3.13.0.dev5.dist-info → rasa_pro-3.13.0.dev7.dist-info}/RECORD +149 -140
  147. rasa/core/channels/inspector/dist/assets/channel-dfa68278.js +0 -1
  148. rasa/core/channels/inspector/dist/assets/clone-edb7f119.js +0 -1
  149. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-65e7c670.js +0 -1
  150. rasa/core/channels/inspector/src/helpers/audiostream.ts +0 -191
  151. rasa/core/tracker_store.py +0 -1792
  152. {rasa_pro-3.13.0.dev5.dist-info → rasa_pro-3.13.0.dev7.dist-info}/NOTICE +0 -0
  153. {rasa_pro-3.13.0.dev5.dist-info → rasa_pro-3.13.0.dev7.dist-info}/WHEEL +0 -0
  154. {rasa_pro-3.13.0.dev5.dist-info → rasa_pro-3.13.0.dev7.dist-info}/entry_points.txt +0 -0
rasa/core/utils.py CHANGED
@@ -198,6 +198,9 @@ class AvailableEndpoints:
198
198
  model_groups = read_property_config_from_endpoints_file(
199
199
  endpoint_file, property_name="model_groups"
200
200
  )
201
+ privacy = read_property_config_from_endpoints_file(
202
+ endpoint_file, property_name="privacy"
203
+ )
201
204
 
202
205
  return cls(
203
206
  nlg,
@@ -209,6 +212,7 @@ class AvailableEndpoints:
209
212
  event_broker,
210
213
  vector_store,
211
214
  model_groups,
215
+ privacy,
212
216
  )
213
217
 
214
218
  def __init__(
@@ -222,6 +226,7 @@ class AvailableEndpoints:
222
226
  event_broker: Optional[EndpointConfig] = None,
223
227
  vector_store: Optional[EndpointConfig] = None,
224
228
  model_groups: Optional[List[Dict[str, Any]]] = None,
229
+ privacy: Optional[Dict[Text, Any]] = None,
225
230
  ) -> None:
226
231
  """Create an `AvailableEndpoints` object."""
227
232
  self.model = model
@@ -233,6 +238,7 @@ class AvailableEndpoints:
233
238
  self.event_broker = event_broker
234
239
  self.vector_store = vector_store
235
240
  self.model_groups = model_groups
241
+ self.privacy = privacy
236
242
 
237
243
  @classmethod
238
244
  def get_instance(
@@ -23,11 +23,14 @@ from rasa.engine.recipes.default_recipe import DefaultV1Recipe
23
23
  from rasa.engine.storage.resource import Resource
24
24
  from rasa.engine.storage.storage import ModelStorage
25
25
  from rasa.shared.constants import (
26
+ LOGIT_BIAS_CONFIG_KEY,
27
+ MAX_COMPLETION_TOKENS_CONFIG_KEY,
26
28
  MODEL_CONFIG_KEY,
27
29
  OPENAI_PROVIDER,
28
30
  PROMPT_CONFIG_KEY,
29
31
  PROVIDER_CONFIG_KEY,
30
32
  ROUTE_TO_CALM_SLOT,
33
+ TEMPERATURE_CONFIG_KEY,
31
34
  TIMEOUT_CONFIG_KEY,
32
35
  )
33
36
  from rasa.shared.core.trackers import DialogueStateTracker
@@ -66,9 +69,11 @@ DEFAULT_LLM_CONFIG = {
66
69
  PROVIDER_CONFIG_KEY: OPENAI_PROVIDER,
67
70
  MODEL_CONFIG_KEY: DEFAULT_OPENAI_CHAT_MODEL_NAME,
68
71
  TIMEOUT_CONFIG_KEY: 7,
69
- "temperature": 0.0,
70
- "max_tokens": 1,
71
- "logit_bias": {str(token_id): 100 for token_id in A_TO_C_TOKEN_IDS_CHATGPT},
72
+ TEMPERATURE_CONFIG_KEY: 0.0,
73
+ MAX_COMPLETION_TOKENS_CONFIG_KEY: 1,
74
+ LOGIT_BIAS_CONFIG_KEY: {
75
+ str(token_id): 100 for token_id in A_TO_C_TOKEN_IDS_CHATGPT
76
+ },
72
77
  }
73
78
 
74
79
  structlogger = structlog.get_logger()
@@ -117,9 +117,9 @@ class ClarifyCommand(Command):
117
117
  @staticmethod
118
118
  def regex_pattern() -> str:
119
119
  mapper = {
120
- CommandSyntaxVersion.v1: r"Clarify\(([\"\'a-zA-Z0-9_, ]*)\)",
120
+ CommandSyntaxVersion.v1: r"Clarify\(([\"\'a-zA-Z0-9_, -]*)\)",
121
121
  CommandSyntaxVersion.v2: (
122
- r"""^[\s\W\d]*disambiguate flows (["'a-zA-Z0-9_, ]*)['"`]*$"""
122
+ r"""^[\s\W\d]*disambiguate flows (["'a-zA-Z0-9_, -]*)['"`]*$"""
123
123
  ),
124
124
  }
125
125
  return mapper.get(
@@ -65,7 +65,7 @@ class KnowledgeAnswerCommand(FreeFormAnswerCommand):
65
65
  """Converts the command to a DSL string."""
66
66
  mapper = {
67
67
  CommandSyntaxVersion.v1: "SearchAndReply()",
68
- CommandSyntaxVersion.v2: "provide info",
68
+ CommandSyntaxVersion.v2: "search and reply",
69
69
  }
70
70
  return mapper.get(
71
71
  CommandSyntaxManager.get_syntax_version(),
@@ -81,7 +81,7 @@ class KnowledgeAnswerCommand(FreeFormAnswerCommand):
81
81
  def regex_pattern() -> str:
82
82
  mapper = {
83
83
  CommandSyntaxVersion.v1: r"SearchAndReply\(\)",
84
- CommandSyntaxVersion.v2: r"""^[\s\W\d]*provide info['"`]*$""",
84
+ CommandSyntaxVersion.v2: r"""^[\s\W\d]*search and reply['"`]*$""",
85
85
  }
86
86
  return mapper.get(
87
87
  CommandSyntaxManager.get_syntax_version(),
@@ -1,5 +1,5 @@
1
1
  from rasa.shared.constants import (
2
- MAX_TOKENS_CONFIG_KEY,
2
+ MAX_COMPLETION_TOKENS_CONFIG_KEY,
3
3
  MODEL_CONFIG_KEY,
4
4
  OPENAI_PROVIDER,
5
5
  PROVIDER_CONFIG_KEY,
@@ -15,7 +15,7 @@ DEFAULT_LLM_CONFIG = {
15
15
  PROVIDER_CONFIG_KEY: OPENAI_PROVIDER,
16
16
  MODEL_CONFIG_KEY: DEFAULT_OPENAI_CHAT_MODEL_NAME_ADVANCED,
17
17
  TEMPERATURE_CONFIG_KEY: 0.0,
18
- MAX_TOKENS_CONFIG_KEY: DEFAULT_OPENAI_MAX_GENERATED_TOKENS,
18
+ MAX_COMPLETION_TOKENS_CONFIG_KEY: DEFAULT_OPENAI_MAX_GENERATED_TOKENS,
19
19
  TIMEOUT_CONFIG_KEY: 7,
20
20
  }
21
21
 
@@ -527,7 +527,7 @@ class LLMBasedCommandGenerator(
527
527
  either contain a StartFlowCommand or a SetSlot command
528
528
  for the current collect step.
529
529
  """
530
- return self.config.get(KEY_MINIMIZE_NUM_CALLS, False) and (
530
+ return self.config.get(KEY_MINIMIZE_NUM_CALLS, True) and (
531
531
  self._prior_commands_contain_start_flow(prior_commands)
532
532
  or self._prior_commands_contain_set_slot_for_active_collect_step(
533
533
  prior_commands, flows, tracker
@@ -1,5 +1,5 @@
1
1
  ## Task Description
2
- Your task is to analyze the current conversation context and generate a list of actions to start new business processes that we call flows, to extract slots, or respond to small talk and knowledge requests.
2
+ Your task is to analyze the current conversation context and generate a list of actions to start new business processes that we call flows, to extract slots, or respond to off-topic and knowledge requests.
3
3
 
4
4
  ---
5
5
 
@@ -12,31 +12,52 @@ Use the following structured data:
12
12
  ---
13
13
 
14
14
  ## Available Actions:
15
- * `start flow flow_name`: Starting a flow. For example, `start flow transfer_money` or `start flow list_contacts`.
16
- * `set slot slot_name slot_value`: Slot setting. For example, `set slot transfer_money_recipient Freddy`. Can be used to correct and change previously set values.
17
- * `cancel flow`: Cancelling the current flow.
18
- * `disambiguate flows flow_name1 flow_name2 ... flow_name_n`: Disambiguate which flow should be started when user input is ambiguous by listing the potential flows as options. For example, `disambiguate flows list_contacts add_contact remove_contact ...` if the user just wrote "contacts".
19
- * `provide info`: Responding to the user's questions by supplying relevant information, such as answering FAQs or explaining services.
20
- * `offtopic reply`: Responding to casual or social user messages that are unrelated to any flows, engaging in friendly conversation and addressing off-topic remarks.
21
- * `hand over`: Handing over to a human, in case the user seems frustrated or explicitly asks to speak to one.
15
+ * `start flow flow_name`: Start a flow. For example, `start flow transfer_money` or `start flow list_contacts`.
16
+ * `set slot slot_name slot_value`: Set a slot for the active flow. For example, `set slot transfer_money_recipient Freddy`. Can be used to correct and change previously set values.
17
+ * `disambiguate flows flow_name1 flow_name2 ... flow_name_n`: When a message could refer to multiple flows, list the possible flows as options to clarify. Example: `disambiguate flows list_contacts add_contact remove_contact`.
18
+ * `search and reply`: Provide a response from the knowledge base to address the user’s inquiry when no flows fit, including domain knowledge, FAQs, and all off-topic or social messages.
19
+ * `cancel flow`: Cancel the current flow if the user requests it.
22
20
 
23
21
  ---
24
22
 
25
- ## General Tips
23
+ ## General Instructions
24
+ ### Start Flow
25
+ * Only start a flow if the user's message is clear and fully addressed by that flow's description and purpose.
26
+ * Pay close attention to exact wording and scope in the flow description — do not assume or “stretch” the intended use of a flow.
27
+ ### Set Slot
26
28
  * Do not fill slots with abstract values or placeholders.
27
29
  * For categorical slots try to match the user message with allowed slot values. Use "other" if you cannot match it.
28
30
  * Set the boolean slots based on the user response. Map positive responses to `True`, and negative to `False`.
29
31
  * Extract text slot values exactly as provided by the user. Avoid assumptions, format changes, or partial extractions.
32
+ ### Disambiguate Flows
33
+ * Use `disambiguate flows` when the user's message matches multiple flows and you cannot decide which flow is most appropriate.
34
+ * If the user message is short and not precise enough to start a flow or `search and reply`, disambiguate.
35
+ * If a single flow is a strong/plausible fit, prefer starting that flow directly.
36
+ * If a user's message unambiguously and distinctly matches multiple flows, start all relevant flows at once (rather than disambiguating).
37
+ ### Search and Reply
38
+ * Only start `search and reply` if the user intent is clear.
39
+ * Flow Priority: If you are unsure between starting a flow or `search and reply`, always prioritize starting a flow.
40
+ ### Cancel Flow
41
+ * Do not cancel any flow unless the user explicitly requests it.
42
+ * Multiple flows can be started without cancelling the previous, if the user wants to pursue multiple processes.
43
+ ### General Tips
30
44
  * Only use information provided by the user.
31
- * Use clarification in ambiguous cases.
32
- * Multiple flows can be started. If a user wants to digress into a second flow, you do not need to cancel the current flow.
33
- * Do not cancel the flow unless the user explicitly requests it.
34
45
  * Strictly adhere to the provided action format.
35
46
  * Focus on the last message and take it one step at a time.
36
47
  * Use the previous conversation steps only to aid understanding.
37
48
 
38
49
  ---
39
50
 
51
+ ## Decision Rule Table
52
+ | Condition | Action |
53
+ |-------------------------------------------------------|--------------------|
54
+ | Flow perfectly matches user's message | start flow |
55
+ | Multiple flows are equally strong, relevant matches | disambiguate flows |
56
+ | User's message is unclear or imprecise | disambiguate flows |
57
+ | No flow fits at all, but knowledge base may help | search and reply |
58
+
59
+ ---
60
+
40
61
  ## Current State
41
62
  {% if current_flow != None %}Use the following structured data:
42
63
  ```json
@@ -47,7 +47,7 @@ from rasa.shared.constants import (
47
47
  AWS_BEDROCK_PROVIDER,
48
48
  AZURE_OPENAI_PROVIDER,
49
49
  EMBEDDINGS_CONFIG_KEY,
50
- MAX_TOKENS_CONFIG_KEY,
50
+ MAX_COMPLETION_TOKENS_CONFIG_KEY,
51
51
  PROMPT_TEMPLATE_CONFIG_KEY,
52
52
  ROUTE_TO_CALM_SLOT,
53
53
  TEMPERATURE_CONFIG_KEY,
@@ -81,7 +81,7 @@ DEFAULT_LLM_CONFIG = {
81
81
  PROVIDER_CONFIG_KEY: OPENAI_PROVIDER,
82
82
  MODEL_CONFIG_KEY: MODEL_NAME_GPT_4O_2024_11_20,
83
83
  TEMPERATURE_CONFIG_KEY: 0.0,
84
- MAX_TOKENS_CONFIG_KEY: DEFAULT_OPENAI_MAX_GENERATED_TOKENS,
84
+ MAX_COMPLETION_TOKENS_CONFIG_KEY: DEFAULT_OPENAI_MAX_GENERATED_TOKENS,
85
85
  TIMEOUT_CONFIG_KEY: 7,
86
86
  }
87
87
 
rasa/hooks.py CHANGED
@@ -12,7 +12,7 @@ if TYPE_CHECKING:
12
12
  from rasa.anonymization.anonymization_pipeline import AnonymizationPipeline
13
13
  from rasa.cli import SubParsersAction
14
14
  from rasa.core.brokers.broker import EventBroker
15
- from rasa.core.tracker_store import TrackerStore
15
+ from rasa.core.tracker_stores.tracker_store import TrackerStore
16
16
  from rasa.shared.core.domain import Domain
17
17
  from rasa.utils.endpoints import EndpointConfig
18
18
 
@@ -80,7 +80,7 @@ def create_tracker_store(
80
80
  domain: "Domain",
81
81
  event_broker: Optional["EventBroker"],
82
82
  ) -> "TrackerStore":
83
- from rasa.core.auth_retry_tracker_store import AuthRetryTrackerStore
83
+ from rasa.core.tracker_stores.auth_retry_tracker_store import AuthRetryTrackerStore
84
84
  from rasa.utils.endpoints import EndpointConfig
85
85
 
86
86
  if isinstance(endpoint_config, EndpointConfig):
rasa/keys ADDED
@@ -0,0 +1 @@
1
+ {"segment": "CcvVD1I68Nkkxrv93cIqv1twIwrwG8nz", "sentry": "a283f1fde04347b099c8d729109dd450@o251570"}
@@ -11,10 +11,12 @@ from rasa.llm_fine_tuning.paraphrasing.rephrased_user_message import (
11
11
  )
12
12
  from rasa.shared.constants import (
13
13
  LLM_CONFIG_KEY,
14
+ MAX_COMPLETION_TOKENS_CONFIG_KEY,
14
15
  MODEL_CONFIG_KEY,
15
16
  MODEL_NAME_CONFIG_KEY,
16
17
  PROMPT_TEMPLATE_CONFIG_KEY,
17
18
  PROVIDER_CONFIG_KEY,
19
+ TEMPERATURE_CONFIG_KEY,
18
20
  TIMEOUT_CONFIG_KEY,
19
21
  )
20
22
  from rasa.shared.exceptions import ProviderClientAPIException
@@ -39,8 +41,8 @@ DEFAULT_LLM_CONFIG = {
39
41
  PROVIDER_CONFIG_KEY: OPENAI_PROVIDER,
40
42
  MODEL_CONFIG_KEY: "gpt-4o-mini",
41
43
  TIMEOUT_CONFIG_KEY: 7,
42
- "temperature": 0.0,
43
- "max_tokens": 4096,
44
+ TEMPERATURE_CONFIG_KEY: 0.0,
45
+ MAX_COMPLETION_TOKENS_CONFIG_KEY: 4096,
44
46
  }
45
47
 
46
48
  structlogger = structlog.get_logger()
@@ -1,6 +1,8 @@
1
1
  import os
2
2
  import sys
3
3
 
4
+ from rasa.constants import RASA_REMOTE_STORAGE_ENV_VAR_NAME
5
+
4
6
  DEFAULT_SERVER_BASE_WORKING_DIRECTORY = "working-data"
5
7
 
6
8
  SERVER_BASE_WORKING_DIRECTORY = os.environ.get(
@@ -12,7 +14,7 @@ SERVER_PORT = os.environ.get("RASA_MODEL_SERVER_PORT", 8000)
12
14
  SERVER_BASE_URL = os.environ.get("RASA_MODEL_SERVER_BASE_URL", None)
13
15
 
14
16
  # defaults to storing on the local hard drive
15
- SERVER_MODEL_REMOTE_STORAGE = os.environ.get("RASA_REMOTE_STORAGE", None)
17
+ SERVER_MODEL_REMOTE_STORAGE = os.environ.get(RASA_REMOTE_STORAGE_ENV_VAR_NAME, None)
16
18
 
17
19
  # The path to the python executable that is running this script
18
20
  # we will use the same python to run training / bots
@@ -532,8 +532,7 @@ def size_of_model(model_name: str) -> Optional[int]:
532
532
  model_name=model_file_name,
533
533
  )
534
534
  return fetch_size_of_remote_model(
535
- model_file_name,
536
- config.SERVER_MODEL_REMOTE_STORAGE,
535
+ model_file_name, config.SERVER_MODEL_REMOTE_STORAGE, model_path
537
536
  )
538
537
  raise ModelNotFound("Model not found.")
539
538
 
@@ -166,13 +166,13 @@ def fetch_remote_model_to_dir(
166
166
  ) -> str:
167
167
  """Fetch the model from remote storage.
168
168
 
169
- Returns the path to the model diretory.
169
+ Returns the path to the model directory.
170
170
  """
171
171
  from rasa.core.persistor import get_persistor
172
172
 
173
173
  persistor = get_persistor(storage_type)
174
174
 
175
- # we now there must be a persistor, because the config is set
175
+ # we know there must be a persistor, because the config is set
176
176
  # this is here to please the type checker for the call below
177
177
  assert persistor is not None
178
178
 
@@ -182,7 +182,9 @@ def fetch_remote_model_to_dir(
182
182
  raise ModelNotFound() from e
183
183
 
184
184
 
185
- def fetch_size_of_remote_model(model_name: str, storage_type: str) -> int:
185
+ def fetch_size_of_remote_model(
186
+ model_name: str, storage_type: str, model_path: str
187
+ ) -> int:
186
188
  """Fetch the size of the model from remote storage."""
187
189
  from rasa.core.persistor import get_persistor
188
190
 
@@ -192,7 +194,9 @@ def fetch_size_of_remote_model(model_name: str, storage_type: str) -> int:
192
194
  # this is here to please the type checker for the call below
193
195
  assert persistor is not None
194
196
 
195
- return persistor.size_of_persisted_model(model_name=model_name)
197
+ return persistor.size_of_persisted_model(
198
+ model_name=model_name, target_path=model_path
199
+ )
196
200
 
197
201
 
198
202
  def start_bot_process(
@@ -278,6 +278,7 @@ def start_training_process(
278
278
  "--keep-local-model-copy",
279
279
  "--remote-storage",
280
280
  config.SERVER_MODEL_REMOTE_STORAGE,
281
+ "--remote-root-only",
281
282
  ]
282
283
  )
283
284
 
rasa/model_training.py CHANGED
@@ -160,6 +160,7 @@ async def train(
160
160
  remote_storage: Optional[StorageType] = None,
161
161
  file_importer: Optional[TrainingDataImporter] = None,
162
162
  keep_local_model_copy: bool = False,
163
+ remote_root_only: bool = False,
163
164
  ) -> TrainingResult:
164
165
  """Trains a Rasa model (Core and NLU).
165
166
 
@@ -187,6 +188,8 @@ async def train(
187
188
  If it is not provided, a new instance will be created.
188
189
  keep_local_model_copy: If `True` the model will be stored locally even if
189
190
  remote storage is configured.
191
+ remote_root_only: If `True`, the model will be stored in the root of the
192
+ remote model storage.
190
193
 
191
194
  Returns:
192
195
  An instance of `TrainingResult`.
@@ -269,6 +272,7 @@ async def train(
269
272
  dry_run=dry_run,
270
273
  remote_storage=remote_storage,
271
274
  keep_local_model_copy=keep_local_model_copy,
275
+ remote_root_only=remote_root_only,
272
276
  **(core_additional_arguments or {}),
273
277
  **(nlu_additional_arguments or {}),
274
278
  )
@@ -284,6 +288,7 @@ async def _train_graph(
284
288
  dry_run: bool = False,
285
289
  remote_storage: Optional[StorageType] = None,
286
290
  keep_local_model_copy: bool = False,
291
+ remote_root_only: bool = False,
287
292
  **kwargs: Any,
288
293
  ) -> TrainingResult:
289
294
  if model_to_finetune:
@@ -363,7 +368,9 @@ async def _train_graph(
363
368
  is_finetuning=is_finetuning,
364
369
  )
365
370
  if remote_storage:
366
- push_model_to_remote_storage(full_model_path, remote_storage)
371
+ push_model_to_remote_storage(
372
+ full_model_path, remote_storage, remote_root_only
373
+ )
367
374
  if not keep_local_model_copy:
368
375
  full_model_path.unlink()
369
376
  structlogger.info(
@@ -581,14 +588,16 @@ async def train_nlu(
581
588
  ).model
582
589
 
583
590
 
584
- def push_model_to_remote_storage(model_path: Path, remote_storage: StorageType) -> None:
591
+ def push_model_to_remote_storage(
592
+ model_path: Path, remote_storage: StorageType, remote_root_only: bool = False
593
+ ) -> None:
585
594
  """Push model to remote storage."""
586
595
  from rasa.core.persistor import get_persistor
587
596
 
588
597
  persistor = get_persistor(remote_storage)
589
598
 
590
599
  if persistor is not None:
591
- persistor.persist(str(model_path))
600
+ persistor.persist(str(model_path), remote_root_only)
592
601
 
593
602
  else:
594
603
  raise RasaException(
@@ -1,9 +1,11 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import logging
4
+ import shutil
4
5
  import typing
5
6
  from collections import OrderedDict
6
7
  from enum import Enum
8
+ from pathlib import Path
7
9
  from typing import Any, Callable, Dict, List, Optional, Text, Tuple, Type
8
10
 
9
11
  import numpy as np
@@ -43,6 +45,10 @@ if typing.TYPE_CHECKING:
43
45
 
44
46
  CONFIG_FEATURES = "features"
45
47
 
48
+ TAGGERS_DIR = "taggers"
49
+ CRFSUITE_MODEL_FILE_NAME = "model.crfsuite"
50
+ PLAIN_CRF_MODEL_FILE_NAME = "model.txt"
51
+
46
52
 
47
53
  class CRFToken:
48
54
  def __init__(
@@ -419,19 +425,11 @@ class CRFEntityExtractor(GraphComponent, EntityExtractorMixin):
419
425
  """Loads trained component (see parent class for full docstring)."""
420
426
  try:
421
427
  with model_storage.read_from(resource) as model_dir:
422
- dataset = rasa.shared.utils.io.read_json_file(
423
- model_dir / "crf_dataset.json"
424
- )
425
428
  crf_order = rasa.shared.utils.io.read_json_file(
426
429
  model_dir / "crf_order.json"
427
430
  )
428
431
 
429
- dataset = [
430
- [CRFToken.create_from_dict(token_data) for token_data in sub_list]
431
- for sub_list in dataset
432
- ]
433
-
434
- entity_taggers = cls.train_model(dataset, config, crf_order)
432
+ entity_taggers = cls._load_taggers(model_dir, config)
435
433
 
436
434
  entity_extractor = cls(config, model_storage, resource, entity_taggers)
437
435
  entity_extractor.crf_order = crf_order
@@ -443,19 +441,71 @@ class CRFEntityExtractor(GraphComponent, EntityExtractorMixin):
443
441
  )
444
442
  return cls(config, model_storage, resource)
445
443
 
444
+ @classmethod
445
+ def _load_taggers(
446
+ cls, model_dir: Path, config: Dict[Text, Any]
447
+ ) -> Dict[str, "CRF"]:
448
+ """
449
+ Load taggers from model directory that persists trained binary
450
+ `model.crfsuite` files.
451
+ """
452
+
453
+ import pycrfsuite
454
+ import sklearn_crfsuite
455
+
456
+ # Get tagger directories
457
+ taggers_base = model_dir / TAGGERS_DIR
458
+ if not taggers_base.exists():
459
+ return {}
460
+
461
+ taggers_dirs = [
462
+ directory for directory in taggers_base.iterdir() if directory.is_dir()
463
+ ]
464
+
465
+ entity_taggers: Dict[str, "CRF"] = {}
466
+
467
+ for tagger_dir in taggers_dirs:
468
+ # Instantiate sklearns CRF wrapper for the pycrfsuite's Tagger
469
+ entity_tagger = sklearn_crfsuite.CRF(
470
+ algorithm="lbfgs",
471
+ # coefficient for L1 penalty
472
+ c1=config["L1_c"],
473
+ # coefficient for L2 penalty
474
+ c2=config["L2_c"],
475
+ # stop earlier
476
+ max_iterations=config["max_iterations"],
477
+ # include transitions that are possible, but not observed
478
+ all_possible_transitions=True,
479
+ )
480
+
481
+ # Load pycrfsuite tagger from the persisted binary model.crfsuite file
482
+ entity_tagger._tagger = pycrfsuite.Tagger()
483
+ entity_tagger._tagger.open(str(tagger_dir / CRFSUITE_MODEL_FILE_NAME))
484
+
485
+ entity_taggers[tagger_dir.name] = entity_tagger
486
+
487
+ return entity_taggers
488
+
446
489
  def persist(self, dataset: List[List[CRFToken]]) -> None:
447
490
  """Persist this model into the passed directory."""
448
491
  with self._model_storage.write_to(self._resource) as model_dir:
449
- data_to_store = [
450
- [token.to_dict() for token in sub_list] for sub_list in dataset
451
- ]
452
-
453
- rasa.shared.utils.io.dump_obj_as_json_to_file(
454
- model_dir / "crf_dataset.json", data_to_store
455
- )
456
492
  rasa.shared.utils.io.dump_obj_as_json_to_file(
457
493
  model_dir / "crf_order.json", self.crf_order
458
494
  )
495
+ if self.entity_taggers is not None:
496
+ for tag_name, entity_tagger in self.entity_taggers.items():
497
+ # Create the directories for storing the CRF model
498
+ tagger_dir = model_dir / TAGGERS_DIR / tag_name
499
+ tagger_dir.mkdir(parents=True, exist_ok=True)
500
+ # Create a plain text version of the CRF model
501
+ entity_tagger.tagger_.dump(
502
+ str(tagger_dir / PLAIN_CRF_MODEL_FILE_NAME)
503
+ )
504
+ # Persist binary version of the model.crfsuite
505
+ shutil.copy2(
506
+ src=entity_tagger.modelfile.name,
507
+ dst=tagger_dir / CRFSUITE_MODEL_FILE_NAME,
508
+ )
459
509
 
460
510
  @classmethod
461
511
  def _crf_tokens_to_features(
rasa/plugin.py CHANGED
@@ -11,7 +11,7 @@ from rasa.cli import SubParsersAction
11
11
 
12
12
  if TYPE_CHECKING:
13
13
  from rasa.core.brokers.broker import EventBroker
14
- from rasa.core.tracker_store import TrackerStore
14
+ from rasa.core.tracker_stores.tracker_store import TrackerStore
15
15
  from rasa.shared.core.domain import Domain
16
16
  from rasa.shared.core.trackers import DialogueStateTracker
17
17
  from rasa.utils.endpoints import EndpointConfig
rasa/server.py CHANGED
@@ -522,12 +522,15 @@ def configure_cors(
522
522
  )
523
523
 
524
524
 
525
- def add_root_route(app: Sanic) -> None:
525
+ def add_root_route(app: Sanic, is_inspector_enabled: bool = False) -> None:
526
526
  """Add '/' route to return hello."""
527
527
 
528
528
  @app.get("/")
529
529
  async def hello(request: Request) -> HTTPResponse:
530
530
  """Check if the server is running and responds with the version."""
531
+ if not is_inspector_enabled:
532
+ return response.text("Hello from Rasa: " + rasa.__version__)
533
+
531
534
  html_content = f"""
532
535
  <html>
533
536
  <body>
@@ -688,6 +691,7 @@ def create_app(
688
691
  jwt_private_key: Optional[Text] = None,
689
692
  jwt_method: Text = "HS256",
690
693
  endpoints: Optional[AvailableEndpoints] = None,
694
+ is_inspector_enabled: bool = False,
691
695
  ) -> Sanic:
692
696
  """Class representing a Rasa HTTP server."""
693
697
  app = Sanic("rasa_server")
@@ -733,7 +737,7 @@ def create_app(
733
737
  ) -> HTTPResponse:
734
738
  return response.json(exception.error_info, status=exception.status)
735
739
 
736
- add_root_route(app)
740
+ add_root_route(app, is_inspector_enabled)
737
741
 
738
742
  @app.get("/version")
739
743
  async def version(request: Request) -> HTTPResponse:
rasa/shared/constants.py CHANGED
@@ -197,7 +197,10 @@ PROVIDER_CONFIG_KEY = "provider"
197
197
  REQUEST_TIMEOUT_CONFIG_KEY = "request_timeout" # deprecated
198
198
  TIMEOUT_CONFIG_KEY = "timeout"
199
199
 
200
+ LOGIT_BIAS_CONFIG_KEY = "logit_bias"
201
+ MAX_RETRIES_CONFIG_KEY = "max_retries"
200
202
  TEMPERATURE_CONFIG_KEY = "temperature"
203
+ MAX_COMPLETION_TOKENS_CONFIG_KEY = "max_completion_tokens"
201
204
  MAX_TOKENS_CONFIG_KEY = "max_tokens"
202
205
 
203
206
  DEPLOYMENT_NAME_CONFIG_KEY = "deployment_name"