rasa-pro 3.12.21__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.21.dist-info → rasa_pro-3.13.0.dist-info}/METADATA +13 -14
- {rasa_pro-3.12.21.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.21.dist-info → rasa_pro-3.13.0.dist-info}/NOTICE +0 -0
- {rasa_pro-3.12.21.dist-info → rasa_pro-3.13.0.dist-info}/WHEEL +0 -0
- {rasa_pro-3.12.21.dist-info → rasa_pro-3.13.0.dist-info}/entry_points.txt +0 -0
rasa/core/lock_store.py
CHANGED
|
@@ -2,18 +2,27 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import asyncio
|
|
4
4
|
import json
|
|
5
|
-
import logging
|
|
6
5
|
import os
|
|
7
6
|
from contextlib import asynccontextmanager
|
|
8
|
-
from typing import AsyncGenerator, Dict, Optional, Text, Union
|
|
7
|
+
from typing import Any, AsyncGenerator, Dict, Literal, Optional, Text, Union
|
|
8
|
+
|
|
9
|
+
import structlog
|
|
10
|
+
from pydantic import (
|
|
11
|
+
AnyUrl,
|
|
12
|
+
BaseModel,
|
|
13
|
+
Field,
|
|
14
|
+
NonNegativeInt,
|
|
15
|
+
model_validator,
|
|
16
|
+
)
|
|
9
17
|
|
|
10
18
|
import rasa.shared.utils.common
|
|
11
19
|
from rasa.core.constants import DEFAULT_LOCK_LIFETIME
|
|
12
20
|
from rasa.core.lock import TicketLock
|
|
13
21
|
from rasa.shared.exceptions import ConnectionException, RasaException
|
|
22
|
+
from rasa.shared.utils.io import raise_deprecation_warning
|
|
14
23
|
from rasa.utils.endpoints import EndpointConfig
|
|
15
24
|
|
|
16
|
-
|
|
25
|
+
structlogger = structlog.getLogger(__name__)
|
|
17
26
|
|
|
18
27
|
|
|
19
28
|
def _get_lock_lifetime() -> int:
|
|
@@ -76,7 +85,10 @@ class LockStore:
|
|
|
76
85
|
|
|
77
86
|
Creates a new lock if none is found.
|
|
78
87
|
"""
|
|
79
|
-
|
|
88
|
+
structlogger.debug(
|
|
89
|
+
"lock_store.issue_ticket",
|
|
90
|
+
event_info=f"Issuing ticket for conversation '{conversation_id}'.",
|
|
91
|
+
)
|
|
80
92
|
try:
|
|
81
93
|
lock = self.get_or_create_lock(conversation_id)
|
|
82
94
|
ticket = lock.issue_ticket(lock_lifetime)
|
|
@@ -109,7 +121,10 @@ class LockStore:
|
|
|
109
121
|
async def _acquire_lock(
|
|
110
122
|
self, conversation_id: Text, ticket: int, wait_time_in_seconds: float
|
|
111
123
|
) -> TicketLock:
|
|
112
|
-
|
|
124
|
+
structlogger.debug(
|
|
125
|
+
"lock_store._acquiring_lock_for_conversation",
|
|
126
|
+
event_info=f"Acquiring lock for conversation '{conversation_id}'.",
|
|
127
|
+
)
|
|
113
128
|
while True:
|
|
114
129
|
# fetch lock in every iteration because lock might no longer exist
|
|
115
130
|
lock = self.get_lock(conversation_id)
|
|
@@ -120,16 +135,22 @@ class LockStore:
|
|
|
120
135
|
|
|
121
136
|
# acquire lock if it isn't locked
|
|
122
137
|
if not lock.is_locked(ticket):
|
|
123
|
-
|
|
138
|
+
structlogger.debug(
|
|
139
|
+
"lock_store._acquired_lock_for_conversation",
|
|
140
|
+
event_info=f"Acquired lock for conversation '{conversation_id}'.",
|
|
141
|
+
)
|
|
124
142
|
return lock
|
|
125
143
|
|
|
126
144
|
items_before_this = ticket - (lock.now_serving or 0)
|
|
127
145
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
146
|
+
structlogger.debug(
|
|
147
|
+
"lock_store._retrying_lock_acquisition",
|
|
148
|
+
event_info=(
|
|
149
|
+
f"Failed to acquire lock for conversation ID '{conversation_id}' "
|
|
150
|
+
f"because {items_before_this} other item(s) for this "
|
|
151
|
+
f"conversation ID have to be finished processing first. "
|
|
152
|
+
f"Retrying in {wait_time_in_seconds} seconds ..."
|
|
153
|
+
),
|
|
133
154
|
)
|
|
134
155
|
|
|
135
156
|
# sleep and update lock
|
|
@@ -186,9 +207,99 @@ class LockStore:
|
|
|
186
207
|
@staticmethod
|
|
187
208
|
def _log_deletion(conversation_id: Text, deletion_successful: bool) -> None:
|
|
188
209
|
if deletion_successful:
|
|
189
|
-
|
|
210
|
+
structlogger.debug(
|
|
211
|
+
"lock_store._deleted_lock_for_conversation",
|
|
212
|
+
event_info=f"Deleted lock for conversation '{conversation_id}'.",
|
|
213
|
+
)
|
|
190
214
|
else:
|
|
191
|
-
|
|
215
|
+
structlogger.debug(
|
|
216
|
+
"lock_store._failed_to_delete_lock_for_conversation",
|
|
217
|
+
event_info=(
|
|
218
|
+
f"Could not delete lock for conversation '{conversation_id}'."
|
|
219
|
+
),
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
class RedisLockStoreConfig(BaseModel):
|
|
224
|
+
host: Union[AnyUrl, Literal["localhost"]] = Field(
|
|
225
|
+
default="localhost", description="The host of the redis server."
|
|
226
|
+
)
|
|
227
|
+
port: NonNegativeInt = Field(
|
|
228
|
+
default=6379, ge=0, le=65535, description="The port of the redis server."
|
|
229
|
+
)
|
|
230
|
+
db: NonNegativeInt = Field(
|
|
231
|
+
default=0,
|
|
232
|
+
ge=0,
|
|
233
|
+
description="The name of the database within Redis "
|
|
234
|
+
"which should be used by Rasa",
|
|
235
|
+
)
|
|
236
|
+
username: Optional[str] = Field(
|
|
237
|
+
default=None,
|
|
238
|
+
description="The username which should be used for "
|
|
239
|
+
"authentication with the Redis database.",
|
|
240
|
+
)
|
|
241
|
+
password: Optional[str] = Field(
|
|
242
|
+
default=None,
|
|
243
|
+
description="The username which should be used for "
|
|
244
|
+
"authentication with the Redis database.",
|
|
245
|
+
)
|
|
246
|
+
use_ssl: bool = Field(
|
|
247
|
+
default=False,
|
|
248
|
+
serialization_alias="ssl",
|
|
249
|
+
description="True if SSL should be used for the connection to Redis.",
|
|
250
|
+
)
|
|
251
|
+
ssl_certfile: Optional[str] = Field(
|
|
252
|
+
default=None,
|
|
253
|
+
description="Path to the SSL certificate file.",
|
|
254
|
+
)
|
|
255
|
+
ssl_keyfile: Optional[str] = Field(
|
|
256
|
+
default=None, description="Path to the SSL private key file."
|
|
257
|
+
)
|
|
258
|
+
ssl_ca_certs: Optional[str] = Field(
|
|
259
|
+
default=None, description="Path to the SSL CA certificate file."
|
|
260
|
+
)
|
|
261
|
+
key_prefix: Optional[str] = Field(
|
|
262
|
+
default=None,
|
|
263
|
+
description="Prefix to prepend to all keys "
|
|
264
|
+
"used by the lock store. Must be alphanumeric.",
|
|
265
|
+
)
|
|
266
|
+
socket_timeout: float = Field(
|
|
267
|
+
default=DEFAULT_SOCKET_TIMEOUT_IN_SECONDS,
|
|
268
|
+
description="Timeout in seconds after which an exception "
|
|
269
|
+
"will be raised in case Redis doesn't respond "
|
|
270
|
+
"within `socket_timeout` seconds.",
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
@model_validator(mode="before")
|
|
274
|
+
@classmethod
|
|
275
|
+
def validate_url_and_host_properties(cls, data: Any) -> Any:
|
|
276
|
+
if isinstance(data, dict):
|
|
277
|
+
if bool(data.get("url", None)) and bool(data.get("host", None)):
|
|
278
|
+
raise RasaException(
|
|
279
|
+
"You cannot specify both 'url' and 'host' in the Redis lock store "
|
|
280
|
+
"configuration. Please use only one of them."
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
if data.get("url", None):
|
|
284
|
+
raise_deprecation_warning(
|
|
285
|
+
"The 'url' property in the redis lock store "
|
|
286
|
+
"configuration is deprecated. Please use 'host' instead."
|
|
287
|
+
)
|
|
288
|
+
data["host"] = data.pop("url")
|
|
289
|
+
return data
|
|
290
|
+
|
|
291
|
+
@model_validator(mode="after")
|
|
292
|
+
def verify_username_password(self) -> RedisLockStoreConfig:
|
|
293
|
+
if bool(self.username) ^ bool(self.password):
|
|
294
|
+
raise ValueError(
|
|
295
|
+
f"Expected username and password. "
|
|
296
|
+
f"Found: username: {'<has value>' if self.username else '<N/A>'}, "
|
|
297
|
+
f"password: {'<has value>' if self.password else '<N/A>'}"
|
|
298
|
+
)
|
|
299
|
+
return self
|
|
300
|
+
|
|
301
|
+
def to_strict_redis(self) -> Dict[str, Any]:
|
|
302
|
+
return self.model_dump(by_alias=True, exclude={"key_prefix"})
|
|
192
303
|
|
|
193
304
|
|
|
194
305
|
class RedisLockStore(LockStore):
|
|
@@ -196,57 +307,28 @@ class RedisLockStore(LockStore):
|
|
|
196
307
|
|
|
197
308
|
def __init__(
|
|
198
309
|
self,
|
|
199
|
-
|
|
200
|
-
port: int = 6379,
|
|
201
|
-
db: int = 1,
|
|
202
|
-
username: Optional[Text] = None,
|
|
203
|
-
password: Optional[Text] = None,
|
|
204
|
-
use_ssl: bool = False,
|
|
205
|
-
ssl_certfile: Optional[Text] = None,
|
|
206
|
-
ssl_keyfile: Optional[Text] = None,
|
|
207
|
-
ssl_ca_certs: Optional[Text] = None,
|
|
208
|
-
key_prefix: Optional[Text] = None,
|
|
209
|
-
socket_timeout: float = DEFAULT_SOCKET_TIMEOUT_IN_SECONDS,
|
|
310
|
+
config: RedisLockStoreConfig = RedisLockStoreConfig(),
|
|
210
311
|
) -> None:
|
|
211
312
|
"""Create a lock store which uses Redis for persistence.
|
|
212
313
|
|
|
213
314
|
Args:
|
|
214
|
-
|
|
215
|
-
port: The port of the redis server.
|
|
216
|
-
db: The name of the database within Redis which should be used by Rasa
|
|
217
|
-
Open Source.
|
|
218
|
-
username: The username which should be used for authentication with the
|
|
219
|
-
Redis database.
|
|
220
|
-
password: The password which should be used for authentication with the
|
|
221
|
-
Redis database.
|
|
222
|
-
use_ssl: `True` if SSL should be used for the connection to Redis.
|
|
223
|
-
ssl_certfile: Path to the SSL certificate file.
|
|
224
|
-
ssl_keyfile: Path to the SSL private key file.
|
|
225
|
-
ssl_ca_certs: Path to the SSL CA certificate file.
|
|
226
|
-
key_prefix: prefix to prepend to all keys used by the lock store. Must be
|
|
227
|
-
alphanumeric.
|
|
228
|
-
socket_timeout: Timeout in seconds after which an exception will be raised
|
|
229
|
-
in case Redis doesn't respond within `socket_timeout` seconds.
|
|
315
|
+
config: Redis lock store configuration.
|
|
230
316
|
"""
|
|
231
317
|
import redis
|
|
232
318
|
|
|
233
|
-
self.
|
|
234
|
-
|
|
235
|
-
port=int(port),
|
|
236
|
-
db=int(db),
|
|
237
|
-
username=username,
|
|
238
|
-
password=password,
|
|
239
|
-
ssl=use_ssl,
|
|
240
|
-
ssl_certfile=ssl_certfile,
|
|
241
|
-
ssl_keyfile=ssl_keyfile,
|
|
242
|
-
ssl_ca_certs=ssl_ca_certs,
|
|
243
|
-
socket_timeout=socket_timeout,
|
|
244
|
-
)
|
|
319
|
+
self.config = config
|
|
320
|
+
self.red = redis.StrictRedis(**self.config.to_strict_redis())
|
|
245
321
|
|
|
246
322
|
self.key_prefix = DEFAULT_REDIS_LOCK_STORE_KEY_PREFIX
|
|
247
|
-
if key_prefix:
|
|
248
|
-
|
|
249
|
-
|
|
323
|
+
if self.config.key_prefix:
|
|
324
|
+
structlogger.debug(
|
|
325
|
+
"redis_lock_store._set_key_prefix.non_default_key_prefix",
|
|
326
|
+
event_info=(
|
|
327
|
+
f"Setting non-default "
|
|
328
|
+
f"redis key prefix: '{self.config.key_prefix}'.",
|
|
329
|
+
),
|
|
330
|
+
)
|
|
331
|
+
self._set_key_prefix(self.config.key_prefix)
|
|
250
332
|
|
|
251
333
|
super().__init__()
|
|
252
334
|
|
|
@@ -254,9 +336,13 @@ class RedisLockStore(LockStore):
|
|
|
254
336
|
if isinstance(key_prefix, str) and key_prefix.isalnum():
|
|
255
337
|
self.key_prefix = key_prefix + ":" + DEFAULT_REDIS_LOCK_STORE_KEY_PREFIX
|
|
256
338
|
else:
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
339
|
+
structlogger.warning(
|
|
340
|
+
"redis_lock_store._set_key_prefix.default_instead_of_invalid_key_prefix",
|
|
341
|
+
event_info=(
|
|
342
|
+
f"Omitting provided non-alphanumeric "
|
|
343
|
+
f"redis key prefix: '{key_prefix}'. "
|
|
344
|
+
f"Using default '{self.key_prefix}' instead."
|
|
345
|
+
),
|
|
260
346
|
)
|
|
261
347
|
|
|
262
348
|
def get_lock(self, conversation_id: Text) -> Optional[TicketLock]:
|
|
@@ -313,7 +399,9 @@ def _create_from_endpoint_config(
|
|
|
313
399
|
|
|
314
400
|
lock_store: LockStore = InMemoryLockStore()
|
|
315
401
|
elif endpoint_config.type == "redis":
|
|
316
|
-
|
|
402
|
+
config = RedisLockStoreConfig.model_validate(endpoint_config.to_dict())
|
|
403
|
+
|
|
404
|
+
lock_store = RedisLockStore(config)
|
|
317
405
|
elif endpoint_config.type == "concurrent_redis":
|
|
318
406
|
from rasa.core.concurrent_lock_store import ConcurrentRedisLockStore
|
|
319
407
|
|
|
@@ -321,7 +409,10 @@ def _create_from_endpoint_config(
|
|
|
321
409
|
else:
|
|
322
410
|
lock_store = _load_from_module_name_in_endpoint_config(endpoint_config)
|
|
323
411
|
|
|
324
|
-
|
|
412
|
+
structlogger.debug(
|
|
413
|
+
"lock_store._create_from_endpoint_config.lock_store_connected",
|
|
414
|
+
event_info=f"Connected to lock store '{lock_store.__class__.__name__}'.",
|
|
415
|
+
)
|
|
325
416
|
|
|
326
417
|
return lock_store
|
|
327
418
|
|
|
@@ -17,6 +17,7 @@ from rasa.shared.constants import (
|
|
|
17
17
|
MODEL_NAME_CONFIG_KEY,
|
|
18
18
|
OPENAI_PROVIDER,
|
|
19
19
|
PROMPT_CONFIG_KEY,
|
|
20
|
+
PROMPT_TEMPLATE_CONFIG_KEY,
|
|
20
21
|
PROVIDER_CONFIG_KEY,
|
|
21
22
|
TEMPERATURE_CONFIG_KEY,
|
|
22
23
|
TIMEOUT_CONFIG_KEY,
|
|
@@ -38,6 +39,7 @@ from rasa.shared.utils.llm import (
|
|
|
38
39
|
DEFAULT_OPENAI_GENERATE_MODEL_NAME,
|
|
39
40
|
DEFAULT_OPENAI_MAX_GENERATED_TOKENS,
|
|
40
41
|
USER,
|
|
42
|
+
check_prompt_config_keys_and_warn_if_deprecated,
|
|
41
43
|
combine_custom_and_default_config,
|
|
42
44
|
get_prompt_template,
|
|
43
45
|
llm_factory,
|
|
@@ -110,8 +112,15 @@ class ContextualResponseRephraser(
|
|
|
110
112
|
super().__init__(domain.responses)
|
|
111
113
|
|
|
112
114
|
self.nlg_endpoint = endpoint_config
|
|
115
|
+
|
|
116
|
+
# Warn if the prompt config key is used to set the prompt template
|
|
117
|
+
check_prompt_config_keys_and_warn_if_deprecated(
|
|
118
|
+
self.nlg_endpoint.kwargs, "contextual_response_rephraser"
|
|
119
|
+
)
|
|
120
|
+
|
|
113
121
|
self.prompt_template = get_prompt_template(
|
|
114
|
-
self.nlg_endpoint.kwargs.get(
|
|
122
|
+
self.nlg_endpoint.kwargs.get(PROMPT_TEMPLATE_CONFIG_KEY)
|
|
123
|
+
or self.nlg_endpoint.kwargs.get(PROMPT_CONFIG_KEY),
|
|
115
124
|
DEFAULT_RESPONSE_VARIATION_PROMPT_TEMPLATE,
|
|
116
125
|
log_source_component=ContextualResponseRephraser.__name__,
|
|
117
126
|
log_source_method=LOG_COMPONENT_SOURCE_METHOD_INIT,
|
|
@@ -215,10 +224,8 @@ class ContextualResponseRephraser(
|
|
|
215
224
|
|
|
216
225
|
@measure_llm_latency
|
|
217
226
|
async def _generate_llm_response(self, prompt: str) -> Optional[LLMResponse]:
|
|
218
|
-
"""Use LLM to generate a response
|
|
219
|
-
|
|
220
|
-
Returns an LLMResponse object containing both the generated text
|
|
221
|
-
(choices) and metadata.
|
|
227
|
+
"""Use LLM to generate a response, returning an LLMResponse object
|
|
228
|
+
containing both the generated text (choices) and metadata.
|
|
222
229
|
|
|
223
230
|
Args:
|
|
224
231
|
prompt: The prompt to send to the LLM.
|
|
@@ -399,9 +406,12 @@ class ContextualResponseRephraser(
|
|
|
399
406
|
Returns:
|
|
400
407
|
The generated response.
|
|
401
408
|
"""
|
|
402
|
-
|
|
409
|
+
filled_slots = tracker.current_slot_values()
|
|
410
|
+
stack_context = tracker.stack.current_context()
|
|
411
|
+
templated_response = self.generate_from_slots(
|
|
403
412
|
utter_action=utter_action,
|
|
404
|
-
|
|
413
|
+
filled_slots=filled_slots,
|
|
414
|
+
stack_context=stack_context,
|
|
405
415
|
output_channel=output_channel,
|
|
406
416
|
**kwargs,
|
|
407
417
|
)
|
rasa/core/nlg/generator.py
CHANGED
|
@@ -6,8 +6,6 @@ from pypred import Predicate
|
|
|
6
6
|
|
|
7
7
|
import rasa.shared.utils.common
|
|
8
8
|
import rasa.shared.utils.io
|
|
9
|
-
from rasa.core.nlg.translate import has_translation
|
|
10
|
-
from rasa.engine.language import Language
|
|
11
9
|
from rasa.shared.constants import CHANNEL, RESPONSE_CONDITION
|
|
12
10
|
from rasa.shared.core.domain import Domain
|
|
13
11
|
from rasa.shared.core.trackers import DialogueStateTracker
|
|
@@ -133,23 +131,11 @@ class ResponseVariationFilter:
|
|
|
133
131
|
|
|
134
132
|
return True
|
|
135
133
|
|
|
136
|
-
def _filter_by_language(
|
|
137
|
-
self, responses: List[Dict[Text, Any]], language: Optional[Language] = None
|
|
138
|
-
) -> List[Dict[Text, Any]]:
|
|
139
|
-
if not language:
|
|
140
|
-
return responses
|
|
141
|
-
|
|
142
|
-
if filtered := [r for r in responses if has_translation(r, language)]:
|
|
143
|
-
return filtered
|
|
144
|
-
# if no translation is found, return the original response variations
|
|
145
|
-
return responses
|
|
146
|
-
|
|
147
134
|
def responses_for_utter_action(
|
|
148
135
|
self,
|
|
149
136
|
utter_action: Text,
|
|
150
137
|
output_channel: Text,
|
|
151
138
|
filled_slots: Dict[Text, Any],
|
|
152
|
-
language: Optional[Language] = None,
|
|
153
139
|
) -> List[Dict[Text, Any]]:
|
|
154
140
|
"""Returns array of responses that fit the channel, action and condition."""
|
|
155
141
|
# filter responses without a condition
|
|
@@ -190,16 +176,16 @@ class ResponseVariationFilter:
|
|
|
190
176
|
)
|
|
191
177
|
|
|
192
178
|
if conditional_channel:
|
|
193
|
-
return
|
|
179
|
+
return conditional_channel
|
|
194
180
|
|
|
195
181
|
if default_channel:
|
|
196
|
-
return
|
|
182
|
+
return default_channel
|
|
197
183
|
|
|
198
184
|
if conditional_no_channel:
|
|
199
|
-
return
|
|
185
|
+
return conditional_no_channel
|
|
200
186
|
|
|
201
187
|
if default_no_channel:
|
|
202
|
-
return
|
|
188
|
+
return default_no_channel
|
|
203
189
|
|
|
204
190
|
# if there is no response variation selected,
|
|
205
191
|
# return the internal error response to prevent
|
|
@@ -212,9 +198,7 @@ class ResponseVariationFilter:
|
|
|
212
198
|
f"a default variation and that all the conditions are valid. "
|
|
213
199
|
f"Returning the internal error response.",
|
|
214
200
|
)
|
|
215
|
-
return self.
|
|
216
|
-
self.responses.get("utter_internal_error_rasa", []), language
|
|
217
|
-
)
|
|
201
|
+
return self.responses.get("utter_internal_error_rasa", [])
|
|
218
202
|
|
|
219
203
|
def get_response_variation_id(
|
|
220
204
|
self,
|
|
@@ -308,7 +292,6 @@ def _evaluate_predicate(constraint: str, filled_slots: Dict[Text, Any]) -> bool:
|
|
|
308
292
|
structlogger.error(
|
|
309
293
|
"rasa.core.nlg.generator.evaluate_conditional_response_predicate.error",
|
|
310
294
|
predicate=constraint,
|
|
311
|
-
document=document,
|
|
312
295
|
error=str(e),
|
|
313
296
|
)
|
|
314
297
|
return False
|
rasa/core/nlg/interpolator.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import copy
|
|
2
1
|
import logging
|
|
3
2
|
import re
|
|
4
3
|
from typing import Any, Dict, List, Text, Union
|
|
@@ -70,9 +69,9 @@ def interpolate_format_template(response: Text, values: Dict[Text, Text]) -> Tex
|
|
|
70
69
|
)
|
|
71
70
|
structlogger.exception(
|
|
72
71
|
"interpolator.interpolate.text",
|
|
73
|
-
response=copy.deepcopy(response),
|
|
74
72
|
placeholder_key=e.args[0],
|
|
75
73
|
event_info=event_info,
|
|
74
|
+
error=str(e),
|
|
76
75
|
)
|
|
77
76
|
return response
|
|
78
77
|
|
|
@@ -98,9 +97,9 @@ def interpolate_jinja_template(response: Text, values: Dict[Text, Any]) -> Text:
|
|
|
98
97
|
)
|
|
99
98
|
structlogger.exception(
|
|
100
99
|
"interpolator.interpolate.text",
|
|
101
|
-
response=copy.deepcopy(response),
|
|
102
100
|
placeholder_key=e.args[0],
|
|
103
101
|
event_info=event_info,
|
|
102
|
+
error=str(e),
|
|
104
103
|
)
|
|
105
104
|
return response
|
|
106
105
|
|
rasa/core/nlg/response.py
CHANGED
|
@@ -5,11 +5,8 @@ from typing import Any, Dict, List, Optional, Text
|
|
|
5
5
|
from rasa.core.constants import DEFAULT_TEMPLATE_ENGINE, TEMPLATE_ENGINE_CONFIG_KEY
|
|
6
6
|
from rasa.core.nlg import interpolator
|
|
7
7
|
from rasa.core.nlg.generator import NaturalLanguageGenerator, ResponseVariationFilter
|
|
8
|
-
from rasa.
|
|
9
|
-
from rasa.engine.language import Language
|
|
10
|
-
from rasa.shared.constants import BUTTONS, RESPONSE_CONDITION, TEXT
|
|
8
|
+
from rasa.shared.constants import RESPONSE_CONDITION
|
|
11
9
|
from rasa.shared.core.domain import RESPONSE_KEYS_TO_INTERPOLATE
|
|
12
|
-
from rasa.shared.core.flows.constants import KEY_TRANSLATION
|
|
13
10
|
from rasa.shared.core.trackers import DialogueStateTracker
|
|
14
11
|
from rasa.shared.nlu.constants import METADATA
|
|
15
12
|
|
|
@@ -33,11 +30,7 @@ class TemplatedNaturalLanguageGenerator(NaturalLanguageGenerator):
|
|
|
33
30
|
|
|
34
31
|
# noinspection PyUnusedLocal
|
|
35
32
|
def _random_response_for(
|
|
36
|
-
self,
|
|
37
|
-
utter_action: Text,
|
|
38
|
-
output_channel: Text,
|
|
39
|
-
filled_slots: Dict[Text, Any],
|
|
40
|
-
language: Optional[Language] = None,
|
|
33
|
+
self, utter_action: Text, output_channel: Text, filled_slots: Dict[Text, Any]
|
|
41
34
|
) -> Optional[Dict[Text, Any]]:
|
|
42
35
|
"""Select random response for the utter action from available ones.
|
|
43
36
|
|
|
@@ -49,7 +42,7 @@ class TemplatedNaturalLanguageGenerator(NaturalLanguageGenerator):
|
|
|
49
42
|
if utter_action in self.responses:
|
|
50
43
|
response_filter = ResponseVariationFilter(self.responses)
|
|
51
44
|
suitable_responses = response_filter.responses_for_utter_action(
|
|
52
|
-
utter_action, output_channel, filled_slots
|
|
45
|
+
utter_action, output_channel, filled_slots
|
|
53
46
|
)
|
|
54
47
|
|
|
55
48
|
if suitable_responses:
|
|
@@ -82,36 +75,9 @@ class TemplatedNaturalLanguageGenerator(NaturalLanguageGenerator):
|
|
|
82
75
|
"""Generate a response for the requested utter action."""
|
|
83
76
|
filled_slots = tracker.current_slot_values()
|
|
84
77
|
stack_context = tracker.stack.current_context()
|
|
85
|
-
|
|
86
|
-
utter_action,
|
|
87
|
-
filled_slots,
|
|
88
|
-
stack_context,
|
|
89
|
-
output_channel,
|
|
90
|
-
tracker.current_language,
|
|
91
|
-
**kwargs,
|
|
78
|
+
return self.generate_from_slots(
|
|
79
|
+
utter_action, filled_slots, stack_context, output_channel, **kwargs
|
|
92
80
|
)
|
|
93
|
-
if response is not None:
|
|
94
|
-
return self.translate_response(response, tracker.current_language)
|
|
95
|
-
return None
|
|
96
|
-
|
|
97
|
-
def translate_response(
|
|
98
|
-
self, response: Dict[Text, Any], language: Optional[Language] = None
|
|
99
|
-
) -> Dict[Text, Any]:
|
|
100
|
-
message_copy = copy.deepcopy(response)
|
|
101
|
-
|
|
102
|
-
text = get_translated_text(
|
|
103
|
-
text=message_copy.pop(TEXT, None),
|
|
104
|
-
translation=message_copy.pop(KEY_TRANSLATION, {}),
|
|
105
|
-
language=language,
|
|
106
|
-
)
|
|
107
|
-
|
|
108
|
-
buttons = get_translated_buttons(
|
|
109
|
-
buttons=message_copy.pop(BUTTONS, None), language=language
|
|
110
|
-
)
|
|
111
|
-
message_copy[TEXT] = text
|
|
112
|
-
if buttons:
|
|
113
|
-
message_copy[BUTTONS] = buttons
|
|
114
|
-
return message_copy
|
|
115
81
|
|
|
116
82
|
def generate_from_slots(
|
|
117
83
|
self,
|
|
@@ -119,15 +85,12 @@ class TemplatedNaturalLanguageGenerator(NaturalLanguageGenerator):
|
|
|
119
85
|
filled_slots: Dict[Text, Any],
|
|
120
86
|
stack_context: Dict[Text, Any],
|
|
121
87
|
output_channel: Text,
|
|
122
|
-
language: Optional[Language] = None,
|
|
123
88
|
**kwargs: Any,
|
|
124
89
|
) -> Optional[Dict[Text, Any]]:
|
|
125
90
|
"""Generate a response for the requested utter action."""
|
|
126
91
|
# Fetching a random response for the passed utter action
|
|
127
92
|
r = copy.deepcopy(
|
|
128
|
-
self._random_response_for(
|
|
129
|
-
utter_action, output_channel, filled_slots, language
|
|
130
|
-
)
|
|
93
|
+
self._random_response_for(utter_action, output_channel, filled_slots)
|
|
131
94
|
)
|
|
132
95
|
# Filling the slots in the response with placeholders and returning the response
|
|
133
96
|
if r is not None:
|
rasa/core/nlg/summarize.py
CHANGED
|
@@ -4,7 +4,7 @@ from typing import Callable, List, Optional
|
|
|
4
4
|
import structlog
|
|
5
5
|
from jinja2 import Template
|
|
6
6
|
|
|
7
|
-
from rasa.core.
|
|
7
|
+
from rasa.shared.core.trackers import DialogueStateTracker
|
|
8
8
|
from rasa.shared.providers.llm.llm_client import LLMClient
|
|
9
9
|
from rasa.shared.utils.llm import (
|
|
10
10
|
tracker_as_readable_transcript,
|
rasa/core/nlg/translate.py
CHANGED
|
@@ -23,14 +23,6 @@ def get_translated_text(
|
|
|
23
23
|
return translation.get(language_code, text)
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
def has_translation(
|
|
27
|
-
message: Dict[Text, Any], language: Optional[Language] = None
|
|
28
|
-
) -> bool:
|
|
29
|
-
"""Check if the message has a translation for the given language."""
|
|
30
|
-
language_code = language.code if language else None
|
|
31
|
-
return language_code in message.get(KEY_TRANSLATION, {})
|
|
32
|
-
|
|
33
|
-
|
|
34
26
|
def get_translated_buttons(
|
|
35
27
|
buttons: Optional[List[Dict[Text, Any]]], language: Optional[Language] = None
|
|
36
28
|
) -> Optional[List[Dict[Text, Any]]]:
|