rasa-pro 3.11.0a4.dev3__py3-none-any.whl → 3.11.0rc2__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 (184) hide show
  1. rasa/__main__.py +22 -12
  2. rasa/api.py +1 -1
  3. rasa/cli/arguments/default_arguments.py +1 -2
  4. rasa/cli/arguments/shell.py +5 -1
  5. rasa/cli/e2e_test.py +1 -1
  6. rasa/cli/evaluate.py +8 -8
  7. rasa/cli/inspect.py +6 -4
  8. rasa/cli/llm_fine_tuning.py +1 -1
  9. rasa/cli/project_templates/calm/config.yml +5 -7
  10. rasa/cli/project_templates/calm/endpoints.yml +8 -0
  11. rasa/cli/project_templates/tutorial/config.yml +8 -5
  12. rasa/cli/project_templates/tutorial/data/flows.yml +1 -1
  13. rasa/cli/project_templates/tutorial/data/patterns.yml +5 -0
  14. rasa/cli/project_templates/tutorial/domain.yml +14 -0
  15. rasa/cli/project_templates/tutorial/endpoints.yml +7 -7
  16. rasa/cli/run.py +1 -1
  17. rasa/cli/scaffold.py +4 -2
  18. rasa/cli/studio/studio.py +18 -8
  19. rasa/cli/utils.py +5 -0
  20. rasa/cli/x.py +8 -8
  21. rasa/constants.py +1 -1
  22. rasa/core/actions/action_repeat_bot_messages.py +17 -0
  23. rasa/core/channels/channel.py +20 -0
  24. rasa/core/channels/inspector/dist/assets/{arc-6852c607.js → arc-bc141fb2.js} +1 -1
  25. rasa/core/channels/inspector/dist/assets/{c4Diagram-d0fbc5ce-acc952b2.js → c4Diagram-d0fbc5ce-be2db283.js} +1 -1
  26. rasa/core/channels/inspector/dist/assets/{classDiagram-936ed81e-848a7597.js → classDiagram-936ed81e-55366915.js} +1 -1
  27. rasa/core/channels/inspector/dist/assets/{classDiagram-v2-c3cb15f1-a73d3e68.js → classDiagram-v2-c3cb15f1-bb529518.js} +1 -1
  28. rasa/core/channels/inspector/dist/assets/{createText-62fc7601-e5ee049d.js → createText-62fc7601-b0ec81d6.js} +1 -1
  29. rasa/core/channels/inspector/dist/assets/{edges-f2ad444c-771e517e.js → edges-f2ad444c-6166330c.js} +1 -1
  30. rasa/core/channels/inspector/dist/assets/{erDiagram-9d236eb7-aa347178.js → erDiagram-9d236eb7-5ccc6a8e.js} +1 -1
  31. rasa/core/channels/inspector/dist/assets/{flowDb-1972c806-651fc57d.js → flowDb-1972c806-fca3bfe4.js} +1 -1
  32. rasa/core/channels/inspector/dist/assets/{flowDiagram-7ea5b25a-ca67804f.js → flowDiagram-7ea5b25a-4739080f.js} +1 -1
  33. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-855bc5b3-736177bf.js +1 -0
  34. rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-abe16c3d-2dbc568d.js → flowchart-elk-definition-abe16c3d-7c1b0e0f.js} +1 -1
  35. rasa/core/channels/inspector/dist/assets/{ganttDiagram-9b5ea136-25a65bd8.js → ganttDiagram-9b5ea136-772fd050.js} +1 -1
  36. rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-99d0ae7c-fdc7378d.js → gitGraphDiagram-99d0ae7c-8eae1dc9.js} +1 -1
  37. rasa/core/channels/inspector/dist/assets/{index-2c4b9a3b-6f1fd606.js → index-2c4b9a3b-f55afcdf.js} +1 -1
  38. rasa/core/channels/inspector/dist/assets/{index-efdd30c1.js → index-e7cef9de.js} +68 -68
  39. rasa/core/channels/inspector/dist/assets/{infoDiagram-736b4530-cb1a041a.js → infoDiagram-736b4530-124d4a14.js} +1 -1
  40. rasa/core/channels/inspector/dist/assets/{journeyDiagram-df861f2b-14609879.js → journeyDiagram-df861f2b-7c4fae44.js} +1 -1
  41. rasa/core/channels/inspector/dist/assets/{layout-2490f52b.js → layout-b9885fb6.js} +1 -1
  42. rasa/core/channels/inspector/dist/assets/{line-40186f1f.js → line-7c59abb6.js} +1 -1
  43. rasa/core/channels/inspector/dist/assets/{linear-08814e93.js → linear-4776f780.js} +1 -1
  44. rasa/core/channels/inspector/dist/assets/{mindmap-definition-beec6740-1a534584.js → mindmap-definition-beec6740-2332c46c.js} +1 -1
  45. rasa/core/channels/inspector/dist/assets/{pieDiagram-dbbf0591-72397b61.js → pieDiagram-dbbf0591-8fb39303.js} +1 -1
  46. rasa/core/channels/inspector/dist/assets/{quadrantDiagram-4d7f4fd6-3bb0b6a3.js → quadrantDiagram-4d7f4fd6-3c7180a2.js} +1 -1
  47. rasa/core/channels/inspector/dist/assets/{requirementDiagram-6fc4c22a-57334f61.js → requirementDiagram-6fc4c22a-e910bcb8.js} +1 -1
  48. rasa/core/channels/inspector/dist/assets/{sankeyDiagram-8f13d901-111e1297.js → sankeyDiagram-8f13d901-ead16c89.js} +1 -1
  49. rasa/core/channels/inspector/dist/assets/{sequenceDiagram-b655622a-10bcfe62.js → sequenceDiagram-b655622a-29a02a19.js} +1 -1
  50. rasa/core/channels/inspector/dist/assets/{stateDiagram-59f0c015-acaf7513.js → stateDiagram-59f0c015-042b3137.js} +1 -1
  51. rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-2b26beab-3ec2a235.js → stateDiagram-v2-2b26beab-2178c0f3.js} +1 -1
  52. rasa/core/channels/inspector/dist/assets/{styles-080da4f6-62730289.js → styles-080da4f6-23ffa4fc.js} +1 -1
  53. rasa/core/channels/inspector/dist/assets/{styles-3dcbcfbf-5284ee76.js → styles-3dcbcfbf-94f59763.js} +1 -1
  54. rasa/core/channels/inspector/dist/assets/{styles-9c745c82-642435e3.js → styles-9c745c82-78a6bebc.js} +1 -1
  55. rasa/core/channels/inspector/dist/assets/{svgDrawCommon-4835440b-b250a350.js → svgDrawCommon-4835440b-eae2a6f6.js} +1 -1
  56. rasa/core/channels/inspector/dist/assets/{timeline-definition-5b62e21b-c2b147ed.js → timeline-definition-5b62e21b-5c968d92.js} +1 -1
  57. rasa/core/channels/inspector/dist/assets/{xychartDiagram-2b33534f-f92cfea9.js → xychartDiagram-2b33534f-fd3db0d5.js} +1 -1
  58. rasa/core/channels/inspector/dist/index.html +1 -1
  59. rasa/core/channels/inspector/src/App.tsx +1 -1
  60. rasa/core/channels/inspector/src/helpers/audiostream.ts +77 -16
  61. rasa/core/channels/socketio.py +2 -1
  62. rasa/core/channels/telegram.py +1 -1
  63. rasa/core/channels/twilio.py +1 -1
  64. rasa/core/channels/voice_ready/audiocodes.py +12 -0
  65. rasa/core/channels/voice_ready/jambonz.py +15 -4
  66. rasa/core/channels/voice_ready/twilio_voice.py +6 -21
  67. rasa/core/channels/voice_stream/asr/asr_event.py +5 -0
  68. rasa/core/channels/voice_stream/asr/azure.py +122 -0
  69. rasa/core/channels/voice_stream/asr/deepgram.py +16 -6
  70. rasa/core/channels/voice_stream/audio_bytes.py +1 -0
  71. rasa/core/channels/voice_stream/browser_audio.py +31 -8
  72. rasa/core/channels/voice_stream/call_state.py +23 -0
  73. rasa/core/channels/voice_stream/tts/azure.py +6 -2
  74. rasa/core/channels/voice_stream/tts/cartesia.py +10 -6
  75. rasa/core/channels/voice_stream/tts/tts_engine.py +1 -0
  76. rasa/core/channels/voice_stream/twilio_media_streams.py +27 -18
  77. rasa/core/channels/voice_stream/util.py +4 -4
  78. rasa/core/channels/voice_stream/voice_channel.py +189 -39
  79. rasa/core/featurizers/single_state_featurizer.py +22 -1
  80. rasa/core/featurizers/tracker_featurizers.py +115 -18
  81. rasa/core/nlg/contextual_response_rephraser.py +32 -30
  82. rasa/core/persistor.py +86 -39
  83. rasa/core/policies/enterprise_search_policy.py +119 -60
  84. rasa/core/policies/flows/flow_executor.py +7 -4
  85. rasa/core/policies/intentless_policy.py +78 -22
  86. rasa/core/policies/ted_policy.py +58 -33
  87. rasa/core/policies/unexpected_intent_policy.py +15 -7
  88. rasa/core/processor.py +25 -0
  89. rasa/core/training/interactive.py +34 -35
  90. rasa/core/utils.py +8 -3
  91. rasa/dialogue_understanding/coexistence/llm_based_router.py +39 -12
  92. rasa/dialogue_understanding/commands/change_flow_command.py +6 -0
  93. rasa/dialogue_understanding/commands/user_silence_command.py +59 -0
  94. rasa/dialogue_understanding/commands/utils.py +5 -0
  95. rasa/dialogue_understanding/generator/constants.py +2 -0
  96. rasa/dialogue_understanding/generator/flow_retrieval.py +49 -4
  97. rasa/dialogue_understanding/generator/llm_based_command_generator.py +37 -23
  98. rasa/dialogue_understanding/generator/multi_step/multi_step_llm_command_generator.py +57 -10
  99. rasa/dialogue_understanding/generator/nlu_command_adapter.py +19 -1
  100. rasa/dialogue_understanding/generator/single_step/single_step_llm_command_generator.py +71 -11
  101. rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +39 -0
  102. rasa/dialogue_understanding/patterns/user_silence.py +37 -0
  103. rasa/dialogue_understanding/processor/command_processor.py +21 -1
  104. rasa/e2e_test/e2e_test_case.py +85 -6
  105. rasa/e2e_test/e2e_test_runner.py +4 -2
  106. rasa/e2e_test/utils/io.py +1 -1
  107. rasa/engine/validation.py +316 -10
  108. rasa/model_manager/config.py +15 -3
  109. rasa/model_manager/model_api.py +15 -7
  110. rasa/model_manager/runner_service.py +8 -6
  111. rasa/model_manager/socket_bridge.py +6 -3
  112. rasa/model_manager/trainer_service.py +7 -5
  113. rasa/model_manager/utils.py +28 -7
  114. rasa/model_service.py +9 -2
  115. rasa/model_training.py +2 -0
  116. rasa/nlu/classifiers/diet_classifier.py +38 -25
  117. rasa/nlu/classifiers/logistic_regression_classifier.py +22 -9
  118. rasa/nlu/classifiers/sklearn_intent_classifier.py +37 -16
  119. rasa/nlu/extractors/crf_entity_extractor.py +93 -50
  120. rasa/nlu/featurizers/sparse_featurizer/count_vectors_featurizer.py +45 -16
  121. rasa/nlu/featurizers/sparse_featurizer/lexical_syntactic_featurizer.py +52 -17
  122. rasa/nlu/featurizers/sparse_featurizer/regex_featurizer.py +5 -3
  123. rasa/nlu/tokenizers/whitespace_tokenizer.py +3 -14
  124. rasa/server.py +3 -1
  125. rasa/shared/constants.py +36 -3
  126. rasa/shared/core/constants.py +7 -0
  127. rasa/shared/core/domain.py +26 -0
  128. rasa/shared/core/flows/flow.py +5 -0
  129. rasa/shared/core/flows/flows_list.py +5 -1
  130. rasa/shared/core/flows/flows_yaml_schema.json +10 -0
  131. rasa/shared/core/flows/utils.py +39 -0
  132. rasa/shared/core/flows/validation.py +96 -0
  133. rasa/shared/core/slots.py +5 -0
  134. rasa/shared/nlu/training_data/features.py +120 -2
  135. rasa/shared/providers/_configs/azure_openai_client_config.py +5 -3
  136. rasa/shared/providers/_configs/litellm_router_client_config.py +200 -0
  137. rasa/shared/providers/_configs/model_group_config.py +167 -0
  138. rasa/shared/providers/_configs/openai_client_config.py +1 -1
  139. rasa/shared/providers/_configs/rasa_llm_client_config.py +73 -0
  140. rasa/shared/providers/_configs/self_hosted_llm_client_config.py +1 -0
  141. rasa/shared/providers/_configs/utils.py +16 -0
  142. rasa/shared/providers/embedding/_base_litellm_embedding_client.py +18 -29
  143. rasa/shared/providers/embedding/azure_openai_embedding_client.py +54 -21
  144. rasa/shared/providers/embedding/litellm_router_embedding_client.py +135 -0
  145. rasa/shared/providers/llm/_base_litellm_client.py +37 -31
  146. rasa/shared/providers/llm/azure_openai_llm_client.py +50 -29
  147. rasa/shared/providers/llm/litellm_router_llm_client.py +127 -0
  148. rasa/shared/providers/llm/rasa_llm_client.py +112 -0
  149. rasa/shared/providers/llm/self_hosted_llm_client.py +1 -1
  150. rasa/shared/providers/mappings.py +19 -0
  151. rasa/shared/providers/router/__init__.py +0 -0
  152. rasa/shared/providers/router/_base_litellm_router_client.py +149 -0
  153. rasa/shared/providers/router/router_client.py +73 -0
  154. rasa/shared/utils/common.py +8 -0
  155. rasa/shared/utils/health_check/__init__.py +0 -0
  156. rasa/shared/utils/health_check/embeddings_health_check_mixin.py +31 -0
  157. rasa/shared/utils/health_check/health_check.py +256 -0
  158. rasa/shared/utils/health_check/llm_health_check_mixin.py +31 -0
  159. rasa/shared/utils/io.py +28 -6
  160. rasa/shared/utils/llm.py +353 -46
  161. rasa/shared/utils/yaml.py +111 -73
  162. rasa/studio/auth.py +3 -5
  163. rasa/studio/config.py +13 -4
  164. rasa/studio/constants.py +1 -0
  165. rasa/studio/data_handler.py +10 -3
  166. rasa/studio/upload.py +81 -26
  167. rasa/telemetry.py +92 -17
  168. rasa/tracing/config.py +2 -0
  169. rasa/tracing/instrumentation/attribute_extractors.py +94 -17
  170. rasa/tracing/instrumentation/instrumentation.py +121 -0
  171. rasa/utils/common.py +5 -0
  172. rasa/utils/io.py +7 -81
  173. rasa/utils/log_utils.py +9 -2
  174. rasa/utils/sanic_error_handler.py +32 -0
  175. rasa/utils/tensorflow/feature_array.py +366 -0
  176. rasa/utils/tensorflow/model_data.py +2 -193
  177. rasa/validator.py +70 -0
  178. rasa/version.py +1 -1
  179. {rasa_pro-3.11.0a4.dev3.dist-info → rasa_pro-3.11.0rc2.dist-info}/METADATA +11 -10
  180. {rasa_pro-3.11.0a4.dev3.dist-info → rasa_pro-3.11.0rc2.dist-info}/RECORD +183 -163
  181. rasa/core/channels/inspector/dist/assets/flowDiagram-v2-855bc5b3-587d82d8.js +0 -1
  182. {rasa_pro-3.11.0a4.dev3.dist-info → rasa_pro-3.11.0rc2.dist-info}/NOTICE +0 -0
  183. {rasa_pro-3.11.0a4.dev3.dist-info → rasa_pro-3.11.0rc2.dist-info}/WHEEL +0 -0
  184. {rasa_pro-3.11.0a4.dev3.dist-info → rasa_pro-3.11.0rc2.dist-info}/entry_points.txt +0 -0
