rasa-pro 3.13.0.dev20250612__py3-none-any.whl → 3.13.0rc1__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.
- rasa/__main__.py +0 -3
- rasa/api.py +1 -1
- rasa/cli/dialogue_understanding_test.py +1 -1
- rasa/cli/e2e_test.py +1 -8
- rasa/cli/evaluate.py +1 -1
- rasa/cli/export.py +3 -1
- rasa/cli/llm_fine_tuning.py +12 -11
- rasa/cli/project_templates/defaults.py +133 -0
- rasa/cli/project_templates/tutorial/config.yml +1 -1
- rasa/cli/project_templates/tutorial/endpoints.yml +1 -1
- rasa/cli/run.py +1 -1
- rasa/cli/studio/download.py +1 -23
- rasa/cli/studio/link.py +52 -0
- rasa/cli/studio/pull.py +79 -0
- rasa/cli/studio/push.py +78 -0
- rasa/cli/studio/studio.py +12 -0
- rasa/cli/studio/train.py +0 -1
- rasa/cli/studio/upload.py +8 -0
- rasa/cli/train.py +1 -1
- rasa/cli/utils.py +1 -1
- rasa/cli/x.py +1 -1
- rasa/constants.py +2 -0
- rasa/core/__init__.py +0 -16
- rasa/core/actions/action.py +5 -1
- rasa/core/actions/action_repeat_bot_messages.py +18 -22
- rasa/core/actions/action_run_slot_rejections.py +0 -1
- rasa/core/agent.py +16 -1
- rasa/core/available_endpoints.py +146 -0
- rasa/core/brokers/pika.py +1 -2
- rasa/core/channels/__init__.py +2 -0
- rasa/core/channels/botframework.py +2 -2
- rasa/core/channels/channel.py +2 -2
- rasa/core/channels/development_inspector.py +1 -1
- rasa/core/channels/facebook.py +1 -4
- rasa/core/channels/hangouts.py +8 -5
- rasa/core/channels/inspector/README.md +3 -3
- rasa/core/channels/inspector/dist/assets/{arc-c4b064fc.js → arc-371401b1.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-215b5026.js → blockDiagram-38ab4fdb-3f126156.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-2b54a0a3.js → c4Diagram-3d4e48cf-12f22eb7.js} +1 -1
- rasa/core/channels/inspector/dist/assets/channel-f1efda17.js +1 -0
- rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-daacea5f.js → classDiagram-70f12bd4-03b1d386.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-930d4dc2.js → classDiagram-v2-f2320105-84f69d63.js} +1 -1
- rasa/core/channels/inspector/dist/assets/clone-fdf164e2.js +1 -0
- rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-83c206ba.js → createText-2e5e7dd3-ca47fd38.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-b0eb01d0.js → edges-e0da2a9e-f837ca8a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-17586500.js → erDiagram-9861fffd-8717ac54.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-be2a1776.js → flowDb-956e92f1-94f38b83.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-c2120ebd.js → flowDiagram-66a62f08-b616f9fb.js} +1 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-7d7a1629.js +1 -0
- rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-a6ab5c48.js → flowchart-elk-definition-4a651766-f5d24bb8.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-ef613457.js → ganttDiagram-c361ad54-b43ba8d9.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-d59185b3.js → gitGraphDiagram-72cf32ee-c3aafaa5.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{graph-0f155405.js → graph-0d0a2c10.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-3862675e-d5f1d1b7.js → index-3862675e-58ea0305.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-47737d3a.js → index-cce6f8a1.js} +3 -3
- rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-b07d141f.js → infoDiagram-f8f76790-b8f60461.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-1936d429.js → journeyDiagram-49397b02-95be5545.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-dde8d0f3.js → layout-da885b9b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{line-0c2c7ee0.js → line-f1c817d3.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-35dd89a4.js → linear-d42801e6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-56192851.js → mindmap-definition-fc14e90a-a38923a6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-fc21ed78.js → pieDiagram-8a3498a8-ca6e71e9.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-25e98518.js → quadrantDiagram-120e2f19-b290dae9.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-546ff1f5.js → requirementDiagram-deff3bca-03f02ceb.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-02d8b82d.js → sankeyDiagram-04a897e0-c49eee40.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-3ca5a92e.js → sequenceDiagram-704730f1-b2cd6a3d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-128ea07c.js → stateDiagram-587899a1-e53a2028.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-95f290af.js → stateDiagram-v2-d93cdb3a-e1982a03.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-4984898a.js → styles-6aaf32cf-d0226ca5.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-9a916d00-1bf266ba.js → styles-9a916d00-0e21dc00.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-c10674c1-60521c63.js → styles-c10674c1-9588494e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-a25b6e12.js → svgDrawCommon-08f97a94-be478d4f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-0fc086bf.js → timeline-definition-85554ec2-74631749.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-44ee592e.js → xychartDiagram-e933f94c-a043552f.js} +1 -1
- rasa/core/channels/inspector/dist/index.html +1 -1
- rasa/core/channels/inspector/src/components/RecruitmentPanel.tsx +1 -1
- rasa/core/channels/mattermost.py +1 -1
- rasa/core/channels/rasa_chat.py +2 -4
- rasa/core/channels/rest.py +5 -4
- rasa/core/channels/socketio.py +56 -41
- rasa/core/channels/studio_chat.py +314 -10
- rasa/core/channels/vier_cvg.py +1 -2
- rasa/core/channels/voice_ready/audiocodes.py +2 -9
- rasa/core/channels/voice_stream/asr/azure.py +9 -0
- rasa/core/channels/voice_stream/audiocodes.py +8 -5
- rasa/core/channels/voice_stream/browser_audio.py +1 -1
- rasa/core/channels/voice_stream/genesys.py +2 -2
- rasa/core/channels/voice_stream/jambonz.py +166 -0
- rasa/core/channels/voice_stream/tts/__init__.py +8 -0
- rasa/core/channels/voice_stream/twilio_media_streams.py +17 -5
- rasa/core/channels/voice_stream/voice_channel.py +44 -24
- rasa/core/exporter.py +36 -0
- rasa/core/http_interpreter.py +3 -7
- rasa/core/information_retrieval/faiss.py +18 -11
- rasa/core/information_retrieval/ingestion/faq_parser.py +158 -0
- rasa/core/jobs.py +2 -1
- rasa/core/nlg/contextual_response_rephraser.py +48 -12
- rasa/core/nlg/generator.py +0 -1
- rasa/core/nlg/interpolator.py +2 -3
- rasa/core/nlg/summarize.py +39 -5
- rasa/core/policies/enterprise_search_policy.py +298 -184
- rasa/core/policies/enterprise_search_policy_config.py +241 -0
- rasa/core/policies/enterprise_search_prompt_with_relevancy_check_and_citation_template.jinja2 +64 -0
- rasa/core/policies/flow_policy.py +1 -1
- rasa/core/policies/flows/flow_executor.py +96 -17
- rasa/core/policies/intentless_policy.py +71 -26
- rasa/core/processor.py +104 -51
- rasa/core/run.py +33 -11
- rasa/core/tracker_stores/tracker_store.py +1 -1
- rasa/core/training/interactive.py +1 -1
- rasa/core/utils.py +35 -99
- rasa/dialogue_understanding/coexistence/intent_based_router.py +2 -1
- rasa/dialogue_understanding/coexistence/llm_based_router.py +13 -17
- rasa/dialogue_understanding/commands/__init__.py +4 -0
- rasa/dialogue_understanding/commands/can_not_handle_command.py +2 -0
- rasa/dialogue_understanding/commands/cancel_flow_command.py +6 -2
- rasa/dialogue_understanding/commands/chit_chat_answer_command.py +2 -0
- rasa/dialogue_understanding/commands/clarify_command.py +7 -3
- rasa/dialogue_understanding/commands/command_syntax_manager.py +1 -0
- rasa/dialogue_understanding/commands/correct_slots_command.py +5 -6
- rasa/dialogue_understanding/commands/error_command.py +1 -1
- rasa/dialogue_understanding/commands/human_handoff_command.py +3 -3
- rasa/dialogue_understanding/commands/knowledge_answer_command.py +2 -0
- rasa/dialogue_understanding/commands/repeat_bot_messages_command.py +2 -0
- rasa/dialogue_understanding/commands/set_slot_command.py +15 -5
- rasa/dialogue_understanding/commands/skip_question_command.py +3 -3
- rasa/dialogue_understanding/commands/start_flow_command.py +7 -3
- rasa/dialogue_understanding/commands/utils.py +26 -2
- rasa/dialogue_understanding/generator/__init__.py +7 -1
- rasa/dialogue_understanding/generator/command_generator.py +15 -3
- rasa/dialogue_understanding/generator/command_parser.py +2 -2
- rasa/dialogue_understanding/generator/command_parser_validator.py +63 -0
- rasa/dialogue_understanding/generator/constants.py +2 -2
- rasa/dialogue_understanding/generator/nlu_command_adapter.py +2 -2
- rasa/dialogue_understanding/generator/prompt_templates/command_prompt_template.jinja2 +0 -2
- rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v2_claude_3_5_sonnet_20240620_template.jinja2 +1 -0
- rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v2_gpt_4o_2024_11_20_template.jinja2 +1 -0
- rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v3_claude_3_5_sonnet_20240620_template.jinja2 +79 -0
- rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v3_gpt_4o_2024_11_20_template.jinja2 +79 -0
- rasa/dialogue_understanding/generator/single_step/compact_llm_command_generator.py +28 -463
- rasa/dialogue_understanding/generator/single_step/search_ready_llm_command_generator.py +147 -0
- rasa/dialogue_understanding/generator/single_step/single_step_based_llm_command_generator.py +461 -0
- rasa/dialogue_understanding/generator/single_step/single_step_llm_command_generator.py +11 -64
- rasa/dialogue_understanding/patterns/cancel.py +1 -2
- rasa/dialogue_understanding/patterns/clarify.py +1 -1
- rasa/dialogue_understanding/patterns/correction.py +2 -2
- rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +37 -25
- rasa/dialogue_understanding/patterns/domain_for_patterns.py +190 -0
- rasa/dialogue_understanding/processor/command_processor.py +11 -12
- rasa/dialogue_understanding/processor/command_processor_component.py +3 -3
- rasa/dialogue_understanding/stack/frames/flow_stack_frame.py +17 -4
- rasa/dialogue_understanding/stack/utils.py +3 -1
- rasa/dialogue_understanding/utils.py +68 -12
- rasa/dialogue_understanding_test/du_test_case.py +1 -1
- rasa/dialogue_understanding_test/du_test_runner.py +4 -22
- rasa/dialogue_understanding_test/test_case_simulation/test_case_tracker_simulator.py +2 -6
- rasa/e2e_test/e2e_test_coverage_report.py +1 -1
- rasa/e2e_test/e2e_test_runner.py +1 -1
- rasa/engine/constants.py +1 -1
- rasa/engine/graph.py +2 -2
- rasa/engine/recipes/default_recipe.py +26 -2
- rasa/engine/validation.py +3 -2
- rasa/hooks.py +0 -28
- rasa/llm_fine_tuning/annotation_module.py +39 -9
- rasa/llm_fine_tuning/conversations.py +3 -0
- rasa/llm_fine_tuning/llm_data_preparation_module.py +66 -49
- rasa/llm_fine_tuning/paraphrasing/conversation_rephraser.py +5 -7
- rasa/llm_fine_tuning/paraphrasing/rephrase_validator.py +52 -44
- rasa/llm_fine_tuning/paraphrasing_module.py +10 -12
- rasa/llm_fine_tuning/storage.py +4 -4
- rasa/llm_fine_tuning/utils.py +63 -1
- rasa/model_manager/model_api.py +88 -0
- rasa/model_manager/trainer_service.py +4 -4
- rasa/plugin.py +1 -11
- rasa/privacy/__init__.py +0 -0
- rasa/privacy/constants.py +83 -0
- rasa/privacy/event_broker_utils.py +77 -0
- rasa/privacy/privacy_config.py +281 -0
- rasa/privacy/privacy_config_schema.json +86 -0
- rasa/privacy/privacy_filter.py +340 -0
- rasa/privacy/privacy_manager.py +576 -0
- rasa/server.py +23 -2
- rasa/shared/constants.py +18 -0
- rasa/shared/core/command_payload_reader.py +1 -5
- rasa/shared/core/constants.py +4 -3
- rasa/shared/core/domain.py +7 -0
- rasa/shared/core/events.py +38 -10
- rasa/shared/core/flows/constants.py +2 -0
- rasa/shared/core/flows/flow.py +127 -14
- rasa/shared/core/flows/flows_list.py +18 -1
- rasa/shared/core/flows/flows_yaml_schema.json +3 -0
- rasa/shared/core/flows/steps/collect.py +46 -2
- rasa/shared/core/flows/steps/link.py +7 -2
- rasa/shared/core/flows/validation.py +25 -5
- rasa/shared/core/slots.py +28 -0
- rasa/shared/core/training_data/story_reader/yaml_story_reader.py +1 -4
- rasa/shared/exceptions.py +4 -0
- rasa/shared/providers/_configs/azure_openai_client_config.py +6 -2
- rasa/shared/providers/_configs/default_litellm_client_config.py +1 -1
- rasa/shared/providers/_configs/huggingface_local_embedding_client_config.py +1 -1
- rasa/shared/providers/_configs/openai_client_config.py +5 -1
- rasa/shared/providers/_configs/rasa_llm_client_config.py +1 -1
- rasa/shared/providers/_configs/self_hosted_llm_client_config.py +1 -1
- rasa/shared/providers/_configs/utils.py +0 -99
- rasa/shared/providers/embedding/_base_litellm_embedding_client.py +3 -0
- rasa/shared/providers/llm/_base_litellm_client.py +5 -2
- rasa/shared/utils/common.py +1 -1
- rasa/shared/utils/configs.py +110 -0
- rasa/shared/utils/constants.py +0 -3
- rasa/shared/utils/llm.py +195 -9
- rasa/shared/utils/pykwalify_extensions.py +0 -9
- rasa/shared/utils/yaml.py +32 -0
- rasa/studio/constants.py +1 -0
- rasa/studio/data_handler.py +11 -4
- rasa/studio/download.py +167 -0
- rasa/studio/link.py +200 -0
- rasa/studio/prompts.py +223 -0
- rasa/studio/pull/__init__.py +0 -0
- rasa/studio/{download/flows.py → pull/data.py} +23 -160
- rasa/studio/{download → pull}/domains.py +1 -1
- rasa/studio/pull/pull.py +235 -0
- rasa/studio/push.py +136 -0
- rasa/studio/train.py +1 -1
- rasa/studio/upload.py +117 -67
- rasa/telemetry.py +82 -25
- rasa/tracing/config.py +3 -4
- rasa/tracing/constants.py +19 -1
- rasa/tracing/instrumentation/attribute_extractors.py +30 -8
- rasa/tracing/instrumentation/instrumentation.py +53 -2
- rasa/tracing/instrumentation/metrics.py +98 -15
- rasa/tracing/metric_instrument_provider.py +75 -3
- rasa/utils/common.py +7 -22
- rasa/utils/log_utils.py +1 -45
- rasa/validator.py +2 -8
- rasa/version.py +1 -1
- {rasa_pro-3.13.0.dev20250612.dist-info → rasa_pro-3.13.0rc1.dist-info}/METADATA +8 -9
- {rasa_pro-3.13.0.dev20250612.dist-info → rasa_pro-3.13.0rc1.dist-info}/RECORD +241 -220
- rasa/anonymization/__init__.py +0 -2
- rasa/anonymization/anonymisation_rule_yaml_reader.py +0 -91
- rasa/anonymization/anonymization_pipeline.py +0 -286
- rasa/anonymization/anonymization_rule_executor.py +0 -266
- rasa/anonymization/anonymization_rule_orchestrator.py +0 -119
- rasa/anonymization/schemas/config.yml +0 -47
- rasa/anonymization/utils.py +0 -118
- rasa/core/channels/inspector/dist/assets/channel-3730f5fd.js +0 -1
- rasa/core/channels/inspector/dist/assets/clone-e847561e.js +0 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-efbbfe00.js +0 -1
- rasa/studio/download/download.py +0 -439
- /rasa/{studio/download → core/information_retrieval/ingestion}/__init__.py +0 -0
- {rasa_pro-3.13.0.dev20250612.dist-info → rasa_pro-3.13.0rc1.dist-info}/NOTICE +0 -0
- {rasa_pro-3.13.0.dev20250612.dist-info → rasa_pro-3.13.0rc1.dist-info}/WHEEL +0 -0
- {rasa_pro-3.13.0.dev20250612.dist-info → rasa_pro-3.13.0rc1.dist-info}/entry_points.txt +0 -0
rasa/studio/download/download.py
DELETED
|
@@ -1,439 +0,0 @@
|
|
|
1
|
-
import argparse
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
from typing import Dict, List, Optional, Tuple
|
|
4
|
-
|
|
5
|
-
import questionary
|
|
6
|
-
import structlog
|
|
7
|
-
from ruamel import yaml
|
|
8
|
-
from ruamel.yaml.scalarstring import LiteralScalarString
|
|
9
|
-
|
|
10
|
-
import rasa.cli.utils
|
|
11
|
-
import rasa.shared.utils.cli
|
|
12
|
-
from rasa.shared.constants import (
|
|
13
|
-
DEFAULT_CONFIG_PATH,
|
|
14
|
-
DEFAULT_DATA_PATH,
|
|
15
|
-
DEFAULT_DOMAIN_PATH,
|
|
16
|
-
DEFAULT_DOMAIN_PATHS,
|
|
17
|
-
DEFAULT_ENDPOINTS_PATH,
|
|
18
|
-
)
|
|
19
|
-
from rasa.shared.core.flows.yaml_flows_io import YamlFlowsWriter
|
|
20
|
-
from rasa.shared.importers.importer import TrainingDataImporter
|
|
21
|
-
from rasa.shared.utils.yaml import read_yaml
|
|
22
|
-
from rasa.studio import data_handler
|
|
23
|
-
from rasa.studio.config import StudioConfig
|
|
24
|
-
from rasa.studio.constants import (
|
|
25
|
-
STUDIO_DOMAIN_FILENAME,
|
|
26
|
-
STUDIO_FLOWS_FILENAME,
|
|
27
|
-
STUDIO_NLU_FILENAME,
|
|
28
|
-
)
|
|
29
|
-
from rasa.studio.data_handler import StudioDataHandler, import_data_from_studio
|
|
30
|
-
from rasa.studio.download.domains import merge_domain_with_overwrite
|
|
31
|
-
from rasa.studio.download.flows import merge_flows_with_overwrite
|
|
32
|
-
from rasa.utils.mapper import RasaPrimitiveStorageMapper
|
|
33
|
-
|
|
34
|
-
structlogger = structlog.getLogger(__name__)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def handle_download(args: argparse.Namespace) -> None:
|
|
38
|
-
"""Main function to handle downloading and merging data.
|
|
39
|
-
|
|
40
|
-
Args:
|
|
41
|
-
args: The command line arguments.
|
|
42
|
-
"""
|
|
43
|
-
handler = StudioDataHandler(
|
|
44
|
-
studio_config=StudioConfig.read_config(),
|
|
45
|
-
assistant_name=args.assistant_name[0],
|
|
46
|
-
)
|
|
47
|
-
handler.request_all_data()
|
|
48
|
-
|
|
49
|
-
domain_path, data_paths = _prepare_data_and_domain_paths(args)
|
|
50
|
-
|
|
51
|
-
# Handle config and endpoints.
|
|
52
|
-
config_path, write_config = _handle_file_overwrite(
|
|
53
|
-
args.config, DEFAULT_CONFIG_PATH, "config"
|
|
54
|
-
)
|
|
55
|
-
endpoints_path, write_endpoints = _handle_file_overwrite(
|
|
56
|
-
args.endpoints, DEFAULT_ENDPOINTS_PATH, "endpoints"
|
|
57
|
-
)
|
|
58
|
-
message_parts = []
|
|
59
|
-
config_path = config_path if write_config else None
|
|
60
|
-
endpoints_path = endpoints_path if write_endpoints else None
|
|
61
|
-
|
|
62
|
-
if config_path:
|
|
63
|
-
config_data = handler.get_config()
|
|
64
|
-
if not config_data:
|
|
65
|
-
rasa.shared.utils.cli.print_error_and_exit("No config data found.")
|
|
66
|
-
with open(config_path, "w") as f:
|
|
67
|
-
f.write(config_data)
|
|
68
|
-
message_parts.append(f"config to '{config_path}'")
|
|
69
|
-
if endpoints_path:
|
|
70
|
-
endpoints_data = handler.get_endpoints()
|
|
71
|
-
if not endpoints_data:
|
|
72
|
-
raise ValueError("No endpoints data found.")
|
|
73
|
-
with open(endpoints_path, "w") as f:
|
|
74
|
-
f.write(endpoints_data)
|
|
75
|
-
message_parts.append(f"endpoints to '{endpoints_path}'")
|
|
76
|
-
if message_parts:
|
|
77
|
-
message = "Downloaded " + " and ".join(message_parts)
|
|
78
|
-
structlogger.info("studio.download.config_endpoints", event_info=message)
|
|
79
|
-
|
|
80
|
-
if not args.overwrite:
|
|
81
|
-
_handle_download_no_overwrite(handler, domain_path, data_paths)
|
|
82
|
-
else:
|
|
83
|
-
_handle_download_with_overwrite(handler, domain_path, data_paths)
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
def _prepare_data_and_domain_paths(args: argparse.Namespace) -> Tuple[Path, List[Path]]:
|
|
87
|
-
"""Prepars the domain and data paths based on the provided arguments.
|
|
88
|
-
|
|
89
|
-
Args:
|
|
90
|
-
args: The command line arguments.
|
|
91
|
-
|
|
92
|
-
Returns:
|
|
93
|
-
A tuple containing the domain path and a list of data paths.
|
|
94
|
-
"""
|
|
95
|
-
# Prepare domain path.
|
|
96
|
-
domain_path = rasa.cli.utils.get_validated_path(
|
|
97
|
-
args.domain, "domain", DEFAULT_DOMAIN_PATHS, none_is_valid=True
|
|
98
|
-
)
|
|
99
|
-
domain_or_default_path = args.domain or DEFAULT_DOMAIN_PATH
|
|
100
|
-
|
|
101
|
-
if domain_path is None:
|
|
102
|
-
domain_path = Path(domain_or_default_path)
|
|
103
|
-
domain_path.touch()
|
|
104
|
-
|
|
105
|
-
if isinstance(domain_path, str):
|
|
106
|
-
domain_path = Path(domain_path)
|
|
107
|
-
|
|
108
|
-
if domain_path.is_file():
|
|
109
|
-
if not args.overwrite:
|
|
110
|
-
domain_path.unlink()
|
|
111
|
-
domain_path.touch()
|
|
112
|
-
|
|
113
|
-
if domain_path.is_dir():
|
|
114
|
-
if not args.overwrite:
|
|
115
|
-
domain_path = domain_path / STUDIO_DOMAIN_FILENAME
|
|
116
|
-
domain_path.touch()
|
|
117
|
-
|
|
118
|
-
# Prepare data paths.
|
|
119
|
-
data_paths: List[Path] = []
|
|
120
|
-
for f in args.data:
|
|
121
|
-
data_path = rasa.cli.utils.get_validated_path(
|
|
122
|
-
f, "data", DEFAULT_DATA_PATH, none_is_valid=True
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
if data_path is None:
|
|
126
|
-
data_path = Path(f)
|
|
127
|
-
data_path.mkdir(parents=True, exist_ok=True)
|
|
128
|
-
else:
|
|
129
|
-
data_path = Path(data_path)
|
|
130
|
-
|
|
131
|
-
if data_path.is_file() or data_path.is_dir():
|
|
132
|
-
data_paths.append(data_path)
|
|
133
|
-
else:
|
|
134
|
-
data_path.mkdir(parents=True, exist_ok=True)
|
|
135
|
-
data_paths.append(data_path)
|
|
136
|
-
|
|
137
|
-
# Remove duplicates while preserving order.
|
|
138
|
-
data_paths = list(dict.fromkeys(data_paths))
|
|
139
|
-
return domain_path, data_paths
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
def _handle_file_overwrite(
|
|
143
|
-
file_path: Optional[str], default_path: str, file_type: str
|
|
144
|
-
) -> Tuple[Optional[Path], bool]:
|
|
145
|
-
"""Determines whether to overwrite an existing file or create a new one.
|
|
146
|
-
|
|
147
|
-
Works for config and endpoints at this moment.
|
|
148
|
-
|
|
149
|
-
Args:
|
|
150
|
-
file_path: The path to the file.
|
|
151
|
-
default_path: The default path to use if no file path is provided.
|
|
152
|
-
file_type: The type of the file (e.g., config, endpoints).
|
|
153
|
-
|
|
154
|
-
Returns:
|
|
155
|
-
A tuple of the file path and a boolean indicating overwrite status.
|
|
156
|
-
"""
|
|
157
|
-
file_already_exists = rasa.cli.utils.get_validated_path(
|
|
158
|
-
file_path, file_type, default_path, none_is_valid=True
|
|
159
|
-
)
|
|
160
|
-
write_file = False
|
|
161
|
-
path = None
|
|
162
|
-
file_or_default_path = file_path or default_path
|
|
163
|
-
|
|
164
|
-
if file_already_exists is None:
|
|
165
|
-
path = Path(file_or_default_path)
|
|
166
|
-
if path.is_dir():
|
|
167
|
-
path = path / default_path
|
|
168
|
-
return path, True
|
|
169
|
-
|
|
170
|
-
if questionary.confirm(
|
|
171
|
-
f"{file_type.capitalize()} file '{file_or_default_path}' already exists. "
|
|
172
|
-
f"Do you want to overwrite it?"
|
|
173
|
-
).ask():
|
|
174
|
-
write_file = True
|
|
175
|
-
path = Path(file_or_default_path)
|
|
176
|
-
return path, write_file
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
def _handle_download_no_overwrite(
|
|
180
|
-
handler: StudioDataHandler, domain_path: Path, data_paths: List[Path]
|
|
181
|
-
) -> None:
|
|
182
|
-
"""Handles downloading without overwriting existing files.
|
|
183
|
-
|
|
184
|
-
Args:
|
|
185
|
-
handler: The StudioDataHandler instance.
|
|
186
|
-
domain_path: The path to the domain file or directory.
|
|
187
|
-
data_paths: The paths to the data files or directories.
|
|
188
|
-
"""
|
|
189
|
-
data_from_studio, data_local = import_data_from_studio(
|
|
190
|
-
handler, domain_path, data_paths
|
|
191
|
-
)
|
|
192
|
-
_merge_domain_no_overwrite(domain_path, data_from_studio, data_local)
|
|
193
|
-
_merge_data_no_overwrite(data_paths, handler, data_from_studio, data_local)
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
def _merge_domain_no_overwrite(
|
|
197
|
-
domain_path: Path,
|
|
198
|
-
data_from_studio: TrainingDataImporter,
|
|
199
|
-
data_local: TrainingDataImporter,
|
|
200
|
-
) -> None:
|
|
201
|
-
"""
|
|
202
|
-
Merges the domain data without overwriting.
|
|
203
|
-
|
|
204
|
-
If the domain path is a directory, a new domain file is created under that folder.
|
|
205
|
-
If the domain path is a file, it merges both domains into that file.
|
|
206
|
-
|
|
207
|
-
Args:
|
|
208
|
-
domain_path: The path to the domain file or directory.
|
|
209
|
-
data_from_studio: The Studio data importer.
|
|
210
|
-
data_local: The local data importer.
|
|
211
|
-
"""
|
|
212
|
-
if domain_path.is_dir():
|
|
213
|
-
_merge_directory_domain(domain_path, data_from_studio, data_local)
|
|
214
|
-
elif domain_path.is_file():
|
|
215
|
-
_merge_file_domain(domain_path, data_from_studio, data_local)
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
def _merge_directory_domain(
|
|
219
|
-
domain_path: Path,
|
|
220
|
-
data_from_studio: TrainingDataImporter,
|
|
221
|
-
data_local: TrainingDataImporter,
|
|
222
|
-
) -> None:
|
|
223
|
-
"""Merges domain data without overwriting when the domain is a directory.
|
|
224
|
-
|
|
225
|
-
Args:
|
|
226
|
-
domain_path: The path to the domain directory.
|
|
227
|
-
data_from_studio: The Studio data importer.
|
|
228
|
-
data_local: The local data importer.
|
|
229
|
-
"""
|
|
230
|
-
from rasa.shared.core.domain import Domain
|
|
231
|
-
|
|
232
|
-
studio_domain_path = domain_path / STUDIO_NLU_FILENAME
|
|
233
|
-
new_domain_data = data_handler.combine_domains(
|
|
234
|
-
data_from_studio.get_user_domain().as_dict(),
|
|
235
|
-
data_local.get_user_domain().as_dict(),
|
|
236
|
-
)
|
|
237
|
-
studio_domain = Domain.from_dict(new_domain_data)
|
|
238
|
-
|
|
239
|
-
if not studio_domain.is_empty():
|
|
240
|
-
studio_domain.persist(studio_domain_path)
|
|
241
|
-
else:
|
|
242
|
-
structlogger.warning(
|
|
243
|
-
"studio.download.merge_directory_domain",
|
|
244
|
-
event_info="No additional domain data found in Studio assistant.",
|
|
245
|
-
)
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
def _merge_file_domain(
|
|
249
|
-
domain_path: Path,
|
|
250
|
-
data_from_studio: TrainingDataImporter,
|
|
251
|
-
data_local: TrainingDataImporter,
|
|
252
|
-
) -> None:
|
|
253
|
-
"""Merges domain data without overwriting when the domain is a file.
|
|
254
|
-
|
|
255
|
-
Args:
|
|
256
|
-
domain_path: The path to the domain file.
|
|
257
|
-
data_from_studio: The Studio data importer.
|
|
258
|
-
data_local: The local data importer.
|
|
259
|
-
"""
|
|
260
|
-
domain_merged = data_local.get_user_domain().merge(
|
|
261
|
-
data_from_studio.get_user_domain()
|
|
262
|
-
)
|
|
263
|
-
domain_merged.persist(domain_path)
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
def _merge_data_no_overwrite(
|
|
267
|
-
data_paths: List[Path],
|
|
268
|
-
handler: StudioDataHandler,
|
|
269
|
-
data_from_studio: TrainingDataImporter,
|
|
270
|
-
data_local: TrainingDataImporter,
|
|
271
|
-
) -> None:
|
|
272
|
-
"""Merges NLU and flow data without overwriting existing data.
|
|
273
|
-
|
|
274
|
-
Args:
|
|
275
|
-
data_paths: The paths to the data files or directories.
|
|
276
|
-
handler: The StudioDataHandler instance.
|
|
277
|
-
data_from_studio: The Studio data importer.
|
|
278
|
-
data_local: The local data importer.
|
|
279
|
-
"""
|
|
280
|
-
if not data_paths:
|
|
281
|
-
structlogger.warning(
|
|
282
|
-
"studio.download.merge_data_no_overwrite.no_path",
|
|
283
|
-
event_info="No data paths provided. Skipping data merge.",
|
|
284
|
-
)
|
|
285
|
-
return
|
|
286
|
-
|
|
287
|
-
if len(data_paths) == 1:
|
|
288
|
-
data_path = data_paths[0]
|
|
289
|
-
if data_path.is_file():
|
|
290
|
-
_merge_file_data_no_overwrite(
|
|
291
|
-
data_path, handler, data_from_studio, data_local
|
|
292
|
-
)
|
|
293
|
-
elif data_path.is_dir():
|
|
294
|
-
_merge_dir_data_no_overwrite(
|
|
295
|
-
data_path, handler, data_from_studio, data_local
|
|
296
|
-
)
|
|
297
|
-
else:
|
|
298
|
-
structlogger.warning(
|
|
299
|
-
"studio.download.merge_data_no_overwrite.invalid_path",
|
|
300
|
-
event_info=(
|
|
301
|
-
f"Provided path '{data_path}' is neither a file nor a directory."
|
|
302
|
-
),
|
|
303
|
-
)
|
|
304
|
-
else:
|
|
305
|
-
# TODO: Handle multiple data paths.
|
|
306
|
-
raise NotImplementedError("Multiple data paths are not supported yet.")
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
def _merge_file_data_no_overwrite(
|
|
310
|
-
data_path: Path,
|
|
311
|
-
handler: StudioDataHandler,
|
|
312
|
-
data_from_studio: TrainingDataImporter,
|
|
313
|
-
data_local: TrainingDataImporter,
|
|
314
|
-
) -> None:
|
|
315
|
-
"""Merges NLU and flows data into a single file without overwriting.
|
|
316
|
-
|
|
317
|
-
Args:
|
|
318
|
-
data_path: Path to the single data file.
|
|
319
|
-
handler: The StudioDataHandler instance.
|
|
320
|
-
data_from_studio: The Studio data importer.
|
|
321
|
-
data_local: The local data importer.
|
|
322
|
-
"""
|
|
323
|
-
if handler.has_nlu():
|
|
324
|
-
merged_nlu = data_local.get_nlu_data().merge(data_from_studio.get_nlu_data())
|
|
325
|
-
merged_nlu.persist_nlu(str(data_path))
|
|
326
|
-
if handler.has_flows():
|
|
327
|
-
merged_flows = data_local.get_user_flows().merge(
|
|
328
|
-
data_from_studio.get_user_flows()
|
|
329
|
-
)
|
|
330
|
-
YamlFlowsWriter.dump(merged_flows.underlying_flows, data_path)
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
def _merge_dir_data_no_overwrite(
|
|
334
|
-
dir_path: Path,
|
|
335
|
-
handler: StudioDataHandler,
|
|
336
|
-
data_from_studio: TrainingDataImporter,
|
|
337
|
-
data_local: TrainingDataImporter,
|
|
338
|
-
) -> None:
|
|
339
|
-
"""Merges NLU and flows data into a single directory without overwriting.
|
|
340
|
-
|
|
341
|
-
Args:
|
|
342
|
-
dir_path: Path to the data directory.
|
|
343
|
-
handler: The StudioDataHandler instance.
|
|
344
|
-
data_from_studio: The Studio data importer.
|
|
345
|
-
data_local: The local data importer.
|
|
346
|
-
"""
|
|
347
|
-
if handler.has_nlu():
|
|
348
|
-
nlu_path = dir_path / Path(STUDIO_NLU_FILENAME)
|
|
349
|
-
_persist_nlu_diff(data_local, data_from_studio, nlu_path)
|
|
350
|
-
if handler.has_flows():
|
|
351
|
-
flows_path = dir_path / Path(STUDIO_FLOWS_FILENAME)
|
|
352
|
-
_persist_flows_diff(data_local, data_from_studio, flows_path)
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
def _handle_download_with_overwrite(
|
|
356
|
-
handler: StudioDataHandler, domain_path: Path, data_paths: List[Path]
|
|
357
|
-
) -> None:
|
|
358
|
-
"""Handles downloading and merging data when the user opts for overwrite.
|
|
359
|
-
|
|
360
|
-
Args:
|
|
361
|
-
handler: The StudioDataHandler instance.
|
|
362
|
-
domain_path: The path to the domain file or directory.
|
|
363
|
-
data_paths: The paths to the data files or directories.
|
|
364
|
-
"""
|
|
365
|
-
data_from_studio, data_local = import_data_from_studio(
|
|
366
|
-
handler, domain_path, data_paths
|
|
367
|
-
)
|
|
368
|
-
mapper = RasaPrimitiveStorageMapper(
|
|
369
|
-
domain_path=domain_path, training_data_paths=data_paths
|
|
370
|
-
)
|
|
371
|
-
merge_domain_with_overwrite(data_from_studio, data_local, domain_path)
|
|
372
|
-
merge_flows_with_overwrite(
|
|
373
|
-
data_paths, handler, data_from_studio, data_local, mapper
|
|
374
|
-
)
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
def _persist_nlu_diff(
|
|
378
|
-
data_local: TrainingDataImporter,
|
|
379
|
-
data_from_studio: TrainingDataImporter,
|
|
380
|
-
data_path: Path,
|
|
381
|
-
) -> None:
|
|
382
|
-
"""Creates a new NLU file from the diff of local and studio data.
|
|
383
|
-
|
|
384
|
-
Args:
|
|
385
|
-
data_local: The local training data.
|
|
386
|
-
data_from_studio: The training data from Rasa Studio.
|
|
387
|
-
data_path: The path to the NLU file.
|
|
388
|
-
"""
|
|
389
|
-
new_nlu_data = data_handler.create_new_nlu_from_diff(
|
|
390
|
-
read_yaml(data_from_studio.get_nlu_data().nlu_as_yaml()),
|
|
391
|
-
read_yaml(data_local.get_nlu_data().nlu_as_yaml()),
|
|
392
|
-
)
|
|
393
|
-
if new_nlu_data["nlu"]:
|
|
394
|
-
pretty_write_nlu_yaml(new_nlu_data, data_path)
|
|
395
|
-
else:
|
|
396
|
-
structlogger.warning(
|
|
397
|
-
"studio.download.persist_nlu_diff",
|
|
398
|
-
event_info="No additional nlu data found.",
|
|
399
|
-
)
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
def _persist_flows_diff(
|
|
403
|
-
data_local: TrainingDataImporter,
|
|
404
|
-
data_from_studio: TrainingDataImporter,
|
|
405
|
-
data_path: Path,
|
|
406
|
-
) -> None:
|
|
407
|
-
"""Creates a new flows file from the diff of local and studio data.
|
|
408
|
-
|
|
409
|
-
Args:
|
|
410
|
-
data_local: The local training data.
|
|
411
|
-
data_from_studio: The training data from Rasa Studio.
|
|
412
|
-
data_path: The path to the flows file.
|
|
413
|
-
"""
|
|
414
|
-
new_flows_data = data_handler.create_new_flows_from_diff(
|
|
415
|
-
data_from_studio.get_user_flows().underlying_flows,
|
|
416
|
-
data_local.get_user_flows().underlying_flows,
|
|
417
|
-
)
|
|
418
|
-
if new_flows_data:
|
|
419
|
-
YamlFlowsWriter.dump(new_flows_data, data_path)
|
|
420
|
-
else:
|
|
421
|
-
structlogger.warning(
|
|
422
|
-
"studio.download.persist_flows_diff",
|
|
423
|
-
event_info="No additional flows data found.",
|
|
424
|
-
)
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
def pretty_write_nlu_yaml(data: Dict, file: Path) -> None:
|
|
428
|
-
"""Writes the NLU YAML in a pretty way.
|
|
429
|
-
|
|
430
|
-
Args:
|
|
431
|
-
data: The data to write.
|
|
432
|
-
file: The file to write to.
|
|
433
|
-
"""
|
|
434
|
-
dumper = yaml.YAML()
|
|
435
|
-
for item in data["nlu"]:
|
|
436
|
-
if item.get("examples"):
|
|
437
|
-
item["examples"] = LiteralScalarString(item["examples"])
|
|
438
|
-
with file.open("w", encoding="utf-8") as outfile:
|
|
439
|
-
dumper.dump(data, outfile)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|