rasa-pro 3.14.0.dev6__py3-none-any.whl → 3.14.0.dev8__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/agents/agent_manager.py +1 -1
- rasa/agents/constants.py +2 -2
- rasa/agents/exceptions.py +31 -1
- rasa/agents/protocol/a2a/a2a_agent.py +385 -227
- rasa/agents/protocol/mcp/mcp_base_agent.py +37 -19
- rasa/agents/protocol/mcp/mcp_open_agent.py +31 -8
- rasa/agents/protocol/mcp/mcp_task_agent.py +33 -10
- rasa/agents/schemas/agent_output.py +1 -1
- rasa/agents/utils.py +95 -1
- rasa/agents/validation.py +484 -0
- rasa/api.py +9 -6
- rasa/builder/README.md +120 -0
- rasa/builder/__init__.py +0 -0
- rasa/builder/auth.py +176 -0
- rasa/builder/config.py +92 -0
- rasa/builder/copilot/__init__.py +0 -0
- rasa/builder/copilot/constants.py +31 -0
- rasa/builder/copilot/copilot.py +450 -0
- rasa/builder/copilot/copilot_response_handler.py +522 -0
- rasa/builder/copilot/copilot_templated_message_provider.py +58 -0
- rasa/builder/copilot/exceptions.py +32 -0
- rasa/builder/copilot/models.py +500 -0
- rasa/builder/copilot/prompts/__init__.py +0 -0
- rasa/builder/copilot/prompts/copilot_system_prompt.jinja2 +766 -0
- rasa/builder/copilot/prompts/latest_user_message_context_prompt.jinja2 +61 -0
- rasa/builder/copilot/signing.py +305 -0
- rasa/builder/copilot/telemetry.py +210 -0
- rasa/builder/copilot/templated_messages/__init__.py +0 -0
- rasa/builder/copilot/templated_messages/copilot_internal_messages_templates.yml +16 -0
- rasa/builder/copilot/templated_messages/copilot_templated_responses.yml +38 -0
- rasa/builder/document_retrieval/__init__.py +0 -0
- rasa/builder/document_retrieval/constants.py +15 -0
- rasa/builder/document_retrieval/inkeep-rag-response-schema.json +64 -0
- rasa/builder/document_retrieval/inkeep_document_retrieval.py +238 -0
- rasa/builder/document_retrieval/models.py +62 -0
- rasa/builder/download.py +140 -0
- rasa/builder/exceptions.py +91 -0
- rasa/builder/guardrails/__init__.py +1 -0
- rasa/builder/guardrails/constants.py +9 -0
- rasa/builder/guardrails/exceptions.py +4 -0
- rasa/builder/guardrails/lakera.py +206 -0
- rasa/builder/guardrails/models.py +231 -0
- rasa/builder/guardrails/store.py +238 -0
- rasa/builder/guardrails/utils.py +328 -0
- rasa/builder/job_manager.py +87 -0
- rasa/builder/jobs.py +282 -0
- rasa/builder/llm_service.py +246 -0
- rasa/builder/logging_utils.py +265 -0
- rasa/builder/main.py +243 -0
- rasa/builder/models.py +216 -0
- rasa/builder/project_generator.py +458 -0
- rasa/builder/project_info.py +72 -0
- rasa/builder/scrape_rasa_docs.py +97 -0
- rasa/builder/service.py +1345 -0
- rasa/builder/shared/tracker_context.py +212 -0
- rasa/builder/skill_to_bot_prompt.jinja2 +164 -0
- rasa/builder/template_cache.py +244 -0
- rasa/builder/training_service.py +194 -0
- rasa/builder/validation_service.py +97 -0
- rasa/cli/arguments/train.py +2 -0
- rasa/cli/interactive.py +2 -0
- rasa/cli/project_templates/basic/README.md +23 -0
- rasa/cli/project_templates/basic/actions/__init__ +0 -0
- rasa/cli/project_templates/basic/actions/action_human_handoff.py +40 -0
- rasa/cli/project_templates/basic/actions/actions.md +10 -0
- rasa/cli/project_templates/basic/config.yml +29 -0
- rasa/cli/project_templates/basic/credentials.yml +33 -0
- rasa/cli/project_templates/basic/data/data.md +9 -0
- rasa/cli/project_templates/basic/data/general/feedback.yml +21 -0
- rasa/cli/project_templates/basic/data/general/goodbye.yml +6 -0
- rasa/cli/project_templates/basic/data/general/hello.yml +6 -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/show_faqs.yml +6 -0
- rasa/cli/project_templates/basic/data/system/patterns/pattern_cannot_handle.yml +7 -0
- rasa/cli/project_templates/basic/data/system/patterns/pattern_completed.yml +7 -0
- rasa/cli/project_templates/basic/data/system/patterns/pattern_correction.yml +7 -0
- rasa/cli/project_templates/basic/data/system/patterns/pattern_search.yml +8 -0
- rasa/cli/project_templates/basic/data/system/patterns/pattern_session_start.yml +8 -0
- rasa/cli/project_templates/basic/docs/docs.md +5 -0
- rasa/cli/project_templates/basic/docs/template.txt +28 -0
- rasa/cli/project_templates/basic/domain/domain.md +8 -0
- rasa/cli/project_templates/basic/domain/general/feedback.yml +25 -0
- rasa/cli/project_templates/basic/domain/general/goodbye.yml +9 -0
- rasa/cli/project_templates/basic/domain/general/hello.yml +7 -0
- rasa/cli/project_templates/basic/domain/general/help.yml +21 -0
- rasa/cli/project_templates/basic/domain/general/human_handoff.yml +32 -0
- rasa/cli/project_templates/basic/domain/general/show_faqs.yml +14 -0
- rasa/cli/project_templates/basic/domain/system/patterns/pattern_cannot_handle.yml +5 -0
- rasa/cli/project_templates/basic/domain/system/patterns/pattern_session_start.yml +19 -0
- rasa/cli/project_templates/basic/endpoints.yml +67 -0
- rasa/cli/project_templates/basic/prompts/rephraser_demo_personality_prompt.jinja2 +38 -0
- rasa/cli/project_templates/default/config.yml +4 -0
- rasa/cli/project_templates/default/endpoints.yml +4 -0
- rasa/cli/project_templates/finance/README.md +25 -0
- 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/accounts/action_ask_account.py +47 -0
- rasa/cli/project_templates/finance/actions/accounts/action_check_balance.py +40 -0
- rasa/cli/project_templates/finance/actions/action_session_start.py +74 -0
- rasa/cli/project_templates/finance/actions/actions.md +15 -0
- rasa/cli/project_templates/finance/actions/cards/__init__.py +0 -0
- rasa/cli/project_templates/finance/actions/cards/action_ask_card.py +48 -0
- rasa/cli/project_templates/finance/actions/cards/action_check_card_existence.py +36 -0
- rasa/cli/project_templates/finance/actions/cards/action_update_card_status.py +54 -0
- rasa/cli/project_templates/finance/actions/database.py +277 -0
- rasa/cli/project_templates/finance/actions/transfers/__init__.py +0 -0
- rasa/cli/project_templates/finance/actions/transfers/action_add_payee.py +52 -0
- rasa/cli/project_templates/finance/actions/transfers/action_ask_account_from.py +51 -0
- rasa/cli/project_templates/finance/actions/transfers/action_check_payee_existence.py +40 -0
- rasa/cli/project_templates/finance/actions/transfers/action_check_sufficient_funds.py +40 -0
- rasa/cli/project_templates/finance/actions/transfers/action_list_payees.py +46 -0
- rasa/cli/project_templates/finance/actions/transfers/action_process_immediate_payment.py +18 -0
- rasa/cli/project_templates/finance/actions/transfers/action_remove_payee.py +49 -0
- rasa/cli/project_templates/finance/actions/transfers/action_schedule_payment.py +19 -0
- rasa/cli/project_templates/finance/actions/transfers/action_validate_payment_date.py +36 -0
- rasa/cli/project_templates/finance/config.yml +23 -0
- rasa/cli/project_templates/finance/credentials.yml +32 -0
- rasa/cli/project_templates/finance/csvs/accounts.csv +8 -0
- rasa/cli/project_templates/finance/csvs/advisors.csv +7 -0
- rasa/cli/project_templates/finance/csvs/appointments.csv +211 -0
- rasa/cli/project_templates/finance/csvs/branches.csv +10 -0
- rasa/cli/project_templates/finance/csvs/cards.csv +11 -0
- rasa/cli/project_templates/finance/csvs/payees.csv +11 -0
- rasa/cli/project_templates/finance/csvs/transactions.csv +71 -0
- rasa/cli/project_templates/finance/csvs/users.csv +4 -0
- rasa/cli/project_templates/finance/data/accounts/check_balance.yml +10 -0
- rasa/cli/project_templates/finance/data/cards/block_card.yml +66 -0
- rasa/cli/project_templates/finance/data/cards/select_card.yml +12 -0
- rasa/cli/project_templates/finance/data/data.md +11 -0
- 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/general/help.yml +9 -0
- 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/system/patterns/pattern_chitchat.yml +5 -0
- 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/system/patterns/pattern_session_start.yml +8 -0
- rasa/cli/project_templates/finance/data/system/source/accounts.json +51 -0
- rasa/cli/project_templates/finance/data/system/source/advisors.json +44 -0
- rasa/cli/project_templates/finance/data/system/source/appointments.json +1474 -0
- rasa/cli/project_templates/finance/data/system/source/branches.json +47 -0
- rasa/cli/project_templates/finance/data/system/source/cards.json +72 -0
- rasa/cli/project_templates/finance/data/system/source/payees.json +74 -0
- rasa/cli/project_templates/finance/data/system/source/transactions.json +492 -0
- rasa/cli/project_templates/finance/data/system/source/users.json +29 -0
- rasa/cli/project_templates/finance/data/transfers/add_payee.yml +29 -0
- rasa/cli/project_templates/finance/data/transfers/list_payees.yml +5 -0
- rasa/cli/project_templates/finance/data/transfers/remove_payee.yml +21 -0
- rasa/cli/project_templates/finance/data/transfers/transfer_money.yml +67 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/consequences_of_blocking_card.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/reasons_to_block_card.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/recovering_from_card_fraud.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/tips_for_card_security.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/block_card/what_to_do_if_card_is_lost.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/account_balance_security.txt +7 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/common_balance_inquiries.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/methods_to_check_balance.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/understanding_balance_updates.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/check_balance/what_to_do_if_balance_is_incorrect.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/benefits_of_authorised_payees.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/common_issues_with_payees.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/general_payee_information.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/payee_management_tips.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/manage_payees/understanding_payee_types.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/common_transfer_errors.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/fees_for_transfers.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/general_transfer_information.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/security_tips_for_transfers.txt +8 -0
- rasa/cli/project_templates/finance/docs/bank_of_rasa_faq/transfer_money/transfer_processing_times.txt +8 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part1.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part10.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part11.txt +48 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part12.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part13.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part14.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part15.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part16.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part17.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part18.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part19.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part2.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part20.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part21.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part22.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part23.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part24.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part25.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part26.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part27.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part28.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part29.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part3.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part30.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part31.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part32.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part33.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part34.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part35.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part36.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part37.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part38.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part39.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part4.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part40.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part41.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part42.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part43.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part44.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part45.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part46.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part47.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part48.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part49.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part5.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part50.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part51.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part52.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part53.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part54.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part55.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part56.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part57.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part58.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part59.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part6.txt +47 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part60.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part61.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part7.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part8.txt +50 -0
- rasa/cli/project_templates/finance/docs/huggingface_alpaca_dataset/questions_part9.txt +47 -0
- rasa/cli/project_templates/finance/domain/accounts/check_balance.yml +11 -0
- rasa/cli/project_templates/finance/domain/cards/block_card.yml +101 -0
- rasa/cli/project_templates/finance/domain/cards/select_card.yml +12 -0
- rasa/cli/project_templates/finance/domain/domain.md +10 -0
- rasa/cli/project_templates/finance/domain/general/agent_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/domain/transfers/add_payee.yml +47 -0
- rasa/cli/project_templates/finance/domain/transfers/list_payees.yml +4 -0
- rasa/cli/project_templates/finance/domain/transfers/remove_payee.yml +16 -0
- rasa/cli/project_templates/finance/domain/transfers/transfer_money.yml +79 -0
- rasa/cli/project_templates/finance/endpoints.yml +66 -0
- rasa/cli/project_templates/finance/prompts/rephraser_demo_personality_prompt.jinja2 +19 -0
- rasa/cli/project_templates/telco/README.md +25 -0
- rasa/cli/project_templates/telco/actions/__init__.py +0 -0
- rasa/cli/project_templates/telco/actions/actions.md +12 -0
- rasa/cli/project_templates/telco/actions/billing/__init__.py +0 -0
- rasa/cli/project_templates/telco/actions/billing/actions_billing.py +204 -0
- rasa/cli/project_templates/telco/actions/general/__init__.py +0 -0
- rasa/cli/project_templates/telco/actions/general/action_human_handoff.py +49 -0
- rasa/cli/project_templates/telco/actions/network/__init__.py +0 -0
- rasa/cli/project_templates/telco/actions/network/actions_get_data_from_db.py +48 -0
- rasa/cli/project_templates/telco/actions/network/actions_run_diagnostics.py +28 -0
- rasa/cli/project_templates/telco/actions/network/actions_session_start.py +18 -0
- rasa/cli/project_templates/telco/config.yml +29 -0
- rasa/cli/project_templates/telco/credentials.yml +33 -0
- rasa/cli/project_templates/telco/csvs/billing.csv +19 -0
- rasa/cli/project_templates/telco/csvs/customers.csv +5 -0
- rasa/cli/project_templates/telco/data/billing/flow_understand_bill.yml +45 -0
- rasa/cli/project_templates/telco/data/data.md +11 -0
- rasa/cli/project_templates/telco/data/general/bot_challenge.yml +6 -0
- rasa/cli/project_templates/telco/data/general/feedback.yml +20 -0
- rasa/cli/project_templates/telco/data/general/goodbye.yml +6 -0
- rasa/cli/project_templates/telco/data/general/hello.yml +6 -0
- rasa/cli/project_templates/telco/data/general/human_handoff.yml +16 -0
- rasa/cli/project_templates/telco/data/general/patterns.yml +30 -0
- rasa/cli/project_templates/telco/data/network/flow_reboot_router.yml +8 -0
- rasa/cli/project_templates/telco/data/network/flow_reset_router.yml +7 -0
- rasa/cli/project_templates/telco/data/network/flow_solve_internet_issue.yml +73 -0
- rasa/cli/project_templates/telco/docs/docs.md +5 -0
- rasa/cli/project_templates/telco/docs/network/reset_vs_rboot_router.txt +1 -0
- rasa/cli/project_templates/telco/docs/network/restart_router.txt +6 -0
- rasa/cli/project_templates/telco/docs/network/run_speed_test.txt +6 -0
- rasa/cli/project_templates/telco/domain/billing/understand_bill.yml +102 -0
- rasa/cli/project_templates/telco/domain/domain.md +14 -0
- rasa/cli/project_templates/telco/domain/general/bot_challenge.yml +4 -0
- rasa/cli/project_templates/telco/domain/general/feedback.yml +25 -0
- rasa/cli/project_templates/telco/domain/general/goodbye.yml +7 -0
- rasa/cli/project_templates/telco/domain/general/hello.yml +5 -0
- rasa/cli/project_templates/telco/domain/general/human_handoff.yml +26 -0
- rasa/cli/project_templates/telco/domain/general/patterns.yml +33 -0
- rasa/cli/project_templates/telco/domain/network/reboot_router.yml +21 -0
- rasa/cli/project_templates/telco/domain/network/reset_router.yml +12 -0
- rasa/cli/project_templates/telco/domain/network/run_speed_test.yml +25 -0
- rasa/cli/project_templates/telco/domain/network/solve_internet_issue.yml +75 -0
- rasa/cli/project_templates/telco/domain/shared.yml +129 -0
- rasa/cli/project_templates/telco/endpoints.yml +67 -0
- rasa/cli/project_templates/telco/prompts/rephraser_demo_personality_prompt.jinja2 +40 -0
- rasa/cli/project_templates/telco/tests/e2e_test_cases/billing/understand_bill.yml +67 -0
- rasa/cli/project_templates/telco/tests/e2e_test_cases/general/bot_challenge.yml +8 -0
- rasa/cli/project_templates/telco/tests/e2e_test_cases/general/feedback.yml +46 -0
- rasa/cli/project_templates/telco/tests/e2e_test_cases/general/goodbye.yml +9 -0
- rasa/cli/project_templates/telco/tests/e2e_test_cases/general/hello.yml +8 -0
- rasa/cli/project_templates/telco/tests/e2e_test_cases/general/human_handoff.yml +35 -0
- rasa/cli/project_templates/telco/tests/e2e_test_cases/general/patterns.yml +23 -0
- rasa/cli/project_templates/telco/tests/e2e_test_cases/network/solve_internet_issue.yml +57 -0
- rasa/cli/project_templates/tutorial/config.yml +2 -1
- rasa/cli/scaffold.py +46 -2
- rasa/cli/train.py +2 -0
- rasa/cli/utils.py +85 -1
- rasa/core/actions/action.py +2 -7
- rasa/core/available_agents.py +49 -26
- rasa/core/available_endpoints.py +17 -2
- rasa/core/channels/channel.py +4 -3
- rasa/core/channels/constants.py +3 -0
- rasa/core/channels/development_inspector.py +2 -22
- rasa/core/channels/inspector/README.md +26 -14
- rasa/core/channels/inspector/dist/assets/{arc-63212852.js → arc-edef10dd.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-eecf6b13.js → blockDiagram-38ab4fdb-49f6762b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-8f798a9a.js → c4Diagram-3d4e48cf-313c08e6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/channel-63aa27d1.js +1 -0
- rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-df71a04c.js → classDiagram-70f12bd4-35e41ce9.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-9b275968.js → classDiagram-v2-f2320105-f346068d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/clone-5566bae8.js +1 -0
- rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-1c669cad.js → createText-2e5e7dd3-7a44bce8.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-b1553799.js → edges-e0da2a9e-d7cf78c7.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-112388d6.js → erDiagram-9861fffd-9813e81c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-fdebec47.js → flowDb-956e92f1-d8ba0870.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-6280ede1.js → flowDiagram-66a62f08-51f0db4d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-32936074.js +1 -0
- rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-e1dc03e5.js → flowchart-elk-definition-4a651766-ff9ea384.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-83f68c51.js → ganttDiagram-c361ad54-a8e13b6b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-22f8666f.js → gitGraphDiagram-72cf32ee-3b171c6d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{graph-ca9e6217.js → graph-790ef78b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-3862675e-c5ceb692.js → index-3862675e-ecdce073.js} +1 -1
- rasa/core/channels/inspector/dist/assets/index-d705da80.js +1352 -0
- rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-faa9999b.js → infoDiagram-f8f76790-f5a422fe.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-c4dda8d9.js → journeyDiagram-49397b02-3185b7ac.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-d4307784.js → layout-837fd3aa.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{line-0567aaa7.js → line-7e05afcb.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-c11b95cf.js → linear-162eb295.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-0c7d3ca9.js → mindmap-definition-fc14e90a-f4978aee.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-34b433fa.js → pieDiagram-8a3498a8-b25d0a52.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-4cab816e.js → quadrantDiagram-120e2f19-63db1afa.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-8c22fa9e.js → requirementDiagram-deff3bca-1b486cc9.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-70ce9e8e.js → sankeyDiagram-04a897e0-7e795291.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-fbcd7fc9.js → sequenceDiagram-704730f1-b8aba159.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-45f05ea6.js → stateDiagram-587899a1-41529fd5.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-beab1ea6.js → stateDiagram-v2-d93cdb3a-b241043c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-2f29dbd5.js → styles-6aaf32cf-b5b53234.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-9a916d00-951eac83.js → styles-9a916d00-13d138e5.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-c10674c1-897fbfdd.js → styles-c10674c1-94cbde3f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-d667fac1.js → svgDrawCommon-08f97a94-453ae764.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-e3205144.js → timeline-definition-85554ec2-8dcb88a4.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-4abeb0e2.js → xychartDiagram-e933f94c-376af5f0.js} +1 -1
- rasa/core/channels/inspector/dist/index.html +2 -2
- rasa/core/channels/inspector/index.html +1 -1
- rasa/core/channels/inspector/src/App.tsx +42 -44
- rasa/core/channels/inspector/src/components/Chat.tsx +2 -3
- rasa/core/channels/inspector/src/components/DialogueAgentStack.tsx +108 -0
- rasa/core/channels/inspector/src/components/{DialogueStack.tsx → DialogueHistoryStack.tsx} +8 -8
- rasa/core/channels/inspector/src/components/DialogueInformation.tsx +20 -3
- rasa/core/channels/inspector/src/components/LatencyDisplay.tsx +63 -35
- rasa/core/channels/inspector/src/helpers/audio/audiostream.ts +14 -0
- rasa/core/channels/inspector/src/helpers/formatters.test.ts +4 -0
- rasa/core/channels/inspector/src/helpers/utils.test.ts +127 -0
- rasa/core/channels/inspector/src/helpers/utils.ts +66 -1
- rasa/core/channels/inspector/src/types.ts +49 -7
- rasa/core/channels/socketio.py +212 -51
- rasa/core/channels/studio_chat.py +59 -57
- rasa/core/channels/voice_stream/asr/asr_event.py +1 -1
- rasa/core/channels/voice_stream/asr/azure.py +6 -3
- rasa/core/channels/voice_stream/asr/deepgram.py +1 -1
- rasa/core/channels/voice_stream/audiocodes.py +3 -0
- rasa/core/channels/voice_stream/browser_audio.py +53 -3
- rasa/core/channels/voice_stream/genesys.py +2 -1
- rasa/core/channels/voice_stream/jambonz.py +9 -1
- rasa/core/channels/voice_stream/twilio_media_streams.py +16 -0
- rasa/core/channels/voice_stream/voice_channel.py +66 -3
- rasa/core/constants.py +6 -0
- rasa/core/iam_credentials_providers/__init__.py +0 -0
- rasa/core/iam_credentials_providers/aws_iam_credentials_providers.py +66 -0
- rasa/core/iam_credentials_providers/credentials_provider_protocol.py +89 -0
- rasa/core/policies/enterprise_search_policy.py +4 -7
- rasa/core/policies/flows/flow_executor.py +66 -36
- rasa/core/policies/ted_policy.py +7 -5
- rasa/core/processor.py +32 -0
- rasa/core/redis_connection_factory.py +411 -0
- rasa/core/run.py +13 -3
- rasa/core/tracker_stores/redis_tracker_store.py +32 -14
- rasa/core/tracker_stores/sql_tracker_store.py +57 -1
- rasa/dialogue_understanding/commands/cancel_flow_command.py +2 -81
- rasa/dialogue_understanding/commands/start_flow_command.py +18 -113
- rasa/dialogue_understanding/commands/utils.py +118 -0
- rasa/dialogue_understanding/generator/flow_retrieval.py +10 -9
- rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v2_claude_3_5_sonnet_20240620_template.jinja2 +10 -5
- rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v2_gpt_4o_2024_11_20_template.jinja2 +10 -5
- rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v3_claude_3_5_sonnet_20240620_template.jinja2 +20 -12
- rasa/dialogue_understanding/generator/prompt_templates/agent_command_prompt_v3_gpt_4o_2024_11_20_template.jinja2 +19 -12
- rasa/dialogue_understanding/generator/single_step/single_step_based_llm_command_generator.py +6 -35
- rasa/dialogue_understanding/patterns/cancel.py +27 -6
- rasa/dialogue_understanding/patterns/clarify.py +3 -14
- rasa/dialogue_understanding/patterns/continue_interrupted.py +185 -114
- rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +18 -24
- rasa/dialogue_understanding/processor/command_processor.py +35 -0
- rasa/dialogue_understanding/stack/utils.py +43 -4
- rasa/dialogue_understanding/utils.py +24 -4
- rasa/engine/graph.py +5 -1
- rasa/engine/recipes/default_components.py +78 -10
- rasa/engine/recipes/default_recipe.py +41 -1
- rasa/engine/storage/local_model_storage.py +83 -3
- rasa/graph_components/validators/default_recipe_validator.py +153 -135
- rasa/model_manager/model_api.py +4 -5
- rasa/model_manager/runner_service.py +1 -1
- rasa/model_manager/socket_bridge.py +20 -15
- rasa/model_manager/trainer_service.py +12 -9
- rasa/model_manager/utils.py +1 -29
- rasa/model_manager/warm_rasa_process.py +1 -1
- rasa/model_training.py +22 -6
- rasa/nlu/classifiers/diet_classifier.py +22 -6
- rasa/nlu/classifiers/logistic_regression_classifier.py +18 -0
- rasa/nlu/extractors/extractor.py +1 -2
- rasa/shared/agents/auth/__init__.py +0 -0
- rasa/shared/agents/auth/agent_auth_factory.py +74 -0
- rasa/shared/agents/auth/agent_auth_manager.py +86 -0
- rasa/shared/agents/auth/auth_strategy/__init__.py +19 -0
- rasa/shared/agents/auth/auth_strategy/agent_auth_strategy.py +52 -0
- rasa/shared/agents/auth/auth_strategy/api_key_auth_strategy.py +42 -0
- rasa/shared/agents/auth/auth_strategy/bearer_token_auth_strategy.py +28 -0
- rasa/shared/agents/auth/auth_strategy/oauth2_auth_strategy.py +159 -0
- rasa/shared/agents/auth/constants.py +11 -0
- rasa/shared/agents/auth/types.py +11 -0
- rasa/shared/constants.py +3 -0
- rasa/shared/core/constants.py +6 -6
- rasa/shared/core/domain.py +58 -11
- rasa/shared/core/events.py +2 -0
- rasa/shared/core/flows/constants.py +5 -0
- rasa/shared/core/flows/flow_step.py +7 -1
- rasa/shared/core/flows/flows_list.py +6 -0
- rasa/shared/core/flows/steps/call.py +15 -12
- rasa/shared/core/flows/validation.py +238 -44
- rasa/shared/core/flows/yaml_flows_io.py +15 -6
- rasa/shared/core/slots.py +4 -0
- rasa/shared/exceptions.py +12 -0
- rasa/shared/importers/importer.py +6 -0
- rasa/shared/importers/utils.py +77 -1
- rasa/shared/nlu/training_data/schemas/responses.yml +3 -0
- rasa/shared/providers/_utils.py +60 -44
- rasa/shared/providers/embedding/default_litellm_embedding_client.py +2 -0
- rasa/shared/providers/llm/_base_litellm_client.py +2 -2
- rasa/shared/providers/llm/default_litellm_llm_client.py +2 -0
- rasa/shared/providers/llm/llm_response.py +4 -4
- rasa/shared/utils/common.py +24 -0
- rasa/shared/utils/health_check/health_check.py +7 -3
- rasa/shared/utils/llm.py +2 -1
- rasa/shared/utils/mcp/server_connection.py +108 -27
- rasa/shared/utils/mcp/utils.py +20 -0
- rasa/studio/upload.py +16 -47
- rasa/telemetry.py +97 -23
- rasa/tracing/config.py +38 -12
- rasa/tracing/instrumentation/attribute_extractors.py +5 -1
- rasa/tracing/instrumentation/instrumentation.py +85 -8
- rasa/utils/common.py +1 -1
- rasa/utils/io.py +27 -9
- rasa/utils/json_utils.py +6 -1
- rasa/utils/log_utils.py +5 -1
- rasa/utils/openapi.py +144 -0
- rasa/utils/tensorflow/__init__.py +29 -0
- rasa/utils/tensorflow/callback.py +1 -1
- rasa/utils/tensorflow/crf.py +1 -1
- rasa/utils/tensorflow/data_generator.py +21 -8
- rasa/utils/tensorflow/layers.py +11 -4
- rasa/utils/tensorflow/metrics.py +7 -3
- rasa/utils/tensorflow/models.py +41 -6
- rasa/utils/tensorflow/rasa_layers.py +6 -4
- rasa/utils/tensorflow/transformer.py +2 -3
- rasa/utils/train_utils.py +68 -38
- rasa/validator.py +18 -16
- rasa/version.py +1 -1
- rasa_pro-3.14.0.dev8.dist-info/METADATA +199 -0
- {rasa_pro-3.14.0.dev6.dist-info → rasa_pro-3.14.0.dev8.dist-info}/RECORD +486 -173
- rasa/core/channels/inspector/dist/assets/channel-0cd70adf.js +0 -1
- rasa/core/channels/inspector/dist/assets/clone-a0f9c4ed.js +0 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-de9cc4aa.js +0 -1
- rasa/core/channels/inspector/dist/assets/index-3e293924.js +0 -1353
- rasa_pro-3.14.0.dev6.dist-info/METADATA +0 -190
- {rasa_pro-3.14.0.dev6.dist-info → rasa_pro-3.14.0.dev8.dist-info}/NOTICE +0 -0
- {rasa_pro-3.14.0.dev6.dist-info → rasa_pro-3.14.0.dev8.dist-info}/WHEEL +0 -0
- {rasa_pro-3.14.0.dev6.dist-info → rasa_pro-3.14.0.dev8.dist-info}/entry_points.txt +0 -0
|
@@ -13,13 +13,13 @@ Use the following structured data:
|
|
|
13
13
|
|
|
14
14
|
## Available Actions:
|
|
15
15
|
* `start flow flow_name`: Start a flow. For example, `start flow transfer_money` or `start flow list_contacts`.
|
|
16
|
-
* `set slot slot_name slot_value`: Set a slot for the active flow. For example, `set slot transfer_money_recipient Freddy`. Can be used to correct and change previously set values.
|
|
16
|
+
* `set slot slot_name slot_value`: Set a slot for the active flow. For example, `set slot transfer_money_recipient Freddy`. Can be used to correct and change previously set values. ONLY use slots that are explicitly defined in the flow's slot list.
|
|
17
17
|
* `disambiguate flows flow_name1 flow_name2 ... flow_name_n`: When a message could refer to multiple flows, list the possible flows as options to clarify. Example: `disambiguate flows list_contacts add_contact remove_contact`.
|
|
18
18
|
* `search and reply`: Provide a response from the knowledge base to address the user’s inquiry when no flows fit, including domain knowledge, FAQs, and all off-topic or social messages.
|
|
19
19
|
* `cancel flow`: Cancel the current flow if the user requests it.
|
|
20
20
|
* `repeat message`: Repeat the last bot message.
|
|
21
|
-
{% if active_agent %} * `continue agent`: Continue the currently active agent {{ active_agent.name }}.{% endif %}
|
|
22
|
-
{% if completed_agents %}* `restart agent agent_name`: Restart the agent with the given name, in case the user wants to change some answer to a previous question asked by the agent. For example, `restart agent car_research_agent` if the user
|
|
21
|
+
{% if active_agent %} * `continue agent`: Continue the currently active agent {{ active_agent.name }}. This has HIGHEST PRIORITY when an agent is active and the user is responding to agent questions.{% endif %}
|
|
22
|
+
{% if completed_agents %}* `restart agent agent_name`: Restart the agent with the given name, in case the user wants to change some answer to a previous question asked by the agent. For example, `restart agent car_research_agent` if the user changed his mind about the car he wants to buy. ONLY use agents that are listed in the `completed_agents` section.{% endif %}
|
|
23
23
|
|
|
24
24
|
---
|
|
25
25
|
|
|
@@ -32,6 +32,7 @@ Use the following structured data:
|
|
|
32
32
|
* For categorical slots try to match the user message with allowed slot values. Use "other" if you cannot match it.
|
|
33
33
|
* Set the boolean slots based on the user response. Map positive responses to `True`, and negative to `False`.
|
|
34
34
|
* Extract text slot values exactly as provided by the user. Avoid assumptions, format changes, or partial extractions.
|
|
35
|
+
* ONLY use `set slot` with slots that are explicitly defined in the current flow's slot list. Do NOT create or assume slots that don't exist.
|
|
35
36
|
### Disambiguate Flows
|
|
36
37
|
* Use `disambiguate flows` when the user's message matches multiple flows and you cannot decide which flow is most appropriate.
|
|
37
38
|
* If the user message is short and not precise enough to start a flow or `search and reply`, disambiguate.
|
|
@@ -42,29 +43,35 @@ Use the following structured data:
|
|
|
42
43
|
* Flow Priority: If you are unsure between starting a flow or `search and reply`, always prioritize starting a flow.
|
|
43
44
|
### Cancel Flow
|
|
44
45
|
* Do not cancel any flow unless the user explicitly requests it.
|
|
45
|
-
* Multiple flows can be started without cancelling the previous, if the user wants to pursue multiple processes.
|
|
46
|
-
###
|
|
46
|
+
* Multiple flows can be started without cancelling the previous, if the user wants to pursue multiple processes.{% if active_agent or completed_agents %}
|
|
47
|
+
### Agents{% if active_agent %}
|
|
48
|
+
* When an agent is active, ALWAYS prioritize `continue agent` over `search and reply` unless the user is clearly asking something unrelated to the agent's task.{% endif %}{% if completed_agents %}
|
|
49
|
+
* ONLY use `restart agent` with agents that are listed in the `completed_agents` section. Do NOT restart non-existent agents.{% endif %}
|
|
50
|
+
* If you're unsure about agent names, refer to the structured data provided in the `Current State` section.
|
|
51
|
+
{% endif %}### General Tips
|
|
47
52
|
* Only use information provided by the user.
|
|
48
53
|
* Strictly adhere to the provided action format.
|
|
54
|
+
* ONLY use the exact actions listed above. Do NOT invent new actions like "respond <message>" or any other variations.
|
|
49
55
|
* Focus on the last message and take it one step at a time.
|
|
50
56
|
* Use the previous conversation steps only to aid understanding.
|
|
51
57
|
|
|
52
58
|
---
|
|
53
59
|
|
|
54
60
|
## Decision Rule Table
|
|
55
|
-
| Condition
|
|
56
|
-
|
|
57
|
-
|
|
|
58
|
-
|
|
|
59
|
-
|
|
|
60
|
-
|
|
|
61
|
+
| Condition | Action |
|
|
62
|
+
|---------------------------------------------------------------|--------------------|{% if active_agent %}
|
|
63
|
+
| Agent is active and the user is responding to agent questions | continue agent |{% endif %}
|
|
64
|
+
| Flow perfectly matches user's message | start flow |
|
|
65
|
+
| Multiple flows are equally strong, relevant matches | disambiguate flows |
|
|
66
|
+
| User's message is unclear or imprecise | disambiguate flows |
|
|
67
|
+
| No flow fits at all, but knowledge base may help | search and reply |
|
|
61
68
|
|
|
62
69
|
---
|
|
63
70
|
|
|
64
71
|
## Current State
|
|
65
72
|
{% if current_flow != None %}Use the following structured data:
|
|
66
73
|
```json
|
|
67
|
-
{"active_flow":
|
|
74
|
+
{"active_flow":{"name":"{{ current_flow }}","current_step":{"requested_slot":"{{ current_slot }}","requested_slot_description":{{ current_slot_description | to_json_escaped_string }}},"slots":[{% for slot in flow_slots %}{"name":"{{ slot.name }}","value":"{{ slot.value }}","type":"{{ slot.type }}"{% if slot.description %},"description":{{ slot.description | to_json_escaped_string }}{% endif %}{% if slot.allowed_values %},"allowed_values":"{{ slot.allowed_values }}"{% endif %}}{% if not loop.last %},{% endif %}{% endfor %}]}{% if active_agent %},"active_agent":{"name":"{{ active_agent.name }}","description":{{ active_agent.description | to_json_escaped_string }}}{% endif %}{% if completed_agents %},"completed_agents":[{% for agent in completed_agents %}{"name":"{{ agent.name }}","description":{{ agent.description | to_json_escaped_string }}}{% if not loop.last %},{% endif %}{% endfor %}]{% endif %}}
|
|
68
75
|
```{% else %}
|
|
69
76
|
You are currently not inside any flow.{% endif %}
|
|
70
77
|
|
rasa/dialogue_understanding/generator/single_step/single_step_based_llm_command_generator.py
CHANGED
|
@@ -5,7 +5,10 @@ from typing import Any, Dict, List, Literal, Optional, Text
|
|
|
5
5
|
import structlog
|
|
6
6
|
|
|
7
7
|
import rasa.shared.utils.io
|
|
8
|
-
from rasa.
|
|
8
|
+
from rasa.agents.utils import (
|
|
9
|
+
get_active_agent_info,
|
|
10
|
+
get_completed_agents_info,
|
|
11
|
+
)
|
|
9
12
|
from rasa.dialogue_understanding.commands import (
|
|
10
13
|
CannotHandleCommand,
|
|
11
14
|
Command,
|
|
@@ -45,7 +48,6 @@ from rasa.shared.constants import (
|
|
|
45
48
|
PROMPT_TEMPLATE_CONFIG_KEY,
|
|
46
49
|
ROUTE_TO_CALM_SLOT,
|
|
47
50
|
)
|
|
48
|
-
from rasa.shared.core.events import AgentCompleted
|
|
49
51
|
from rasa.shared.core.flows import FlowsList
|
|
50
52
|
from rasa.shared.core.trackers import DialogueStateTracker
|
|
51
53
|
from rasa.shared.exceptions import ProviderClientAPIException
|
|
@@ -416,10 +418,10 @@ class SingleStepBasedLLMCommandGenerator(LLMBasedCommandGenerator, ABC):
|
|
|
416
418
|
"current_slot_type": current_slot_type,
|
|
417
419
|
"current_slot_allowed_values": current_slot_allowed_values,
|
|
418
420
|
"user_message": latest_user_message,
|
|
419
|
-
"active_agent":
|
|
421
|
+
"active_agent": get_active_agent_info(tracker, top_flow.id)
|
|
420
422
|
if top_flow
|
|
421
423
|
else None,
|
|
422
|
-
"completed_agents":
|
|
424
|
+
"completed_agents": get_completed_agents_info(tracker),
|
|
423
425
|
}
|
|
424
426
|
|
|
425
427
|
return self.compile_template(self.prompt_template).render(**inputs)
|
|
@@ -467,34 +469,3 @@ class SingleStepBasedLLMCommandGenerator(LLMBasedCommandGenerator, ABC):
|
|
|
467
469
|
) -> Optional[str]:
|
|
468
470
|
"""Get the prompt template from the config or the default prompt template."""
|
|
469
471
|
pass
|
|
470
|
-
|
|
471
|
-
def _get_active_agent(
|
|
472
|
-
self, tracker: DialogueStateTracker, active_flow_id: str
|
|
473
|
-
) -> Optional[Dict[str, Any]]:
|
|
474
|
-
agent_frame = tracker.stack.find_active_agent_stack_frame_for_flow(
|
|
475
|
-
active_flow_id
|
|
476
|
-
)
|
|
477
|
-
if agent_frame:
|
|
478
|
-
return self._get_agent_info(agent_frame.agent_id)
|
|
479
|
-
return None
|
|
480
|
-
|
|
481
|
-
def _get_completed_agents(
|
|
482
|
-
self, tracker: DialogueStateTracker
|
|
483
|
-
) -> List[Dict[str, Any]]:
|
|
484
|
-
completed_agents: List[Dict[str, Any]] = []
|
|
485
|
-
for event in reversed(tracker.events):
|
|
486
|
-
if isinstance(event, AgentCompleted):
|
|
487
|
-
agent_info = self._get_agent_info(event.agent_id)
|
|
488
|
-
if agent_info:
|
|
489
|
-
completed_agents.append(agent_info)
|
|
490
|
-
return completed_agents
|
|
491
|
-
|
|
492
|
-
def _get_agent_info(self, agent_id: str) -> Optional[Dict[str, Any]]:
|
|
493
|
-
agent_config = AvailableAgents.get_agent_config(agent_id)
|
|
494
|
-
if agent_config is None:
|
|
495
|
-
return None
|
|
496
|
-
|
|
497
|
-
return {
|
|
498
|
-
"name": agent_config.agent.name,
|
|
499
|
-
"description": agent_config.agent.description,
|
|
500
|
-
}
|
|
@@ -8,10 +8,12 @@ import structlog
|
|
|
8
8
|
from rasa.core.actions import action
|
|
9
9
|
from rasa.core.channels.channel import OutputChannel
|
|
10
10
|
from rasa.core.nlg.generator import NaturalLanguageGenerator
|
|
11
|
+
from rasa.dialogue_understanding.stack.dialogue_stack import DialogueStack
|
|
11
12
|
from rasa.dialogue_understanding.stack.frames import (
|
|
12
13
|
BaseFlowStackFrame,
|
|
13
14
|
PatternFlowStackFrame,
|
|
14
15
|
)
|
|
16
|
+
from rasa.dialogue_understanding.stack.frames.flow_stack_frame import AgentStackFrame
|
|
15
17
|
from rasa.shared.constants import RASA_DEFAULT_FLOW_PATTERN_PREFIX
|
|
16
18
|
from rasa.shared.core.constants import ACTION_CANCEL_FLOW
|
|
17
19
|
from rasa.shared.core.domain import Domain
|
|
@@ -30,7 +32,8 @@ class CancelPatternFlowStackFrame(PatternFlowStackFrame):
|
|
|
30
32
|
"""A pattern flow stack frame which cancels a flow.
|
|
31
33
|
|
|
32
34
|
The frame contains the information about the stack frames that should
|
|
33
|
-
be canceled.
|
|
35
|
+
be canceled.
|
|
36
|
+
"""
|
|
34
37
|
|
|
35
38
|
flow_id: str = FLOW_PATTERN_CANCEL
|
|
36
39
|
"""The ID of the flow."""
|
|
@@ -93,19 +96,37 @@ class ActionCancelFlow(action.Action):
|
|
|
93
96
|
structlogger.warning("action.cancel_flow.no_cancel_frame")
|
|
94
97
|
return []
|
|
95
98
|
|
|
99
|
+
agent_frame_ids_to_cancel = []
|
|
96
100
|
for canceled_frame_id in top.canceled_frames:
|
|
97
101
|
for frame in stack.frames:
|
|
98
102
|
if frame.frame_id == canceled_frame_id and isinstance(
|
|
99
103
|
frame, BaseFlowStackFrame
|
|
100
104
|
):
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
+
if isinstance(frame, AgentStackFrame):
|
|
106
|
+
# When an AgentStackFrame needs to be canceled, we can
|
|
107
|
+
# remove it directly from the stack. No extra logic is
|
|
108
|
+
# required in the flow executor, since
|
|
109
|
+
# the AgentCanceled event has already been created by
|
|
110
|
+
# ActionCancelInterruptedFlows or CancelFlowCommand, and the
|
|
111
|
+
# steps following the agentic call step should not be executed.
|
|
112
|
+
agent_frame_ids_to_cancel.append(frame.frame_id)
|
|
113
|
+
break
|
|
114
|
+
else:
|
|
115
|
+
# Setting the stack frame to the end step so it is
|
|
116
|
+
# properly wrapped up by the flow policy
|
|
117
|
+
frame.step_id = ContinueFlowStep.continue_step_for_id(END_STEP)
|
|
118
|
+
break
|
|
105
119
|
else:
|
|
106
120
|
structlogger.warning(
|
|
107
121
|
"action.cancel_flow.frame_not_found",
|
|
108
122
|
frame_id=canceled_frame_id,
|
|
109
123
|
)
|
|
110
124
|
|
|
111
|
-
|
|
125
|
+
# Create a copy of the stack without the agentic frames that should
|
|
126
|
+
# be canceled
|
|
127
|
+
new_stack = DialogueStack.empty()
|
|
128
|
+
for frame in stack.frames:
|
|
129
|
+
if frame.frame_id not in agent_frame_ids_to_cancel:
|
|
130
|
+
new_stack.push(frame)
|
|
131
|
+
|
|
132
|
+
return tracker.create_stack_updated_events(new_stack)
|
|
@@ -61,19 +61,6 @@ class ActionClarifyFlows(action.Action):
|
|
|
61
61
|
"""Return the flow name."""
|
|
62
62
|
return ACTION_CLARIFY_FLOWS
|
|
63
63
|
|
|
64
|
-
@staticmethod
|
|
65
|
-
def assemble_options_string(names: List[str]) -> str:
|
|
66
|
-
"""Concatenate options to a human-readable string."""
|
|
67
|
-
clarification_message = ""
|
|
68
|
-
for i, name in enumerate(names):
|
|
69
|
-
if i == 0:
|
|
70
|
-
clarification_message += name
|
|
71
|
-
elif i == len(names) - 1:
|
|
72
|
-
clarification_message += f" or {name}"
|
|
73
|
-
else:
|
|
74
|
-
clarification_message += f", {name}"
|
|
75
|
-
return clarification_message
|
|
76
|
-
|
|
77
64
|
async def run(
|
|
78
65
|
self,
|
|
79
66
|
output_channel: "OutputChannel",
|
|
@@ -83,6 +70,8 @@ class ActionClarifyFlows(action.Action):
|
|
|
83
70
|
metadata: Optional[Dict[str, Any]] = None,
|
|
84
71
|
) -> List[Event]:
|
|
85
72
|
"""Correct the slots."""
|
|
73
|
+
from rasa.dialogue_understanding.utils import assemble_options_string
|
|
74
|
+
|
|
86
75
|
stack = tracker.stack
|
|
87
76
|
if not (top := stack.top()):
|
|
88
77
|
structlogger.warning("action.clarify_flows.no_active_flow")
|
|
@@ -92,7 +81,7 @@ class ActionClarifyFlows(action.Action):
|
|
|
92
81
|
structlogger.warning("action.clarify_flows.no_clarification_frame")
|
|
93
82
|
return []
|
|
94
83
|
|
|
95
|
-
options_string =
|
|
84
|
+
options_string = assemble_options_string(top.names, conjunction="or")
|
|
96
85
|
top.clarification_options = options_string
|
|
97
86
|
# since we modified the stack frame, we need to update the stack
|
|
98
87
|
return tracker.create_stack_updated_events(stack)
|
|
@@ -1,31 +1,47 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from dataclasses import dataclass
|
|
4
|
-
from typing import Any, Dict, List, Optional, Text
|
|
3
|
+
from dataclasses import dataclass, field
|
|
4
|
+
from typing import Any, Dict, List, Optional, Text, Tuple
|
|
5
|
+
|
|
6
|
+
import structlog
|
|
5
7
|
|
|
6
8
|
from rasa.core.actions.action import Action
|
|
7
9
|
from rasa.core.channels import OutputChannel
|
|
8
10
|
from rasa.core.nlg import NaturalLanguageGenerator
|
|
11
|
+
from rasa.dialogue_understanding.commands.utils import (
|
|
12
|
+
resume_flow,
|
|
13
|
+
)
|
|
14
|
+
from rasa.dialogue_understanding.patterns.cancel import CancelPatternFlowStackFrame
|
|
15
|
+
from rasa.dialogue_understanding.stack.dialogue_stack import DialogueStack
|
|
9
16
|
from rasa.dialogue_understanding.stack.frames import PatternFlowStackFrame
|
|
10
|
-
from rasa.dialogue_understanding.stack.
|
|
17
|
+
from rasa.dialogue_understanding.stack.frames.dialogue_stack_frame import (
|
|
18
|
+
DialogueStackFrame,
|
|
19
|
+
)
|
|
20
|
+
from rasa.dialogue_understanding.stack.frames.flow_stack_frame import (
|
|
21
|
+
AgentStackFrame,
|
|
22
|
+
FlowStackFrameType,
|
|
23
|
+
UserFlowStackFrame,
|
|
24
|
+
)
|
|
25
|
+
from rasa.dialogue_understanding.stack.utils import (
|
|
26
|
+
get_active_continue_interrupted_pattern_frame,
|
|
27
|
+
)
|
|
11
28
|
from rasa.shared.constants import RASA_DEFAULT_FLOW_PATTERN_PREFIX
|
|
12
29
|
from rasa.shared.core.constants import (
|
|
13
|
-
|
|
14
|
-
ACTION_CANCEL_INTERRUPTED_FLOW,
|
|
30
|
+
ACTION_CANCEL_INTERRUPTED_FLOWS,
|
|
15
31
|
ACTION_CONTINUE_INTERRUPTED_FLOW,
|
|
16
|
-
ACTION_SET_INTERRUPTED_FLOWS,
|
|
17
32
|
)
|
|
18
33
|
from rasa.shared.core.domain import Domain
|
|
19
|
-
from rasa.shared.core.events import Event, SlotSet
|
|
34
|
+
from rasa.shared.core.events import AgentCancelled, Event, FlowCancelled, SlotSet
|
|
20
35
|
from rasa.shared.core.trackers import DialogueStateTracker
|
|
21
36
|
|
|
22
37
|
FLOW_PATTERN_CONTINUE_INTERRUPTED = (
|
|
23
38
|
RASA_DEFAULT_FLOW_PATTERN_PREFIX + "continue_interrupted"
|
|
24
39
|
)
|
|
25
|
-
INTERRUPTED_FLOWS_SLOT = "interrupted_flows"
|
|
26
40
|
INTERRUPTED_FLOW_TO_CONTINUE_SLOT = "interrupted_flow_to_continue"
|
|
27
|
-
|
|
28
|
-
|
|
41
|
+
CONTINUE_INTERRUPTED_FLOW_CONFIRMATION_SLOT = "continue_interrupted_flow_confirmation"
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
structlogger = structlog.get_logger()
|
|
29
45
|
|
|
30
46
|
|
|
31
47
|
@dataclass
|
|
@@ -34,8 +50,14 @@ class ContinueInterruptedPatternFlowStackFrame(PatternFlowStackFrame):
|
|
|
34
50
|
|
|
35
51
|
flow_id: str = FLOW_PATTERN_CONTINUE_INTERRUPTED
|
|
36
52
|
"""The ID of the flow."""
|
|
37
|
-
|
|
38
|
-
"""The
|
|
53
|
+
interrupted_flow_names: List[str] = field(default_factory=list)
|
|
54
|
+
"""The names of the previous flows that were interrupted."""
|
|
55
|
+
interrupted_flow_ids: List[str] = field(default_factory=list)
|
|
56
|
+
"""The ids of the previous flows that were interrupted."""
|
|
57
|
+
interrupted_flow_options: str = ""
|
|
58
|
+
"""The options that the user can choose from as a string."""
|
|
59
|
+
multiple_flows_interrupted: bool = False
|
|
60
|
+
"""Whether the user has interrupted multiple flows."""
|
|
39
61
|
|
|
40
62
|
@classmethod
|
|
41
63
|
def type(cls) -> str:
|
|
@@ -55,7 +77,10 @@ class ContinueInterruptedPatternFlowStackFrame(PatternFlowStackFrame):
|
|
|
55
77
|
return ContinueInterruptedPatternFlowStackFrame(
|
|
56
78
|
frame_id=data["frame_id"],
|
|
57
79
|
step_id=data["step_id"],
|
|
58
|
-
|
|
80
|
+
interrupted_flow_names=data["interrupted_flow_names"],
|
|
81
|
+
interrupted_flow_ids=data["interrupted_flow_ids"],
|
|
82
|
+
interrupted_flow_options=data["interrupted_flow_options"],
|
|
83
|
+
multiple_flows_interrupted=len(data["interrupted_flow_names"]) > 1,
|
|
59
84
|
)
|
|
60
85
|
|
|
61
86
|
def __eq__(self, other: Any) -> bool:
|
|
@@ -64,13 +89,15 @@ class ContinueInterruptedPatternFlowStackFrame(PatternFlowStackFrame):
|
|
|
64
89
|
return (
|
|
65
90
|
self.flow_id == other.flow_id
|
|
66
91
|
and self.step_id == other.step_id
|
|
67
|
-
and self.
|
|
92
|
+
and self.interrupted_flow_names == other.interrupted_flow_names
|
|
93
|
+
and self.interrupted_flow_ids == other.interrupted_flow_ids
|
|
94
|
+
and self.interrupted_flow_options == other.interrupted_flow_options
|
|
68
95
|
)
|
|
69
96
|
|
|
70
97
|
|
|
71
|
-
class
|
|
98
|
+
class ActionContinueInterruptedFlow(Action):
|
|
72
99
|
def name(self) -> str:
|
|
73
|
-
return
|
|
100
|
+
return ACTION_CONTINUE_INTERRUPTED_FLOW
|
|
74
101
|
|
|
75
102
|
async def run(
|
|
76
103
|
self,
|
|
@@ -79,25 +106,62 @@ class ActionSetInterruptedFlows(Action):
|
|
|
79
106
|
tracker: DialogueStateTracker,
|
|
80
107
|
domain: Domain,
|
|
81
108
|
metadata: Optional[Dict[Text, Any]] = None,
|
|
82
|
-
) ->
|
|
83
|
-
|
|
84
|
-
|
|
109
|
+
) -> List[Event]:
|
|
110
|
+
# get the pattern frame from the stack
|
|
111
|
+
pattern_frame = get_active_continue_interrupted_pattern_frame(tracker.stack)
|
|
112
|
+
|
|
113
|
+
if pattern_frame is None:
|
|
114
|
+
structlogger.warning(
|
|
115
|
+
"action.continue_interrupted_flows.no_continue_interrupted_frame"
|
|
116
|
+
)
|
|
117
|
+
return []
|
|
85
118
|
|
|
86
|
-
|
|
87
|
-
|
|
119
|
+
interrupted_flow_ids = pattern_frame.interrupted_flow_ids
|
|
120
|
+
interrupted_flow_names = pattern_frame.interrupted_flow_names
|
|
121
|
+
multiple_flows_interrupted = pattern_frame.multiple_flows_interrupted
|
|
122
|
+
|
|
123
|
+
flow_to_continue = None
|
|
124
|
+
if not multiple_flows_interrupted:
|
|
125
|
+
# the user confirmed that they want to continue the flow
|
|
126
|
+
# as only one flow was interrupted, we can just continue the first one
|
|
127
|
+
flow_to_continue = interrupted_flow_ids[0]
|
|
128
|
+
else:
|
|
129
|
+
# the user mentioned the flow they want to continue
|
|
130
|
+
# check if the flow is in the list of interrupted flows
|
|
131
|
+
selected_flow = tracker.get_slot(INTERRUPTED_FLOW_TO_CONTINUE_SLOT)
|
|
132
|
+
if selected_flow in interrupted_flow_ids:
|
|
133
|
+
flow_to_continue = selected_flow
|
|
134
|
+
elif selected_flow in interrupted_flow_names:
|
|
135
|
+
# the user mentioned the flow by name
|
|
136
|
+
# find the flow id for the flow name
|
|
137
|
+
# the list of names and ids are in the same order
|
|
138
|
+
flow_to_continue = interrupted_flow_ids[
|
|
139
|
+
interrupted_flow_names.index(selected_flow)
|
|
140
|
+
]
|
|
141
|
+
|
|
142
|
+
# if the user did not select a valid flow,
|
|
143
|
+
# we need to ask them to select a valid flow
|
|
144
|
+
if flow_to_continue is None:
|
|
145
|
+
await output_channel.send_text_message(
|
|
146
|
+
tracker.sender_id,
|
|
147
|
+
"You haven't selected a valid task to resume. "
|
|
148
|
+
"Please specify the task you would like to continue. "
|
|
149
|
+
"The options are: {{context.interrupted_flow_options}}",
|
|
150
|
+
)
|
|
151
|
+
return []
|
|
88
152
|
|
|
89
|
-
|
|
90
|
-
|
|
153
|
+
# resume the flow the user selected
|
|
154
|
+
events = resume_flow(flow_to_continue, tracker, tracker.stack)
|
|
91
155
|
|
|
92
|
-
return [
|
|
93
|
-
SlotSet(
|
|
94
|
-
SlotSet(
|
|
156
|
+
return events + [
|
|
157
|
+
SlotSet(INTERRUPTED_FLOW_TO_CONTINUE_SLOT, None),
|
|
158
|
+
SlotSet(CONTINUE_INTERRUPTED_FLOW_CONFIRMATION_SLOT, None),
|
|
95
159
|
]
|
|
96
160
|
|
|
97
161
|
|
|
98
|
-
class
|
|
162
|
+
class ActionCancelInterruptedFlows(Action):
|
|
99
163
|
def name(self) -> str:
|
|
100
|
-
return
|
|
164
|
+
return ACTION_CANCEL_INTERRUPTED_FLOWS
|
|
101
165
|
|
|
102
166
|
async def run(
|
|
103
167
|
self,
|
|
@@ -107,107 +171,114 @@ class ActionAskInterruptedFlowToContinue(Action):
|
|
|
107
171
|
domain: Domain,
|
|
108
172
|
metadata: Optional[Dict[Text, Any]] = None,
|
|
109
173
|
) -> List[Event]:
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
buttons = [
|
|
113
|
-
{
|
|
114
|
-
"title": flow_id,
|
|
115
|
-
"payload": f'/SetSlots{{"{INTERRUPTED_FLOW_TO_CONTINUE_SLOT}": '
|
|
116
|
-
f'"{flow_id}"}}',
|
|
117
|
-
}
|
|
118
|
-
for flow_id in interrupted_flows or []
|
|
119
|
-
]
|
|
120
|
-
buttons.append(
|
|
121
|
-
{
|
|
122
|
-
"title": "None of them",
|
|
123
|
-
"payload": f'/SetSlots{{"{INTERRUPTED_FLOW_TO_CONTINUE_SLOT}": '
|
|
124
|
-
f'"none"}}',
|
|
125
|
-
}
|
|
126
|
-
)
|
|
174
|
+
# get the pattern frame from the stack
|
|
175
|
+
pattern_frame = get_active_continue_interrupted_pattern_frame(tracker.stack)
|
|
127
176
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
)
|
|
177
|
+
if pattern_frame is None:
|
|
178
|
+
structlogger.warning(
|
|
179
|
+
"action.continue_interrupted_flows.no_continue_interrupted_frame"
|
|
180
|
+
)
|
|
181
|
+
return []
|
|
134
182
|
|
|
135
|
-
|
|
183
|
+
interrupted_flow_ids = pattern_frame.interrupted_flow_ids
|
|
136
184
|
|
|
185
|
+
event_list: List[Event] = []
|
|
137
186
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
187
|
+
# cancel all interrupted flows
|
|
188
|
+
for flow_id in interrupted_flow_ids:
|
|
189
|
+
event_list.extend(self.cancel_flow(tracker, tracker.stack, flow_id))
|
|
141
190
|
|
|
142
|
-
|
|
191
|
+
return event_list + [
|
|
192
|
+
SlotSet(INTERRUPTED_FLOW_TO_CONTINUE_SLOT, None),
|
|
193
|
+
SlotSet(CONTINUE_INTERRUPTED_FLOW_CONFIRMATION_SLOT, None),
|
|
194
|
+
]
|
|
195
|
+
|
|
196
|
+
def cancel_flow(
|
|
143
197
|
self,
|
|
144
|
-
output_channel: OutputChannel,
|
|
145
|
-
nlg: NaturalLanguageGenerator,
|
|
146
198
|
tracker: DialogueStateTracker,
|
|
147
|
-
|
|
148
|
-
|
|
199
|
+
stack: DialogueStack,
|
|
200
|
+
flow_id: str,
|
|
149
201
|
) -> List[Event]:
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
# get all necessary slot values
|
|
153
|
-
multiple = tracker.get_slot(MULTIPLE_FLOWS_INTERRUPTED_SLOT)
|
|
154
|
-
selected_flow = tracker.get_slot(INTERRUPTED_FLOW_TO_CONTINUE_SLOT)
|
|
155
|
-
interrupted_flows = tracker.get_slot(INTERRUPTED_FLOWS_SLOT) or []
|
|
202
|
+
"""Cancels a flow by flow id."""
|
|
203
|
+
applied_events: List[Event] = []
|
|
156
204
|
|
|
157
|
-
|
|
205
|
+
frames_to_cancel, user_frame_to_cancel = self._collect_frames_to_cancel(
|
|
206
|
+
stack, flow_id
|
|
207
|
+
)
|
|
158
208
|
|
|
159
|
-
#
|
|
160
|
-
if
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
flow_id = interrupted_flows[0] if interrupted_flows else None
|
|
165
|
-
|
|
166
|
-
event_list = []
|
|
167
|
-
if flow_id:
|
|
168
|
-
# TODO: refactor to avoid creating a StartFlowCommand first
|
|
169
|
-
# resume the flow with the provided flow id
|
|
170
|
-
start_flow_command = StartFlowCommand(flow_id)
|
|
171
|
-
event_list = start_flow_command.resume_flow(
|
|
172
|
-
tracker, tracker.stack, original_user_frame
|
|
173
|
-
)
|
|
174
|
-
else:
|
|
175
|
-
await output_channel.send_text_message(
|
|
176
|
-
tracker.sender_id,
|
|
177
|
-
"You haven't selected a valid task to resume. "
|
|
178
|
-
"Please specify the task you would like to continue.",
|
|
209
|
+
# if the flow is not on the stack, do nothing
|
|
210
|
+
if user_frame_to_cancel is None:
|
|
211
|
+
structlogger.error(
|
|
212
|
+
"cancel_flow.no_user_frame_to_cancel",
|
|
213
|
+
flow_id=flow_id,
|
|
179
214
|
)
|
|
215
|
+
return []
|
|
180
216
|
|
|
181
|
-
|
|
217
|
+
frames_ids_to_cancel = [frame.frame_id for frame in frames_to_cancel]
|
|
182
218
|
|
|
219
|
+
stack.push(
|
|
220
|
+
CancelPatternFlowStackFrame(
|
|
221
|
+
canceled_name=flow_id,
|
|
222
|
+
canceled_frames=frames_ids_to_cancel,
|
|
223
|
+
)
|
|
224
|
+
)
|
|
183
225
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
226
|
+
# create flow cancelled event
|
|
227
|
+
applied_events.extend(
|
|
228
|
+
[
|
|
229
|
+
FlowCancelled(
|
|
230
|
+
user_frame_to_cancel.flow_id, user_frame_to_cancel.step_id
|
|
231
|
+
),
|
|
232
|
+
]
|
|
233
|
+
)
|
|
234
|
+
# create agent cancelled events for any agent frames that are on the stack
|
|
235
|
+
for frame in frames_to_cancel:
|
|
236
|
+
if isinstance(frame, AgentStackFrame):
|
|
237
|
+
applied_events.append(
|
|
238
|
+
AgentCancelled(
|
|
239
|
+
frame.agent_id, frame.flow_id, reason="Flow was cancelled"
|
|
240
|
+
)
|
|
241
|
+
)
|
|
187
242
|
|
|
188
|
-
|
|
189
|
-
self,
|
|
190
|
-
output_channel: OutputChannel,
|
|
191
|
-
nlg: NaturalLanguageGenerator,
|
|
192
|
-
tracker: DialogueStateTracker,
|
|
193
|
-
domain: Domain,
|
|
194
|
-
metadata: Optional[Dict[Text, Any]] = None,
|
|
195
|
-
) -> List[Event]:
|
|
196
|
-
from rasa.dialogue_understanding.commands import CancelFlowCommand
|
|
243
|
+
update_stack_events = tracker.create_stack_updated_events(stack)
|
|
197
244
|
|
|
198
|
-
|
|
245
|
+
return applied_events + update_stack_events
|
|
199
246
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
event_list.extend(
|
|
205
|
-
cancel_flow_command.cancel_flow(tracker, tracker.stack, flow_id)
|
|
206
|
-
)
|
|
247
|
+
def _collect_frames_to_cancel(
|
|
248
|
+
self, stack: DialogueStack, target_flow_id: str
|
|
249
|
+
) -> Tuple[List[DialogueStackFrame], Optional[UserFlowStackFrame]]:
|
|
250
|
+
"""Collect frames that need to be cancelled.
|
|
207
251
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
252
|
+
Args:
|
|
253
|
+
stack: The stack to collect frames from.
|
|
254
|
+
target_flow_id: The ID of the flow to cancel.
|
|
255
|
+
|
|
256
|
+
Returns:
|
|
257
|
+
A tuple containing (frames_to_cancel, frame_to_cancel).
|
|
258
|
+
"""
|
|
259
|
+
frames_to_cancel: List[DialogueStackFrame] = []
|
|
260
|
+
frame_found = False
|
|
261
|
+
frame_to_cancel = None
|
|
262
|
+
|
|
263
|
+
# collect all frames that belong to the target flow
|
|
264
|
+
# i.e. we want to cancel all frames that are on the stack and between
|
|
265
|
+
# the user flow frame that belongs to the target flow and the next user
|
|
266
|
+
# flow frame that belongs to a different flow
|
|
267
|
+
# this includes any pattern frames or agent frames as well
|
|
268
|
+
for frame in stack.frames:
|
|
269
|
+
if isinstance(frame, UserFlowStackFrame) and (
|
|
270
|
+
frame.frame_type == FlowStackFrameType.REGULAR
|
|
271
|
+
or frame.frame_type == FlowStackFrameType.INTERRUPT
|
|
272
|
+
):
|
|
273
|
+
if frame.flow_id == target_flow_id:
|
|
274
|
+
frames_to_cancel.append(frame)
|
|
275
|
+
frame_to_cancel = frame
|
|
276
|
+
frame_found = True
|
|
277
|
+
continue
|
|
278
|
+
elif frame_found:
|
|
279
|
+
break
|
|
280
|
+
|
|
281
|
+
if frame_found:
|
|
282
|
+
frames_to_cancel.append(frame)
|
|
283
|
+
|
|
284
|
+
return list(frames_to_cancel), frame_to_cancel
|