rasa/__main__.py CHANGED
@@ -1,5 +1,5 @@
1
1
  import argparse
2
- import logging
2
+ import structlog
3
3
  import os
4
4
  import platform
5
5
  import sys
@@ -35,10 +35,9 @@ from rasa.cli.utils import (
35
35
  )
36
36
  from rasa.plugin import plugin_manager
37
37
  from rasa.shared.exceptions import RasaException
38
- from rasa.shared.utils.cli import print_error
39
38
  from rasa.utils.common import configure_logging_and_warnings
40
39
 
41
- logger = logging.getLogger(__name__)
40
+ structlogger = structlog.get_logger()
42
41
 
43
42
 
44
43
  def create_argument_parser() -> argparse.ArgumentParser:
@@ -89,7 +88,7 @@ def print_version() -> None:
89
88
  """Prints version information of rasa tooling and python."""
90
89
  from rasa.utils.licensing import get_license_expiration_date
91
90
 
92
- print(f"Rasa Version : {version.__version__}")
91
+ print(f"Rasa Pro Version : {version.__version__}")
93
92
  print(f"Minimum Compatible Version: {MINIMUM_COMPATIBLE_VERSION}")
94
93
  print(f"Rasa SDK Version : {rasa_sdk_version}")
95
94
  print(f"Python Version : {platform.python_version()}")
