rasa-pro 3.12.18__py3-none-any.whl → 3.13.0a1.dev1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rasa-pro might be problematic. Click here for more details.
- rasa/__main__.py +3 -4
- rasa/api.py +1 -1
- rasa/builder/create_openai_vector_store.py +69 -0
- rasa/builder/llm-helper-schema.json +69 -0
- rasa/builder/prompt_to_bot.py +645 -0
- rasa/builder/scrape_rasa_docs.py +97 -0
- rasa/builder/skill_to_bot_prompt.jinja +158 -0
- rasa/cli/dialogue_understanding_test.py +1 -1
- rasa/cli/e2e_test.py +1 -1
- rasa/cli/evaluate.py +2 -2
- rasa/cli/export.py +3 -3
- rasa/cli/llm_fine_tuning.py +1 -1
- rasa/cli/project_templates/default/config.yml +5 -32
- rasa/cli/project_templates/{calm → default}/e2e_tests/cancelations/user_cancels_during_a_correction.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/cancelations/user_changes_mind_on_a_whim.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/corrections/user_corrects_contact_handle.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/corrections/user_corrects_contact_name.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/happy_paths/user_adds_contact_to_their_list.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/happy_paths/user_lists_contacts.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/happy_paths/user_removes_contact.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/happy_paths/user_removes_contact_from_list.yml +1 -1
- rasa/cli/project_templates/default/endpoints.yml +18 -2
- rasa/cli/project_templates/defaults.py +133 -0
- rasa/cli/run.py +1 -1
- rasa/cli/scaffold.py +2 -3
- rasa/cli/studio/download.py +1 -1
- rasa/cli/studio/link.py +53 -0
- rasa/cli/studio/pull.py +78 -0
- rasa/cli/studio/push.py +78 -0
- rasa/cli/studio/studio.py +12 -0
- rasa/cli/studio/upload.py +5 -3
- 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 +43 -29
- rasa/core/actions/action_repeat_bot_messages.py +18 -22
- rasa/core/actions/action_run_slot_rejections.py +1 -2
- rasa/core/agent.py +18 -3
- rasa/core/available_endpoints.py +146 -0
- rasa/core/brokers/kafka.py +4 -0
- rasa/core/brokers/pika.py +5 -2
- rasa/core/brokers/sql.py +1 -1
- 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/.eslintrc.cjs +12 -6
- rasa/core/channels/inspector/.prettierrc +5 -0
- rasa/core/channels/inspector/README.md +11 -5
- rasa/core/channels/inspector/dist/assets/{arc-9f75cc3b.js → arc-02053cc1.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-7f34db23.js → blockDiagram-38ab4fdb-008b6289.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-948bab2c.js → c4Diagram-3d4e48cf-fb2597be.js} +1 -1
- rasa/core/channels/inspector/dist/assets/channel-078dada8.js +1 -0
- rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-53b0dd0e.js → classDiagram-70f12bd4-7f847e00.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-fdf789e7.js → classDiagram-v2-f2320105-ba1d689b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/clone-5b4516de.js +1 -0
- rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-87c4ece5.js → createText-2e5e7dd3-dd8e67c4.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-5a8b0749.js → edges-e0da2a9e-10784939.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-66da90e2.js → erDiagram-9861fffd-24947ae6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-10044f05.js → flowDb-956e92f1-a9ced505.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-f338f66a.js → flowDiagram-66a62f08-afda9c7c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-f9613071.js +1 -0
- rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-b13140aa.js → flowchart-elk-definition-4a651766-6ef530b8.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-f2b4a55a.js → ganttDiagram-c361ad54-0c7dd39a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-dedc298d.js → gitGraphDiagram-72cf32ee-b57239d6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{graph-4ede11ff.js → graph-9ed57cec.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-3862675e-65549d37.js → index-3862675e-233090de.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-3a23e736.js → index-72184470.js} +123 -123
- rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-65439671.js → infoDiagram-f8f76790-aa116649.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-56d03d98.js → journeyDiagram-49397b02-e51877cc.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-dd48f7f4.js → layout-3ca3798c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{line-1569ad2c.js → line-26ee10d3.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-48bf4935.js → linear-aedded32.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-688504c1.js → mindmap-definition-fc14e90a-d8957261.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-78b6d7e6.js → pieDiagram-8a3498a8-d771f885.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-048b84b3.js → quadrantDiagram-120e2f19-09fdf50c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-dd67f107.js → requirementDiagram-deff3bca-9f0af02e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-8128436e.js → sankeyDiagram-04a897e0-84415b37.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-1a0d1461.js → sequenceDiagram-704730f1-8dec4055.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-46d388ed.js → stateDiagram-587899a1-c5431d07.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-ea42951a.js → stateDiagram-v2-d93cdb3a-274e77d9.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-7427ed0c.js → styles-6aaf32cf-e364a1d7.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-9a916d00-ff5e5a16.js → styles-9a916d00-0dae36f6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-c10674c1-7b3680cf.js → styles-c10674c1-c4641675.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-f860f2ad.js → svgDrawCommon-08f97a94-831fe9a1.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-2eebf0c8.js → timeline-definition-85554ec2-c3304b3a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-5d7f4e96.js → xychartDiagram-e933f94c-da799369.js} +1 -1
- rasa/core/channels/inspector/dist/index.html +1 -1
- rasa/core/channels/inspector/package.json +3 -1
- rasa/core/channels/inspector/src/App.tsx +91 -90
- rasa/core/channels/inspector/src/components/Chat.tsx +45 -41
- rasa/core/channels/inspector/src/components/DiagramFlow.tsx +40 -40
- rasa/core/channels/inspector/src/components/DialogueInformation.tsx +57 -57
- rasa/core/channels/inspector/src/components/DialogueStack.tsx +36 -27
- rasa/core/channels/inspector/src/components/ExpandIcon.tsx +4 -4
- rasa/core/channels/inspector/src/components/FullscreenButton.tsx +7 -7
- rasa/core/channels/inspector/src/components/LoadingSpinner.tsx +28 -12
- rasa/core/channels/inspector/src/components/NoActiveFlow.tsx +9 -9
- rasa/core/channels/inspector/src/components/RasaLogo.tsx +5 -5
- rasa/core/channels/inspector/src/components/RecruitmentPanel.tsx +55 -60
- rasa/core/channels/inspector/src/components/SaraDiagrams.tsx +5 -5
- rasa/core/channels/inspector/src/components/Slots.tsx +22 -22
- rasa/core/channels/inspector/src/components/Welcome.tsx +28 -31
- rasa/core/channels/inspector/src/helpers/audio/audiostream.ts +245 -0
- rasa/core/channels/inspector/src/helpers/audio/microphone-processor.js +12 -0
- rasa/core/channels/inspector/src/helpers/audio/playback-processor.js +36 -0
- rasa/core/channels/inspector/src/helpers/conversation.ts +7 -7
- rasa/core/channels/inspector/src/helpers/formatters.test.ts +181 -181
- rasa/core/channels/inspector/src/helpers/formatters.ts +111 -111
- rasa/core/channels/inspector/src/helpers/utils.ts +78 -61
- rasa/core/channels/inspector/src/main.tsx +8 -8
- rasa/core/channels/inspector/src/theme/Button/Button.ts +8 -8
- rasa/core/channels/inspector/src/theme/Heading/Heading.ts +7 -7
- rasa/core/channels/inspector/src/theme/Input/Input.ts +9 -9
- rasa/core/channels/inspector/src/theme/Link/Link.ts +6 -6
- rasa/core/channels/inspector/src/theme/Modal/Modal.ts +13 -13
- rasa/core/channels/inspector/src/theme/Table/Table.tsx +10 -10
- rasa/core/channels/inspector/src/theme/Tooltip/Tooltip.ts +5 -5
- rasa/core/channels/inspector/src/theme/base/breakpoints.ts +7 -7
- rasa/core/channels/inspector/src/theme/base/colors.ts +64 -64
- rasa/core/channels/inspector/src/theme/base/fonts/fontFaces.css +21 -18
- rasa/core/channels/inspector/src/theme/base/radii.ts +8 -8
- rasa/core/channels/inspector/src/theme/base/shadows.ts +5 -5
- rasa/core/channels/inspector/src/theme/base/sizes.ts +5 -5
- rasa/core/channels/inspector/src/theme/base/space.ts +12 -12
- rasa/core/channels/inspector/src/theme/base/styles.ts +5 -5
- rasa/core/channels/inspector/src/theme/base/typography.ts +12 -12
- rasa/core/channels/inspector/src/theme/base/zIndices.ts +3 -3
- rasa/core/channels/inspector/src/theme/index.ts +38 -38
- rasa/core/channels/inspector/src/types.ts +56 -50
- rasa/core/channels/inspector/yarn.lock +5 -0
- 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 +337 -71
- rasa/core/channels/vier_cvg.py +1 -2
- rasa/core/channels/voice_ready/audiocodes.py +4 -11
- 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/tts/__init__.py +8 -0
- rasa/core/channels/voice_stream/twilio_media_streams.py +10 -5
- rasa/core/channels/voice_stream/voice_channel.py +65 -23
- rasa/core/concurrent_lock_store.py +24 -10
- rasa/core/evaluation/marker_tracker_loader.py +1 -1
- rasa/core/exporter.py +1 -1
- rasa/core/http_interpreter.py +3 -7
- rasa/core/information_retrieval/faiss.py +18 -11
- rasa/core/information_retrieval/ingestion/__init__.py +0 -0
- rasa/core/information_retrieval/ingestion/faq_parser.py +158 -0
- rasa/core/jobs.py +2 -1
- rasa/core/lock_store.py +151 -60
- rasa/core/nlg/contextual_response_rephraser.py +17 -7
- rasa/core/nlg/generator.py +5 -22
- rasa/core/nlg/interpolator.py +2 -3
- rasa/core/nlg/response.py +6 -43
- rasa/core/nlg/summarize.py +1 -1
- rasa/core/nlg/translate.py +0 -8
- rasa/core/policies/enterprise_search_policy.py +262 -62
- rasa/core/policies/enterprise_search_prompt_with_relevancy_check_and_citation_template.jinja2 +63 -0
- rasa/core/policies/flow_policy.py +1 -1
- rasa/core/policies/flows/flow_executor.py +96 -17
- rasa/core/policies/intentless_policy.py +56 -17
- rasa/core/processor.py +64 -49
- rasa/core/run.py +33 -11
- rasa/core/tracker_stores/__init__.py +0 -0
- rasa/core/{auth_retry_tracker_store.py → tracker_stores/auth_retry_tracker_store.py} +5 -1
- rasa/core/tracker_stores/dynamo_tracker_store.py +218 -0
- rasa/core/tracker_stores/mongo_tracker_store.py +206 -0
- rasa/core/tracker_stores/redis_tracker_store.py +219 -0
- rasa/core/tracker_stores/sql_tracker_store.py +555 -0
- rasa/core/tracker_stores/tracker_store.py +805 -0
- rasa/core/training/interactive.py +1 -1
- rasa/core/utils.py +24 -95
- rasa/dialogue_understanding/coexistence/intent_based_router.py +2 -1
- rasa/dialogue_understanding/coexistence/llm_based_router.py +9 -6
- rasa/dialogue_understanding/commands/can_not_handle_command.py +2 -0
- rasa/dialogue_understanding/commands/cancel_flow_command.py +5 -1
- rasa/dialogue_understanding/commands/chit_chat_answer_command.py +2 -0
- rasa/dialogue_understanding/commands/clarify_command.py +4 -0
- rasa/dialogue_understanding/commands/command_syntax_manager.py +1 -0
- rasa/dialogue_understanding/commands/correct_slots_command.py +1 -3
- rasa/dialogue_understanding/commands/human_handoff_command.py +2 -0
- 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 +4 -0
- rasa/dialogue_understanding/commands/skip_question_command.py +2 -0
- rasa/dialogue_understanding/commands/start_flow_command.py +4 -0
- rasa/dialogue_understanding/generator/__init__.py +7 -1
- rasa/dialogue_understanding/generator/command_generator.py +4 -2
- rasa/dialogue_understanding/generator/command_parser.py +2 -2
- rasa/dialogue_understanding/generator/command_parser_validator.py +63 -0
- rasa/dialogue_understanding/generator/llm_based_command_generator.py +1 -2
- rasa/dialogue_understanding/generator/nlu_command_adapter.py +2 -2
- rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v3_gpt_4o_2024_11_20_template.jinja2 +78 -0
- rasa/dialogue_understanding/generator/single_step/compact_llm_command_generator.py +26 -461
- 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 +477 -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 +6 -7
- rasa/dialogue_understanding/stack/utils.py +3 -1
- rasa/dialogue_understanding_test/command_metric_calculation.py +7 -40
- rasa/dialogue_understanding_test/command_metrics.py +38 -0
- rasa/dialogue_understanding_test/du_test_case.py +58 -25
- rasa/dialogue_understanding_test/du_test_result.py +228 -132
- rasa/dialogue_understanding_test/du_test_runner.py +11 -2
- rasa/dialogue_understanding_test/du_test_schema.yml +3 -3
- rasa/dialogue_understanding_test/io.py +35 -8
- rasa/e2e_test/e2e_test_runner.py +1 -1
- rasa/e2e_test/e2e_test_schema.yml +3 -3
- rasa/engine/constants.py +1 -1
- rasa/engine/graph.py +2 -2
- rasa/engine/recipes/default_recipe.py +1 -1
- rasa/engine/validation.py +3 -2
- rasa/hooks.py +2 -30
- rasa/llm_fine_tuning/paraphrasing/conversation_rephraser.py +1 -5
- rasa/model_manager/model_api.py +90 -2
- rasa/model_manager/socket_bridge.py +0 -7
- rasa/model_manager/trainer_service.py +15 -12
- rasa/plugin.py +2 -15
- 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 +14 -0
- rasa/shared/core/command_payload_reader.py +1 -5
- rasa/shared/core/constants.py +4 -3
- rasa/shared/core/domain.py +172 -11
- rasa/shared/core/events.py +100 -6
- rasa/shared/core/flows/flow.py +35 -8
- rasa/shared/core/flows/flow_step.py +26 -4
- rasa/shared/core/flows/flow_step_links.py +15 -0
- rasa/shared/core/flows/flow_step_sequence.py +6 -0
- rasa/shared/core/flows/flows_yaml_schema.json +3 -0
- rasa/shared/core/flows/nlu_trigger.py +13 -0
- rasa/shared/core/flows/steps/action.py +7 -4
- rasa/shared/core/flows/steps/call.py +11 -4
- rasa/shared/core/flows/steps/collect.py +71 -6
- rasa/shared/core/flows/steps/internal.py +6 -1
- rasa/shared/core/flows/steps/link.py +7 -4
- rasa/shared/core/flows/steps/no_operation.py +7 -4
- rasa/shared/core/flows/steps/set_slots.py +8 -4
- rasa/shared/core/flows/validation.py +16 -3
- rasa/shared/core/flows/yaml_flows_io.py +106 -5
- rasa/shared/core/slots.py +33 -1
- rasa/shared/core/trackers.py +4 -10
- rasa/shared/core/training_data/story_reader/yaml_story_reader.py +1 -4
- rasa/shared/importers/importer.py +14 -0
- rasa/shared/importers/static.py +63 -0
- rasa/shared/providers/llm/default_litellm_llm_client.py +2 -2
- rasa/shared/utils/common.py +43 -1
- rasa/shared/utils/llm.py +155 -3
- rasa/shared/utils/yaml.py +32 -0
- rasa/studio/data_handler.py +3 -3
- rasa/studio/download/__init__.py +0 -0
- rasa/studio/download/domains.py +49 -0
- rasa/studio/download/download.py +416 -0
- rasa/studio/download/flows.py +351 -0
- rasa/studio/link.py +200 -0
- rasa/studio/pull.py +94 -0
- rasa/studio/push.py +131 -0
- rasa/studio/results_logger.py +6 -1
- rasa/studio/upload.py +185 -71
- rasa/telemetry.py +83 -26
- rasa/tracing/config.py +4 -5
- rasa/tracing/constants.py +19 -1
- rasa/tracing/instrumentation/attribute_extractors.py +47 -9
- rasa/tracing/instrumentation/instrumentation.py +54 -3
- rasa/tracing/instrumentation/metrics.py +98 -15
- rasa/tracing/metric_instrument_provider.py +75 -3
- rasa/utils/common.py +37 -27
- rasa/utils/endpoints.py +22 -1
- rasa/utils/licensing.py +2 -3
- rasa/utils/log_utils.py +1 -45
- rasa/validator.py +9 -11
- rasa/version.py +1 -1
- {rasa_pro-3.12.18.dist-info → rasa_pro-3.13.0a1.dev1.dist-info}/METADATA +12 -13
- {rasa_pro-3.12.18.dist-info → rasa_pro-3.13.0a1.dev1.dist-info}/RECORD +308 -283
- 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/cli/project_templates/calm/config.yml +0 -10
- rasa/cli/project_templates/calm/credentials.yml +0 -33
- rasa/cli/project_templates/calm/endpoints.yml +0 -58
- rasa/cli/project_templates/default/actions/actions.py +0 -27
- rasa/cli/project_templates/default/data/nlu.yml +0 -91
- rasa/cli/project_templates/default/data/rules.yml +0 -13
- rasa/cli/project_templates/default/data/stories.yml +0 -30
- rasa/cli/project_templates/default/domain.yml +0 -34
- rasa/cli/project_templates/default/tests/test_stories.yml +0 -91
- rasa/core/channels/inspector/dist/assets/channel-dfa68278.js +0 -1
- rasa/core/channels/inspector/dist/assets/clone-edb7f119.js +0 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-65e7c670.js +0 -1
- rasa/core/channels/inspector/src/helpers/audiostream.ts +0 -191
- rasa/core/tracker_store.py +0 -1792
- rasa/studio/download.py +0 -489
- /rasa/{cli/project_templates/calm/actions → builder}/__init__.py +0 -0
- /rasa/cli/project_templates/{calm → default}/actions/action_template.py +0 -0
- /rasa/cli/project_templates/{calm → default}/actions/add_contact.py +0 -0
- /rasa/cli/project_templates/{calm → default}/actions/db.py +0 -0
- /rasa/cli/project_templates/{calm → default}/actions/list_contacts.py +0 -0
- /rasa/cli/project_templates/{calm → default}/actions/remove_contact.py +0 -0
- /rasa/cli/project_templates/{calm → default}/data/flows/add_contact.yml +0 -0
- /rasa/cli/project_templates/{calm → default}/data/flows/list_contacts.yml +0 -0
- /rasa/cli/project_templates/{calm → default}/data/flows/remove_contact.yml +0 -0
- /rasa/cli/project_templates/{calm → default}/db/contacts.json +0 -0
- /rasa/cli/project_templates/{calm → default}/domain/add_contact.yml +0 -0
- /rasa/cli/project_templates/{calm → default}/domain/list_contacts.yml +0 -0
- /rasa/cli/project_templates/{calm → default}/domain/remove_contact.yml +0 -0
- /rasa/cli/project_templates/{calm → default}/domain/shared.yml +0 -0
- {rasa_pro-3.12.18.dist-info → rasa_pro-3.13.0a1.dev1.dist-info}/NOTICE +0 -0
- {rasa_pro-3.12.18.dist-info → rasa_pro-3.13.0a1.dev1.dist-info}/WHEEL +0 -0
- {rasa_pro-3.12.18.dist-info → rasa_pro-3.13.0a1.dev1.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from typing import Dict, Optional, Text
|
|
3
|
+
|
|
4
|
+
from rasa.shared.core.domain import Domain
|
|
5
|
+
from rasa.shared.core.flows import FlowsList
|
|
6
|
+
from rasa.shared.core.training_data.structures import StoryGraph
|
|
7
|
+
from rasa.shared.importers.importer import TrainingDataImporter
|
|
8
|
+
from rasa.shared.nlu.training_data.training_data import TrainingData
|
|
9
|
+
from rasa.shared.utils.common import cached_method
|
|
10
|
+
|
|
11
|
+
logger = logging.getLogger(__name__)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class StaticTrainingDataImporter(TrainingDataImporter):
|
|
15
|
+
"""Static `TrainingFileImporter` implementation."""
|
|
16
|
+
|
|
17
|
+
def __init__(
|
|
18
|
+
self,
|
|
19
|
+
domain: Domain,
|
|
20
|
+
stories: Optional[StoryGraph] = None,
|
|
21
|
+
flows: Optional[FlowsList] = None,
|
|
22
|
+
nlu_data: Optional[TrainingData] = None,
|
|
23
|
+
config: Optional[Dict] = None,
|
|
24
|
+
):
|
|
25
|
+
self.domain = domain
|
|
26
|
+
self.stories = stories or StoryGraph([])
|
|
27
|
+
self.flows = flows or FlowsList(underlying_flows=[])
|
|
28
|
+
self.nlu_data = nlu_data or TrainingData()
|
|
29
|
+
self.config = config or {}
|
|
30
|
+
|
|
31
|
+
@cached_method
|
|
32
|
+
def get_config(self) -> Dict:
|
|
33
|
+
"""Retrieves model config (see parent class for full docstring)."""
|
|
34
|
+
return self.config
|
|
35
|
+
|
|
36
|
+
def get_config_file_for_auto_config(self) -> Optional[Text]:
|
|
37
|
+
"""Returns config file path for auto-config only if there is a single one."""
|
|
38
|
+
return None
|
|
39
|
+
|
|
40
|
+
@cached_method
|
|
41
|
+
def get_stories(self, exclusion_percentage: Optional[int] = None) -> StoryGraph:
|
|
42
|
+
"""Retrieves training stories / rules (see parent class for full docstring)."""
|
|
43
|
+
return self.stories
|
|
44
|
+
|
|
45
|
+
@cached_method
|
|
46
|
+
def get_flows(self) -> FlowsList:
|
|
47
|
+
"""Retrieves training stories / rules (see parent class for full docstring)."""
|
|
48
|
+
return self.flows
|
|
49
|
+
|
|
50
|
+
@cached_method
|
|
51
|
+
def get_conversation_tests(self) -> StoryGraph:
|
|
52
|
+
"""Retrieves conversation test stories (see parent class for full docstring)."""
|
|
53
|
+
return StoryGraph([])
|
|
54
|
+
|
|
55
|
+
@cached_method
|
|
56
|
+
def get_nlu_data(self, language: Optional[Text] = "en") -> TrainingData:
|
|
57
|
+
"""Retrieves NLU training data (see parent class for full docstring)."""
|
|
58
|
+
return self.nlu_data
|
|
59
|
+
|
|
60
|
+
@cached_method
|
|
61
|
+
def get_domain(self) -> Domain:
|
|
62
|
+
"""Retrieves model domain (see parent class for full docstring)."""
|
|
63
|
+
return self.domain
|
|
@@ -101,11 +101,11 @@ class DefaultLiteLLMClient(_BaseLiteLLMClient):
|
|
|
101
101
|
# SageMaker) in Rasa by allowing AWS secrets to be provided as extra
|
|
102
102
|
# parameters without triggering validation errors due to missing AWS
|
|
103
103
|
# environment variables.
|
|
104
|
-
if self.provider.lower() in
|
|
104
|
+
if self.provider.lower() in {
|
|
105
105
|
AWS_BEDROCK_PROVIDER,
|
|
106
106
|
AWS_SAGEMAKER_PROVIDER,
|
|
107
107
|
AWS_SAGEMAKER_CHAT_PROVIDER,
|
|
108
|
-
|
|
108
|
+
}:
|
|
109
109
|
validate_aws_setup_for_litellm_clients(
|
|
110
110
|
self._litellm_model_name,
|
|
111
111
|
self._litellm_extra_parameters,
|
rasa/shared/utils/common.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
+
import copy
|
|
2
3
|
import functools
|
|
3
4
|
import importlib
|
|
4
5
|
import inspect
|
|
@@ -288,6 +289,47 @@ def merge_lists_of_dicts(
|
|
|
288
289
|
return list(merged_dicts.values())
|
|
289
290
|
|
|
290
291
|
|
|
292
|
+
def partial_merge_list(
|
|
293
|
+
self_list: List[Any],
|
|
294
|
+
other_list: List[Any],
|
|
295
|
+
is_same_item_fn: Callable[[Any, Any], bool],
|
|
296
|
+
) -> List[Any]:
|
|
297
|
+
"""Merges two lists based on a custom intersection logic."""
|
|
298
|
+
matched_other_indices = set()
|
|
299
|
+
result = []
|
|
300
|
+
|
|
301
|
+
for s_item in self_list:
|
|
302
|
+
match = next(
|
|
303
|
+
(
|
|
304
|
+
(i, o_item)
|
|
305
|
+
for i, o_item in enumerate(other_list)
|
|
306
|
+
if i not in matched_other_indices and is_same_item_fn(s_item, o_item)
|
|
307
|
+
),
|
|
308
|
+
None,
|
|
309
|
+
)
|
|
310
|
+
if match:
|
|
311
|
+
i, o_item = match
|
|
312
|
+
result.append(copy.deepcopy(o_item))
|
|
313
|
+
matched_other_indices.add(i)
|
|
314
|
+
else:
|
|
315
|
+
result.append(copy.deepcopy(s_item))
|
|
316
|
+
|
|
317
|
+
return result
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
def partial_merge_dict(
|
|
321
|
+
self_d: Dict[Text, Any], other_d: Dict[Text, Any]
|
|
322
|
+
) -> Dict[Text, Any]:
|
|
323
|
+
"""Merges two dictionaries based on a custom intersection logic."""
|
|
324
|
+
merged = {}
|
|
325
|
+
for k, v in self_d.items():
|
|
326
|
+
if k in other_d:
|
|
327
|
+
merged[k] = copy.deepcopy(other_d[k])
|
|
328
|
+
else:
|
|
329
|
+
merged[k] = copy.deepcopy(v)
|
|
330
|
+
return merged
|
|
331
|
+
|
|
332
|
+
|
|
291
333
|
def warn_and_exit_if_module_path_contains_rasa_plus(
|
|
292
334
|
module_path: Text, lookup_path: Optional[str] = None
|
|
293
335
|
) -> None:
|
|
@@ -342,7 +384,7 @@ def display_research_study_prompt() -> None:
|
|
|
342
384
|
{separator}
|
|
343
385
|
Want to help shape the future of Rasa Pro?
|
|
344
386
|
Share your feedback in a short conversation with our team.
|
|
345
|
-
Sign up at: https://
|
|
387
|
+
Sign up at: https://rasa.com/book-feedback-call
|
|
346
388
|
{separator}
|
|
347
389
|
"""
|
|
348
390
|
print_success(message)
|
rasa/shared/utils/llm.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
import importlib.resources
|
|
2
4
|
import json
|
|
3
5
|
import logging
|
|
@@ -20,15 +22,23 @@ from typing import (
|
|
|
20
22
|
)
|
|
21
23
|
|
|
22
24
|
import structlog
|
|
25
|
+
from pydantic import BaseModel, Field
|
|
23
26
|
|
|
24
27
|
import rasa.shared.utils.io
|
|
25
|
-
from rasa.core.
|
|
28
|
+
from rasa.core.available_endpoints import AvailableEndpoints
|
|
26
29
|
from rasa.shared.constants import (
|
|
30
|
+
CONFIG_NAME_KEY,
|
|
31
|
+
CONFIG_PIPELINE_KEY,
|
|
32
|
+
CONFIG_POLICIES_KEY,
|
|
27
33
|
DEFAULT_PROMPT_PACKAGE_NAME,
|
|
34
|
+
LLM_CONFIG_KEY,
|
|
28
35
|
MODEL_CONFIG_KEY,
|
|
29
36
|
MODEL_GROUP_CONFIG_KEY,
|
|
30
37
|
MODEL_GROUP_ID_CONFIG_KEY,
|
|
38
|
+
MODEL_GROUPS_CONFIG_KEY,
|
|
31
39
|
MODELS_CONFIG_KEY,
|
|
40
|
+
PROMPT_CONFIG_KEY,
|
|
41
|
+
PROMPT_TEMPLATE_CONFIG_KEY,
|
|
32
42
|
PROVIDER_CONFIG_KEY,
|
|
33
43
|
RASA_PATTERN_INTERNAL_ERROR_USER_INPUT_EMPTY,
|
|
34
44
|
RASA_PATTERN_INTERNAL_ERROR_USER_INPUT_TOO_LONG,
|
|
@@ -63,6 +73,7 @@ from rasa.shared.providers.mappings import (
|
|
|
63
73
|
get_embedding_client_from_provider,
|
|
64
74
|
get_llm_client_from_provider,
|
|
65
75
|
)
|
|
76
|
+
from rasa.shared.utils.common import all_subclasses
|
|
66
77
|
from rasa.shared.utils.constants import LOG_COMPONENT_SOURCE_METHOD_INIT
|
|
67
78
|
|
|
68
79
|
if TYPE_CHECKING:
|
|
@@ -110,6 +121,18 @@ _CombineConfigs_F = TypeVar(
|
|
|
110
121
|
)
|
|
111
122
|
|
|
112
123
|
|
|
124
|
+
class SystemPrompts(BaseModel):
|
|
125
|
+
command_generator: str = Field(
|
|
126
|
+
..., description="Prompt used by the LLM command generator."
|
|
127
|
+
)
|
|
128
|
+
enterprise_search: str = Field(
|
|
129
|
+
..., description="Prompt for standard enterprise search requests."
|
|
130
|
+
)
|
|
131
|
+
contextual_response_rephraser: str = Field(
|
|
132
|
+
..., description="Prompt used for re-phrasing assistant responses."
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
|
|
113
136
|
def _compute_hash_for_cache_from_configs(
|
|
114
137
|
config_x: Dict[str, Any], config_y: Dict[str, Any]
|
|
115
138
|
) -> int:
|
|
@@ -821,7 +844,9 @@ def allowed_values_for_slot(slot: Slot) -> Union[str, None]:
|
|
|
821
844
|
|
|
822
845
|
|
|
823
846
|
def resolve_model_client_config(
|
|
824
|
-
model_config: Optional[Dict[str, Any]],
|
|
847
|
+
model_config: Optional[Dict[str, Any]],
|
|
848
|
+
component_name: Optional[str] = None,
|
|
849
|
+
model_groups: Optional[List[Dict[str, Any]]] = None,
|
|
825
850
|
) -> Optional[Dict[str, Any]]:
|
|
826
851
|
"""Resolve the model group in the model config.
|
|
827
852
|
|
|
@@ -835,6 +860,7 @@ def resolve_model_client_config(
|
|
|
835
860
|
model_config: The model config to be resolved.
|
|
836
861
|
component_name: The name of the component.
|
|
837
862
|
component_name: The method of the component.
|
|
863
|
+
model_groups: Model groups from endpoints.yml.
|
|
838
864
|
|
|
839
865
|
Returns:
|
|
840
866
|
The resolved llm config.
|
|
@@ -861,7 +887,12 @@ def resolve_model_client_config(
|
|
|
861
887
|
|
|
862
888
|
model_group_id = model_config.get(MODEL_GROUP_CONFIG_KEY)
|
|
863
889
|
|
|
864
|
-
|
|
890
|
+
# If `model_groups` is provided, use it to initialise `AvailableEndpoints`,
|
|
891
|
+
# since `get_instance()` reads from the local endpoints file instead.
|
|
892
|
+
if model_groups:
|
|
893
|
+
endpoints = AvailableEndpoints(model_groups=model_groups)
|
|
894
|
+
else:
|
|
895
|
+
endpoints = AvailableEndpoints.get_instance()
|
|
865
896
|
if endpoints.model_groups is None:
|
|
866
897
|
_raise_invalid_config_exception(
|
|
867
898
|
reason=(
|
|
@@ -919,3 +950,124 @@ async def create_tracker_for_user_step(
|
|
|
919
950
|
|
|
920
951
|
# store the tracker with the unique sender id
|
|
921
952
|
await agent.tracker_store.save(tracker)
|
|
953
|
+
|
|
954
|
+
|
|
955
|
+
def check_prompt_config_keys_and_warn_if_deprecated(
|
|
956
|
+
config: dict, component_source: str
|
|
957
|
+
) -> None:
|
|
958
|
+
"""Checks and warns about deprecated config parameters."""
|
|
959
|
+
if PROMPT_CONFIG_KEY in config and PROMPT_TEMPLATE_CONFIG_KEY in config:
|
|
960
|
+
structlogger.warning(
|
|
961
|
+
f"{component_source}.init"
|
|
962
|
+
".both_deprecated_and_non_deprecated_config_keys_used_at_the_same_time",
|
|
963
|
+
event_info=(
|
|
964
|
+
f"Both '{PROMPT_CONFIG_KEY}' and '{PROMPT_TEMPLATE_CONFIG_KEY}' "
|
|
965
|
+
f"are present in the config. '{PROMPT_CONFIG_KEY}' will be ignored "
|
|
966
|
+
f"in favor of {PROMPT_TEMPLATE_CONFIG_KEY}."
|
|
967
|
+
),
|
|
968
|
+
)
|
|
969
|
+
|
|
970
|
+
# 'prompt' config key is deprecated in favor of 'prompt_template'
|
|
971
|
+
if PROMPT_CONFIG_KEY in config:
|
|
972
|
+
structlogger.warning(
|
|
973
|
+
f"{component_source}.init.deprecated_config_key",
|
|
974
|
+
event_info=(
|
|
975
|
+
f"The config parameter '{PROMPT_CONFIG_KEY}' is deprecated "
|
|
976
|
+
"and will be removed in Rasa 4.0.0. "
|
|
977
|
+
f"Please use the config parameter '{PROMPT_TEMPLATE_CONFIG_KEY}'"
|
|
978
|
+
f" instead. "
|
|
979
|
+
),
|
|
980
|
+
)
|
|
981
|
+
|
|
982
|
+
|
|
983
|
+
def _get_llm_command_generator_config(
|
|
984
|
+
config: Dict[Text, Any],
|
|
985
|
+
) -> Optional[Dict[Text, Any]]:
|
|
986
|
+
"""Get the llm command generator config from config.yml.
|
|
987
|
+
|
|
988
|
+
Args:
|
|
989
|
+
config: The config.yml file data.
|
|
990
|
+
|
|
991
|
+
Returns:
|
|
992
|
+
The llm command generator config.
|
|
993
|
+
"""
|
|
994
|
+
from rasa.dialogue_understanding.generator import LLMBasedCommandGenerator
|
|
995
|
+
|
|
996
|
+
# Collect all LLM based Command Generator class names.
|
|
997
|
+
command_generator_subclasses = all_subclasses(LLMBasedCommandGenerator)
|
|
998
|
+
command_generator_class_names = [
|
|
999
|
+
command_generator.__name__ for command_generator in command_generator_subclasses
|
|
1000
|
+
]
|
|
1001
|
+
|
|
1002
|
+
# Read the LLM config of the Command Generator from the config.yml file.
|
|
1003
|
+
pipelines = config.get(CONFIG_PIPELINE_KEY, [])
|
|
1004
|
+
for pipeline in pipelines:
|
|
1005
|
+
if pipeline.get(CONFIG_NAME_KEY) in command_generator_class_names:
|
|
1006
|
+
return pipeline.get(LLM_CONFIG_KEY)
|
|
1007
|
+
|
|
1008
|
+
return None
|
|
1009
|
+
|
|
1010
|
+
|
|
1011
|
+
def _get_command_generator_prompt(
|
|
1012
|
+
config: Dict[Text, Any], endpoints: Dict[Text, Any]
|
|
1013
|
+
) -> Text:
|
|
1014
|
+
"""Get the command generator prompt based on the config."""
|
|
1015
|
+
from rasa.dialogue_understanding.generator.single_step.compact_llm_command_generator import ( # noqa: E501
|
|
1016
|
+
DEFAULT_COMMAND_PROMPT_TEMPLATE_FILE_NAME,
|
|
1017
|
+
FALLBACK_COMMAND_PROMPT_TEMPLATE_FILE_NAME,
|
|
1018
|
+
MODEL_PROMPT_MAPPER,
|
|
1019
|
+
)
|
|
1020
|
+
|
|
1021
|
+
model_config = _get_llm_command_generator_config(config)
|
|
1022
|
+
llm_config = resolve_model_client_config(
|
|
1023
|
+
model_config=model_config,
|
|
1024
|
+
model_groups=endpoints.get(MODEL_GROUPS_CONFIG_KEY),
|
|
1025
|
+
)
|
|
1026
|
+
return get_default_prompt_template_based_on_model(
|
|
1027
|
+
llm_config=llm_config,
|
|
1028
|
+
model_prompt_mapping=MODEL_PROMPT_MAPPER,
|
|
1029
|
+
default_prompt_path=DEFAULT_COMMAND_PROMPT_TEMPLATE_FILE_NAME,
|
|
1030
|
+
fallback_prompt_path=FALLBACK_COMMAND_PROMPT_TEMPLATE_FILE_NAME,
|
|
1031
|
+
)
|
|
1032
|
+
|
|
1033
|
+
|
|
1034
|
+
def _get_enterprise_search_prompt(config: Dict[Text, Any]) -> Text:
|
|
1035
|
+
"""Get the enterprise search prompt based on the config."""
|
|
1036
|
+
from rasa.core.policies.enterprise_search_policy import EnterpriseSearchPolicy
|
|
1037
|
+
|
|
1038
|
+
def get_enterprise_search_config() -> Dict[Text, Any]:
|
|
1039
|
+
policies = config.get(CONFIG_POLICIES_KEY, [])
|
|
1040
|
+
for policy in policies:
|
|
1041
|
+
if policy.get(CONFIG_NAME_KEY) == EnterpriseSearchPolicy.__name__:
|
|
1042
|
+
return policy
|
|
1043
|
+
|
|
1044
|
+
return {}
|
|
1045
|
+
|
|
1046
|
+
enterprise_search_config = get_enterprise_search_config()
|
|
1047
|
+
return EnterpriseSearchPolicy.get_system_default_prompt_based_on_config(
|
|
1048
|
+
enterprise_search_config
|
|
1049
|
+
)
|
|
1050
|
+
|
|
1051
|
+
|
|
1052
|
+
def get_system_default_prompts(
|
|
1053
|
+
config: Dict[Text, Any], endpoints: Dict[Text, Any]
|
|
1054
|
+
) -> SystemPrompts:
|
|
1055
|
+
"""
|
|
1056
|
+
Returns the system default prompts for the component.
|
|
1057
|
+
|
|
1058
|
+
Args:
|
|
1059
|
+
config: The config.yml file data.
|
|
1060
|
+
endpoints: The endpoints.yml file data.
|
|
1061
|
+
|
|
1062
|
+
Returns:
|
|
1063
|
+
SystemPrompts: A Pydantic model containing all default prompts.
|
|
1064
|
+
"""
|
|
1065
|
+
from rasa.core.nlg.contextual_response_rephraser import (
|
|
1066
|
+
DEFAULT_RESPONSE_VARIATION_PROMPT_TEMPLATE,
|
|
1067
|
+
)
|
|
1068
|
+
|
|
1069
|
+
return SystemPrompts(
|
|
1070
|
+
command_generator=_get_command_generator_prompt(config, endpoints),
|
|
1071
|
+
enterprise_search=_get_enterprise_search_prompt(config),
|
|
1072
|
+
contextual_response_rephraser=DEFAULT_RESPONSE_VARIATION_PROMPT_TEMPLATE,
|
|
1073
|
+
)
|
rasa/shared/utils/yaml.py
CHANGED
|
@@ -21,6 +21,7 @@ from ruamel.yaml import YAML, RoundTripRepresenter, YAMLError
|
|
|
21
21
|
from ruamel.yaml.comments import CommentedMap, CommentedSeq
|
|
22
22
|
from ruamel.yaml.constructor import BaseConstructor, DuplicateKeyError, ScalarNode
|
|
23
23
|
from ruamel.yaml.loader import SafeLoader
|
|
24
|
+
from ruamel.yaml.scalarstring import LiteralScalarString
|
|
24
25
|
|
|
25
26
|
from rasa.shared.constants import (
|
|
26
27
|
ASSERTIONS_SCHEMA_EXTENSIONS_FILE,
|
|
@@ -794,6 +795,25 @@ def write_yaml(
|
|
|
794
795
|
should_preserve_key_order: Whether to force preserve key order in `data`.
|
|
795
796
|
transform: A function to transform the data before writing it to the file.
|
|
796
797
|
"""
|
|
798
|
+
|
|
799
|
+
def multiline_str_representer(self: Any, value: str) -> Any:
|
|
800
|
+
"""Dump multi-line strings as readable YAML block scalars where possible."""
|
|
801
|
+
if "\n" in value:
|
|
802
|
+
# First line after the newline decides: paragraph vs. snippet
|
|
803
|
+
first_line = value.split("\n", 1)[1]
|
|
804
|
+
|
|
805
|
+
# If the first line after the newline is not indented, treat the value
|
|
806
|
+
# as plain text. Indented text is likely pre-formatted YAML/JSON/etc.
|
|
807
|
+
if not first_line.startswith((" ", "\t")):
|
|
808
|
+
return self.represent_scalar(
|
|
809
|
+
"tag:yaml.org,2002:str",
|
|
810
|
+
LiteralScalarString(value),
|
|
811
|
+
style="|",
|
|
812
|
+
)
|
|
813
|
+
|
|
814
|
+
# Fallback: keep default YAML scalar style (plain/quoted)
|
|
815
|
+
return self.represent_scalar("tag:yaml.org,2002:str", value)
|
|
816
|
+
|
|
797
817
|
_enable_ordered_dict_yaml_dumping()
|
|
798
818
|
|
|
799
819
|
if should_preserve_key_order:
|
|
@@ -808,6 +828,7 @@ def write_yaml(
|
|
|
808
828
|
type(None),
|
|
809
829
|
lambda self, _: self.represent_scalar("tag:yaml.org,2002:null", "null"),
|
|
810
830
|
)
|
|
831
|
+
dumper.representer.add_representer(str, multiline_str_representer)
|
|
811
832
|
|
|
812
833
|
if isinstance(target, StringIO):
|
|
813
834
|
dumper.dump(data, target, transform=transform)
|
|
@@ -1025,6 +1046,17 @@ def validate_yaml_with_jsonschema(
|
|
|
1025
1046
|
except (YAMLError, DuplicateKeyError) as e:
|
|
1026
1047
|
raise YamlSyntaxException(underlying_yaml_exception=e)
|
|
1027
1048
|
|
|
1049
|
+
validate_data_with_jsonschema(source_data, schema_content, humanize_error)
|
|
1050
|
+
|
|
1051
|
+
|
|
1052
|
+
def validate_data_with_jsonschema(
|
|
1053
|
+
source_data: Any,
|
|
1054
|
+
schema_content: Any,
|
|
1055
|
+
humanize_error: Callable[
|
|
1056
|
+
[jsonschema.ValidationError], str
|
|
1057
|
+
] = default_error_humanizer,
|
|
1058
|
+
) -> None:
|
|
1059
|
+
"""Validate Python object against the provided jsonschema content."""
|
|
1028
1060
|
try:
|
|
1029
1061
|
jsonschema.validate(source_data, schema_content)
|
|
1030
1062
|
except jsonschema.ValidationError as error:
|
rasa/studio/data_handler.py
CHANGED
|
@@ -320,14 +320,14 @@ def create_new_flows_from_diff(
|
|
|
320
320
|
|
|
321
321
|
|
|
322
322
|
def import_data_from_studio(
|
|
323
|
-
handler: StudioDataHandler, domain_path: Path,
|
|
323
|
+
handler: StudioDataHandler, domain_path: Path, data_path: Path
|
|
324
324
|
) -> Tuple[TrainingDataImporter, TrainingDataImporter]:
|
|
325
325
|
"""Construct TrainingDataImporter from Studio data and original data.
|
|
326
326
|
|
|
327
327
|
Args:
|
|
328
328
|
handler (StudioDataHandler): handler with data from studio
|
|
329
329
|
domain_path (Path): Path to a domain file
|
|
330
|
-
|
|
330
|
+
data_path (List[Path]): List of paths to training data files
|
|
331
331
|
|
|
332
332
|
Returns:
|
|
333
333
|
Tuple[TrainingDataImporter, TrainingDataImporter]:
|
|
@@ -335,7 +335,7 @@ def import_data_from_studio(
|
|
|
335
335
|
"""
|
|
336
336
|
tmp_dir = get_temp_dir_name()
|
|
337
337
|
data_original = TrainingDataImporter.load_from_dict(
|
|
338
|
-
domain_path=domain_path, training_data_paths=
|
|
338
|
+
domain_path=str(domain_path), training_data_paths=[str(data_path)]
|
|
339
339
|
)
|
|
340
340
|
|
|
341
341
|
data_paths = []
|
|
File without changes
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from rasa.shared.core.domain import (
|
|
5
|
+
Domain,
|
|
6
|
+
)
|
|
7
|
+
from rasa.shared.importers.importer import TrainingDataImporter
|
|
8
|
+
from rasa.studio.constants import STUDIO_DOMAIN_FILENAME
|
|
9
|
+
|
|
10
|
+
logger = logging.getLogger(__name__)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def merge_domain_with_overwrite(
|
|
14
|
+
data_from_studio: TrainingDataImporter,
|
|
15
|
+
data_local: TrainingDataImporter,
|
|
16
|
+
domain_path: Path,
|
|
17
|
+
) -> None:
|
|
18
|
+
"""
|
|
19
|
+
Merges the domain from Rasa Studio with the local domain.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
data_from_studio: The training data importer for the Rasa Studio domain.
|
|
23
|
+
data_local: The training data importer for the local domain.
|
|
24
|
+
domain_path: The path to the domain file or directory.
|
|
25
|
+
"""
|
|
26
|
+
if domain_path.is_file():
|
|
27
|
+
all_local_domain_files = [str(domain_path)]
|
|
28
|
+
domain_path = domain_path.parent
|
|
29
|
+
else:
|
|
30
|
+
all_local_domain_files = data_local.get_domain_files([str(domain_path)])
|
|
31
|
+
|
|
32
|
+
# leftover_domain represents the items in the studio
|
|
33
|
+
# domain that are not in the local domain
|
|
34
|
+
leftover_domain = data_from_studio.get_user_domain()
|
|
35
|
+
for file_path in all_local_domain_files:
|
|
36
|
+
# For each local domain file, we do a partial merge
|
|
37
|
+
local_domain = Domain.from_file(str(file_path))
|
|
38
|
+
updated_local_domain = local_domain.partial_merge(leftover_domain)
|
|
39
|
+
|
|
40
|
+
# If this partial merge made changes, persist them
|
|
41
|
+
if local_domain != updated_local_domain:
|
|
42
|
+
updated_local_domain.persist(file_path)
|
|
43
|
+
|
|
44
|
+
# Remove every item now present in updated_local_domain from leftover_domain
|
|
45
|
+
leftover_domain = leftover_domain.difference(updated_local_domain)
|
|
46
|
+
|
|
47
|
+
# If there are still items in leftover_domain, persist them
|
|
48
|
+
if not leftover_domain.is_empty():
|
|
49
|
+
leftover_domain.persist(domain_path / STUDIO_DOMAIN_FILENAME)
|