rasa-pro 3.13.1a18__py3-none-any.whl → 3.13.1a20__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 +8 -0
- rasa/builder/auth.py +71 -0
- rasa/builder/config.py +16 -0
- rasa/builder/copilot/constants.py +15 -0
- rasa/builder/copilot/copilot.py +342 -0
- rasa/builder/copilot/copilot_response_handler.py +471 -0
- rasa/builder/copilot/exceptions.py +20 -0
- rasa/builder/copilot/models.py +344 -0
- rasa/builder/copilot/prompts/copilot_system_prompt.jinja2 +495 -0
- rasa/builder/copilot/telemetry.py +195 -0
- rasa/builder/document_retrieval/__init__.py +0 -0
- rasa/builder/document_retrieval/constants.py +16 -0
- rasa/builder/{inkeep_document_retrieval.py → document_retrieval/inkeep_document_retrieval.py} +53 -44
- rasa/builder/document_retrieval/models.py +62 -0
- rasa/builder/download.py +140 -0
- rasa/builder/guardrails/__init__.py +1 -0
- rasa/builder/guardrails/constants.py +4 -0
- rasa/builder/guardrails/exceptions.py +4 -0
- rasa/builder/guardrails/lakera.py +188 -0
- rasa/builder/guardrails/models.py +199 -0
- rasa/builder/guardrails/utils.py +305 -0
- rasa/builder/job_manager.py +87 -0
- rasa/builder/jobs.py +232 -0
- rasa/builder/llm_service.py +89 -173
- rasa/builder/logging_utils.py +162 -4
- rasa/builder/main.py +29 -16
- rasa/builder/models.py +93 -121
- rasa/builder/project_generator.py +91 -7
- rasa/builder/scrape_rasa_docs.py +1 -1
- rasa/builder/service.py +650 -452
- rasa/builder/shared/tracker_context.py +212 -0
- rasa/builder/validation_service.py +4 -4
- rasa/cli/data.py +8 -3
- rasa/cli/project_templates/basic/actions/action_api.py +15 -0
- rasa/cli/project_templates/basic/actions/action_human_handoff.py +44 -0
- rasa/cli/project_templates/basic/config.yml +23 -0
- rasa/cli/project_templates/{plain → basic}/credentials.yml +8 -7
- rasa/cli/project_templates/basic/data/general/feedback.yml +20 -0
- rasa/cli/project_templates/basic/data/general/goodbye.yml +6 -0
- rasa/cli/project_templates/basic/data/general/hello.yml +7 -0
- rasa/cli/project_templates/basic/data/general/help.yml +6 -0
- rasa/cli/project_templates/basic/data/general/human_handoff.yml +16 -0
- rasa/cli/project_templates/basic/data/general/welcome.yml +9 -0
- rasa/cli/project_templates/{finance/data/patterns → basic/data/system}/pattern_completed.yml +2 -1
- rasa/cli/project_templates/basic/data/system/pattern_correction.yml +7 -0
- rasa/cli/project_templates/basic/data/system/pattern_search.yml +8 -0
- rasa/cli/project_templates/basic/data/system/pattern_session_start.yml +8 -0
- rasa/cli/project_templates/basic/docs/rasa_assistant_qa.txt +65 -0
- rasa/cli/project_templates/basic/docs/template.txt +7 -0
- rasa/cli/project_templates/basic/domain/general/assistant_details.yml +12 -0
- rasa/cli/project_templates/basic/domain/general/bot_identity.yml +5 -0
- rasa/cli/project_templates/basic/domain/general/cannot_handle.yml +5 -0
- rasa/cli/project_templates/basic/domain/general/feedback.yml +28 -0
- rasa/cli/project_templates/basic/domain/general/goodbye.yml +7 -0
- rasa/cli/project_templates/basic/domain/general/help.yml +5 -0
- rasa/cli/project_templates/basic/domain/general/human_handoff_domain.yml +35 -0
- rasa/cli/project_templates/{finance/domain/default_actions.yml → basic/domain/general/utils.yml} +0 -3
- rasa/cli/project_templates/basic/domain/general/welcome.yml +7 -0
- rasa/cli/project_templates/{plain → basic}/endpoints.yml +42 -27
- rasa/cli/project_templates/basic/prompts/rephraser_demo_personality_prompt.jinja2 +19 -0
- rasa/cli/project_templates/defaults.py +25 -3
- rasa/cli/project_templates/finance/actions/__init__.py +46 -0
- rasa/cli/project_templates/finance/actions/accounts/__init__.py +0 -0
- rasa/cli/project_templates/finance/actions/{action_ask_account.py → accounts/action_ask_account.py} +6 -9
- rasa/cli/project_templates/finance/actions/{action_check_balance.py → accounts/action_check_balance.py} +4 -4
- rasa/cli/project_templates/finance/actions/action_session_start.py +11 -6
- rasa/cli/project_templates/finance/actions/cards/__init__.py +0 -0
- rasa/cli/project_templates/finance/actions/{action_ask_card.py → cards/action_ask_card.py} +4 -3
- rasa/cli/project_templates/finance/actions/{action_check_card_existence.py → cards/action_check_card_existence.py} +4 -3
- rasa/cli/project_templates/finance/actions/{action_update_card_status.py → cards/action_update_card_status.py} +18 -9
- rasa/cli/project_templates/finance/actions/database.py +1 -0
- rasa/cli/project_templates/finance/actions/transfers/__init__.py +0 -0
- rasa/cli/project_templates/finance/actions/{action_add_payee.py → transfers/action_add_payee.py} +8 -3
- rasa/cli/project_templates/finance/actions/{action_ask_account_from.py → transfers/action_ask_account_from.py} +5 -4
- rasa/cli/project_templates/finance/actions/{action_check_payee_existence.py → transfers/action_check_payee_existence.py} +3 -3
- rasa/cli/project_templates/finance/actions/{action_check_sufficient_funds.py → transfers/action_check_sufficient_funds.py} +3 -4
- rasa/cli/project_templates/finance/actions/{action_list_payees.py → transfers/action_list_payees.py} +4 -3
- rasa/cli/project_templates/finance/actions/{action_remove_payee.py → transfers/action_remove_payee.py} +4 -4
- rasa/cli/project_templates/finance/config.yml +8 -19
- rasa/cli/project_templates/finance/credentials.yml +6 -7
- rasa/cli/project_templates/finance/csvs/cards.csv +10 -10
- rasa/cli/project_templates/finance/csvs/payees.csv +10 -9
- rasa/cli/project_templates/finance/data/{flows → accounts}/check_balance.yml +2 -1
- rasa/cli/project_templates/finance/data/general/bot_identity.yml +6 -0
- rasa/cli/project_templates/finance/data/general/feedback.yml +20 -0
- rasa/cli/project_templates/finance/data/general/goodbye.yml +6 -0
- rasa/cli/project_templates/finance/data/general/hello.yml +7 -0
- rasa/cli/project_templates/finance/data/{flows/welcome.yml → general/help.yml} +2 -7
- rasa/cli/project_templates/finance/data/general/human_handoff.yml +16 -0
- rasa/cli/project_templates/finance/data/general/welcome.yml +9 -0
- rasa/cli/project_templates/finance/data/{patterns → system/patterns}/pattern_chitchat.yml +0 -2
- rasa/cli/project_templates/finance/data/system/patterns/pattern_completed.yml +7 -0
- rasa/cli/project_templates/finance/data/system/patterns/pattern_correction.yml +7 -0
- rasa/cli/project_templates/finance/data/system/patterns/pattern_search.yml +8 -0
- rasa/cli/project_templates/finance/data/{patterns → system/patterns}/pattern_session_start.yml +0 -1
- rasa/cli/project_templates/finance/domain/{check_balance.yml → accounts/check_balance.yml} +2 -0
- rasa/cli/project_templates/finance/domain/general/assistant_details.yml +12 -0
- rasa/cli/project_templates/finance/domain/general/bot_identity.yml +5 -0
- rasa/cli/project_templates/finance/domain/general/cannot_handle.yml +5 -0
- rasa/cli/project_templates/finance/domain/general/defaults.yml +24 -0
- rasa/cli/project_templates/finance/domain/general/feedback.yml +28 -0
- rasa/cli/project_templates/finance/domain/general/goodbye.yml +7 -0
- rasa/cli/project_templates/finance/domain/general/help.yml +5 -0
- rasa/cli/project_templates/finance/domain/general/human_handoff.yml +30 -0
- rasa/cli/project_templates/finance/domain/general/utils.yml +13 -0
- rasa/cli/project_templates/finance/domain/general/welcome.yml +8 -0
- rasa/cli/project_templates/finance/endpoints.yml +1 -0
- rasa/cli/project_templates/finance/prompts/rephraser_demo_personality_prompt.jinja2 +3 -3
- rasa/cli/project_templates/telco/actions/actions_billing.py +24 -17
- rasa/cli/project_templates/telco/actions/actions_get_data_from_db.py +6 -1
- rasa/cli/project_templates/telco/actions/actions_run_diagnostics.py +6 -1
- rasa/cli/project_templates/telco/actions/actions_session_start.py +6 -1
- rasa/cli/project_templates/tutorial/config.yml +2 -1
- rasa/cli/scaffold.py +27 -2
- rasa/cli/train.py +8 -0
- rasa/cli/utils.py +31 -15
- rasa/core/actions/action.py +28 -41
- rasa/core/actions/action_run_slot_rejections.py +1 -1
- rasa/core/channels/development_inspector.py +47 -14
- rasa/core/channels/inspector/dist/assets/{arc-371401b1.js → arc-1ddec37b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-3f126156.js → blockDiagram-38ab4fdb-18af387c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-12f22eb7.js → c4Diagram-3d4e48cf-250127a3.js} +1 -1
- rasa/core/channels/inspector/dist/assets/channel-59f6d54b.js +1 -0
- rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-03b1d386.js → classDiagram-70f12bd4-c3388b34.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-84f69d63.js → classDiagram-v2-f2320105-9c893a82.js} +1 -1
- rasa/core/channels/inspector/dist/assets/clone-26177ddb.js +1 -0
- rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-ca47fd38.js → createText-2e5e7dd3-c111213b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-f837ca8a.js → edges-e0da2a9e-812a729d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-8717ac54.js → erDiagram-9861fffd-fd5051bc.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-94f38b83.js → flowDb-956e92f1-3287ac02.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-b616f9fb.js → flowDiagram-66a62f08-692fb0b2.js} +1 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-29c03f5a.js +1 -0
- rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-f5d24bb8.js → flowchart-elk-definition-4a651766-008376f1.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-b43ba8d9.js → ganttDiagram-c361ad54-df330a69.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-c3aafaa5.js → gitGraphDiagram-72cf32ee-e03676fb.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{graph-0d0a2c10.js → graph-46fad2ba.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-3862675e-58ea0305.js → index-3862675e-a484ac55.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-cce6f8a1.js → index-a003633f.js} +179 -179
- rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-b8f60461.js → infoDiagram-f8f76790-3f9e6ec2.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-95be5545.js → journeyDiagram-49397b02-79f72383.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-da885b9b.js → layout-aad098e5.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{line-f1c817d3.js → line-219ab7ae.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-d42801e6.js → linear-2cddbe62.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-a38923a6.js → mindmap-definition-fc14e90a-1d41ed99.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-ca6e71e9.js → pieDiagram-8a3498a8-cc496ee8.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-b290dae9.js → quadrantDiagram-120e2f19-84d32884.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-03f02ceb.js → requirementDiagram-deff3bca-c0deb984.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-c49eee40.js → sankeyDiagram-04a897e0-b9d7fd62.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-b2cd6a3d.js → sequenceDiagram-704730f1-7d517565.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-e53a2028.js → stateDiagram-587899a1-98ef9b27.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-e1982a03.js → stateDiagram-v2-d93cdb3a-cee70748.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-d0226ca5.js → styles-6aaf32cf-3f9d1c96.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-9a916d00-0e21dc00.js → styles-9a916d00-67471923.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-c10674c1-9588494e.js → styles-c10674c1-bd093fb7.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-be478d4f.js → svgDrawCommon-08f97a94-675794e8.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-74631749.js → timeline-definition-85554ec2-0ac67617.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-a043552f.js → xychartDiagram-e933f94c-c018dc37.js} +1 -1
- rasa/core/channels/inspector/dist/index.html +2 -2
- rasa/core/channels/inspector/index.html +1 -1
- rasa/core/channels/inspector/package.json +4 -3
- rasa/core/channels/inspector/src/App.tsx +53 -7
- rasa/core/channels/inspector/src/components/Chat.tsx +3 -2
- rasa/core/channels/inspector/src/components/DiagramFlow.tsx +1 -1
- rasa/core/channels/inspector/src/components/LatencyDisplay.tsx +268 -0
- rasa/core/channels/inspector/src/components/LoadingSpinner.tsx +6 -2
- rasa/core/channels/inspector/src/helpers/audio/audiostream.ts +8 -3
- rasa/core/channels/inspector/src/types.ts +8 -0
- rasa/core/channels/inspector/yarn.lock +12 -12
- rasa/core/channels/studio_chat.py +119 -34
- rasa/core/channels/voice_ready/twilio_voice.py +1 -1
- rasa/core/channels/voice_stream/asr/asr_engine.py +5 -1
- rasa/core/channels/voice_stream/asr/deepgram.py +5 -0
- rasa/core/channels/voice_stream/audiocodes.py +16 -8
- rasa/core/channels/voice_stream/browser_audio.py +39 -4
- rasa/core/channels/voice_stream/call_state.py +13 -2
- rasa/core/channels/voice_stream/genesys.py +16 -13
- rasa/core/channels/voice_stream/jambonz.py +14 -12
- rasa/core/channels/voice_stream/twilio_media_streams.py +14 -13
- rasa/core/channels/voice_stream/util.py +11 -1
- rasa/core/channels/voice_stream/voice_channel.py +108 -29
- rasa/core/nlg/callback.py +1 -1
- rasa/core/nlg/contextual_response_rephraser.py +19 -9
- rasa/core/nlg/generator.py +21 -5
- rasa/core/nlg/response.py +43 -6
- rasa/core/nlg/translate.py +8 -0
- rasa/core/policies/enterprise_search_policy.py +16 -21
- rasa/dialogue_understanding/commands/correct_slots_command.py +38 -10
- rasa/dialogue_understanding/generator/command_generator.py +5 -5
- rasa/dialogue_understanding/generator/command_parser.py +9 -13
- rasa/dialogue_understanding/processor/command_processor.py +149 -55
- rasa/dialogue_understanding/stack/utils.py +13 -3
- rasa/dialogue_understanding_test/du_test_schema.yml +3 -3
- rasa/dialogue_understanding_test/validation.py +9 -10
- rasa/e2e_test/e2e_config.py +18 -11
- rasa/e2e_test/e2e_test_schema.yml +3 -3
- rasa/e2e_test/utils/validation.py +17 -19
- rasa/engine/validation.py +86 -91
- rasa/exceptions.py +26 -1
- rasa/model_manager/model_api.py +2 -2
- rasa/model_manager/socket_bridge.py +8 -2
- rasa/shared/providers/_configs/default_litellm_client_config.py +3 -7
- rasa/shared/utils/cli.py +2 -0
- rasa/shared/utils/common.py +2 -1
- rasa/shared/utils/health_check/health_check.py +10 -14
- rasa/studio/upload.py +6 -2
- rasa/studio/utils.py +33 -22
- rasa/telemetry.py +95 -22
- rasa/utils/licensing.py +21 -10
- rasa/utils/log_utils.py +1 -1
- rasa/utils/tensorflow/transformer.py +3 -3
- rasa/validator.py +7 -5
- rasa/version.py +1 -1
- {rasa_pro-3.13.1a18.dist-info → rasa_pro-3.13.1a20.dist-info}/METADATA +7 -7
- {rasa_pro-3.13.1a18.dist-info → rasa_pro-3.13.1a20.dist-info}/RECORD +242 -203
- rasa/builder/create_openai_vector_store.py +0 -228
- rasa/builder/llm-helper-schema.json +0 -69
- rasa/builder/llm_context.py +0 -81
- rasa/builder/llm_helper_prompt.jinja2 +0 -245
- rasa/cli/project_templates/finance/data/nlu.yml +0 -29
- rasa/cli/project_templates/finance/data/patterns/pattern_search.yml +0 -5
- rasa/cli/project_templates/finance/domain/default_flows.yml +0 -33
- rasa/cli/project_templates/finance/prompts/command-generator.jinja2 +0 -57
- rasa/cli/project_templates/finance/tests/conversation_repair/cancellations.yml +0 -12
- rasa/cli/project_templates/finance/tests/conversation_repair/cannot_handle.yml +0 -7
- rasa/cli/project_templates/finance/tests/conversation_repair/chitchat.yml +0 -7
- rasa/cli/project_templates/finance/tests/conversation_repair/clarification.yml +0 -9
- rasa/cli/project_templates/finance/tests/conversation_repair/completion.yml +0 -18
- rasa/cli/project_templates/finance/tests/conversation_repair/corrections.yml +0 -17
- rasa/cli/project_templates/finance/tests/conversation_repair/digressions.yml +0 -32
- rasa/cli/project_templates/finance/tests/conversation_repair/human_handoff.yml +0 -21
- rasa/cli/project_templates/finance/tests/conversation_repair/skipping_collect_steps.yml +0 -16
- rasa/cli/project_templates/finance/tests/demo_scripts/main.yml +0 -16
- rasa/cli/project_templates/finance/tests/happy_paths/balance_verification.yml +0 -15
- rasa/cli/project_templates/finance/tests/happy_paths/banking_questions.yml +0 -12
- rasa/cli/project_templates/finance/tests/happy_paths/card_blocking.yml +0 -52
- rasa/cli/project_templates/finance/tests/happy_paths/money_transfer.yml +0 -136
- rasa/cli/project_templates/finance/tests/happy_paths/payee_management.yml +0 -27
- rasa/cli/project_templates/finance/tests/happy_paths/user_greeted.yml +0 -5
- rasa/cli/project_templates/plain/config.yml +0 -17
- rasa/cli/project_templates/plain/data/patterns/pattern_session_start.yml +0 -7
- rasa/cli/project_templates/plain/domain.yml +0 -5
- rasa/core/channels/inspector/dist/assets/channel-f1efda17.js +0 -1
- rasa/core/channels/inspector/dist/assets/clone-fdf164e2.js +0 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-7d7a1629.js +0 -1
- rasa/shared/importers/static.py +0 -63
- /rasa/{cli/project_templates/plain/actions → builder/copilot}/__init__.py +0 -0
- /rasa/builder/{inkeep-rag-response-schema.json → document_retrieval/inkeep-rag-response-schema.json} +0 -0
- /rasa/cli/project_templates/finance/actions/{action_process_immediate_payment.py → transfers/action_process_immediate_payment.py} +0 -0
- /rasa/cli/project_templates/finance/actions/{action_schedule_payment.py → transfers/action_schedule_payment.py} +0 -0
- /rasa/cli/project_templates/finance/actions/{action_validate_payment_date.py → transfers/action_validate_payment_date.py} +0 -0
- /rasa/cli/project_templates/finance/data/{flows → cards}/block_card.yml +0 -0
- /rasa/cli/project_templates/finance/data/{flows → cards}/select_card.yml +0 -0
- /rasa/cli/project_templates/finance/data/{source → system/source}/accounts.json +0 -0
- /rasa/cli/project_templates/finance/data/{source → system/source}/advisors.json +0 -0
- /rasa/cli/project_templates/finance/data/{source → system/source}/appointments.json +0 -0
- /rasa/cli/project_templates/finance/data/{source → system/source}/branches.json +0 -0
- /rasa/cli/project_templates/finance/data/{source → system/source}/cards.json +0 -0
- /rasa/cli/project_templates/finance/data/{source → system/source}/payees.json +0 -0
- /rasa/cli/project_templates/finance/data/{source → system/source}/transactions.json +0 -0
- /rasa/cli/project_templates/finance/data/{source → system/source}/users.json +0 -0
- /rasa/cli/project_templates/finance/data/{flows → transfers}/add_payee.yml +0 -0
- /rasa/cli/project_templates/finance/data/{flows → transfers}/list_payees.yml +0 -0
- /rasa/cli/project_templates/finance/data/{flows → transfers}/remove_payee.yml +0 -0
- /rasa/cli/project_templates/finance/data/{flows → transfers}/transfer_money.yml +0 -0
- /rasa/cli/project_templates/finance/domain/{block_card.yml → cards/block_card.yml} +0 -0
- /rasa/cli/project_templates/finance/domain/{select_card.yml → cards/select_card.yml} +0 -0
- /rasa/cli/project_templates/finance/domain/{add_payee.yml → transfers/add_payee.yml} +0 -0
- /rasa/cli/project_templates/finance/domain/{list_payees.yml → transfers/list_payees.yml} +0 -0
- /rasa/cli/project_templates/finance/domain/{remove_payee.yml → transfers/remove_payee.yml} +0 -0
- /rasa/cli/project_templates/finance/domain/{transfer_money.yml → transfers/transfer_money.yml} +0 -0
- {rasa_pro-3.13.1a18.dist-info → rasa_pro-3.13.1a20.dist-info}/NOTICE +0 -0
- {rasa_pro-3.13.1a18.dist-info → rasa_pro-3.13.1a20.dist-info}/WHEEL +0 -0
- {rasa_pro-3.13.1a18.dist-info → rasa_pro-3.13.1a20.dist-info}/entry_points.txt +0 -0
|
@@ -232,16 +232,6 @@ class CorrectSlotsCommand(Command):
|
|
|
232
232
|
proposed_slots, all_flows, tracker
|
|
233
233
|
)
|
|
234
234
|
|
|
235
|
-
if not earliest_collect and not is_reset_only:
|
|
236
|
-
# if we could not find any step in the flow, where the slots were
|
|
237
|
-
# previously set, and we also don't want to reset the slots, do
|
|
238
|
-
# not correct the slots.
|
|
239
|
-
structlogger.debug(
|
|
240
|
-
"correct_slots_command.skip_correction",
|
|
241
|
-
is_reset_only=is_reset_only,
|
|
242
|
-
)
|
|
243
|
-
return None
|
|
244
|
-
|
|
245
235
|
return CorrectionPatternFlowStackFrame(
|
|
246
236
|
is_reset_only=is_reset_only,
|
|
247
237
|
corrected_slots=proposed_slots,
|
|
@@ -279,6 +269,20 @@ class CorrectSlotsCommand(Command):
|
|
|
279
269
|
return []
|
|
280
270
|
|
|
281
271
|
structlogger.debug("correct_slots_command", command=self)
|
|
272
|
+
|
|
273
|
+
# check if the correct slot is referring to a slot of a flow on the stack
|
|
274
|
+
# the slot also needs to be part of a collect step in any of those flows
|
|
275
|
+
# if this is not the case, we don't want to correct the slot
|
|
276
|
+
for slot in self.corrected_slots:
|
|
277
|
+
if not self.should_correct_slot(slot, tracker, all_flows):
|
|
278
|
+
structlogger.warning(
|
|
279
|
+
"correct_slots_command.skip_correct_slot",
|
|
280
|
+
correct_slot=slot,
|
|
281
|
+
reason="The slot is not part of a collect step in any of the flows "
|
|
282
|
+
"on the stack. Skipping correction.",
|
|
283
|
+
)
|
|
284
|
+
return []
|
|
285
|
+
|
|
282
286
|
proposed_slots = self.corrected_slots_dict(tracker)
|
|
283
287
|
|
|
284
288
|
correction_frame = self.create_correction_frame(
|
|
@@ -303,3 +307,27 @@ class CorrectSlotsCommand(Command):
|
|
|
303
307
|
return False
|
|
304
308
|
|
|
305
309
|
return True
|
|
310
|
+
|
|
311
|
+
def should_correct_slot(
|
|
312
|
+
self, slot: CorrectedSlot, tracker: DialogueStateTracker, all_flows: FlowsList
|
|
313
|
+
) -> bool:
|
|
314
|
+
"""Checks if the slot should be corrected.
|
|
315
|
+
|
|
316
|
+
Args:
|
|
317
|
+
slot: The slot to check.
|
|
318
|
+
tracker: The tracker.
|
|
319
|
+
all_flows: All flows in the assistant.
|
|
320
|
+
"""
|
|
321
|
+
# get all flows on the stack
|
|
322
|
+
flows_on_stack = utils.user_flows_on_the_stack(tracker.stack)
|
|
323
|
+
|
|
324
|
+
# check if the slot is part of a collect step in any of the flows on the stack
|
|
325
|
+
for flow_id in flows_on_stack:
|
|
326
|
+
flow = all_flows.flow_by_id(flow_id)
|
|
327
|
+
if flow is None:
|
|
328
|
+
continue
|
|
329
|
+
for collect_step in flow.get_collect_steps():
|
|
330
|
+
if collect_step.collect == slot.name:
|
|
331
|
+
return True
|
|
332
|
+
|
|
333
|
+
return False
|
|
@@ -114,7 +114,7 @@ class CommandGenerator:
|
|
|
114
114
|
# slot asked by the active collect step.
|
|
115
115
|
# Or return a CannotHandleCommand if no matching command is found.
|
|
116
116
|
commands = self._filter_commands_during_force_slot_filling(
|
|
117
|
-
commands,
|
|
117
|
+
commands, flows, tracker
|
|
118
118
|
)
|
|
119
119
|
|
|
120
120
|
commands_dicts = [command.as_dict() for command in commands]
|
|
@@ -385,14 +385,14 @@ class CommandGenerator:
|
|
|
385
385
|
@staticmethod
|
|
386
386
|
def _filter_commands_during_force_slot_filling(
|
|
387
387
|
commands: List[Command],
|
|
388
|
-
|
|
388
|
+
flows: FlowsList,
|
|
389
389
|
tracker: Optional[DialogueStateTracker] = None,
|
|
390
390
|
) -> List[Command]:
|
|
391
391
|
"""Filter commands during a collect step that has set `force_slot_filling`.
|
|
392
392
|
|
|
393
393
|
Args:
|
|
394
394
|
commands: The commands to filter.
|
|
395
|
-
|
|
395
|
+
flows: All flows.
|
|
396
396
|
tracker: The tracker.
|
|
397
397
|
|
|
398
398
|
Returns:
|
|
@@ -409,7 +409,7 @@ class CommandGenerator:
|
|
|
409
409
|
)
|
|
410
410
|
return commands
|
|
411
411
|
|
|
412
|
-
updated_flows = find_updated_flows(tracker,
|
|
412
|
+
updated_flows = find_updated_flows(tracker, flows)
|
|
413
413
|
if updated_flows:
|
|
414
414
|
structlogger.debug(
|
|
415
415
|
"command_generator.filter_commands_during_force_slot_filling.running_flows_were_updated",
|
|
@@ -418,7 +418,7 @@ class CommandGenerator:
|
|
|
418
418
|
return [HandleCodeChangeCommand()]
|
|
419
419
|
|
|
420
420
|
stack = tracker.stack
|
|
421
|
-
step = get_current_collect_step(stack,
|
|
421
|
+
step = get_current_collect_step(stack, flows)
|
|
422
422
|
|
|
423
423
|
if step is None or not step.force_slot_filling:
|
|
424
424
|
return commands
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import re
|
|
2
|
-
import sys
|
|
3
2
|
from functools import lru_cache
|
|
4
3
|
from typing import Any, Callable, Dict, List, Optional, Type, Union
|
|
5
4
|
|
|
@@ -19,6 +18,7 @@ from rasa.dialogue_understanding.commands import (
|
|
|
19
18
|
)
|
|
20
19
|
from rasa.dialogue_understanding.commands.prompt_command import PromptCommand
|
|
21
20
|
from rasa.dialogue_understanding.commands.utils import start_flow_by_name
|
|
21
|
+
from rasa.exceptions import ValidationError
|
|
22
22
|
from rasa.shared.core.flows import FlowsList
|
|
23
23
|
|
|
24
24
|
structlogger = structlog.get_logger()
|
|
@@ -87,16 +87,13 @@ def validate_custom_commands(command_classes: List[Type[PromptCommand]]) -> None
|
|
|
87
87
|
]
|
|
88
88
|
|
|
89
89
|
if clz_not_inheriting_from_command_clz:
|
|
90
|
-
|
|
91
|
-
"command_parser.validate_custom_commands.invalid_command",
|
|
90
|
+
raise ValidationError(
|
|
91
|
+
code="command_parser.validate_custom_commands.invalid_command",
|
|
92
|
+
event_info="The additional command classes must be a subclass of the "
|
|
93
|
+
"'Command' class. Please refer to the class in "
|
|
94
|
+
"`rasa.dialogue_understanding.commands.command.Command`",
|
|
92
95
|
invalid_commands=clz_not_inheriting_from_command_clz,
|
|
93
|
-
event_info=(
|
|
94
|
-
"The additional command classes must be a subclass of the 'Command' "
|
|
95
|
-
"class. Please refer to the class in "
|
|
96
|
-
"`rasa.dialogue_understanding.commands.command.Command`"
|
|
97
|
-
),
|
|
98
96
|
)
|
|
99
|
-
sys.exit(1)
|
|
100
97
|
|
|
101
98
|
clz_not_adhering_to_prompt_command_protocol = [
|
|
102
99
|
command_clz.__name__
|
|
@@ -105,16 +102,15 @@ def validate_custom_commands(command_classes: List[Type[PromptCommand]]) -> None
|
|
|
105
102
|
]
|
|
106
103
|
|
|
107
104
|
if clz_not_adhering_to_prompt_command_protocol:
|
|
108
|
-
|
|
109
|
-
"command_parser.validate_custom_commands.invalid_command",
|
|
110
|
-
invalid_commands=clz_not_adhering_to_prompt_command_protocol,
|
|
105
|
+
raise ValidationError(
|
|
106
|
+
code="command_parser.validate_custom_commands.invalid_command",
|
|
111
107
|
event_info=(
|
|
112
108
|
"The additional command classes must adhere to the 'PromptCommand' "
|
|
113
109
|
"protocol. Please refer to the protocol in "
|
|
114
110
|
"`rasa.dialogue_understanding.commands.prompt_command.PromptCommand`"
|
|
115
111
|
),
|
|
112
|
+
invalid_commands=clz_not_adhering_to_prompt_command_protocol,
|
|
116
113
|
)
|
|
117
|
-
sys.exit(1)
|
|
118
114
|
|
|
119
115
|
|
|
120
116
|
def parse_commands(
|
|
@@ -37,7 +37,6 @@ from rasa.dialogue_understanding.stack.frames import (
|
|
|
37
37
|
BaseFlowStackFrame,
|
|
38
38
|
)
|
|
39
39
|
from rasa.dialogue_understanding.stack.utils import (
|
|
40
|
-
filled_slots_for_active_flow,
|
|
41
40
|
top_flow_frame,
|
|
42
41
|
top_user_flow_frame,
|
|
43
42
|
)
|
|
@@ -125,7 +124,8 @@ def validate_state_of_commands(commands: List[Command]) -> None:
|
|
|
125
124
|
# check that there is only at max one cancel flow command
|
|
126
125
|
if sum(isinstance(c, CancelFlowCommand) for c in commands) > 1:
|
|
127
126
|
structlogger.error(
|
|
128
|
-
"command_processor.validate_state_of_commands.
|
|
127
|
+
"command_processor.validate_state_of_commands."
|
|
128
|
+
"multiple_cancel_flow_commands",
|
|
129
129
|
commands=[command.__class__.__name__ for command in commands],
|
|
130
130
|
)
|
|
131
131
|
raise ValueError("There can only be one cancel flow command.")
|
|
@@ -136,7 +136,8 @@ def validate_state_of_commands(commands: List[Command]) -> None:
|
|
|
136
136
|
]
|
|
137
137
|
if free_form_answer_commands != commands[: len(free_form_answer_commands)]:
|
|
138
138
|
structlogger.error(
|
|
139
|
-
"command_processor.validate_state_of_commands.
|
|
139
|
+
"command_processor.validate_state_of_commands."
|
|
140
|
+
"free_form_answer_commands_not_at_beginning",
|
|
140
141
|
commands=[command.__class__.__name__ for command in commands],
|
|
141
142
|
)
|
|
142
143
|
raise ValueError(
|
|
@@ -146,7 +147,8 @@ def validate_state_of_commands(commands: List[Command]) -> None:
|
|
|
146
147
|
# check that there is at max only one correctslots command
|
|
147
148
|
if sum(isinstance(c, CorrectSlotsCommand) for c in commands) > 1:
|
|
148
149
|
structlogger.error(
|
|
149
|
-
"command_processor.validate_state_of_commands.
|
|
150
|
+
"command_processor.validate_state_of_commands."
|
|
151
|
+
"multiple_correct_slots_commands",
|
|
150
152
|
commands=[command.__class__.__name__ for command in commands],
|
|
151
153
|
)
|
|
152
154
|
raise ValueError("There can only be one correct slots command.")
|
|
@@ -230,11 +232,9 @@ def execute_commands(
|
|
|
230
232
|
|
|
231
233
|
events: List[Event] = flow_hash_events
|
|
232
234
|
|
|
233
|
-
# commands
|
|
234
|
-
#
|
|
235
|
-
|
|
236
|
-
# and then pushing the commands onto the stack in the reversed order.
|
|
237
|
-
reversed_commands = list(reversed(commands))
|
|
235
|
+
# reorder commands: in case there is no active flow, we want to make sure to
|
|
236
|
+
# run the start flow commands first.
|
|
237
|
+
final_commands = reorder_commands(commands, tracker)
|
|
238
238
|
|
|
239
239
|
# we need to keep track of the ValidateSlotPatternFlowStackFrame that
|
|
240
240
|
# should be pushed onto the stack before executing the StartFlowCommands.
|
|
@@ -245,7 +245,7 @@ def execute_commands(
|
|
|
245
245
|
|
|
246
246
|
validate_state_of_commands(commands)
|
|
247
247
|
|
|
248
|
-
for command in
|
|
248
|
+
for command in final_commands:
|
|
249
249
|
new_events = command.run_command_on_tracker(
|
|
250
250
|
tracker, all_flows, original_tracker
|
|
251
251
|
)
|
|
@@ -398,14 +398,12 @@ def clean_up_commands(
|
|
|
398
398
|
"""
|
|
399
399
|
domain = domain if domain else Domain.empty()
|
|
400
400
|
|
|
401
|
-
slots_so_far, active_flow = filled_slots_for_active_flow(tracker, all_flows)
|
|
402
|
-
|
|
403
401
|
clean_commands: List[Command] = []
|
|
404
402
|
|
|
405
403
|
for command in commands:
|
|
406
404
|
if isinstance(command, SetSlotCommand):
|
|
407
405
|
clean_commands = clean_up_slot_command(
|
|
408
|
-
clean_commands, command, tracker, all_flows
|
|
406
|
+
clean_commands, command, tracker, all_flows
|
|
409
407
|
)
|
|
410
408
|
|
|
411
409
|
elif isinstance(command, CancelFlowCommand) and contains_command(
|
|
@@ -439,7 +437,8 @@ def clean_up_commands(
|
|
|
439
437
|
# drop a start flow command if the starting flow is equal
|
|
440
438
|
# to the currently active flow
|
|
441
439
|
structlogger.debug(
|
|
442
|
-
"command_processor.clean_up_commands.
|
|
440
|
+
"command_processor.clean_up_commands."
|
|
441
|
+
"skip_command_flow_already_active",
|
|
443
442
|
command=command,
|
|
444
443
|
)
|
|
445
444
|
continue
|
|
@@ -470,7 +469,8 @@ def clean_up_commands(
|
|
|
470
469
|
clean_commands = clean_up_clarify_command(clean_commands, commands, command)
|
|
471
470
|
if command not in clean_commands:
|
|
472
471
|
structlogger.debug(
|
|
473
|
-
"command_processor.clean_up_commands.
|
|
472
|
+
"command_processor.clean_up_commands."
|
|
473
|
+
"drop_clarify_given_other_commands",
|
|
474
474
|
command=command,
|
|
475
475
|
)
|
|
476
476
|
else:
|
|
@@ -494,6 +494,25 @@ def clean_up_commands(
|
|
|
494
494
|
return clean_commands
|
|
495
495
|
|
|
496
496
|
|
|
497
|
+
def _get_slots_eligible_for_correction(tracker: DialogueStateTracker) -> Set[str]:
|
|
498
|
+
"""Get all slots that are eligible for correction.
|
|
499
|
+
|
|
500
|
+
# We consider all slots, which are not None, that were set in the tracker
|
|
501
|
+
# eligible for correction.
|
|
502
|
+
# In the correct_slot_command we will check if a slot should actually be
|
|
503
|
+
# corrected.
|
|
504
|
+
"""
|
|
505
|
+
# get all slots that were set in the tracker
|
|
506
|
+
slots_so_far = set(
|
|
507
|
+
[event.key for event in tracker.events if isinstance(event, SlotSet)]
|
|
508
|
+
)
|
|
509
|
+
|
|
510
|
+
# filter out slots that are set to None (None = empty value)
|
|
511
|
+
slots_so_far = {slot for slot in slots_so_far if tracker.get_slot(slot) is not None}
|
|
512
|
+
|
|
513
|
+
return slots_so_far
|
|
514
|
+
|
|
515
|
+
|
|
497
516
|
def ensure_max_number_of_command_type(
|
|
498
517
|
commands: List[Command], command_type: Type[Command], n: int
|
|
499
518
|
) -> List[Command]:
|
|
@@ -553,7 +572,6 @@ def clean_up_slot_command(
|
|
|
553
572
|
command: SetSlotCommand,
|
|
554
573
|
tracker: DialogueStateTracker,
|
|
555
574
|
all_flows: FlowsList,
|
|
556
|
-
slots_so_far: Set[str],
|
|
557
575
|
) -> List[Command]:
|
|
558
576
|
"""Clean up a slot command.
|
|
559
577
|
|
|
@@ -566,16 +584,15 @@ def clean_up_slot_command(
|
|
|
566
584
|
command: The command to clean up.
|
|
567
585
|
tracker: The dialogue state tracker.
|
|
568
586
|
all_flows: All flows.
|
|
569
|
-
slots_so_far: The slots that have been filled so far.
|
|
570
587
|
|
|
571
588
|
Returns:
|
|
572
589
|
The cleaned up commands.
|
|
573
590
|
"""
|
|
574
591
|
stack = tracker.stack
|
|
575
|
-
|
|
576
592
|
resulting_commands = commands_so_far[:]
|
|
577
|
-
|
|
578
593
|
slot = tracker.slots.get(command.name)
|
|
594
|
+
|
|
595
|
+
# if the slot is not in the domain, we cannot set it
|
|
579
596
|
if slot is None:
|
|
580
597
|
structlogger.debug(
|
|
581
598
|
"command_processor.clean_up_slot_command.skip_command_slot_not_in_domain",
|
|
@@ -588,6 +605,7 @@ def clean_up_slot_command(
|
|
|
588
605
|
)
|
|
589
606
|
return resulting_commands
|
|
590
607
|
|
|
608
|
+
# check if the slot should be set by the command
|
|
591
609
|
if not should_slot_be_set(slot, command, resulting_commands):
|
|
592
610
|
structlogger.debug(
|
|
593
611
|
"command_processor.clean_up_slot_command.skip_command.extractor_"
|
|
@@ -613,6 +631,7 @@ def clean_up_slot_command(
|
|
|
613
631
|
|
|
614
632
|
return resulting_commands
|
|
615
633
|
|
|
634
|
+
# check if the slot can be corrected by the LLM
|
|
616
635
|
if (
|
|
617
636
|
slot.filled_by == SetSlotExtractor.NLU.value
|
|
618
637
|
and command.extractor == SetSlotExtractor.LLM.value
|
|
@@ -633,7 +652,13 @@ def clean_up_slot_command(
|
|
|
633
652
|
)
|
|
634
653
|
return resulting_commands
|
|
635
654
|
|
|
636
|
-
|
|
655
|
+
# get all slots that were set in the tracker and are eligible for correction
|
|
656
|
+
slots_eligible_for_correction = _get_slots_eligible_for_correction(tracker)
|
|
657
|
+
|
|
658
|
+
if (
|
|
659
|
+
command.name in slots_eligible_for_correction
|
|
660
|
+
and command.name != ROUTE_TO_CALM_SLOT
|
|
661
|
+
):
|
|
637
662
|
current_collect_info = get_current_collect_step(stack, all_flows)
|
|
638
663
|
|
|
639
664
|
if current_collect_info and current_collect_info.collect == command.name:
|
|
@@ -641,49 +666,71 @@ def clean_up_slot_command(
|
|
|
641
666
|
resulting_commands.append(command)
|
|
642
667
|
return resulting_commands
|
|
643
668
|
|
|
644
|
-
if (
|
|
645
|
-
slot
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
"command_processor.clean_up_slot_command.skip_command_slot_already_set",
|
|
650
|
-
command=command,
|
|
651
|
-
)
|
|
669
|
+
if should_slot_be_corrected(command, tracker, stack, all_flows):
|
|
670
|
+
# if the slot was already set before, we need to convert it into
|
|
671
|
+
# a correction
|
|
672
|
+
return convert_set_slot_to_correction(command, resulting_commands)
|
|
673
|
+
else:
|
|
652
674
|
return resulting_commands
|
|
653
675
|
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
already_corrected_slots = top.corrected_slots
|
|
657
|
-
else:
|
|
658
|
-
already_corrected_slots = {}
|
|
676
|
+
resulting_commands.append(command)
|
|
677
|
+
return resulting_commands
|
|
659
678
|
|
|
660
|
-
if command.name in already_corrected_slots and str(
|
|
661
|
-
already_corrected_slots[command.name]
|
|
662
|
-
) == str(command.value):
|
|
663
|
-
structlogger.debug(
|
|
664
|
-
"command_processor.clean_up_slot_command"
|
|
665
|
-
".skip_command_slot_already_corrected",
|
|
666
|
-
command=command,
|
|
667
|
-
)
|
|
668
|
-
return resulting_commands
|
|
669
679
|
|
|
680
|
+
def should_slot_be_corrected(
|
|
681
|
+
command: SetSlotCommand,
|
|
682
|
+
tracker: DialogueStateTracker,
|
|
683
|
+
stack: DialogueStack,
|
|
684
|
+
all_flows: FlowsList,
|
|
685
|
+
) -> bool:
|
|
686
|
+
"""Check if a slot should be corrected."""
|
|
687
|
+
if (slot := tracker.slots.get(command.name)) is not None and str(slot.value) == str(
|
|
688
|
+
command.value
|
|
689
|
+
):
|
|
690
|
+
# the slot is already set to the same value, we don't need to set it again
|
|
670
691
|
structlogger.debug(
|
|
671
|
-
"command_processor.clean_up_slot_command.
|
|
692
|
+
"command_processor.clean_up_slot_command.skip_command_slot_already_set",
|
|
672
693
|
command=command,
|
|
673
694
|
)
|
|
695
|
+
return False
|
|
674
696
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
if isinstance(c, CorrectSlotsCommand):
|
|
679
|
-
c.corrected_slots.append(corrected_slot)
|
|
680
|
-
break
|
|
681
|
-
else:
|
|
682
|
-
resulting_commands.append(
|
|
683
|
-
CorrectSlotsCommand(corrected_slots=[corrected_slot])
|
|
684
|
-
)
|
|
697
|
+
top = top_flow_frame(stack)
|
|
698
|
+
if isinstance(top, CorrectionPatternFlowStackFrame):
|
|
699
|
+
already_corrected_slots = top.corrected_slots
|
|
685
700
|
else:
|
|
686
|
-
|
|
701
|
+
already_corrected_slots = {}
|
|
702
|
+
|
|
703
|
+
if command.name in already_corrected_slots and str(
|
|
704
|
+
already_corrected_slots[command.name]
|
|
705
|
+
) == str(command.value):
|
|
706
|
+
structlogger.debug(
|
|
707
|
+
"command_processor.clean_up_slot_command"
|
|
708
|
+
".skip_command_slot_already_corrected",
|
|
709
|
+
command=command,
|
|
710
|
+
)
|
|
711
|
+
return False
|
|
712
|
+
|
|
713
|
+
return True
|
|
714
|
+
|
|
715
|
+
|
|
716
|
+
def convert_set_slot_to_correction(
|
|
717
|
+
command: SetSlotCommand,
|
|
718
|
+
resulting_commands: List[Command],
|
|
719
|
+
) -> List[Command]:
|
|
720
|
+
"""Convert a set slot command to a correction command."""
|
|
721
|
+
structlogger.debug(
|
|
722
|
+
"command_processor.convert_set_slot_to_correction",
|
|
723
|
+
command=command,
|
|
724
|
+
)
|
|
725
|
+
|
|
726
|
+
# Group all corrections into one command
|
|
727
|
+
corrected_slot = CorrectedSlot(command.name, command.value, command.extractor)
|
|
728
|
+
for c in resulting_commands:
|
|
729
|
+
if isinstance(c, CorrectSlotsCommand):
|
|
730
|
+
c.corrected_slots.append(corrected_slot)
|
|
731
|
+
break
|
|
732
|
+
else:
|
|
733
|
+
resulting_commands.append(CorrectSlotsCommand(corrected_slots=[corrected_slot]))
|
|
687
734
|
|
|
688
735
|
return resulting_commands
|
|
689
736
|
|
|
@@ -742,7 +789,8 @@ def clean_up_chitchat_command(
|
|
|
742
789
|
0, CannotHandleCommand(RASA_PATTERN_CANNOT_HANDLE_CHITCHAT)
|
|
743
790
|
)
|
|
744
791
|
structlogger.warn(
|
|
745
|
-
"command_processor.clean_up_chitchat_command.
|
|
792
|
+
"command_processor.clean_up_chitchat_command."
|
|
793
|
+
"replace_chitchat_answer_with_cannot_handle",
|
|
746
794
|
command=resulting_commands[0], # no PII
|
|
747
795
|
pattern_chitchat_uses_action_trigger_chitchat=has_action_trigger_chitchat,
|
|
748
796
|
defined_intentless_policy_in_config=defines_intentless_policy,
|
|
@@ -845,3 +893,49 @@ def filter_cannot_handle_command(
|
|
|
845
893
|
for command in clean_commands
|
|
846
894
|
if not isinstance(command, CannotHandleCommand)
|
|
847
895
|
]
|
|
896
|
+
|
|
897
|
+
|
|
898
|
+
def reorder_commands(
|
|
899
|
+
commands: List[Command], tracker: DialogueStateTracker
|
|
900
|
+
) -> List[Command]:
|
|
901
|
+
"""Reorder commands.
|
|
902
|
+
|
|
903
|
+
In case there is no active flow, we want to make sure to run the start flow
|
|
904
|
+
commands first.
|
|
905
|
+
"""
|
|
906
|
+
reordered_commands = commands
|
|
907
|
+
|
|
908
|
+
top_flow_frame = top_user_flow_frame(tracker.stack)
|
|
909
|
+
|
|
910
|
+
if top_flow_frame is None:
|
|
911
|
+
# no active flow, we want to make sure to run the start flow commands first
|
|
912
|
+
start_flow_commands: List[Command] = [
|
|
913
|
+
command for command in commands if isinstance(command, StartFlowCommand)
|
|
914
|
+
]
|
|
915
|
+
|
|
916
|
+
# if there are no start flow commands, we can return the commands as they are
|
|
917
|
+
if not start_flow_commands:
|
|
918
|
+
reordered_commands = commands
|
|
919
|
+
|
|
920
|
+
# if there is just one start flow command, we want to run it first
|
|
921
|
+
# as the order of commands is reserved later,
|
|
922
|
+
# we need to add it to the end of the list
|
|
923
|
+
elif len(start_flow_commands) == 1:
|
|
924
|
+
reordered_commands = [
|
|
925
|
+
command for command in commands if command not in start_flow_commands
|
|
926
|
+
] + start_flow_commands
|
|
927
|
+
|
|
928
|
+
# if there are multiple start flow commands,
|
|
929
|
+
# we just make sure to move the first start flow command to the end of the list
|
|
930
|
+
# (due to the reverse execution order of commands) and keep the other commands
|
|
931
|
+
# as they are.
|
|
932
|
+
else:
|
|
933
|
+
reordered_commands = [
|
|
934
|
+
command for command in commands if command != start_flow_commands[-1]
|
|
935
|
+
] + [start_flow_commands[-1]]
|
|
936
|
+
|
|
937
|
+
# commands need to be reversed to make sure they end up in the right order
|
|
938
|
+
# on the stack. e.g. if there multiple start flow commands, the first one
|
|
939
|
+
# should be on top of the stack. this is achieved by reversing the list
|
|
940
|
+
# and then pushing the commands onto the stack in the reversed order.
|
|
941
|
+
return list(reversed(reordered_commands))
|
|
@@ -209,14 +209,24 @@ def get_collect_steps_excluding_ask_before_filling_for_active_flow(
|
|
|
209
209
|
All collect steps that are part of the current active flow,
|
|
210
210
|
excluding the collect steps that have to be asked before filling.
|
|
211
211
|
"""
|
|
212
|
-
|
|
212
|
+
active_primary_frame = top_user_flow_frame(dialogue_stack)
|
|
213
|
+
any_active_frame = top_user_flow_frame(
|
|
213
214
|
dialogue_stack, ignore_call_and_link_frames=False
|
|
214
215
|
)
|
|
215
|
-
|
|
216
|
+
|
|
217
|
+
active_flows = []
|
|
218
|
+
if any_active_frame:
|
|
219
|
+
active_flows.append(any_active_frame.flow(all_flows))
|
|
220
|
+
|
|
221
|
+
if active_primary_frame and active_primary_frame != any_active_frame:
|
|
222
|
+
active_flows.append(active_primary_frame.flow(all_flows))
|
|
223
|
+
|
|
224
|
+
if not active_flows:
|
|
216
225
|
return set()
|
|
217
|
-
|
|
226
|
+
|
|
218
227
|
return set(
|
|
219
228
|
step.collect
|
|
229
|
+
for active_flow in active_flows
|
|
220
230
|
for step in active_flow.get_collect_steps()
|
|
221
231
|
if not step.ask_before_filling
|
|
222
232
|
)
|
|
@@ -5,12 +5,12 @@ mapping:
|
|
|
5
5
|
sequence:
|
|
6
6
|
- type: map
|
|
7
7
|
mapping:
|
|
8
|
-
regex;(^[a-zA-Z_]+[a-zA-Z0-9_]*$):
|
|
8
|
+
regex;(^[a-zA-Z_]+[a-zA-Z0-9_\-]*$):
|
|
9
9
|
type: "seq"
|
|
10
10
|
sequence:
|
|
11
11
|
- type: map
|
|
12
12
|
mapping:
|
|
13
|
-
regex;(^[a-zA-Z_]+[a-zA-Z0-9_]*$):
|
|
13
|
+
regex;(^[a-zA-Z_]+[a-zA-Z0-9_\-]*$):
|
|
14
14
|
type: any
|
|
15
15
|
|
|
16
16
|
metadata:
|
|
@@ -129,7 +129,7 @@ mapping:
|
|
|
129
129
|
type: "seq"
|
|
130
130
|
sequence:
|
|
131
131
|
- type: "str"
|
|
132
|
-
pattern: ^[a-zA-Z_]+[a-zA-Z0-9_]*$
|
|
132
|
+
pattern: ^[a-zA-Z_]+[a-zA-Z0-9_\-]*$
|
|
133
133
|
metadata:
|
|
134
134
|
type: "str"
|
|
135
135
|
pattern: ^[a-zA-Z_]+[a-zA-Z0-9_]*$
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import argparse
|
|
2
|
-
import sys
|
|
3
2
|
from typing import List, Optional
|
|
4
3
|
|
|
5
4
|
import structlog
|
|
@@ -9,6 +8,7 @@ from rasa.dialogue_understanding_test.constants import (
|
|
|
9
8
|
PLACEHOLDER_GENERATED_ANSWER_TEMPLATE,
|
|
10
9
|
)
|
|
11
10
|
from rasa.dialogue_understanding_test.du_test_case import DialogueUnderstandingTestCase
|
|
11
|
+
from rasa.exceptions import ValidationError
|
|
12
12
|
from rasa.shared.core.domain import Domain
|
|
13
13
|
|
|
14
14
|
structlogger = structlog.get_logger()
|
|
@@ -28,14 +28,14 @@ def validate_cli_arguments(args: argparse.Namespace) -> None:
|
|
|
28
28
|
args.remote_storage
|
|
29
29
|
and args.remote_storage.lower() not in supported_remote_storages
|
|
30
30
|
):
|
|
31
|
-
|
|
32
|
-
"dialogue_understanding_test.validate_cli_arguments
|
|
31
|
+
raise ValidationError(
|
|
32
|
+
code="dialogue_understanding_test.validate_cli_arguments"
|
|
33
|
+
".invalid_remote_storage",
|
|
33
34
|
event_info=(
|
|
34
35
|
f"Invalid remote storage option - '{args.remote_storage}'. Supported "
|
|
35
36
|
f"options are: {supported_remote_storages}"
|
|
36
37
|
),
|
|
37
38
|
)
|
|
38
|
-
sys.exit(1)
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
def validate_test_cases(
|
|
@@ -48,11 +48,10 @@ def validate_test_cases(
|
|
|
48
48
|
domain: Domain of the assistant.
|
|
49
49
|
"""
|
|
50
50
|
if not domain:
|
|
51
|
-
|
|
52
|
-
"dialogue_understanding_test.validate_test_cases.no_domain",
|
|
51
|
+
raise ValidationError(
|
|
52
|
+
code="dialogue_understanding_test.validate_test_cases.no_domain",
|
|
53
53
|
event_info="No domain found. Retrain the model with a valid domain.",
|
|
54
54
|
)
|
|
55
|
-
sys.exit(1)
|
|
56
55
|
|
|
57
56
|
# Retrieve all valid templates from the domain
|
|
58
57
|
valid_templates = domain.utterances_for_response
|
|
@@ -64,8 +63,9 @@ def validate_test_cases(
|
|
|
64
63
|
for step in test_case.steps:
|
|
65
64
|
if step.actor == ACTOR_BOT and step.template:
|
|
66
65
|
if step.template not in valid_templates:
|
|
67
|
-
|
|
68
|
-
"dialogue_understanding_test.validate_test_cases
|
|
66
|
+
raise ValidationError(
|
|
67
|
+
code="dialogue_understanding_test.validate_test_cases"
|
|
68
|
+
".invalid_template",
|
|
69
69
|
event_info=(
|
|
70
70
|
f"Invalid bot utterance template '{step.template}' in test "
|
|
71
71
|
f"case '{test_case.name}' at line {step.line}. Please "
|
|
@@ -74,4 +74,3 @@ def validate_test_cases(
|
|
|
74
74
|
test_case=test_case.name,
|
|
75
75
|
template=step.template,
|
|
76
76
|
)
|
|
77
|
-
sys.exit(1)
|