rasa-pro 3.12.22__py3-none-any.whl → 3.13.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rasa-pro might be problematic. Click here for more details.
- rasa/__main__.py +3 -4
- rasa/api.py +1 -1
- rasa/cli/dialogue_understanding_test.py +1 -1
- rasa/cli/e2e_test.py +1 -8
- rasa/cli/evaluate.py +2 -2
- rasa/cli/export.py +5 -3
- rasa/cli/inspect.py +7 -0
- rasa/cli/llm_fine_tuning.py +1 -1
- rasa/cli/project_templates/default/config.yml +5 -32
- rasa/cli/project_templates/{calm → default}/e2e_tests/cancelations/user_cancels_during_a_correction.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/cancelations/user_changes_mind_on_a_whim.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/corrections/user_corrects_contact_handle.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/corrections/user_corrects_contact_name.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/happy_paths/user_adds_contact_to_their_list.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/happy_paths/user_lists_contacts.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/happy_paths/user_removes_contact.yml +1 -1
- rasa/cli/project_templates/{calm → default}/e2e_tests/happy_paths/user_removes_contact_from_list.yml +1 -1
- rasa/cli/project_templates/default/endpoints.yml +18 -2
- rasa/cli/project_templates/defaults.py +133 -0
- rasa/cli/project_templates/tutorial/config.yml +1 -1
- rasa/cli/project_templates/tutorial/endpoints.yml +1 -1
- rasa/cli/run.py +1 -1
- rasa/cli/scaffold.py +2 -3
- rasa/cli/shell.py +6 -1
- rasa/cli/studio/download.py +0 -22
- rasa/cli/studio/link.py +36 -0
- rasa/cli/studio/pull.py +79 -0
- rasa/cli/studio/push.py +78 -0
- rasa/cli/studio/studio.py +12 -0
- rasa/cli/studio/train.py +1 -5
- rasa/cli/studio/upload.py +6 -4
- rasa/cli/train.py +5 -1
- rasa/cli/utils.py +1 -1
- rasa/cli/x.py +1 -1
- rasa/constants.py +2 -0
- rasa/core/__init__.py +0 -16
- rasa/core/actions/action.py +43 -29
- rasa/core/actions/action_repeat_bot_messages.py +18 -22
- rasa/core/actions/action_run_slot_rejections.py +1 -2
- rasa/core/agent.py +24 -3
- rasa/core/available_endpoints.py +146 -0
- rasa/core/brokers/kafka.py +4 -0
- rasa/core/brokers/pika.py +5 -2
- rasa/core/brokers/sql.py +1 -1
- rasa/core/channels/__init__.py +3 -0
- rasa/core/channels/botframework.py +2 -2
- rasa/core/channels/channel.py +2 -2
- rasa/core/channels/development_inspector.py +1 -1
- rasa/core/channels/facebook.py +1 -4
- rasa/core/channels/hangouts.py +8 -5
- rasa/core/channels/inspector/.eslintrc.cjs +12 -6
- rasa/core/channels/inspector/.prettierrc +5 -0
- rasa/core/channels/inspector/README.md +11 -5
- rasa/core/channels/inspector/dist/assets/{arc-9f75cc3b.js → arc-371401b1.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-7f34db23.js → blockDiagram-38ab4fdb-3f126156.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-948bab2c.js → c4Diagram-3d4e48cf-12f22eb7.js} +1 -1
- rasa/core/channels/inspector/dist/assets/channel-f1efda17.js +1 -0
- rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-53b0dd0e.js → classDiagram-70f12bd4-03b1d386.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-fdf789e7.js → classDiagram-v2-f2320105-84f69d63.js} +1 -1
- rasa/core/channels/inspector/dist/assets/clone-fdf164e2.js +1 -0
- rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-87c4ece5.js → createText-2e5e7dd3-ca47fd38.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-5a8b0749.js → edges-e0da2a9e-f837ca8a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-66da90e2.js → erDiagram-9861fffd-8717ac54.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-10044f05.js → flowDb-956e92f1-94f38b83.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-f338f66a.js → flowDiagram-66a62f08-b616f9fb.js} +1 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-7d7a1629.js +1 -0
- rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-b13140aa.js → flowchart-elk-definition-4a651766-f5d24bb8.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-f2b4a55a.js → ganttDiagram-c361ad54-b43ba8d9.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-dedc298d.js → gitGraphDiagram-72cf32ee-c3aafaa5.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{graph-4ede11ff.js → graph-0d0a2c10.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-3862675e-65549d37.js → index-3862675e-58ea0305.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-3a23e736.js → index-cce6f8a1.js} +123 -123
- rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-65439671.js → infoDiagram-f8f76790-b8f60461.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-56d03d98.js → journeyDiagram-49397b02-95be5545.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-dd48f7f4.js → layout-da885b9b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{line-1569ad2c.js → line-f1c817d3.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-48bf4935.js → linear-d42801e6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-688504c1.js → mindmap-definition-fc14e90a-a38923a6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-78b6d7e6.js → pieDiagram-8a3498a8-ca6e71e9.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-048b84b3.js → quadrantDiagram-120e2f19-b290dae9.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-dd67f107.js → requirementDiagram-deff3bca-03f02ceb.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-8128436e.js → sankeyDiagram-04a897e0-c49eee40.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-1a0d1461.js → sequenceDiagram-704730f1-b2cd6a3d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-46d388ed.js → stateDiagram-587899a1-e53a2028.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-ea42951a.js → stateDiagram-v2-d93cdb3a-e1982a03.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-7427ed0c.js → styles-6aaf32cf-d0226ca5.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-9a916d00-ff5e5a16.js → styles-9a916d00-0e21dc00.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-c10674c1-7b3680cf.js → styles-c10674c1-9588494e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-f860f2ad.js → svgDrawCommon-08f97a94-be478d4f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-2eebf0c8.js → timeline-definition-85554ec2-74631749.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-5d7f4e96.js → xychartDiagram-e933f94c-a043552f.js} +1 -1
- rasa/core/channels/inspector/dist/index.html +1 -1
- rasa/core/channels/inspector/package.json +3 -1
- rasa/core/channels/inspector/src/App.tsx +91 -90
- rasa/core/channels/inspector/src/components/Chat.tsx +45 -41
- rasa/core/channels/inspector/src/components/DiagramFlow.tsx +40 -40
- rasa/core/channels/inspector/src/components/DialogueInformation.tsx +57 -57
- rasa/core/channels/inspector/src/components/DialogueStack.tsx +36 -27
- rasa/core/channels/inspector/src/components/ExpandIcon.tsx +4 -4
- rasa/core/channels/inspector/src/components/FullscreenButton.tsx +7 -7
- rasa/core/channels/inspector/src/components/LoadingSpinner.tsx +28 -12
- rasa/core/channels/inspector/src/components/NoActiveFlow.tsx +9 -9
- rasa/core/channels/inspector/src/components/RasaLogo.tsx +5 -5
- rasa/core/channels/inspector/src/components/RecruitmentPanel.tsx +55 -60
- rasa/core/channels/inspector/src/components/SaraDiagrams.tsx +5 -5
- rasa/core/channels/inspector/src/components/Slots.tsx +22 -22
- rasa/core/channels/inspector/src/components/Welcome.tsx +28 -31
- rasa/core/channels/inspector/src/helpers/audio/audiostream.ts +245 -0
- rasa/core/channels/inspector/src/helpers/audio/microphone-processor.js +12 -0
- rasa/core/channels/inspector/src/helpers/audio/playback-processor.js +36 -0
- rasa/core/channels/inspector/src/helpers/conversation.ts +7 -7
- rasa/core/channels/inspector/src/helpers/formatters.test.ts +181 -181
- rasa/core/channels/inspector/src/helpers/formatters.ts +111 -111
- rasa/core/channels/inspector/src/helpers/utils.ts +78 -61
- rasa/core/channels/inspector/src/main.tsx +8 -8
- rasa/core/channels/inspector/src/theme/Button/Button.ts +8 -8
- rasa/core/channels/inspector/src/theme/Heading/Heading.ts +7 -7
- rasa/core/channels/inspector/src/theme/Input/Input.ts +9 -9
- rasa/core/channels/inspector/src/theme/Link/Link.ts +6 -6
- rasa/core/channels/inspector/src/theme/Modal/Modal.ts +13 -13
- rasa/core/channels/inspector/src/theme/Table/Table.tsx +10 -10
- rasa/core/channels/inspector/src/theme/Tooltip/Tooltip.ts +5 -5
- rasa/core/channels/inspector/src/theme/base/breakpoints.ts +7 -7
- rasa/core/channels/inspector/src/theme/base/colors.ts +64 -64
- rasa/core/channels/inspector/src/theme/base/fonts/fontFaces.css +21 -18
- rasa/core/channels/inspector/src/theme/base/radii.ts +8 -8
- rasa/core/channels/inspector/src/theme/base/shadows.ts +5 -5
- rasa/core/channels/inspector/src/theme/base/sizes.ts +5 -5
- rasa/core/channels/inspector/src/theme/base/space.ts +12 -12
- rasa/core/channels/inspector/src/theme/base/styles.ts +5 -5
- rasa/core/channels/inspector/src/theme/base/typography.ts +12 -12
- rasa/core/channels/inspector/src/theme/base/zIndices.ts +3 -3
- rasa/core/channels/inspector/src/theme/index.ts +38 -38
- rasa/core/channels/inspector/src/types.ts +56 -50
- rasa/core/channels/inspector/yarn.lock +5 -0
- rasa/core/channels/mattermost.py +1 -1
- rasa/core/channels/rasa_chat.py +2 -4
- rasa/core/channels/rest.py +5 -4
- rasa/core/channels/socketio.py +56 -41
- rasa/core/channels/studio_chat.py +329 -68
- rasa/core/channels/vier_cvg.py +1 -2
- rasa/core/channels/voice_ready/audiocodes.py +4 -11
- rasa/core/channels/voice_ready/jambonz.py +5 -6
- rasa/core/channels/voice_ready/twilio_voice.py +13 -12
- rasa/core/channels/voice_ready/utils.py +22 -0
- rasa/core/channels/voice_stream/audiocodes.py +13 -16
- rasa/core/channels/voice_stream/browser_audio.py +1 -1
- rasa/core/channels/voice_stream/genesys.py +37 -18
- rasa/core/channels/voice_stream/jambonz.py +232 -0
- rasa/core/channels/voice_stream/tts/__init__.py +8 -0
- rasa/core/channels/voice_stream/twilio_media_streams.py +15 -12
- rasa/core/channels/voice_stream/voice_channel.py +71 -27
- rasa/core/concurrent_lock_store.py +24 -10
- rasa/core/evaluation/marker_tracker_loader.py +1 -1
- rasa/core/exporter.py +37 -1
- rasa/core/http_interpreter.py +3 -7
- rasa/core/information_retrieval/faiss.py +18 -11
- rasa/core/information_retrieval/ingestion/faq_parser.py +158 -0
- rasa/core/jobs.py +2 -1
- rasa/core/lock_store.py +151 -60
- rasa/core/nlg/contextual_response_rephraser.py +17 -7
- rasa/core/nlg/generator.py +5 -22
- rasa/core/nlg/interpolator.py +2 -3
- rasa/core/nlg/response.py +6 -43
- rasa/core/nlg/summarize.py +1 -1
- rasa/core/nlg/translate.py +0 -8
- rasa/core/policies/enterprise_search_policy.py +305 -189
- rasa/core/policies/enterprise_search_policy_config.py +241 -0
- rasa/core/policies/enterprise_search_prompt_with_relevancy_check_and_citation_template.jinja2 +67 -0
- rasa/core/policies/flow_policy.py +1 -1
- rasa/core/policies/flows/flow_executor.py +102 -17
- rasa/core/policies/intentless_policy.py +56 -17
- rasa/core/processor.py +70 -49
- rasa/core/run.py +33 -11
- rasa/core/tracker_stores/__init__.py +0 -0
- rasa/core/{auth_retry_tracker_store.py → tracker_stores/auth_retry_tracker_store.py} +66 -1
- rasa/core/tracker_stores/dynamo_tracker_store.py +256 -0
- rasa/core/tracker_stores/mongo_tracker_store.py +223 -0
- rasa/core/tracker_stores/redis_tracker_store.py +252 -0
- rasa/core/tracker_stores/sql_tracker_store.py +582 -0
- rasa/core/tracker_stores/tracker_store.py +839 -0
- rasa/core/training/interactive.py +1 -1
- rasa/core/utils.py +24 -95
- rasa/dialogue_understanding/coexistence/intent_based_router.py +2 -1
- rasa/dialogue_understanding/coexistence/llm_based_router.py +13 -11
- rasa/dialogue_understanding/commands/can_not_handle_command.py +2 -0
- rasa/dialogue_understanding/commands/cancel_flow_command.py +3 -1
- rasa/dialogue_understanding/commands/chit_chat_answer_command.py +2 -0
- rasa/dialogue_understanding/commands/clarify_command.py +6 -2
- rasa/dialogue_understanding/commands/command_syntax_manager.py +1 -0
- rasa/dialogue_understanding/commands/correct_slots_command.py +5 -6
- rasa/dialogue_understanding/commands/error_command.py +1 -1
- rasa/dialogue_understanding/commands/human_handoff_command.py +3 -3
- rasa/dialogue_understanding/commands/knowledge_answer_command.py +2 -0
- rasa/dialogue_understanding/commands/repeat_bot_messages_command.py +2 -0
- rasa/dialogue_understanding/commands/set_slot_command.py +8 -4
- rasa/dialogue_understanding/commands/skip_question_command.py +3 -3
- rasa/dialogue_understanding/commands/start_flow_command.py +7 -3
- rasa/dialogue_understanding/generator/__init__.py +7 -1
- rasa/dialogue_understanding/generator/command_generator.py +4 -2
- rasa/dialogue_understanding/generator/command_parser.py +2 -2
- rasa/dialogue_understanding/generator/command_parser_validator.py +63 -0
- rasa/dialogue_understanding/generator/llm_based_command_generator.py +1 -2
- rasa/dialogue_understanding/generator/multi_step/multi_step_llm_command_generator.py +3 -2
- rasa/dialogue_understanding/generator/nlu_command_adapter.py +2 -2
- rasa/dialogue_understanding/generator/prompt_templates/command_prompt_template.jinja2 +0 -2
- rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v2_claude_3_5_sonnet_20240620_template.jinja2 +1 -0
- rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v2_gpt_4o_2024_11_20_template.jinja2 +1 -0
- rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v3_claude_3_5_sonnet_20240620_template.jinja2 +79 -0
- rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v3_gpt_4o_2024_11_20_template.jinja2 +79 -0
- rasa/dialogue_understanding/generator/single_step/compact_llm_command_generator.py +26 -461
- rasa/dialogue_understanding/generator/single_step/search_ready_llm_command_generator.py +147 -0
- rasa/dialogue_understanding/generator/single_step/single_step_based_llm_command_generator.py +461 -0
- rasa/dialogue_understanding/generator/single_step/single_step_llm_command_generator.py +20 -64
- rasa/dialogue_understanding/patterns/cancel.py +1 -2
- rasa/dialogue_understanding/patterns/clarify.py +1 -1
- rasa/dialogue_understanding/patterns/correction.py +2 -2
- rasa/dialogue_understanding/patterns/default_flows_for_patterns.yml +42 -27
- rasa/dialogue_understanding/patterns/domain_for_patterns.py +190 -0
- rasa/dialogue_understanding/processor/command_processor.py +6 -7
- rasa/dialogue_understanding_test/command_metric_calculation.py +7 -40
- rasa/dialogue_understanding_test/command_metrics.py +38 -0
- rasa/dialogue_understanding_test/du_test_case.py +58 -25
- rasa/dialogue_understanding_test/du_test_result.py +228 -132
- rasa/dialogue_understanding_test/du_test_runner.py +11 -2
- rasa/dialogue_understanding_test/du_test_schema.yml +3 -3
- rasa/dialogue_understanding_test/io.py +35 -8
- rasa/e2e_test/constants.py +1 -1
- rasa/e2e_test/e2e_test_runner.py +1 -1
- rasa/e2e_test/e2e_test_schema.yml +3 -3
- rasa/engine/constants.py +1 -1
- rasa/engine/graph.py +2 -2
- rasa/engine/recipes/default_recipe.py +1 -1
- rasa/engine/validation.py +3 -2
- rasa/hooks.py +2 -30
- rasa/llm_fine_tuning/paraphrasing/conversation_rephraser.py +2 -6
- rasa/model_manager/model_api.py +89 -1
- rasa/model_manager/runner_service.py +20 -4
- rasa/model_manager/socket_bridge.py +0 -7
- rasa/model_manager/trainer_service.py +10 -4
- rasa/plugin.py +2 -15
- rasa/privacy/__init__.py +0 -0
- rasa/privacy/constants.py +83 -0
- rasa/privacy/event_broker_utils.py +77 -0
- rasa/privacy/privacy_config.py +281 -0
- rasa/privacy/privacy_config_schema.json +86 -0
- rasa/privacy/privacy_filter.py +393 -0
- rasa/privacy/privacy_manager.py +594 -0
- rasa/server.py +23 -2
- rasa/shared/constants.py +17 -0
- rasa/shared/core/command_payload_reader.py +1 -5
- rasa/shared/core/constants.py +4 -3
- rasa/shared/core/domain.py +172 -11
- rasa/shared/core/events.py +100 -6
- rasa/shared/core/flows/flow.py +30 -5
- rasa/shared/core/flows/flow_step.py +19 -3
- rasa/shared/core/flows/flow_step_links.py +15 -0
- rasa/shared/core/flows/flow_step_sequence.py +6 -0
- rasa/shared/core/flows/flows_yaml_schema.json +3 -0
- rasa/shared/core/flows/nlu_trigger.py +13 -0
- rasa/shared/core/flows/steps/action.py +7 -4
- rasa/shared/core/flows/steps/call.py +11 -4
- rasa/shared/core/flows/steps/collect.py +71 -6
- rasa/shared/core/flows/steps/internal.py +6 -1
- rasa/shared/core/flows/steps/link.py +7 -4
- rasa/shared/core/flows/steps/no_operation.py +7 -4
- rasa/shared/core/flows/steps/set_slots.py +8 -4
- rasa/shared/core/flows/validation.py +25 -5
- rasa/shared/core/flows/yaml_flows_io.py +106 -5
- rasa/shared/core/slots.py +29 -1
- rasa/shared/core/trackers.py +21 -10
- rasa/shared/core/training_data/story_reader/yaml_story_reader.py +1 -4
- rasa/shared/importers/importer.py +8 -0
- rasa/shared/providers/_configs/azure_openai_client_config.py +2 -2
- rasa/shared/providers/_configs/default_litellm_client_config.py +1 -1
- rasa/shared/providers/_configs/huggingface_local_embedding_client_config.py +1 -1
- rasa/shared/providers/_configs/openai_client_config.py +1 -1
- rasa/shared/providers/_configs/rasa_llm_client_config.py +1 -1
- rasa/shared/providers/_configs/self_hosted_llm_client_config.py +1 -1
- rasa/shared/providers/_configs/utils.py +0 -99
- rasa/shared/providers/llm/default_litellm_llm_client.py +2 -2
- rasa/shared/utils/common.py +43 -1
- rasa/shared/utils/configs.py +110 -0
- rasa/shared/utils/constants.py +0 -3
- rasa/shared/utils/llm.py +245 -8
- rasa/shared/utils/pykwalify_extensions.py +0 -9
- rasa/shared/utils/yaml.py +32 -0
- rasa/studio/constants.py +1 -0
- rasa/studio/data_handler.py +33 -12
- rasa/studio/download.py +117 -435
- rasa/studio/link.py +211 -0
- rasa/studio/prompts.py +221 -0
- rasa/studio/pull/__init__.py +0 -0
- rasa/studio/pull/data.py +222 -0
- rasa/studio/pull/domains.py +60 -0
- rasa/studio/pull/pull.py +239 -0
- rasa/studio/push.py +138 -0
- rasa/studio/results_logger.py +6 -1
- rasa/studio/train.py +1 -1
- rasa/studio/upload.py +243 -72
- rasa/studio/utils.py +33 -0
- rasa/telemetry.py +83 -26
- rasa/tracing/config.py +4 -5
- rasa/tracing/constants.py +19 -1
- rasa/tracing/instrumentation/attribute_extractors.py +68 -16
- rasa/tracing/instrumentation/instrumentation.py +54 -3
- rasa/tracing/instrumentation/metrics.py +98 -15
- rasa/tracing/metric_instrument_provider.py +75 -3
- rasa/utils/common.py +43 -22
- rasa/utils/endpoints.py +22 -1
- rasa/utils/licensing.py +2 -3
- rasa/utils/log_utils.py +1 -45
- rasa/validator.py +2 -8
- rasa/version.py +1 -1
- {rasa_pro-3.12.22.dist-info → rasa_pro-3.13.0.dist-info}/METADATA +11 -12
- {rasa_pro-3.12.22.dist-info → rasa_pro-3.13.0.dist-info}/RECORD +333 -309
- rasa/anonymization/__init__.py +0 -2
- rasa/anonymization/anonymisation_rule_yaml_reader.py +0 -91
- rasa/anonymization/anonymization_pipeline.py +0 -286
- rasa/anonymization/anonymization_rule_executor.py +0 -266
- rasa/anonymization/anonymization_rule_orchestrator.py +0 -119
- rasa/anonymization/schemas/config.yml +0 -47
- rasa/anonymization/utils.py +0 -118
- rasa/cli/project_templates/calm/config.yml +0 -10
- rasa/cli/project_templates/calm/credentials.yml +0 -33
- rasa/cli/project_templates/calm/endpoints.yml +0 -58
- rasa/cli/project_templates/default/actions/actions.py +0 -27
- rasa/cli/project_templates/default/data/nlu.yml +0 -91
- rasa/cli/project_templates/default/data/rules.yml +0 -13
- rasa/cli/project_templates/default/data/stories.yml +0 -30
- rasa/cli/project_templates/default/domain.yml +0 -34
- rasa/cli/project_templates/default/tests/test_stories.yml +0 -91
- rasa/core/channels/inspector/dist/assets/channel-dfa68278.js +0 -1
- rasa/core/channels/inspector/dist/assets/clone-edb7f119.js +0 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-65e7c670.js +0 -1
- rasa/core/channels/inspector/src/helpers/audiostream.ts +0 -191
- rasa/core/tracker_store.py +0 -1792
- /rasa/cli/project_templates/{calm → default}/actions/action_template.py +0 -0
- /rasa/cli/project_templates/{calm → default}/actions/add_contact.py +0 -0
- /rasa/cli/project_templates/{calm → default}/actions/db.py +0 -0
- /rasa/cli/project_templates/{calm → default}/actions/list_contacts.py +0 -0
- /rasa/cli/project_templates/{calm → default}/actions/remove_contact.py +0 -0
- /rasa/cli/project_templates/{calm → default}/data/flows/add_contact.yml +0 -0
- /rasa/cli/project_templates/{calm → default}/data/flows/list_contacts.yml +0 -0
- /rasa/cli/project_templates/{calm → default}/data/flows/remove_contact.yml +0 -0
- /rasa/cli/project_templates/{calm → default}/db/contacts.json +0 -0
- /rasa/cli/project_templates/{calm → default}/domain/add_contact.yml +0 -0
- /rasa/cli/project_templates/{calm → default}/domain/list_contacts.yml +0 -0
- /rasa/cli/project_templates/{calm → default}/domain/remove_contact.yml +0 -0
- /rasa/cli/project_templates/{calm → default}/domain/shared.yml +0 -0
- /rasa/{cli/project_templates/calm/actions → core/information_retrieval/ingestion}/__init__.py +0 -0
- {rasa_pro-3.12.22.dist-info → rasa_pro-3.13.0.dist-info}/NOTICE +0 -0
- {rasa_pro-3.12.22.dist-info → rasa_pro-3.13.0.dist-info}/WHEEL +0 -0
- {rasa_pro-3.12.22.dist-info → rasa_pro-3.13.0.dist-info}/entry_points.txt +0 -0
|
@@ -4,32 +4,22 @@ from typing import Any, Dict, Literal, Optional, Text
|
|
|
4
4
|
import structlog
|
|
5
5
|
|
|
6
6
|
from rasa.dialogue_understanding.commands.command_syntax_manager import (
|
|
7
|
-
CommandSyntaxManager,
|
|
8
7
|
CommandSyntaxVersion,
|
|
9
8
|
)
|
|
10
|
-
from rasa.dialogue_understanding.generator.
|
|
11
|
-
|
|
12
|
-
FLOW_RETRIEVAL_KEY,
|
|
13
|
-
LLM_CONFIG_KEY,
|
|
14
|
-
USER_INPUT_CONFIG_KEY,
|
|
15
|
-
)
|
|
16
|
-
from rasa.dialogue_understanding.generator.flow_retrieval import FlowRetrieval
|
|
17
|
-
from rasa.dialogue_understanding.generator.single_step.compact_llm_command_generator import ( # noqa: E501
|
|
18
|
-
CompactLLMCommandGenerator,
|
|
9
|
+
from rasa.dialogue_understanding.generator.single_step.single_step_based_llm_command_generator import ( # noqa: E501
|
|
10
|
+
SingleStepBasedLLMCommandGenerator,
|
|
19
11
|
)
|
|
20
12
|
from rasa.engine.recipes.default_recipe import DefaultV1Recipe
|
|
21
13
|
from rasa.engine.storage.resource import Resource
|
|
22
14
|
from rasa.engine.storage.storage import ModelStorage
|
|
23
15
|
from rasa.shared.constants import (
|
|
24
|
-
EMBEDDINGS_CONFIG_KEY,
|
|
25
16
|
PROMPT_CONFIG_KEY,
|
|
26
17
|
PROMPT_TEMPLATE_CONFIG_KEY,
|
|
27
18
|
)
|
|
28
|
-
from rasa.shared.utils.
|
|
29
|
-
from rasa.shared.utils.io import deep_container_fingerprint
|
|
19
|
+
from rasa.shared.utils.io import raise_deprecation_warning
|
|
30
20
|
from rasa.shared.utils.llm import (
|
|
21
|
+
check_prompt_config_keys_and_warn_if_deprecated,
|
|
31
22
|
get_prompt_template,
|
|
32
|
-
resolve_model_client_config,
|
|
33
23
|
)
|
|
34
24
|
|
|
35
25
|
DEFAULT_COMMAND_PROMPT_TEMPLATE = importlib.resources.read_text(
|
|
@@ -47,7 +37,7 @@ structlogger = structlog.get_logger()
|
|
|
47
37
|
],
|
|
48
38
|
is_trainable=True,
|
|
49
39
|
)
|
|
50
|
-
class SingleStepLLMCommandGenerator(
|
|
40
|
+
class SingleStepLLMCommandGenerator(SingleStepBasedLLMCommandGenerator):
|
|
51
41
|
"""A single step LLM-based command generator."""
|
|
52
42
|
|
|
53
43
|
def __init__(
|
|
@@ -58,6 +48,14 @@ class SingleStepLLMCommandGenerator(CompactLLMCommandGenerator):
|
|
|
58
48
|
prompt_template: Optional[Text] = None,
|
|
59
49
|
**kwargs: Any,
|
|
60
50
|
) -> None:
|
|
51
|
+
raise_deprecation_warning(
|
|
52
|
+
message=(
|
|
53
|
+
"Support for `SingleStepLLMCommandGenerator` will be removed in Rasa "
|
|
54
|
+
"`4.0.0`. Please modify your assistant's configuration to use the "
|
|
55
|
+
"`CompactLLMCommandGenerator` or `SearchReadyLLMCommandGenerator` "
|
|
56
|
+
"instead."
|
|
57
|
+
)
|
|
58
|
+
)
|
|
61
59
|
super().__init__(
|
|
62
60
|
config,
|
|
63
61
|
model_storage,
|
|
@@ -66,64 +64,22 @@ class SingleStepLLMCommandGenerator(CompactLLMCommandGenerator):
|
|
|
66
64
|
**kwargs,
|
|
67
65
|
)
|
|
68
66
|
|
|
69
|
-
#
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
"single_step_llm_command_generator.init",
|
|
73
|
-
event_info=(
|
|
74
|
-
"The config parameter 'prompt' is deprecated "
|
|
75
|
-
"and will be removed in Rasa 4.0.0. "
|
|
76
|
-
"Please use the config parameter 'prompt_template' instead. "
|
|
77
|
-
),
|
|
78
|
-
)
|
|
79
|
-
|
|
80
|
-
# Set the command syntax version to v1
|
|
81
|
-
CommandSyntaxManager.set_syntax_version(
|
|
82
|
-
self.get_component_command_syntax_version()
|
|
67
|
+
# Warn if the prompt config key is used to set the prompt template
|
|
68
|
+
check_prompt_config_keys_and_warn_if_deprecated(
|
|
69
|
+
config, "single_step_llm_command_generator"
|
|
83
70
|
)
|
|
84
71
|
|
|
85
|
-
@staticmethod
|
|
86
|
-
def get_default_config() -> Dict[str, Any]:
|
|
87
|
-
"""The component's default config (see parent class for full docstring)."""
|
|
88
|
-
return {
|
|
89
|
-
PROMPT_CONFIG_KEY: None, # Legacy
|
|
90
|
-
PROMPT_TEMPLATE_CONFIG_KEY: None,
|
|
91
|
-
USER_INPUT_CONFIG_KEY: None,
|
|
92
|
-
LLM_CONFIG_KEY: None,
|
|
93
|
-
FLOW_RETRIEVAL_KEY: FlowRetrieval.get_default_config(),
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
@classmethod
|
|
97
|
-
def fingerprint_addon(cls: Any, config: Dict[str, Any]) -> Optional[str]:
|
|
98
|
-
"""Add a fingerprint for the graph."""
|
|
99
|
-
prompt_template = cls._resolve_component_prompt_template(
|
|
100
|
-
config, log_context=LOG_COMPONENT_SOURCE_METHOD_FINGERPRINT_ADDON
|
|
101
|
-
)
|
|
102
|
-
llm_config = resolve_model_client_config(
|
|
103
|
-
config.get(LLM_CONFIG_KEY), SingleStepLLMCommandGenerator.__name__
|
|
104
|
-
)
|
|
105
|
-
embedding_config = resolve_model_client_config(
|
|
106
|
-
config.get(FLOW_RETRIEVAL_KEY, {}).get(EMBEDDINGS_CONFIG_KEY),
|
|
107
|
-
FlowRetrieval.__name__,
|
|
108
|
-
)
|
|
109
|
-
return deep_container_fingerprint(
|
|
110
|
-
[prompt_template, llm_config, embedding_config]
|
|
111
|
-
)
|
|
112
|
-
|
|
113
|
-
@staticmethod
|
|
114
|
-
def get_default_llm_config() -> Dict[str, Any]:
|
|
115
|
-
"""Get the default LLM config for the command generator."""
|
|
116
|
-
return DEFAULT_LLM_CONFIG
|
|
117
|
-
|
|
118
72
|
@staticmethod
|
|
119
73
|
def get_component_command_syntax_version() -> CommandSyntaxVersion:
|
|
120
74
|
return CommandSyntaxVersion.v1
|
|
121
75
|
|
|
122
|
-
@
|
|
76
|
+
@classmethod
|
|
123
77
|
def _resolve_component_prompt_template(
|
|
78
|
+
cls: Any,
|
|
124
79
|
config: Dict[str, Any],
|
|
125
80
|
prompt_template: Optional[str] = None,
|
|
126
81
|
log_context: Optional[Literal["init", "fingerprint_addon"]] = None,
|
|
82
|
+
log_source_component: Optional[str] = "SingleStepLLMCommandGenerator",
|
|
127
83
|
) -> Optional[str]:
|
|
128
84
|
"""Get the prompt template from the config or the default prompt template."""
|
|
129
85
|
# Case when model is being loaded
|
|
@@ -143,6 +99,6 @@ class SingleStepLLMCommandGenerator(CompactLLMCommandGenerator):
|
|
|
143
99
|
return get_prompt_template(
|
|
144
100
|
prompt_template_path,
|
|
145
101
|
DEFAULT_COMMAND_PROMPT_TEMPLATE,
|
|
146
|
-
log_source_component=
|
|
102
|
+
log_source_component=log_source_component,
|
|
147
103
|
log_source_method=log_context,
|
|
148
104
|
)
|
|
@@ -90,7 +90,7 @@ class ActionCancelFlow(action.Action):
|
|
|
90
90
|
return []
|
|
91
91
|
|
|
92
92
|
if not isinstance(top, CancelPatternFlowStackFrame):
|
|
93
|
-
structlogger.warning("action.cancel_flow.no_cancel_frame"
|
|
93
|
+
structlogger.warning("action.cancel_flow.no_cancel_frame")
|
|
94
94
|
return []
|
|
95
95
|
|
|
96
96
|
for canceled_frame_id in top.canceled_frames:
|
|
@@ -105,7 +105,6 @@ class ActionCancelFlow(action.Action):
|
|
|
105
105
|
else:
|
|
106
106
|
structlogger.warning(
|
|
107
107
|
"action.cancel_flow.frame_not_found",
|
|
108
|
-
dialogue_stack=stack,
|
|
109
108
|
frame_id=canceled_frame_id,
|
|
110
109
|
)
|
|
111
110
|
|
|
@@ -89,7 +89,7 @@ class ActionClarifyFlows(action.Action):
|
|
|
89
89
|
return []
|
|
90
90
|
|
|
91
91
|
if not isinstance(top, ClarifyPatternFlowStackFrame):
|
|
92
|
-
structlogger.warning("action.clarify_flows.no_clarification_frame"
|
|
92
|
+
structlogger.warning("action.clarify_flows.no_clarification_frame")
|
|
93
93
|
return []
|
|
94
94
|
|
|
95
95
|
options_string = self.assemble_options_string(top.names)
|
|
@@ -114,7 +114,8 @@ class ActionCorrectFlowSlot(action.Action):
|
|
|
114
114
|
|
|
115
115
|
if not isinstance(top, CorrectionPatternFlowStackFrame):
|
|
116
116
|
structlogger.warning(
|
|
117
|
-
"action.correct_flow_slot.no_correction_frame",
|
|
117
|
+
"action.correct_flow_slot.no_correction_frame",
|
|
118
|
+
top=top, # no PII
|
|
118
119
|
)
|
|
119
120
|
return []
|
|
120
121
|
|
|
@@ -246,7 +247,6 @@ def reset_stack_on_tracker_to_prior_state(
|
|
|
246
247
|
"action.correct_flow_slot.no_target_frame_found",
|
|
247
248
|
reset_step_id=reset_step_id,
|
|
248
249
|
reset_flow_id=reset_flow_id,
|
|
249
|
-
stack_to_reset_to=stack_to_reset_to,
|
|
250
250
|
)
|
|
251
251
|
return tracker.stack
|
|
252
252
|
|
|
@@ -93,6 +93,11 @@ responses:
|
|
|
93
93
|
metadata:
|
|
94
94
|
rephrase: True
|
|
95
95
|
|
|
96
|
+
utter_no_relevant_answer_found:
|
|
97
|
+
- text: I’m sorry, I can’t help with that.
|
|
98
|
+
metadata:
|
|
99
|
+
rephrase: True
|
|
100
|
+
|
|
96
101
|
utter_skip_question_answer:
|
|
97
102
|
- text: I'm here to provide you with the best assistance, and in order to do so, I kindly request that we complete this step together. Your input is essential for a seamless experience!
|
|
98
103
|
metadata:
|
|
@@ -129,23 +134,29 @@ flows:
|
|
|
129
134
|
- action: utter_flow_cancelled_rasa
|
|
130
135
|
|
|
131
136
|
pattern_cannot_handle:
|
|
132
|
-
description:
|
|
133
|
-
|
|
134
|
-
name: pattern cannot handle
|
|
137
|
+
description: Conversation repair flow for addressing failed command generation scenarios
|
|
138
|
+
name: pattern_cannot_handle
|
|
135
139
|
steps:
|
|
136
140
|
- noop: true
|
|
137
141
|
next:
|
|
138
|
-
#
|
|
139
|
-
|
|
142
|
+
# Fallback for ChitChat command when IntentlessPolicy isn't set, but
|
|
143
|
+
# pattern_chitchat invokes action_trigger_chitchat
|
|
144
|
+
- if: context.reason is "cannot_handle_chitchat"
|
|
140
145
|
then:
|
|
141
146
|
- action: utter_cannot_handle
|
|
142
147
|
next: "END"
|
|
143
|
-
#
|
|
144
|
-
- if:
|
|
148
|
+
# Fallback for things that are not supported
|
|
149
|
+
- if: context.reason is "cannot_handle_not_supported"
|
|
145
150
|
then:
|
|
146
151
|
- action: utter_cannot_handle
|
|
147
152
|
next: END
|
|
148
|
-
#
|
|
153
|
+
# Fallback when no relevant answer to the user query has been found.
|
|
154
|
+
# This is used by the EnterpriseSearchPolicy.
|
|
155
|
+
- if: context.reason is "cannot_handle_no_relevant_answer"
|
|
156
|
+
then:
|
|
157
|
+
- action: utter_no_relevant_answer_found
|
|
158
|
+
next: END
|
|
159
|
+
# Default
|
|
149
160
|
- else:
|
|
150
161
|
- action: utter_ask_rephrase
|
|
151
162
|
next: END
|
|
@@ -154,7 +165,9 @@ flows:
|
|
|
154
165
|
description: Conversation repair flow for off-topic interactions that won't disrupt the main conversation
|
|
155
166
|
name: pattern chitchat
|
|
156
167
|
steps:
|
|
157
|
-
- action:
|
|
168
|
+
- action: utter_cannot_handle
|
|
169
|
+
# To enable free-form response use:
|
|
170
|
+
# - action: utter_free_chitchat_response
|
|
158
171
|
|
|
159
172
|
pattern_clarification:
|
|
160
173
|
description: Conversation repair flow for handling ambiguous requests that could match multiple flows
|
|
@@ -219,15 +232,15 @@ flows:
|
|
|
219
232
|
|
|
220
233
|
pattern_internal_error:
|
|
221
234
|
description: Conversation repair flow for informing users about internal errors
|
|
222
|
-
name:
|
|
235
|
+
name: pattern_internal_error
|
|
223
236
|
steps:
|
|
224
237
|
- noop: true
|
|
225
238
|
next:
|
|
226
|
-
- if:
|
|
239
|
+
- if: context.error_type is "rasa_internal_error_user_input_too_long"
|
|
227
240
|
then:
|
|
228
241
|
- action: utter_user_input_too_long_error_rasa
|
|
229
242
|
next: END
|
|
230
|
-
- if:
|
|
243
|
+
- if: context.error_type is "rasa_internal_error_user_input_empty"
|
|
231
244
|
then:
|
|
232
245
|
- action: utter_user_input_empty_error_rasa
|
|
233
246
|
next: END
|
|
@@ -236,7 +249,7 @@ flows:
|
|
|
236
249
|
next: END
|
|
237
250
|
|
|
238
251
|
pattern_repeat_bot_messages:
|
|
239
|
-
description:
|
|
252
|
+
description: Conversation repair flow for repeating previous messages
|
|
240
253
|
name: pattern repeat bot messages
|
|
241
254
|
steps:
|
|
242
255
|
- action: action_repeat_bot_messages
|
|
@@ -281,23 +294,25 @@ flows:
|
|
|
281
294
|
- noop: true
|
|
282
295
|
next:
|
|
283
296
|
- if: "slots.consecutive_silence_timeouts = 0.0"
|
|
284
|
-
then:
|
|
285
|
-
- set_slots:
|
|
286
|
-
- consecutive_silence_timeouts: 1.0
|
|
287
|
-
- action: action_repeat_bot_messages
|
|
288
|
-
next: END
|
|
297
|
+
then: set_slots_consecutive_silence_timeouts
|
|
289
298
|
- if: "slots.consecutive_silence_timeouts = 1.0"
|
|
290
|
-
then:
|
|
291
|
-
- set_slots:
|
|
292
|
-
- consecutive_silence_timeouts: 2.0
|
|
293
|
-
- action: utter_ask_still_there
|
|
294
|
-
next: END
|
|
299
|
+
then: set_slots_consecutive_silence_timeouts_2
|
|
295
300
|
- if: "slots.consecutive_silence_timeouts > 1.0"
|
|
296
|
-
then:
|
|
297
|
-
- action: utter_inform_hangup
|
|
298
|
-
- action: action_hangup
|
|
299
|
-
next: END
|
|
301
|
+
then: message_utter_inform_hangup
|
|
300
302
|
- else: END
|
|
303
|
+
- id: set_slots_consecutive_silence_timeouts
|
|
304
|
+
set_slots:
|
|
305
|
+
- consecutive_silence_timeouts: 1.0
|
|
306
|
+
- action: action_repeat_bot_messages
|
|
307
|
+
next: END
|
|
308
|
+
- id: set_slots_consecutive_silence_timeouts_2
|
|
309
|
+
set_slots:
|
|
310
|
+
- consecutive_silence_timeouts: 2.0
|
|
311
|
+
- action: utter_ask_still_there
|
|
312
|
+
next: END
|
|
313
|
+
- id: message_utter_inform_hangup
|
|
314
|
+
action: utter_inform_hangup
|
|
315
|
+
- action: action_hangup
|
|
301
316
|
|
|
302
317
|
pattern_validate_slot:
|
|
303
318
|
description: Flow for running validations on slots
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import importlib
|
|
4
|
+
import inspect
|
|
5
|
+
import os
|
|
6
|
+
from dataclasses import fields, is_dataclass
|
|
7
|
+
from typing import Any, Dict, List, Optional, Set, Text
|
|
8
|
+
|
|
9
|
+
import importlib_resources
|
|
10
|
+
from pydantic import BaseModel, Field, ValidationInfo, field_validator
|
|
11
|
+
|
|
12
|
+
from rasa.dialogue_understanding.stack.frames.pattern_frame import PatternFlowStackFrame
|
|
13
|
+
from rasa.shared.core.constants import (
|
|
14
|
+
DEFAULT_ACTION_NAMES,
|
|
15
|
+
DEFAULT_INTENTS,
|
|
16
|
+
RULE_SNIPPET_ACTION_NAME,
|
|
17
|
+
)
|
|
18
|
+
from rasa.shared.core.slots import AnySlot, BooleanSlot, CategoricalSlot, TextSlot
|
|
19
|
+
|
|
20
|
+
ACTIONS: List[Text] = [
|
|
21
|
+
*DEFAULT_ACTION_NAMES,
|
|
22
|
+
"validate_{{context.collect}}",
|
|
23
|
+
]
|
|
24
|
+
EXCLUDED_ACTIONS: Set[Text] = {RULE_SNIPPET_ACTION_NAME}
|
|
25
|
+
|
|
26
|
+
INTENTS: List[Text] = [*DEFAULT_INTENTS]
|
|
27
|
+
|
|
28
|
+
CONTEXT_FIELD_TYPES: Dict[Text, Text] = {
|
|
29
|
+
"canceled_name": CategoricalSlot.type_name,
|
|
30
|
+
"names": CategoricalSlot.type_name,
|
|
31
|
+
"collect": CategoricalSlot.type_name,
|
|
32
|
+
"utter": CategoricalSlot.type_name,
|
|
33
|
+
"collect_action": CategoricalSlot.type_name,
|
|
34
|
+
"previous_flow_name": CategoricalSlot.type_name,
|
|
35
|
+
"reset_flow_id": CategoricalSlot.type_name,
|
|
36
|
+
"is_reset_only": BooleanSlot.type_name,
|
|
37
|
+
"canceled_frames": AnySlot.type_name,
|
|
38
|
+
"corrected_slots": AnySlot.type_name,
|
|
39
|
+
"rejections": AnySlot.type_name,
|
|
40
|
+
"info": AnySlot.type_name,
|
|
41
|
+
"reason": TextSlot.type_name,
|
|
42
|
+
"error_type": TextSlot.type_name,
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
FLOW_NAME_VALUES = "FLOW_NAME"
|
|
46
|
+
FLOW_ID_VALUES = "FLOW_ID"
|
|
47
|
+
SLOT_NAME_VALUES = "SLOT_NAME"
|
|
48
|
+
RESPONSE_NAME_VALUES = "RESPONSE_NAME"
|
|
49
|
+
ACTION_NAME_VALUES = "ACTION_NAME"
|
|
50
|
+
|
|
51
|
+
CONTEXT_FIELD_VALUES: Dict[Text, Text] = {
|
|
52
|
+
"canceled_name": FLOW_NAME_VALUES,
|
|
53
|
+
"names": FLOW_NAME_VALUES,
|
|
54
|
+
"previous_flow_name": FLOW_NAME_VALUES,
|
|
55
|
+
"reset_flow_id": FLOW_ID_VALUES,
|
|
56
|
+
"collect": SLOT_NAME_VALUES,
|
|
57
|
+
"utter": RESPONSE_NAME_VALUES,
|
|
58
|
+
"collect_action": ACTION_NAME_VALUES,
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
PATTERNS_MODULE_BASE = "rasa.dialogue_understanding.patterns"
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class ContextField(BaseModel):
|
|
65
|
+
"""Element in the `contexts` mapping of the domain."""
|
|
66
|
+
|
|
67
|
+
patterns: List[Text] = Field(
|
|
68
|
+
..., description="Patterns that reference this context field."
|
|
69
|
+
)
|
|
70
|
+
type: Text = Field(
|
|
71
|
+
..., description="Slot type (categorical, text, boolean, any …)."
|
|
72
|
+
)
|
|
73
|
+
values: Optional[List[Text]] = Field(
|
|
74
|
+
None,
|
|
75
|
+
description="Optional placeholder that restricts which values a slot can take "
|
|
76
|
+
"(FLOW_NAME, SLOT_NAME, …).",
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
@field_validator("type")
|
|
80
|
+
def _validate_slot_type(cls, v: str) -> str:
|
|
81
|
+
allowed_types = list(set(CONTEXT_FIELD_TYPES.values()))
|
|
82
|
+
if v not in allowed_types:
|
|
83
|
+
raise ValueError(
|
|
84
|
+
f"Unsupported type '{v}'. "
|
|
85
|
+
f"Must be one of: {', '.join(allowed_types)}."
|
|
86
|
+
)
|
|
87
|
+
return v
|
|
88
|
+
|
|
89
|
+
@field_validator("values")
|
|
90
|
+
def _validate_values_placeholder(
|
|
91
|
+
cls, v: Optional[str], values: ValidationInfo
|
|
92
|
+
) -> Optional[str]:
|
|
93
|
+
if v is None:
|
|
94
|
+
return v
|
|
95
|
+
|
|
96
|
+
allowed_values = set(CONTEXT_FIELD_VALUES.values())
|
|
97
|
+
if not set(v).issubset(allowed_values):
|
|
98
|
+
raise ValueError(
|
|
99
|
+
f"Unsupported values placeholder '{v}'. "
|
|
100
|
+
f"Must be one of {', '.join(allowed_values)}."
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
slot_type = values.data.get("type")
|
|
104
|
+
if slot_type != CategoricalSlot.type_name:
|
|
105
|
+
raise ValueError(
|
|
106
|
+
"`values` can only be specified for categorical slots "
|
|
107
|
+
f"(got slot type '{slot_type}')."
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
return v
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class PatternDomain(BaseModel):
|
|
114
|
+
"""Complete domain that is generated for the default patterns."""
|
|
115
|
+
|
|
116
|
+
actions: List[Text]
|
|
117
|
+
intents: List[Text]
|
|
118
|
+
contexts: Dict[Text, ContextField]
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def build_contexts_from_patterns() -> Dict[str, Dict[str, Any]]:
|
|
122
|
+
"""Builds a dictionary of contexts from the pattern classes.
|
|
123
|
+
|
|
124
|
+
Returns:
|
|
125
|
+
A dictionary where each key is a field name and the value is a dictionary
|
|
126
|
+
"""
|
|
127
|
+
patterns_folder = str(importlib_resources.files(PATTERNS_MODULE_BASE))
|
|
128
|
+
contexts_map: Dict[str, Dict[str, Any]] = {}
|
|
129
|
+
|
|
130
|
+
# Dynamically gather all .py files
|
|
131
|
+
for root, _, files in os.walk(patterns_folder):
|
|
132
|
+
for file in files:
|
|
133
|
+
if not file.endswith(".py"):
|
|
134
|
+
continue
|
|
135
|
+
|
|
136
|
+
try:
|
|
137
|
+
module_name = f"{PATTERNS_MODULE_BASE}.{file[:-3]}"
|
|
138
|
+
module = importlib.import_module(module_name)
|
|
139
|
+
except ImportError:
|
|
140
|
+
continue
|
|
141
|
+
|
|
142
|
+
# Inspect classes in that module
|
|
143
|
+
for _, cls in inspect.getmembers(module, inspect.isclass):
|
|
144
|
+
if not is_dataclass(cls):
|
|
145
|
+
continue
|
|
146
|
+
|
|
147
|
+
# The cls has to be a subclass of PatternFlowStackFrame
|
|
148
|
+
if cls == PatternFlowStackFrame or not issubclass(
|
|
149
|
+
cls, PatternFlowStackFrame
|
|
150
|
+
):
|
|
151
|
+
continue
|
|
152
|
+
|
|
153
|
+
for f in fields(cls):
|
|
154
|
+
field_name = f.name
|
|
155
|
+
if field_name not in contexts_map:
|
|
156
|
+
field_type = CONTEXT_FIELD_TYPES.get(
|
|
157
|
+
field_name, TextSlot.type_name
|
|
158
|
+
)
|
|
159
|
+
contexts_map[field_name] = {
|
|
160
|
+
"patterns": set(),
|
|
161
|
+
"type": field_type,
|
|
162
|
+
}
|
|
163
|
+
values: Optional[Text] = CONTEXT_FIELD_VALUES.get(field_name)
|
|
164
|
+
if values:
|
|
165
|
+
contexts_map[field_name]["values"] = [values]
|
|
166
|
+
|
|
167
|
+
# Add the pattern name to the set
|
|
168
|
+
pattern_name = cls.type()
|
|
169
|
+
contexts_map[field_name]["patterns"].add(pattern_name)
|
|
170
|
+
|
|
171
|
+
# Convert "patterns" from set to list, for a clean final structure
|
|
172
|
+
for field_name, details in contexts_map.items():
|
|
173
|
+
details["patterns"] = sorted(list(details["patterns"]))
|
|
174
|
+
|
|
175
|
+
return contexts_map
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def generate_domain_for_default_patterns() -> PatternDomain:
|
|
179
|
+
"""
|
|
180
|
+
Generate the domain for pattern-based flows as a strongly-typed object.
|
|
181
|
+
|
|
182
|
+
Returns: PatternDomain Pydantic model containing actions, intents and contexts.
|
|
183
|
+
"""
|
|
184
|
+
actions = [action for action in ACTIONS if action not in EXCLUDED_ACTIONS]
|
|
185
|
+
raw_contexts = build_contexts_from_patterns()
|
|
186
|
+
contexts = {
|
|
187
|
+
field_name: ContextField(**details)
|
|
188
|
+
for field_name, details in raw_contexts.items()
|
|
189
|
+
}
|
|
190
|
+
return PatternDomain(actions=actions, intents=INTENTS, contexts=contexts)
|
|
@@ -126,7 +126,7 @@ def validate_state_of_commands(commands: List[Command]) -> None:
|
|
|
126
126
|
if sum(isinstance(c, CancelFlowCommand) for c in commands) > 1:
|
|
127
127
|
structlogger.error(
|
|
128
128
|
"command_processor.validate_state_of_commands.multiple_cancel_flow_commands",
|
|
129
|
-
commands=commands,
|
|
129
|
+
commands=[command.__class__.__name__ for command in commands],
|
|
130
130
|
)
|
|
131
131
|
raise ValueError("There can only be one cancel flow command.")
|
|
132
132
|
|
|
@@ -137,7 +137,7 @@ def validate_state_of_commands(commands: List[Command]) -> None:
|
|
|
137
137
|
if free_form_answer_commands != commands[: len(free_form_answer_commands)]:
|
|
138
138
|
structlogger.error(
|
|
139
139
|
"command_processor.validate_state_of_commands.free_form_answer_commands_not_at_beginning",
|
|
140
|
-
commands=commands,
|
|
140
|
+
commands=[command.__class__.__name__ for command in commands],
|
|
141
141
|
)
|
|
142
142
|
raise ValueError(
|
|
143
143
|
"Free form answer commands must be at start of the predicted command list."
|
|
@@ -147,7 +147,7 @@ def validate_state_of_commands(commands: List[Command]) -> None:
|
|
|
147
147
|
if sum(isinstance(c, CorrectSlotsCommand) for c in commands) > 1:
|
|
148
148
|
structlogger.error(
|
|
149
149
|
"command_processor.validate_state_of_commands.multiple_correct_slots_commands",
|
|
150
|
-
commands=commands,
|
|
150
|
+
commands=[command.__class__.__name__ for command in commands],
|
|
151
151
|
)
|
|
152
152
|
raise ValueError("There can only be one correct slots command.")
|
|
153
153
|
|
|
@@ -342,7 +342,6 @@ def get_current_collect_step(
|
|
|
342
342
|
# but no flow that triggered it. this should never happen.
|
|
343
343
|
structlogger.warning(
|
|
344
344
|
"command_processor.get_current_collect_step.no_flow_on_stack",
|
|
345
|
-
stack=dialogue_stack,
|
|
346
345
|
)
|
|
347
346
|
return None
|
|
348
347
|
|
|
@@ -352,7 +351,7 @@ def get_current_collect_step(
|
|
|
352
351
|
# step from it
|
|
353
352
|
structlogger.warning(
|
|
354
353
|
"command_processor.get_current_collect_step.no_step_for_frame",
|
|
355
|
-
frame=frame_that_triggered_collect_infos,
|
|
354
|
+
frame=frame_that_triggered_collect_infos.frame_id,
|
|
356
355
|
)
|
|
357
356
|
return None
|
|
358
357
|
|
|
@@ -726,7 +725,7 @@ def clean_up_chitchat_command(
|
|
|
726
725
|
)
|
|
727
726
|
structlogger.warn(
|
|
728
727
|
"command_processor.clean_up_chitchat_command.pattern_chitchat_not_found",
|
|
729
|
-
command=resulting_commands[0],
|
|
728
|
+
command=resulting_commands[0], # no PII
|
|
730
729
|
)
|
|
731
730
|
return resulting_commands
|
|
732
731
|
|
|
@@ -744,7 +743,7 @@ def clean_up_chitchat_command(
|
|
|
744
743
|
)
|
|
745
744
|
structlogger.warn(
|
|
746
745
|
"command_processor.clean_up_chitchat_command.replace_chitchat_answer_with_cannot_handle",
|
|
747
|
-
command=resulting_commands[0],
|
|
746
|
+
command=resulting_commands[0], # no PII
|
|
748
747
|
pattern_chitchat_uses_action_trigger_chitchat=has_action_trigger_chitchat,
|
|
749
748
|
defined_intentless_policy_in_config=defines_intentless_policy,
|
|
750
749
|
)
|
|
@@ -1,54 +1,21 @@
|
|
|
1
|
+
import typing
|
|
1
2
|
from collections import defaultdict
|
|
2
3
|
from typing import Dict, List
|
|
3
4
|
|
|
4
|
-
from pydantic import BaseModel
|
|
5
|
-
|
|
6
5
|
from rasa.dialogue_understanding.commands import Command
|
|
7
6
|
from rasa.dialogue_understanding_test.command_comparison import (
|
|
8
7
|
is_command_present_in_list,
|
|
9
8
|
)
|
|
10
|
-
from rasa.dialogue_understanding_test.
|
|
11
|
-
DialogueUnderstandingTestResult,
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class CommandMetrics(BaseModel):
|
|
16
|
-
tp: int
|
|
17
|
-
fp: int
|
|
18
|
-
fn: int
|
|
19
|
-
total_count: int
|
|
20
|
-
|
|
21
|
-
@staticmethod
|
|
22
|
-
def _safe_divide(numerator: float, denominator: float) -> float:
|
|
23
|
-
"""Safely perform division, returning 0.0 if the denominator is zero."""
|
|
24
|
-
return numerator / denominator if denominator > 0 else 0.0
|
|
9
|
+
from rasa.dialogue_understanding_test.command_metrics import CommandMetrics
|
|
25
10
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return self._safe_divide(self.tp, self.tp + self.fn)
|
|
31
|
-
|
|
32
|
-
def get_f1_score(self) -> float:
|
|
33
|
-
precision = self.get_precision()
|
|
34
|
-
recall = self.get_recall()
|
|
35
|
-
|
|
36
|
-
return self._safe_divide(2 * precision * recall, precision + recall)
|
|
37
|
-
|
|
38
|
-
def as_dict(self) -> Dict[str, float]:
|
|
39
|
-
return {
|
|
40
|
-
"tp": self.tp,
|
|
41
|
-
"fp": self.fp,
|
|
42
|
-
"fn": self.fn,
|
|
43
|
-
"precision": self.get_precision(),
|
|
44
|
-
"recall": self.get_recall(),
|
|
45
|
-
"f1_score": self.get_f1_score(),
|
|
46
|
-
"total_count": self.total_count,
|
|
47
|
-
}
|
|
11
|
+
if typing.TYPE_CHECKING:
|
|
12
|
+
from rasa.dialogue_understanding_test.du_test_result import (
|
|
13
|
+
DialogueUnderstandingTestResult,
|
|
14
|
+
)
|
|
48
15
|
|
|
49
16
|
|
|
50
17
|
def calculate_command_metrics(
|
|
51
|
-
test_results: List[DialogueUnderstandingTestResult],
|
|
18
|
+
test_results: List["DialogueUnderstandingTestResult"],
|
|
52
19
|
) -> Dict[str, CommandMetrics]:
|
|
53
20
|
"""Calculate the command metrics for the test result."""
|
|
54
21
|
metrics: Dict[str, CommandMetrics] = defaultdict(
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from typing import Dict
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class CommandMetrics(BaseModel):
|
|
7
|
+
tp: int
|
|
8
|
+
fp: int
|
|
9
|
+
fn: int
|
|
10
|
+
total_count: int
|
|
11
|
+
|
|
12
|
+
@staticmethod
|
|
13
|
+
def _safe_divide(numerator: float, denominator: float) -> float:
|
|
14
|
+
"""Safely perform division, returning 0.0 if the denominator is zero."""
|
|
15
|
+
return numerator / denominator if denominator > 0 else 0.0
|
|
16
|
+
|
|
17
|
+
def get_precision(self) -> float:
|
|
18
|
+
return self._safe_divide(self.tp, self.tp + self.fp)
|
|
19
|
+
|
|
20
|
+
def get_recall(self) -> float:
|
|
21
|
+
return self._safe_divide(self.tp, self.tp + self.fn)
|
|
22
|
+
|
|
23
|
+
def get_f1_score(self) -> float:
|
|
24
|
+
precision = self.get_precision()
|
|
25
|
+
recall = self.get_recall()
|
|
26
|
+
|
|
27
|
+
return self._safe_divide(2 * precision * recall, precision + recall)
|
|
28
|
+
|
|
29
|
+
def as_dict(self) -> Dict[str, float]:
|
|
30
|
+
return {
|
|
31
|
+
"tp": self.tp,
|
|
32
|
+
"fp": self.fp,
|
|
33
|
+
"fn": self.fn,
|
|
34
|
+
"precision": self.get_precision(),
|
|
35
|
+
"recall": self.get_recall(),
|
|
36
|
+
"f1_score": self.get_f1_score(),
|
|
37
|
+
"total_count": self.total_count,
|
|
38
|
+
}
|