@@ -110,6 +109,10 @@ def main() -> None:
110
109
  configure_logging_and_warnings(
111
110
  log_level, logging_config_file, warn_only_once=True, filter_repeated_logs=True
112
111
  )
112
+ # TODO: we shouldn't configure colored logging, since we are using structlog
113
+ # for logging - should be removed as part of logs cleanup
114
+ rasa.utils.io.configure_colored_logging(log_level)
115
+ configure_structlog(log_level)
113
116
 
114
117
  tf_env.setup_tf_environment()
115
118
  tf_env.check_deterministic_ops()
@@ -119,8 +122,6 @@ def main() -> None:
119
122
 
120
123
  try:
121
124
  if hasattr(cmdline_arguments, "func"):
122
- rasa.utils.io.configure_colored_logging(log_level)
123
-
124
125
  is_studio_command = check_if_studio_command()
125
126
 
126
127
  if not is_studio_command:
@@ -137,23 +138,32 @@ def main() -> None:
137
138
  plugin_manager().hook.init_anonymization_pipeline(
138
139
  endpoints_file=endpoints_file
139
140
  )
140
- # configure structlog
141
- configure_structlog(log_level)
142
141
 
143
142
  cmdline_arguments.func(cmdline_arguments)
144
143
  elif hasattr(cmdline_arguments, "version"):
145
144
  print_version()
146
145
  else:
147
146
  # user has not provided a subcommand, let's print the help
148
- logger.error("No command specified.")
147
+ structlogger.error("cli.no_command", event_info="No command specified.")
149
148
  arg_parser.print_help()
150
149
  sys.exit(1)
151
- except RasaException as e:
150
+ except RasaException as exc:
152
151
  # these are exceptions we expect to happen (e.g. invalid training data format)
153
152
  # it doesn't make sense to print a stacktrace for these if we are not in
154
153
  # debug mode
155
- logger.debug("Failed to run CLI command due to an exception.", exc_info=e)
156
- print_error(f"{e.__class__.__name__}: {e}")
154
+ structlogger.debug(
155
+ "cli.exception.details",
156
+ event_info="Failed to run CLI command due to an exception.",
157
+ exc_info=exc,
158
+ )
159
+ structlogger.error("cli.exception.rasa_exception", event_info=f"{exc}")
160
+ sys.exit(1)
161
+ except Exception as exc:
162
+ structlogger.error(
163
+ "cli.exception.general_exception",
164
+ event_info=f"{exc.__class__.__name__}: {exc}",
165
+ exc_info=exc,
166
+ )
157
167
  sys.exit(1)
158
168
 
159
169
 
rasa/api.py CHANGED
@@ -42,7 +42,7 @@ def run(
42
42
  from rasa.shared.constants import DOCS_BASE_URL
43
43
  from rasa.shared.utils.cli import print_warning
44
44
 
45
- _endpoints = AvailableEndpoints.read_endpoints(endpoints)
45
+ _endpoints = AvailableEndpoints.get_instance(endpoints)
46
46
 
47
47
  if not connector and not credentials:
48
48
  connector = "rest"
@@ -7,7 +7,6 @@ from rasa.core.persistor import RemoteStorageType, StorageType, parse_remote_sto
7
7
  from rasa.shared.constants import (
8
8
  DEFAULT_CONFIG_PATH,
9
9
  DEFAULT_DATA_PATH,
10
- DEFAULT_DOMAIN_PATH,
11
10
  DEFAULT_ENDPOINTS_PATH,
12
11
  DEFAULT_MODELS_PATH,
13
12
  )
@@ -53,7 +52,7 @@ def add_nlu_data_param(
53
52
 
54
53
  def add_domain_param(
55
54
  parser: Union[argparse.ArgumentParser, argparse._ActionsContainer],
56
- default: Optional[Text] = DEFAULT_DOMAIN_PATH,
55
+ default: Optional[Text] = None,
57
56
  ) -> None:
58
57
  parser.add_argument(
59
58
  "-d",
@@ -1,12 +1,16 @@
1
1
  import argparse
2
2
 
3
- from rasa.cli.arguments.default_arguments import add_model_param
3
+ from rasa.cli.arguments.default_arguments import (
4
+ add_model_param,
5
+ add_skip_validation_flag,
6
+ )
4
7
  from rasa.cli.arguments.run import add_server_arguments
5
8
 
6
9
 
7
10
  def set_shell_arguments(parser: argparse.ArgumentParser) -> None:
8
11
  add_model_param(parser)
9
12
  add_server_arguments(parser)
13
+ add_skip_validation_flag(parser)
10
14
 
11
15
 
12
16
  def set_shell_nlu_arguments(parser: argparse.ArgumentParser) -> None:
rasa/cli/e2e_test.py CHANGED
@@ -164,7 +164,7 @@ def execute_e2e_tests(args: argparse.Namespace) -> None:
164
164
  args.endpoints = rasa.cli.utils.get_validated_path(
165
165
  args.endpoints, "endpoints", DEFAULT_ENDPOINTS_PATH, True
166
166
  )
167
- endpoints = AvailableEndpoints.read_endpoints(args.endpoints)
167
+ endpoints = AvailableEndpoints.get_instance(args.endpoints)
168
168
 
169
169
  # Ignore all endpoints apart from action server, model, nlu and nlg
170
170
  # to ensure InMemoryTrackerStore is being used instead of production
rasa/cli/evaluate.py CHANGED
@@ -1,16 +1,16 @@
1
1
  import argparse
2
- from typing import List, Text, Optional
3
2
  from pathlib import Path
3
+ from typing import List, Text, Optional
4
4
 
5
+ import rasa.cli.arguments.evaluate as arguments
6
+ import rasa.shared.utils.cli
5
7
  from rasa import telemetry
6
- from rasa.core.utils import AvailableEndpoints
7
- from rasa.core.tracker_store import TrackerStore
8
- from rasa.core.evaluation.marker_tracker_loader import MarkerTrackerLoader
8
+ from rasa.cli import SubParsersAction
9
9
  from rasa.core.evaluation.marker_base import Marker, OperatorMarker
10
+ from rasa.core.evaluation.marker_tracker_loader import MarkerTrackerLoader
11
+ from rasa.core.tracker_store import TrackerStore
12
+ from rasa.core.utils import AvailableEndpoints
10
13
  from rasa.shared.core.domain import Domain
11
- from rasa.cli import SubParsersAction
12
- import rasa.cli.arguments.evaluate as arguments
13
- import rasa.shared.utils.cli
14
14
 
15
15
  STATS_OVERALL_SUFFIX = "-overall.csv"
16
16
  STATS_SESSION_SUFFIX = "-per-session.csv"
@@ -217,6 +217,6 @@ def _create_tracker_loader(
217
217
  A MarkerTrackerLoader object configured with the specified strategy against
218
218
  the configured tracker store.
219
219
  """
220
- endpoints = AvailableEndpoints.read_endpoints(endpoint_config)
220
+ endpoints = AvailableEndpoints.get_instance(endpoint_config)
221
221
  tracker_store = TrackerStore.create(endpoints.tracker_store, domain=domain)
222
222
  return MarkerTrackerLoader(tracker_store, strategy, count, seed)
rasa/cli/inspect.py CHANGED
@@ -5,9 +5,9 @@ from typing import List, Text
5
5
 
6
6
  from sanic import Sanic
7
7
 
8
+ from rasa import telemetry
8
9
  from rasa.cli import SubParsersAction
9
10
  from rasa.cli.arguments import shell as arguments
10
- from rasa.cli.arguments.default_arguments import add_skip_validation_flag
11
11
  from rasa.core import constants
12
12
  from rasa.utils.cli import remove_argument_from_parser
13
13
 
@@ -32,11 +32,12 @@ def add_subparser(
32
32
  ),
33
33
  )
34
34
  inspect_parser.set_defaults(func=inspect)
35
-
36
35
  arguments.set_shell_arguments(inspect_parser)
37
- add_skip_validation_flag(inspect_parser)
38
36
 
39
- inspect_parser.add_argument("--voice", help="Enable voice", action="store_true")
37
+ # additional argument for voice
38
+ inspect_parser.add_argument(
39
+ "--voice", help="Enable voice", action="store_true", default=False
40
+ )
40
41
 
41
42
  # it'd be confusing to expose those arguments to the user,
42
43
  # so we remove them
@@ -70,4 +71,5 @@ def inspect(args: argparse.Namespace) -> None:
70
71
  args.credentials = None
71
72
  args.server_listeners = [(after_start_hook_open_inspector, "after_server_start")]
72
73
 
74
+ telemetry.track_inspect_started(args.connector)
73
75
  rasa.cli.run.run(args)
@@ -352,7 +352,7 @@ def get_valid_endpoints(endpoints_file: str) -> AvailableEndpoints:
352
352
  validated_endpoints_file = rasa.cli.utils.get_validated_path(
353
353
  endpoints_file, "endpoints", DEFAULT_ENDPOINTS_PATH, True
354
354
  )
355
- endpoints = AvailableEndpoints.read_endpoints(validated_endpoints_file)
355
+ endpoints = AvailableEndpoints.get_instance(validated_endpoints_file)
356
356
 
357
357
  # Ignore all endpoints apart from action server, model, nlu and nlg
358
358
  # to ensure InMemoryTrackerStore is being used instead of production
@@ -1,12 +1,10 @@
1
1
  recipe: default.v1
2
2
  language: en
3
3
  pipeline:
4
- - name: SingleStepLLMCommandGenerator
5
- llm:
6
- model_name: gpt-4
7
- request_timeout: 7
8
- max_tokens: 256
4
+ - name: SingleStepLLMCommandGenerator
5
+ llm:
6
+ model_group: openai-gpt-4
9
7
 
10
8
  policies:
11
- - name: FlowPolicy
12
- - name: IntentlessPolicy
9
+ - name: FlowPolicy
10
+ - name: IntentlessPolicy
@@ -48,3 +48,11 @@ action_endpoint:
48
48
  # To enable the rephraser, remove the comment symbols in the lines below.
49
49
  #nlg:
50
50
  # type: rephrase
51
+
52
+ model_groups:
53
+ - id: openai-gpt-4
54
+ models:
55
+ - provider: openai
56
+ model: openai/gpt-4
57
+ request_timeout: 7
58
+ max_tokens: 256
@@ -1,11 +1,14 @@
1
1
  recipe: default.v1
2
2
  language: en
3
3
  pipeline:
4
- - name: SingleStepLLMCommandGenerator
5
- llm:
6
- model_name: gpt-4
4
+ - name: SingleStepLLMCommandGenerator
5
+ llm:
6
+ provider: rasa
7
+ model: rasa/cmd_gen_codellama_13b_calm_demo
8
+ api_base: "https://tutorial-llm.rasa.ai"
9
+ flow_retrieval:
10
+ active: false
7
11
 
8
12
  policies:
9
13
  - name: FlowPolicy
10
- # - name: EnterpriseSearchPolicy
11
- # - name: RulePolicy
14
+ # - name: EnterpriseSearchPolicy
@@ -1,6 +1,6 @@
1
1
  flows:
2
2
  transfer_money:
3
- description: This flow lets users send money to friends and family.
3
+ description: Help users send money to friends and family.
4
4
  steps:
5
5
  - collect: recipient
6
6
  - collect: amount
@@ -4,3 +4,8 @@ flows:
4
4
  name: pattern chitchat
5
5
  steps:
6
6
  - action: utter_free_chitchat_response
7
+ pattern_search:
8
+ description: Flow for handling knowledge-based questions
9
+ name: pattern search
10
+ steps:
11
+ - action: utter_free_chitchat_response
@@ -19,3 +19,17 @@ responses:
19
19
 
20
20
  utter_transfer_complete:
21
21
  - text: "All done. {amount} has been sent to {recipient}."
22
+
23
+ utter_free_chitchat_response:
24
+ - text: "placeholder"
25
+ metadata:
26
+ rephrase: True
27
+ rephrase_prompt: |
28
+ The following is a conversation with an AI assistant built with Rasa.
29
+ The assistant can help the user transfer money.
30
+ The assistant is helpful, creative, clever, and very friendly.
31
+ The user is making small talk, and the assistant should respond, keeping things light.
32
+ Context / previous conversation with the user:
33
+ {{history}}
34
+ {{current_input}}
35
+ Suggested AI Response:
@@ -41,10 +41,10 @@ action_endpoint:
41
41
  # password: password
42
42
  # queue: queue
43
43
 
44
- # The lines below activate contextual rephrasing, using the default OpenAI language model.
45
- # Ensure the OPENAI_API_KEY is set to prevent any missing API key errors.
46
- # For more details, refer to the documentation:
47
- # https://rasa.com/docs/rasa-pro/concepts/contextual-response-rephraser
48
- # To enable the rephraser, remove the comment symbols in the lines below.
49
- #nlg:
50
- # type: rephrase
44
+ # Allow rephrasing of responses using a Rasa-hosted model
45
+ nlg:
46
+ type: rephrase
47
+ llm:
48
+ provider: rasa
49
+ model: rasa/cmd_gen_codellama_13b_calm_demo
50
+ api_base: "https://tutorial-llm.rasa.ai"
rasa/cli/run.py CHANGED
@@ -113,7 +113,7 @@ def run(args: argparse.Namespace) -> None:
113
113
  return
114
114
 
115
115
  # start server if model server is configured
116
- endpoints = AvailableEndpoints.read_endpoints(args.endpoints)
116
+ endpoints = AvailableEndpoints.get_instance(args.endpoints)
117
117
  model_server = endpoints.model if endpoints and endpoints.model else None
118
118
  if model_server is not None:
119
119
  rasa_run(**vars(args))
rasa/cli/scaffold.py CHANGED
@@ -128,20 +128,22 @@ def print_run_or_instructions(args: argparse.Namespace) -> None:
128
128
  setattr(args, a, None)
129
129
 
130
130
  args.port = constants.DEFAULT_SERVER_PORT
131
+ args.voice = False
132
+ args.skip_yaml_validation = ["domain"]
131
133
 
132
134
  inspect(args)
133
135
  else:
134
136
  if args.no_prompt:
135
137
  print(
136
138
  "If you want to speak to the assistant, "
137
- "run 'rasa shell' at any time inside "
139
+ "run 'rasa inspect' at any time inside "
138
140
  "the project directory."
139
141
  )
140
142
  else:
141
143
  print_success(
142
144
  "Ok 👍🏼. "
143
145
  "If you want to speak to the assistant, "
144
- "run 'rasa shell' at any time inside "
146
+ "run 'rasa inspect' at any time inside "
145
147
  "the project directory."
146
148
  )
147
149
 
rasa/cli/studio/studio.py CHANGED
@@ -1,5 +1,5 @@
1
1
  import argparse
2
- from typing import List, Optional
2
+ from typing import List, Optional, Tuple
3
3
  from urllib.parse import ParseResult, urlparse
4
4
 
5
5
  import questionary
@@ -149,7 +149,7 @@ def _configure_studio_url() -> Optional[str]:
149
149
  return studio_url
150
150
 
151
151
 
152
- def _get_advanced_config(studio_url: str) -> tuple:
152
+ def _get_advanced_config(studio_url: str) -> Tuple:
153
153
  """Get the advanced configuration values for Rasa Studio."""
154
154
  keycloak_url = questionary.text(
155
155
  "Please provide your Rasa Studio Keycloak URL",
@@ -167,7 +167,7 @@ def _get_advanced_config(studio_url: str) -> tuple:
167
167
  return keycloak_url, realm_name, client_id
168
168
 
169
169
 
170
- def _get_default_config(studio_url: str) -> tuple:
170
+ def _get_default_config(studio_url: str) -> Tuple:
171
171
  """Get the default configuration values for Rasa Studio."""
172
172
  keycloak_url = studio_url + "auth/"
173
173
  realm_name = DEFAULT_REALM_NAME
@@ -178,6 +178,7 @@ def _get_default_config(studio_url: str) -> tuple:
178
178
  f"Keycloak URL: {keycloak_url}, "
179
179
  f"Realm Name: '{realm_name}', "
180
180
  f"Client ID: '{client_id}'. "
181
+ f"SSL verification is enabled."
181
182
  f"You can use '--advanced' to configure these settings."
182
183
  )
183
184
 
@@ -185,7 +186,11 @@ def _get_default_config(studio_url: str) -> tuple:
185
186
 
186
187
 
187
188
  def _create_studio_config(
188
- studio_url: str, keycloak_url: str, realm_name: str, client_id: str
189
+ studio_url: str,
190
+ keycloak_url: str,
191
+ realm_name: str,
192
+ client_id: str,
193
+ disable_verify: bool = False,
189
194
  ) -> StudioConfig:
190
195
  """Create a StudioConfig object with the provided parameters."""
191
196
  return StudioConfig(
@@ -193,6 +198,7 @@ def _create_studio_config(
193
198
  studio_url=studio_url + "api/graphql/",
194
199
  client_id=client_id,
195
200
  realm_name=realm_name,
201
+ disable_verify=disable_verify,
196
202
  )
197
203
 
198
204
 
@@ -227,19 +233,23 @@ def _configure_studio_config(args: argparse.Namespace) -> StudioConfig:
227
233
 
228
234
  # create a configuration and auth object to try to reach the studio
229
235
  studio_config = _create_studio_config(
230
- studio_url, keycloak_url, realm_name, client_id
236
+ studio_url,
237
+ keycloak_url,
238
+ realm_name,
239
+ client_id,
240
+ disable_verify=args.disable_verify,
231
241
  )
232
242
 
233
- if args.disable_verify:
243
+ if studio_config.disable_verify:
234
244
  rasa.shared.utils.cli.print_info(
235
245
  "Disabling SSL verification for the Rasa Studio authentication server."
236
246
  )
237
- studio_auth = StudioAuth(studio_config, verify=False)
238
247
  else:
239
248
  rasa.shared.utils.cli.print_info(
240
249
  "Enabling SSL verification for the Rasa Studio authentication server."
241
250
  )
242
- studio_auth = StudioAuth(studio_config, verify=True)
251
+
252
+ studio_auth = StudioAuth(studio_config)
243
253
 
244
254
  if _check_studio_auth(studio_auth):
245
255
  return studio_config
rasa/cli/utils.py CHANGED
@@ -477,3 +477,8 @@ def get_e2e_results_file_name(
477
477
  file_name = parent / f"{stem}_{result_type}.yml"
478
478
 
479
479
  return str(file_name)
480
+
481
+
482
+ def is_skip_validation_flag_set() -> bool:
483
+ """Checks if the skip validation flag is set."""
484
+ return "--skip-validation" in sys.argv
rasa/cli/x.py CHANGED
@@ -1,25 +1,25 @@
1
1
  import argparse
2
2
  import asyncio
3
3
  import logging
4
- from pathlib import Path
5
4
  import signal
5
+ from pathlib import Path
6
6
  from typing import Iterable, List, Optional, Text, Tuple, Union
7
7
 
8
8
  import aiohttp
9
9
  import ruamel.yaml as yaml
10
10
 
11
+ import rasa.cli.utils
12
+ import rasa.shared.utils.cli
13
+ import rasa.shared.utils.io
14
+ import rasa.utils.common
15
+ import rasa.utils.io
11
16
  from rasa.cli import SubParsersAction
12
17
  from rasa.cli.arguments import x as arguments
13
- import rasa.cli.utils
18
+ from rasa.core.utils import AvailableEndpoints
14
19
  from rasa.shared.constants import (
15
20
  DEFAULT_CREDENTIALS_PATH,
16
21
  DEFAULT_ENDPOINTS_PATH,
17
22
  )
18
- from rasa.core.utils import AvailableEndpoints
19
- import rasa.shared.utils.cli
20
- import rasa.shared.utils.io
21
- import rasa.utils.common
22
- import rasa.utils.io
23
23
  from rasa.shared.utils.yaml import read_config_file
24
24
 
25
25
  logger = logging.getLogger(__name__)
@@ -179,7 +179,7 @@ def run_in_enterprise_connection_mode(args: argparse.Namespace) -> None:
179
179
  print_success("Starting a Rasa server in Rasa Enterprise connection mode... 🚀")
180
180
 
181
181
  credentials_path, endpoints_path = _get_credentials_and_endpoints_paths(args)
182
- endpoints = AvailableEndpoints.read_endpoints(endpoints_path)
182
+ endpoints = AvailableEndpoints.get_instance(endpoints_path)
183
183
 
184
184
  _rasa_service(args, endpoints, None, credentials_path)
185
185
 
rasa/constants.py CHANGED
@@ -18,7 +18,7 @@ CONFIG_TELEMETRY_ID = "rasa_user_id"
18
18
  CONFIG_TELEMETRY_ENABLED = "enabled"
19
19
  CONFIG_TELEMETRY_DATE = "date"
20
20
 
21
- MINIMUM_COMPATIBLE_VERSION = "3.10.0rc1"
21
+ MINIMUM_COMPATIBLE_VERSION = "3.11.0rc1"
22
22
 
23
23
  GLOBAL_USER_CONFIG_PATH = os.path.expanduser("~/.config/rasa/global.yml")
24
24
 
@@ -3,6 +3,15 @@ from typing import Optional, Dict, Any, List
3
3
  from rasa.core.actions.action import Action
4
4
  from rasa.core.channels import OutputChannel
5
5
  from rasa.core.nlg import NaturalLanguageGenerator
6
+ from rasa.dialogue_understanding.patterns.collect_information import (
7
+ CollectInformationPatternFlowStackFrame,
8
+ )
9
+ from rasa.dialogue_understanding.patterns.repeat import (
10
+ RepeatBotMessagesPatternFlowStackFrame,
11
+ )
12
+ from rasa.dialogue_understanding.patterns.user_silence import (
13
+ UserSilencePatternFlowStackFrame,
14
+ )
6
15
  from rasa.shared.core.constants import ACTION_REPEAT_BOT_MESSAGES
7
16
  from rasa.shared.core.domain import Domain
8
17
  from rasa.shared.core.events import Event, BotUttered, UserUttered
@@ -39,6 +48,14 @@ class ActionRepeatBotMessages(Action):
39
48
  The elif condition doesn't break when it sees User3 event.
40
49
  But it does at User2 event.
41
50
  """
51
+ # Skip action if we are in a collect information step whose
52
+ # default behavior is to repeat anyways
53
+ top_frame = tracker.stack.top(
54
+ lambda frame: isinstance(frame, RepeatBotMessagesPatternFlowStackFrame)
55
+ or isinstance(frame, UserSilencePatternFlowStackFrame)
56
+ )
57
+ if isinstance(top_frame, CollectInformationPatternFlowStackFrame):
58
+ return []
42
59
  # filter user and bot events
43
60
  filtered = [
44
61
  e for e in tracker.events if isinstance(e, (BotUttered, UserUttered))
@@ -227,6 +227,9 @@ class OutputChannel:
227
227
  for text only output channels.
228
228
  """
229
229
 
230
+ def __init__(self) -> None:
231
+ self.tracker_state: Optional[Dict[str, Any]] = None
232
+
230
233
  @classmethod
231
234
  def name(cls) -> Text:
232
235
  """Every output channel needs a name to identify it."""
@@ -310,6 +313,23 @@ class OutputChannel:
310
313
  button_msg = cli_utils.button_to_string(button, idx)
311
314
  await self.send_text_message(recipient_id, button_msg)
312
315
 
316
+ async def send_text_with_buttons_concise(
317
+ self,
318
+ recipient_id: str,
319
+ text: str,
320
+ buttons: List[Dict[str, Any]],
321
+ **kwargs: Any,
322
+ ) -> None:
323
+ """Sends buttons in a concise format, useful for voice channels."""
324
+ if text.strip()[-1] not in {".", "!", "?", ":"}:
325
+ text += "."
326
+ text += " "
327
+ for idx, button in enumerate(buttons):
328
+ text += button["title"]
329
+ if idx != len(buttons) - 1:
330
+ text += ", "
331
+ await self.send_text_message(recipient_id, text)
332
+
313
333
  async def send_quick_replies(
314
334
  self,
315
335
  recipient_id: Text,
@@ -1 +1 @@
1
- import{w as ln,c as W}from"./path-53f90ab3.js";import{aW as an,aX as $,aY as w,aZ as rn,a_ as y,V as on,a$ as B,b0 as _,b1 as un,b2 as t,b3 as sn,b4 as tn,b5 as fn}from"./index-efdd30c1.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function mn(l){return l.endAngle}function pn(l){return l&&l.padAngle}function dn(l,h,E,q,v,A,X,a){var I=E-l,i=q-h,n=X-v,m=a-A,r=m*I-n*i;if(!(r*r<y))return r=(n*(h-A)-m*(l-v))/r,[l+r*I,h+r*i]}function K(l,h,E,q,v,A,X){var a=l-E,I=h-q,i=(X?A:-A)/B(a*a+I*I),n=i*I,m=-i*a,r=l+n,s=h+m,f=E+n,c=q+m,Y=(r+f)/2,o=(s+c)/2,p=f-r,g=c-s,R=p*p+g*g,T=v-A,b=r*c-f*s,O=(g<0?-1:1)*B(fn(0,T*T*R-b*b)),S=(b*g-p*O)/R,V=(-b*p-g*O)/R,P=(b*g+p*O)/R,d=(-b*p+g*O)/R,x=S-Y,e=V-o,u=P-Y,Z=d-o;return x*x+e*e>u*u+Z*Z&&(S=P,V=d),{cx:S,cy:V,x01:-n,y01:-m,x11:S*(v/T-1),y11:V*(v/T-1)}}function vn(){var l=cn,h=yn,E=W(0),q=null,v=gn,A=mn,X=pn,a=null,I=ln(i);function i(){var n,m,r=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-rn,c=A.apply(this,arguments)-rn,Y=un(c-f),o=c>f;if(a||(a=n=I()),s<r&&(m=s,s=r,r=m),!(s>y))a.moveTo(0,0);else if(Y>on-y)a.moveTo(s*$(f),s*w(f)),a.arc(0,0,s,f,c,!o),r>y&&(a.moveTo(r*$(c),r*w(c)),a.arc(0,0,r,c,f,o));else{var p=f,g=c,R=f,T=c,b=Y,O=Y,S=X.apply(this,arguments)/2,V=S>y&&(q?+q.apply(this,arguments):B(r*r+s*s)),P=_(un(s-r)/2,+E.apply(this,arguments)),d=P,x=P,e,u;if(V>y){var Z=sn(V/r*w(S)),C=sn(V/s*w(S));(b-=Z*2)>y?(Z*=o?1:-1,R+=Z,T-=Z):(b=0,R=T=(f+c)/2),(O-=C*2)>y?(C*=o?1:-1,p+=C,g-=C):(O=0,p=g=(f+c)/2)}var j=s*$(p),z=s*w(p),F=r*$(T),G=r*w(T);if(P>y){var H=s*$(g),J=s*w(g),L=r*$(R),M=r*w(R),D;if(Y<an)if(D=dn(j,z,L,M,H,J,F,G)){var N=j-D[0],Q=z-D[1],U=H-D[0],k=J-D[1],nn=1/w(tn((N*U+Q*k)/(B(N*N+Q*Q)*B(U*U+k*k)))/2),en=B(D[0]*D[0]+D[1]*D[1]);d=_(P,(r-en)/(nn-1)),x=_(P,(s-en)/(nn+1))}else d=x=0}O>y?x>y?(e=K(L,M,j,z,s,x,o),u=K(H,J,F,G,s,x,o),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<P?a.arc(e.cx,e.cy,x,t(e.y01,e.x01),t(u.y01,u.x01),!o):(a.arc(e.cx,e.cy,x,t(e.y01,e.x01),t(e.y11,e.x11),!o),a.arc(0,0,s,t(e.cy+e.y11,e.cx+e.x11),t(u.cy+u.y11,u.cx+u.x11),!o),a.arc(u.cx,u.cy,x,t(u.y11,u.x11),t(u.y01,u.x01),!o))):(a.moveTo(j,z),a.arc(0,0,s,p,g,!o)):a.moveTo(j,z),!(r>y)||!(b>y)?a.lineTo(F,G):d>y?(e=K(F,G,H,J,r,-d,o),u=K(j,z,L,M,r,-d,o),a.lineTo(e.cx+e.x01,e.cy+e.y01),d<P?a.arc(e.cx,e.cy,d,t(e.y01,e.x01),t(u.y01,u.x01),!o):(a.arc(e.cx,e.cy,d,t(e.y01,e.x01),t(e.y11,e.x11),!o),a.arc(0,0,r,t(e.cy+e.y11,e.cx+e.x11),t(u.cy+u.y11,u.cx+u.x11),o),a.arc(u.cx,u.cy,d,t(u.y11,u.x11),t(u.y01,u.x01),!o))):a.arc(0,0,r,T,R,o)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,m=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-an/2;return[$(m)*n,w(m)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:W(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:W(+n),i):h},i.cornerRadius=function(n){return arguments.length?(E=typeof n=="function"?n:W(+n),i):E},i.padRadius=function(n){return arguments.length?(q=n==null?null:typeof n=="function"?n:W(+n),i):q},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:W(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:W(+n),i):A},i.padAngle=function(n){return arguments.length?(X=typeof n=="function"?n:W(+n),i):X},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{vn as a};
1
+ import{w as ln,c as W}from"./path-53f90ab3.js";import{aW as an,aX as $,aY as w,aZ as rn,a_ as y,V as on,a$ as B,b0 as _,b1 as un,b2 as t,b3 as sn,b4 as tn,b5 as fn}from"./index-e7cef9de.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function mn(l){return l.endAngle}function pn(l){return l&&l.padAngle}function dn(l,h,E,q,v,A,X,a){var I=E-l,i=q-h,n=X-v,m=a-A,r=m*I-n*i;if(!(r*r<y))return r=(n*(h-A)-m*(l-v))/r,[l+r*I,h+r*i]}function K(l,h,E,q,v,A,X){var a=l-E,I=h-q,i=(X?A:-A)/B(a*a+I*I),n=i*I,m=-i*a,r=l+n,s=h+m,f=E+n,c=q+m,Y=(r+f)/2,o=(s+c)/2,p=f-r,g=c-s,R=p*p+g*g,T=v-A,b=r*c-f*s,O=(g<0?-1:1)*B(fn(0,T*T*R-b*b)),S=(b*g-p*O)/R,V=(-b*p-g*O)/R,P=(b*g+p*O)/R,d=(-b*p+g*O)/R,x=S-Y,e=V-o,u=P-Y,Z=d-o;return x*x+e*e>u*u+Z*Z&&(S=P,V=d),{cx:S,cy:V,x01:-n,y01:-m,x11:S*(v/T-1),y11:V*(v/T-1)}}function vn(){var l=cn,h=yn,E=W(0),q=null,v=gn,A=mn,X=pn,a=null,I=ln(i);function i(){var n,m,r=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-rn,c=A.apply(this,arguments)-rn,Y=un(c-f),o=c>f;if(a||(a=n=I()),s<r&&(m=s,s=r,r=m),!(s>y))a.moveTo(0,0);else if(Y>on-y)a.moveTo(s*$(f),s*w(f)),a.arc(0,0,s,f,c,!o),r>y&&(a.moveTo(r*$(c),r*w(c)),a.arc(0,0,r,c,f,o));else{var p=f,g=c,R=f,T=c,b=Y,O=Y,S=X.apply(this,arguments)/2,V=S>y&&(q?+q.apply(this,arguments):B(r*r+s*s)),P=_(un(s-r)/2,+E.apply(this,arguments)),d=P,x=P,e,u;if(V>y){var Z=sn(V/r*w(S)),C=sn(V/s*w(S));(b-=Z*2)>y?(Z*=o?1:-1,R+=Z,T-=Z):(b=0,R=T=(f+c)/2),(O-=C*2)>y?(C*=o?1:-1,p+=C,g-=C):(O=0,p=g=(f+c)/2)}var j=s*$(p),z=s*w(p),F=r*$(T),G=r*w(T);if(P>y){var H=s*$(g),J=s*w(g),L=r*$(R),M=r*w(R),D;if(Y<an)if(D=dn(j,z,L,M,H,J,F,G)){var N=j-D[0],Q=z-D[1],U=H-D[0],k=J-D[1],nn=1/w(tn((N*U+Q*k)/(B(N*N+Q*Q)*B(U*U+k*k)))/2),en=B(D[0]*D[0]+D[1]*D[1]);d=_(P,(r-en)/(nn-1)),x=_(P,(s-en)/(nn+1))}else d=x=0}O>y?x>y?(e=K(L,M,j,z,s,x,o),u=K(H,J,F,G,s,x,o),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<P?a.arc(e.cx,e.cy,x,t(e.y01,e.x01),t(u.y01,u.x01),!o):(a.arc(e.cx,e.cy,x,t(e.y01,e.x01),t(e.y11,e.x11),!o),a.arc(0,0,s,t(e.cy+e.y11,e.cx+e.x11),t(u.cy+u.y11,u.cx+u.x11),!o),a.arc(u.cx,u.cy,x,t(u.y11,u.x11),t(u.y01,u.x01),!o))):(a.moveTo(j,z),a.arc(0,0,s,p,g,!o)):a.moveTo(j,z),!(r>y)||!(b>y)?a.lineTo(F,G):d>y?(e=K(F,G,H,J,r,-d,o),u=K(j,z,L,M,r,-d,o),a.lineTo(e.cx+e.x01,e.cy+e.y01),d<P?a.arc(e.cx,e.cy,d,t(e.y01,e.x01),t(u.y01,u.x01),!o):(a.arc(e.cx,e.cy,d,t(e.y01,e.x01),t(e.y11,e.x11),!o),a.arc(0,0,r,t(e.cy+e.y11,e.cx+e.x11),t(u.cy+u.y11,u.cx+u.x11),o),a.arc(u.cx,u.cy,d,t(u.y11,u.x11),t(u.y01,u.x01),!o))):a.arc(0,0,r,T,R,o)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,m=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-an/2;return[$(m)*n,w(m)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:W(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:W(+n),i):h},i.cornerRadius=function(n){return arguments.length?(E=typeof n=="function"?n:W(+n),i):E},i.padRadius=function(n){return arguments.length?(q=n==null?null:typeof n=="function"?n:W(+n),i):q},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:W(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:W(+n),i):A},i.padAngle=function(n){return arguments.length?(X=typeof n=="function"?n:W(+n),i):X},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{vn as a};