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
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import asdict, dataclass
|
|
4
|
+
from typing import Any, Dict, List, Optional
|
|
5
|
+
|
|
6
|
+
import structlog
|
|
7
|
+
|
|
8
|
+
from rasa.core.constants import (
|
|
9
|
+
POLICY_MAX_HISTORY,
|
|
10
|
+
POLICY_PRIORITY,
|
|
11
|
+
SEARCH_POLICY_PRIORITY,
|
|
12
|
+
)
|
|
13
|
+
from rasa.shared.constants import (
|
|
14
|
+
EMBEDDINGS_CONFIG_KEY,
|
|
15
|
+
LLM_CONFIG_KEY,
|
|
16
|
+
MAX_COMPLETION_TOKENS_CONFIG_KEY,
|
|
17
|
+
MAX_RETRIES_CONFIG_KEY,
|
|
18
|
+
MODEL_CONFIG_KEY,
|
|
19
|
+
OPENAI_PROVIDER,
|
|
20
|
+
PROMPT_CONFIG_KEY,
|
|
21
|
+
PROMPT_TEMPLATE_CONFIG_KEY,
|
|
22
|
+
PROVIDER_CONFIG_KEY,
|
|
23
|
+
TEMPERATURE_CONFIG_KEY,
|
|
24
|
+
TIMEOUT_CONFIG_KEY,
|
|
25
|
+
)
|
|
26
|
+
from rasa.shared.utils.configs import (
|
|
27
|
+
raise_deprecation_warnings,
|
|
28
|
+
resolve_aliases,
|
|
29
|
+
validate_forbidden_keys,
|
|
30
|
+
validate_required_keys,
|
|
31
|
+
)
|
|
32
|
+
from rasa.shared.utils.llm import (
|
|
33
|
+
DEFAULT_ENTERPRISE_SEARCH_POLICY_MODEL_NAME,
|
|
34
|
+
DEFAULT_OPENAI_EMBEDDING_MODEL_NAME,
|
|
35
|
+
resolve_model_client_config,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
structlogger = structlog.get_logger()
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
SOURCE_PROPERTY = "source"
|
|
42
|
+
VECTOR_STORE_TYPE_PROPERTY = "type"
|
|
43
|
+
VECTOR_STORE_PROPERTY = "vector_store"
|
|
44
|
+
VECTOR_STORE_THRESHOLD_PROPERTY = "threshold"
|
|
45
|
+
TRACE_TOKENS_PROPERTY = "trace_prompt_tokens"
|
|
46
|
+
CITATION_ENABLED_PROPERTY = "citation_enabled"
|
|
47
|
+
USE_LLM_PROPERTY = "use_generative_llm"
|
|
48
|
+
CHECK_RELEVANCY_PROPERTY = "check_relevancy"
|
|
49
|
+
MAX_MESSAGES_IN_QUERY_KEY = "max_messages_in_query"
|
|
50
|
+
|
|
51
|
+
DEFAULT_VECTOR_STORE_TYPE = "faiss"
|
|
52
|
+
DEFAULT_VECTOR_STORE_THRESHOLD = 0.0
|
|
53
|
+
DEFAULT_VECTOR_STORE = {
|
|
54
|
+
VECTOR_STORE_TYPE_PROPERTY: DEFAULT_VECTOR_STORE_TYPE,
|
|
55
|
+
SOURCE_PROPERTY: "./docs",
|
|
56
|
+
VECTOR_STORE_THRESHOLD_PROPERTY: DEFAULT_VECTOR_STORE_THRESHOLD,
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
DEFAULT_CHECK_RELEVANCY_PROPERTY = False
|
|
60
|
+
DEFAULT_USE_LLM_PROPERTY = True
|
|
61
|
+
DEFAULT_CITATION_ENABLED_PROPERTY = False
|
|
62
|
+
DEFAULT_TRACE_PROMPT_TOKEN_PROPERTY = False
|
|
63
|
+
|
|
64
|
+
DEFAULT_MAX_MESSAGES_IN_QUERY = 2
|
|
65
|
+
|
|
66
|
+
DEFAULT_LLM_CONFIG = {
|
|
67
|
+
PROVIDER_CONFIG_KEY: OPENAI_PROVIDER,
|
|
68
|
+
MODEL_CONFIG_KEY: DEFAULT_ENTERPRISE_SEARCH_POLICY_MODEL_NAME,
|
|
69
|
+
TIMEOUT_CONFIG_KEY: 10,
|
|
70
|
+
TEMPERATURE_CONFIG_KEY: 0.0,
|
|
71
|
+
MAX_COMPLETION_TOKENS_CONFIG_KEY: 256,
|
|
72
|
+
MAX_RETRIES_CONFIG_KEY: 1,
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
DEFAULT_EMBEDDINGS_CONFIG = {
|
|
76
|
+
PROVIDER_CONFIG_KEY: OPENAI_PROVIDER,
|
|
77
|
+
MODEL_CONFIG_KEY: DEFAULT_OPENAI_EMBEDDING_MODEL_NAME,
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
DEFAULT_ENTERPRISE_SEARCH_CONFIG = {
|
|
81
|
+
POLICY_PRIORITY: SEARCH_POLICY_PRIORITY,
|
|
82
|
+
VECTOR_STORE_PROPERTY: DEFAULT_VECTOR_STORE,
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
REQUIRED_KEYS: List[str] = []
|
|
86
|
+
|
|
87
|
+
FORBIDDEN_KEYS: List[str] = []
|
|
88
|
+
|
|
89
|
+
DEPRECATED_ALIASES_TO_STANDARD_KEY_MAPPING = {
|
|
90
|
+
PROMPT_CONFIG_KEY: PROMPT_TEMPLATE_CONFIG_KEY
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@dataclass
|
|
95
|
+
class EnterpriseSearchPolicyConfig:
|
|
96
|
+
"""Parses configuration for Enterprise Search Policy."""
|
|
97
|
+
|
|
98
|
+
# TODO: llm_config, embeddings_config, and vector_store_config should also be parsed
|
|
99
|
+
# as "Config" objects. Likely part of a broader Rasa 4.0 rewrite where all
|
|
100
|
+
# components rely on configuration parser. So, for example, llm_config and
|
|
101
|
+
# embeddings_config should be parsed as ClientConfig objects, and
|
|
102
|
+
# vector_store_config parsed as VectorStoreConfig object.
|
|
103
|
+
llm_config: dict
|
|
104
|
+
embeddings_config: dict
|
|
105
|
+
vector_store_config: dict
|
|
106
|
+
|
|
107
|
+
prompt_template: str
|
|
108
|
+
|
|
109
|
+
use_generative_llm: bool = DEFAULT_USE_LLM_PROPERTY
|
|
110
|
+
enable_citation: bool = DEFAULT_CITATION_ENABLED_PROPERTY
|
|
111
|
+
check_relevancy: bool = DEFAULT_CHECK_RELEVANCY_PROPERTY
|
|
112
|
+
|
|
113
|
+
max_history: Optional[int] = None
|
|
114
|
+
max_messages_in_query: int = DEFAULT_MAX_MESSAGES_IN_QUERY
|
|
115
|
+
trace_prompt_tokens: bool = DEFAULT_TRACE_PROMPT_TOKEN_PROPERTY
|
|
116
|
+
|
|
117
|
+
@property
|
|
118
|
+
def vector_store_type(self) -> str:
|
|
119
|
+
# TODO: In the future this should ideally be part of the Vector config
|
|
120
|
+
# and not the property of the EnterpriseSearch config
|
|
121
|
+
return (
|
|
122
|
+
self.vector_store_config.get(VECTOR_STORE_TYPE_PROPERTY)
|
|
123
|
+
or DEFAULT_VECTOR_STORE_TYPE
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
@property
|
|
127
|
+
def vector_store_threshold(self) -> float:
|
|
128
|
+
# TODO: In the future this should ideally be part of the Vector config
|
|
129
|
+
# and not the property of the EnterpriseSearch config
|
|
130
|
+
return (
|
|
131
|
+
self.vector_store_config.get(VECTOR_STORE_THRESHOLD_PROPERTY)
|
|
132
|
+
or DEFAULT_VECTOR_STORE_THRESHOLD
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
@property
|
|
136
|
+
def vector_store_source(self) -> Optional[str]:
|
|
137
|
+
# TODO: In the future this should ideally be part of the Vector config
|
|
138
|
+
# and not the property of the EnterpriseSearch config
|
|
139
|
+
return self.vector_store_config.get(SOURCE_PROPERTY)
|
|
140
|
+
|
|
141
|
+
def __post_init__(self) -> None:
|
|
142
|
+
if self.check_relevancy and not self.use_generative_llm:
|
|
143
|
+
structlogger.warning(
|
|
144
|
+
"enterprise_search_policy"
|
|
145
|
+
".relevancy_check_enabled_with_disabled_generative_search",
|
|
146
|
+
event_info=(
|
|
147
|
+
f"The config parameter '{CHECK_RELEVANCY_PROPERTY}' is set to"
|
|
148
|
+
f"'True', but the generative search is disabled (config"
|
|
149
|
+
f"parameter '{USE_LLM_PROPERTY}' is set to 'False'). As a result, "
|
|
150
|
+
"the relevancy check for the generative search will be disabled. "
|
|
151
|
+
f"To use this check, set the config parameter '{USE_LLM_PROPERTY}' "
|
|
152
|
+
f"to `True`."
|
|
153
|
+
),
|
|
154
|
+
)
|
|
155
|
+
if self.enable_citation and not self.use_generative_llm:
|
|
156
|
+
structlogger.warning(
|
|
157
|
+
"enterprise_search_policy"
|
|
158
|
+
".citation_enabled_with_disabled_generative_search",
|
|
159
|
+
event_info=(
|
|
160
|
+
f"The config parameter '{CITATION_ENABLED_PROPERTY}' is set to"
|
|
161
|
+
f"'True', but the generative search is disabled (config"
|
|
162
|
+
f"parameter '{USE_LLM_PROPERTY}' is set to 'False'). As a result, "
|
|
163
|
+
"the citation for the generative search will be disabled. "
|
|
164
|
+
f"To use this check, set the config parameter '{USE_LLM_PROPERTY}' "
|
|
165
|
+
f"to `True`."
|
|
166
|
+
),
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
@classmethod
|
|
170
|
+
def from_dict(cls, config: dict) -> EnterpriseSearchPolicyConfig:
|
|
171
|
+
"""Initializes a dataclass from the passed config.
|
|
172
|
+
|
|
173
|
+
Args:
|
|
174
|
+
config: (dict) The config from which to initialize.
|
|
175
|
+
|
|
176
|
+
Raises:
|
|
177
|
+
ValueError: Config is missing required keys.
|
|
178
|
+
|
|
179
|
+
Returns:
|
|
180
|
+
AzureOpenAIClientConfig
|
|
181
|
+
"""
|
|
182
|
+
# Resolve LLM config
|
|
183
|
+
llm_config = (
|
|
184
|
+
resolve_model_client_config(
|
|
185
|
+
config.get(LLM_CONFIG_KEY), EnterpriseSearchPolicyConfig.__name__
|
|
186
|
+
)
|
|
187
|
+
or DEFAULT_LLM_CONFIG
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
# Resolve embeddings config
|
|
191
|
+
embeddings_config = (
|
|
192
|
+
resolve_model_client_config(
|
|
193
|
+
config.get(EMBEDDINGS_CONFIG_KEY), EnterpriseSearchPolicyConfig.__name__
|
|
194
|
+
)
|
|
195
|
+
or DEFAULT_EMBEDDINGS_CONFIG
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
# Vector store config
|
|
199
|
+
vector_store_config = config.get(VECTOR_STORE_PROPERTY, DEFAULT_VECTOR_STORE)
|
|
200
|
+
|
|
201
|
+
# Check for deprecated keys
|
|
202
|
+
raise_deprecation_warnings(
|
|
203
|
+
config, DEPRECATED_ALIASES_TO_STANDARD_KEY_MAPPING, "EnterpriseSearchPolicy"
|
|
204
|
+
)
|
|
205
|
+
# Resolve any potential aliases (e.g. 'prompt_template' vs 'prompt')
|
|
206
|
+
config = cls.resolve_config_aliases(config)
|
|
207
|
+
|
|
208
|
+
# Validate that the required keys are present
|
|
209
|
+
validate_required_keys(config, REQUIRED_KEYS)
|
|
210
|
+
# Validate that the forbidden keys are not present
|
|
211
|
+
validate_forbidden_keys(config, FORBIDDEN_KEYS)
|
|
212
|
+
|
|
213
|
+
this = EnterpriseSearchPolicyConfig(
|
|
214
|
+
llm_config=llm_config,
|
|
215
|
+
embeddings_config=embeddings_config,
|
|
216
|
+
vector_store_config=vector_store_config,
|
|
217
|
+
prompt_template=config.get(PROMPT_TEMPLATE_CONFIG_KEY),
|
|
218
|
+
use_generative_llm=config.get(USE_LLM_PROPERTY, DEFAULT_USE_LLM_PROPERTY),
|
|
219
|
+
enable_citation=config.get(
|
|
220
|
+
CITATION_ENABLED_PROPERTY, DEFAULT_CITATION_ENABLED_PROPERTY
|
|
221
|
+
),
|
|
222
|
+
check_relevancy=config.get(
|
|
223
|
+
CHECK_RELEVANCY_PROPERTY, DEFAULT_CHECK_RELEVANCY_PROPERTY
|
|
224
|
+
),
|
|
225
|
+
max_history=config.get(POLICY_MAX_HISTORY),
|
|
226
|
+
max_messages_in_query=config.get(
|
|
227
|
+
MAX_MESSAGES_IN_QUERY_KEY, DEFAULT_MAX_MESSAGES_IN_QUERY
|
|
228
|
+
),
|
|
229
|
+
trace_prompt_tokens=config.get(
|
|
230
|
+
TRACE_TOKENS_PROPERTY, DEFAULT_TRACE_PROMPT_TOKEN_PROPERTY
|
|
231
|
+
),
|
|
232
|
+
)
|
|
233
|
+
return this
|
|
234
|
+
|
|
235
|
+
def to_dict(self) -> dict:
|
|
236
|
+
"""Converts the config instance into a dictionary."""
|
|
237
|
+
return asdict(self)
|
|
238
|
+
|
|
239
|
+
@staticmethod
|
|
240
|
+
def resolve_config_aliases(config: Dict[str, Any]) -> Dict[str, Any]:
|
|
241
|
+
return resolve_aliases(config, DEPRECATED_ALIASES_TO_STANDARD_KEY_MAPPING)
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{% if check_relevancy %}Based on the provided documents and the recent conversation context, answer the following question.
|
|
2
|
+
Before responding, ensure the answer is directly supported by the documents or context.
|
|
3
|
+
Do not make assumptions or infer beyond the given information.
|
|
4
|
+
Only answer if you are more than 80% confident that the response is fully supported.
|
|
5
|
+
If the answer cannot be determined, respond with: [NO_RAG_ANSWER]
|
|
6
|
+
{% else %}Given the following information, please provide an answer based on the provided documents and the context of the recent conversation.
|
|
7
|
+
If the answer is not known or cannot be determined from the provided documents or context, please state that you do not know to the user.
|
|
8
|
+
{% endif %}
|
|
9
|
+
|
|
10
|
+
### Relevant Documents
|
|
11
|
+
Use the following documents to answer the question:
|
|
12
|
+
{% for doc in docs %}
|
|
13
|
+
{{ loop.cycle("*")}}. {{ doc.metadata }}
|
|
14
|
+
{{ doc.text }}
|
|
15
|
+
{% endfor %}
|
|
16
|
+
|
|
17
|
+
{% if citation_enabled %}
|
|
18
|
+
### Citing Sources
|
|
19
|
+
Find the sources from the documents that are most relevant to answering the question.
|
|
20
|
+
The sources must be extracted from the given document metadata source property and not from the conversation context.
|
|
21
|
+
If there are no relevant sources, write "No relevant sources" instead.
|
|
22
|
+
|
|
23
|
+
For each source you cite, follow a 1-based numbering system for citations.
|
|
24
|
+
Start with [1] for the first source you refer to, regardless of its index in the provided list of documents.
|
|
25
|
+
If you cite another source, use the next number in sequence, [2], and so on.
|
|
26
|
+
Ensure each source is only assigned one number, even if referenced multiple times.
|
|
27
|
+
If you refer back to a previously cited source, use its originally assigned number.
|
|
28
|
+
|
|
29
|
+
For example, if you first cite the third source in the list, refer to it as [1].
|
|
30
|
+
If you then cite the first source in the list, refer to it as [2].
|
|
31
|
+
If you mention the third source again, still refer to it as [1].
|
|
32
|
+
|
|
33
|
+
Don't say "According to Source [1]" when answering. Instead, make references to sources relevant to each section of the answer solely by adding the bracketed number at the end of the relevant sentence.
|
|
34
|
+
#### Formatting
|
|
35
|
+
First print the answer with in-text citations which follow a numbered order starting with index 1, then add the sources section.
|
|
36
|
+
The format of your overall answer must look like what's shown between the <example></example> tags.
|
|
37
|
+
Make sure to follow the formatting exactly and remove any line breaks or whitespaces between the answer and the Sources section.
|
|
38
|
+
<example>
|
|
39
|
+
You can use flows to model business logic in Rasa assistants. [1] You can use the Enterprise Search Policy to search vector stores for relevant knowledge base documents. [2]
|
|
40
|
+
Sources:
|
|
41
|
+
[1] https://rasa.com/docs/rasa-pro/concepts/flows
|
|
42
|
+
[2] https://rasa.com/docs/rasa-pro/concepts/policies/enterprise-search-policy
|
|
43
|
+
</example>
|
|
44
|
+
{% endif %}
|
|
45
|
+
|
|
46
|
+
{% if slots|length > 0 %}
|
|
47
|
+
### Slots or Variables
|
|
48
|
+
Here are the variables of the currently active conversation which may be used to answer the question:
|
|
49
|
+
{% for slot in slots -%}
|
|
50
|
+
- name: {{ slot.name }}, value: {{ slot.value }}, type: {{ slot.type }}
|
|
51
|
+
{% endfor %}
|
|
52
|
+
{% endif %}
|
|
53
|
+
### Current Conversation
|
|
54
|
+
Transcript of the current conversation, use it to determine the context of the question:
|
|
55
|
+
{{ current_conversation }}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
## Answering the Question
|
|
59
|
+
Based on the above sections, please formulate an answer to the question or request in the user's last message.
|
|
60
|
+
It is important that you ensure the answer is grounded in the provided documents and conversation context.
|
|
61
|
+
Avoid speculating or making assumptions beyond the given information and keep your answers short, 2 to 3 sentences at most.
|
|
62
|
+
|
|
63
|
+
{% if citation_enabled %}
|
|
64
|
+
If you are unable to find an answer in the given relevant documents, do not cite sources from elsewhere in the conversation context.
|
|
65
|
+
{% endif %}
|
|
66
|
+
|
|
67
|
+
Your answer:
|
|
@@ -150,12 +150,12 @@ class FlowPolicy(Policy):
|
|
|
150
150
|
except FlowCircuitBreakerTrippedException as e:
|
|
151
151
|
structlogger.error(
|
|
152
152
|
"flow.circuit_breaker",
|
|
153
|
-
dialogue_stack=e.dialogue_stack,
|
|
154
153
|
number_of_steps_taken=e.number_of_steps_taken,
|
|
155
154
|
event_info=(
|
|
156
155
|
"The flow circuit breaker tripped. "
|
|
157
156
|
"There appears to be an infinite loop in the flows."
|
|
158
157
|
),
|
|
158
|
+
error=str(e),
|
|
159
159
|
)
|
|
160
160
|
# end the current flow and start the internal error flow
|
|
161
161
|
updated_stack = tracker.stack
|
|
@@ -9,6 +9,7 @@ from structlog.contextvars import (
|
|
|
9
9
|
bound_contextvars,
|
|
10
10
|
)
|
|
11
11
|
|
|
12
|
+
from rasa.core.available_endpoints import AvailableEndpoints
|
|
12
13
|
from rasa.core.constants import ACTIVE_FLOW_METADATA_KEY, STEP_ID_METADATA_KEY
|
|
13
14
|
from rasa.core.policies.flows.flow_exceptions import (
|
|
14
15
|
FlowCircuitBreakerTrippedException,
|
|
@@ -24,6 +25,7 @@ from rasa.core.policies.flows.flow_step_result import (
|
|
|
24
25
|
from rasa.dialogue_understanding.commands import CancelFlowCommand
|
|
25
26
|
from rasa.dialogue_understanding.patterns.cancel import CancelPatternFlowStackFrame
|
|
26
27
|
from rasa.dialogue_understanding.patterns.collect_information import (
|
|
28
|
+
FLOW_PATTERN_COLLECT_INFORMATION,
|
|
27
29
|
CollectInformationPatternFlowStackFrame,
|
|
28
30
|
)
|
|
29
31
|
from rasa.dialogue_understanding.patterns.completed import (
|
|
@@ -39,6 +41,7 @@ from rasa.dialogue_understanding.patterns.internal_error import (
|
|
|
39
41
|
InternalErrorPatternFlowStackFrame,
|
|
40
42
|
)
|
|
41
43
|
from rasa.dialogue_understanding.patterns.search import SearchPatternFlowStackFrame
|
|
44
|
+
from rasa.dialogue_understanding.patterns.user_silence import FLOW_PATTERN_USER_SILENCE
|
|
42
45
|
from rasa.dialogue_understanding.stack.dialogue_stack import DialogueStack
|
|
43
46
|
from rasa.dialogue_understanding.stack.frames import (
|
|
44
47
|
BaseFlowStackFrame,
|
|
@@ -54,6 +57,7 @@ from rasa.dialogue_understanding.stack.utils import (
|
|
|
54
57
|
from rasa.shared.constants import RASA_PATTERN_HUMAN_HANDOFF
|
|
55
58
|
from rasa.shared.core.constants import (
|
|
56
59
|
ACTION_LISTEN_NAME,
|
|
60
|
+
SILENCE_TIMEOUT_SLOT,
|
|
57
61
|
)
|
|
58
62
|
from rasa.shared.core.events import (
|
|
59
63
|
Event,
|
|
@@ -123,7 +127,6 @@ def is_condition_satisfied(
|
|
|
123
127
|
structlogger.error(
|
|
124
128
|
"flow.predicate.error",
|
|
125
129
|
predicate=predicate,
|
|
126
|
-
document=document,
|
|
127
130
|
error=str(e),
|
|
128
131
|
)
|
|
129
132
|
return False
|
|
@@ -177,7 +180,7 @@ def select_next_step_id(
|
|
|
177
180
|
"flow.link.failed_to_select_branch",
|
|
178
181
|
current=current,
|
|
179
182
|
links=next_step.links,
|
|
180
|
-
|
|
183
|
+
sender_id=tracker.sender_id,
|
|
181
184
|
)
|
|
182
185
|
return None
|
|
183
186
|
|
|
@@ -191,7 +194,7 @@ def select_next_step_id(
|
|
|
191
194
|
structlogger.error(
|
|
192
195
|
"flow.step.failed_to_select_next_step",
|
|
193
196
|
step=current,
|
|
194
|
-
|
|
197
|
+
sender_id=tracker.sender_id,
|
|
195
198
|
)
|
|
196
199
|
return None
|
|
197
200
|
|
|
@@ -226,19 +229,6 @@ def events_from_set_slots_step(step: SetSlotsFlowStep) -> List[Event]:
|
|
|
226
229
|
return [SlotSet(slot["key"], slot["value"]) for slot in step.slots]
|
|
227
230
|
|
|
228
231
|
|
|
229
|
-
def events_for_collect_step_execution(
|
|
230
|
-
step: CollectInformationFlowStep, tracker: DialogueStateTracker
|
|
231
|
-
) -> List[Event]:
|
|
232
|
-
"""Create the events needed to prepare for the execution of a collect step."""
|
|
233
|
-
# reset the slots that always need to be explicitly collected
|
|
234
|
-
slot = tracker.slots.get(step.collect, None)
|
|
235
|
-
|
|
236
|
-
if slot and step.ask_before_filling:
|
|
237
|
-
return [SlotSet(step.collect, None)]
|
|
238
|
-
else:
|
|
239
|
-
return []
|
|
240
|
-
|
|
241
|
-
|
|
242
232
|
def trigger_pattern_continue_interrupted(
|
|
243
233
|
current_frame: DialogueStackFrame,
|
|
244
234
|
stack: DialogueStack,
|
|
@@ -600,6 +590,12 @@ def run_step(
|
|
|
600
590
|
# the START_STEP meta step
|
|
601
591
|
initial_events.append(FlowStarted(flow.id, metadata=stack.current_context()))
|
|
602
592
|
|
|
593
|
+
# FLow does not start with collect step or we are not in collect information pattern
|
|
594
|
+
if _first_step_is_not_collect(step, previous_step_id) and not (
|
|
595
|
+
_in_collect_information_pattern(flow) or _in_pattern_user_silence(flow)
|
|
596
|
+
):
|
|
597
|
+
_append_global_silence_timeout_event(initial_events, tracker)
|
|
598
|
+
|
|
603
599
|
if isinstance(step, CollectInformationFlowStep):
|
|
604
600
|
return _run_collect_information_step(
|
|
605
601
|
available_actions,
|
|
@@ -629,12 +625,37 @@ def run_step(
|
|
|
629
625
|
return ContinueFlowWithNextStep(events=initial_events)
|
|
630
626
|
|
|
631
627
|
elif isinstance(step, EndFlowStep):
|
|
628
|
+
# If pattern collect information flow is ending,
|
|
629
|
+
# we need to reset the silence timeout slot to its global value.
|
|
630
|
+
if flow.id == FLOW_PATTERN_COLLECT_INFORMATION:
|
|
631
|
+
_append_global_silence_timeout_event(initial_events, tracker)
|
|
632
|
+
|
|
632
633
|
return _run_end_step(flow, flows, initial_events, stack, tracker)
|
|
633
634
|
|
|
634
635
|
else:
|
|
635
636
|
raise FlowException(f"Unknown flow step type {type(step)}")
|
|
636
637
|
|
|
637
638
|
|
|
639
|
+
def _first_step_is_not_collect(
|
|
640
|
+
step: FlowStep,
|
|
641
|
+
previous_step_id: str,
|
|
642
|
+
) -> bool:
|
|
643
|
+
"""Check if the first step is not a collect information step."""
|
|
644
|
+
return (previous_step_id == START_STEP) and not isinstance(
|
|
645
|
+
step, CollectInformationFlowStep
|
|
646
|
+
)
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
def _in_collect_information_pattern(flow: Flow) -> bool:
|
|
650
|
+
"""Check if the current flow is a collect information pattern."""
|
|
651
|
+
return flow.id == FLOW_PATTERN_COLLECT_INFORMATION
|
|
652
|
+
|
|
653
|
+
|
|
654
|
+
def _in_pattern_user_silence(flow: Flow) -> bool:
|
|
655
|
+
"""Check if the current flow is a user silence pattern."""
|
|
656
|
+
return flow.id == FLOW_PATTERN_USER_SILENCE
|
|
657
|
+
|
|
658
|
+
|
|
638
659
|
def _run_end_step(
|
|
639
660
|
flow: Flow,
|
|
640
661
|
flows: FlowsList,
|
|
@@ -745,5 +766,69 @@ def _run_collect_information_step(
|
|
|
745
766
|
step.collect, stack, step.rejections, step.utter, step.collect_action
|
|
746
767
|
)
|
|
747
768
|
|
|
748
|
-
events: List[Event] =
|
|
769
|
+
events: List[Event] = _events_for_collect_step_execution(step, tracker)
|
|
749
770
|
return ContinueFlowWithNextStep(events=initial_events + events)
|
|
771
|
+
|
|
772
|
+
|
|
773
|
+
def _events_for_collect_step_execution(
|
|
774
|
+
step: CollectInformationFlowStep, tracker: DialogueStateTracker
|
|
775
|
+
) -> List[Event]:
|
|
776
|
+
"""Create the events needed to prepare for the execution of a collect step."""
|
|
777
|
+
# reset the slots that always need to be explicitly collected
|
|
778
|
+
|
|
779
|
+
events = _silence_timeout_events_for_collect_step(step, tracker)
|
|
780
|
+
|
|
781
|
+
slot = tracker.slots.get(step.collect, None)
|
|
782
|
+
if slot and step.ask_before_filling:
|
|
783
|
+
events.append(SlotSet(step.collect, None))
|
|
784
|
+
|
|
785
|
+
return events
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
def _silence_timeout_events_for_collect_step(
|
|
789
|
+
step: CollectInformationFlowStep, tracker: DialogueStateTracker
|
|
790
|
+
) -> List[Event]:
|
|
791
|
+
events: List[Event] = []
|
|
792
|
+
|
|
793
|
+
silence_timeout = (
|
|
794
|
+
AvailableEndpoints.get_instance().interaction_handling.global_silence_timeout
|
|
795
|
+
)
|
|
796
|
+
|
|
797
|
+
if step.silence_timeout:
|
|
798
|
+
structlogger.debug(
|
|
799
|
+
"flow.step.run.adjusting_silence_timeout",
|
|
800
|
+
duration=step.silence_timeout,
|
|
801
|
+
collect=step.collect,
|
|
802
|
+
)
|
|
803
|
+
|
|
804
|
+
silence_timeout = step.silence_timeout
|
|
805
|
+
else:
|
|
806
|
+
structlogger.debug(
|
|
807
|
+
"flow.step.run.reset_silence_timeout_to_global",
|
|
808
|
+
duration=silence_timeout,
|
|
809
|
+
collect=step.collect,
|
|
810
|
+
)
|
|
811
|
+
|
|
812
|
+
current_silence_timeout = tracker.get_slot(SILENCE_TIMEOUT_SLOT)
|
|
813
|
+
|
|
814
|
+
if current_silence_timeout != silence_timeout:
|
|
815
|
+
events.append(SlotSet(SILENCE_TIMEOUT_SLOT, silence_timeout))
|
|
816
|
+
|
|
817
|
+
return events
|
|
818
|
+
|
|
819
|
+
|
|
820
|
+
def _append_global_silence_timeout_event(
|
|
821
|
+
events: List[Event], tracker: DialogueStateTracker
|
|
822
|
+
) -> None:
|
|
823
|
+
current_silence_timeout = tracker.get_slot(SILENCE_TIMEOUT_SLOT)
|
|
824
|
+
global_silence_timeout = (
|
|
825
|
+
AvailableEndpoints.get_instance().interaction_handling.global_silence_timeout
|
|
826
|
+
)
|
|
827
|
+
|
|
828
|
+
if current_silence_timeout != global_silence_timeout:
|
|
829
|
+
events.append(
|
|
830
|
+
SlotSet(
|
|
831
|
+
SILENCE_TIMEOUT_SLOT,
|
|
832
|
+
AvailableEndpoints.get_instance().interaction_handling.global_silence_timeout,
|
|
833
|
+
)
|
|
834
|
+
)
|
|
@@ -5,6 +5,7 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Text, Tuple
|
|
|
5
5
|
|
|
6
6
|
import structlog
|
|
7
7
|
import tiktoken
|
|
8
|
+
from deprecated import deprecated # type: ignore[import]
|
|
8
9
|
from jinja2 import Template
|
|
9
10
|
from langchain.docstore.document import Document
|
|
10
11
|
from langchain.schema.embeddings import Embeddings
|
|
@@ -37,18 +38,14 @@ from rasa.shared.constants import (
|
|
|
37
38
|
MODEL_NAME_CONFIG_KEY,
|
|
38
39
|
OPENAI_PROVIDER,
|
|
39
40
|
PROMPT_CONFIG_KEY,
|
|
41
|
+
PROMPT_TEMPLATE_CONFIG_KEY,
|
|
40
42
|
PROVIDER_CONFIG_KEY,
|
|
41
43
|
TEMPERATURE_CONFIG_KEY,
|
|
42
44
|
TIMEOUT_CONFIG_KEY,
|
|
43
45
|
)
|
|
44
46
|
from rasa.shared.core.constants import ACTION_LISTEN_NAME
|
|
45
47
|
from rasa.shared.core.domain import KEY_RESPONSES_TEXT, Domain
|
|
46
|
-
from rasa.shared.core.events import
|
|
47
|
-
ActionExecuted,
|
|
48
|
-
BotUttered,
|
|
49
|
-
Event,
|
|
50
|
-
UserUttered,
|
|
51
|
-
)
|
|
48
|
+
from rasa.shared.core.events import ActionExecuted, BotUttered, Event, UserUttered
|
|
52
49
|
from rasa.shared.core.flows import FlowsList
|
|
53
50
|
from rasa.shared.core.generator import TrackerWithCachedStates
|
|
54
51
|
from rasa.shared.core.policies.utils import filter_responses_for_intentless_policy
|
|
@@ -60,18 +57,22 @@ from rasa.shared.providers.embedding._langchain_embedding_client_adapter import
|
|
|
60
57
|
_LangchainEmbeddingClientAdapter,
|
|
61
58
|
)
|
|
62
59
|
from rasa.shared.providers.llm.llm_client import LLMClient
|
|
63
|
-
from rasa.shared.utils.constants import
|
|
60
|
+
from rasa.shared.utils.constants import (
|
|
61
|
+
LOG_COMPONENT_SOURCE_METHOD_FINGERPRINT_ADDON,
|
|
62
|
+
LOG_COMPONENT_SOURCE_METHOD_INIT,
|
|
63
|
+
)
|
|
64
64
|
from rasa.shared.utils.health_check.embeddings_health_check_mixin import (
|
|
65
65
|
EmbeddingsHealthCheckMixin,
|
|
66
66
|
)
|
|
67
67
|
from rasa.shared.utils.health_check.llm_health_check_mixin import LLMHealthCheckMixin
|
|
68
|
-
from rasa.shared.utils.io import deep_container_fingerprint
|
|
68
|
+
from rasa.shared.utils.io import deep_container_fingerprint, raise_deprecation_warning
|
|
69
69
|
from rasa.shared.utils.llm import (
|
|
70
70
|
AI,
|
|
71
71
|
DEFAULT_OPENAI_CHAT_MODEL_NAME,
|
|
72
72
|
DEFAULT_OPENAI_EMBEDDING_MODEL_NAME,
|
|
73
73
|
DEFAULT_OPENAI_MAX_GENERATED_TOKENS,
|
|
74
74
|
USER,
|
|
75
|
+
check_prompt_config_keys_and_warn_if_deprecated,
|
|
75
76
|
combine_custom_and_default_config,
|
|
76
77
|
embedder_factory,
|
|
77
78
|
get_prompt_template,
|
|
@@ -123,9 +124,12 @@ DEFAULT_EMBEDDINGS_CONFIG = {
|
|
|
123
124
|
MODEL_CONFIG_KEY: DEFAULT_OPENAI_EMBEDDING_MODEL_NAME,
|
|
124
125
|
}
|
|
125
126
|
|
|
126
|
-
|
|
127
|
+
DEFAULT_INTENTLESS_PROMPT_TEMPLATE_FILE_NAME = importlib.resources.open_text(
|
|
127
128
|
"rasa.core.policies", "intentless_prompt_template.jinja2"
|
|
128
129
|
).name
|
|
130
|
+
DEFAULT_INTENTLESS_PROMPT_TEMPLATE = importlib.resources.read_text(
|
|
131
|
+
"rasa.core.policies", "intentless_prompt_template.jinja2"
|
|
132
|
+
)
|
|
129
133
|
|
|
130
134
|
INTENTLESS_PROMPT_TEMPLATE_FILE_NAME = "intentless_policy_prompt.jinja2"
|
|
131
135
|
INTENTLESS_CONFIG_FILE_NAME = "config.json"
|
|
@@ -325,6 +329,9 @@ def conversation_as_prompt(conversation: Conversation) -> str:
|
|
|
325
329
|
@DefaultV1Recipe.register(
|
|
326
330
|
DefaultV1Recipe.ComponentType.POLICY_WITH_END_TO_END_SUPPORT, is_trainable=True
|
|
327
331
|
)
|
|
332
|
+
@deprecated(
|
|
333
|
+
reason=("The IntentlessPolicy is deprecated and will be removed in Rasa `4.0.0`.")
|
|
334
|
+
)
|
|
328
335
|
class IntentlessPolicy(LLMHealthCheckMixin, EmbeddingsHealthCheckMixin, Policy):
|
|
329
336
|
"""Policy which uses a language model to generate the next action.
|
|
330
337
|
|
|
@@ -346,7 +353,7 @@ class IntentlessPolicy(LLMHealthCheckMixin, EmbeddingsHealthCheckMixin, Policy):
|
|
|
346
353
|
# ensures that the policy will not override a deterministic policy
|
|
347
354
|
# which utilizes the nlu predictions confidence (e.g. Memoization).
|
|
348
355
|
NLU_ABSTENTION_THRESHOLD: 0.9,
|
|
349
|
-
|
|
356
|
+
PROMPT_TEMPLATE_CONFIG_KEY: None, # TODO: remove in Rasa 4.0.0
|
|
350
357
|
}
|
|
351
358
|
|
|
352
359
|
@staticmethod
|
|
@@ -378,6 +385,9 @@ class IntentlessPolicy(LLMHealthCheckMixin, EmbeddingsHealthCheckMixin, Policy):
|
|
|
378
385
|
prompt_template: Optional[Text] = None,
|
|
379
386
|
) -> None:
|
|
380
387
|
"""Constructs a new Policy object."""
|
|
388
|
+
raise_deprecation_warning(
|
|
389
|
+
message=("Support for `IntentlessPolicy` will be removed in Rasa `4.0.0`.")
|
|
390
|
+
)
|
|
381
391
|
super().__init__(config, model_storage, resource, execution_context, featurizer)
|
|
382
392
|
|
|
383
393
|
# Resolve LLM config
|
|
@@ -400,11 +410,43 @@ class IntentlessPolicy(LLMHealthCheckMixin, EmbeddingsHealthCheckMixin, Policy):
|
|
|
400
410
|
self.response_index = responses_docsearch
|
|
401
411
|
self.conversation_samples_index = samples_docsearch
|
|
402
412
|
self.embedder = self._create_plain_embedder(config)
|
|
403
|
-
|
|
404
|
-
|
|
413
|
+
|
|
414
|
+
# Warn if the prompt config key is used to set the prompt template
|
|
415
|
+
check_prompt_config_keys_and_warn_if_deprecated(config, "intentless_policy")
|
|
416
|
+
|
|
417
|
+
self.prompt_template = prompt_template or self._resolve_prompt_template(
|
|
418
|
+
config, LOG_COMPONENT_SOURCE_METHOD_INIT
|
|
405
419
|
)
|
|
406
420
|
self.trace_prompt_tokens = self.config.get("trace_prompt_tokens", False)
|
|
407
421
|
|
|
422
|
+
@classmethod
|
|
423
|
+
def _resolve_prompt_template(
|
|
424
|
+
cls: Any,
|
|
425
|
+
config: dict,
|
|
426
|
+
log_source_method: str,
|
|
427
|
+
) -> str:
|
|
428
|
+
"""Resolves the prompt template from the config.
|
|
429
|
+
|
|
430
|
+
Args:
|
|
431
|
+
config: The config to resolve the prompt template from.
|
|
432
|
+
log_source_method: The method from which the prompt template is resolved.
|
|
433
|
+
|
|
434
|
+
Returns:
|
|
435
|
+
The resolved prompt template.
|
|
436
|
+
"""
|
|
437
|
+
# Prefer prompt template over prompt config key.
|
|
438
|
+
prompt_template_file = (
|
|
439
|
+
config.get(PROMPT_TEMPLATE_CONFIG_KEY)
|
|
440
|
+
or config.get(PROMPT_CONFIG_KEY)
|
|
441
|
+
or DEFAULT_INTENTLESS_PROMPT_TEMPLATE_FILE_NAME
|
|
442
|
+
)
|
|
443
|
+
return get_prompt_template(
|
|
444
|
+
prompt_template_file,
|
|
445
|
+
DEFAULT_INTENTLESS_PROMPT_TEMPLATE,
|
|
446
|
+
log_source_component=IntentlessPolicy.__name__,
|
|
447
|
+
log_source_method=log_source_method,
|
|
448
|
+
)
|
|
449
|
+
|
|
408
450
|
@classmethod
|
|
409
451
|
def _create_plain_embedder(cls, config: Dict[Text, Any]) -> Embeddings:
|
|
410
452
|
"""Creates an embedder that uses the OpenAI API.
|
|
@@ -943,11 +985,8 @@ class IntentlessPolicy(LLMHealthCheckMixin, EmbeddingsHealthCheckMixin, Policy):
|
|
|
943
985
|
@classmethod
|
|
944
986
|
def fingerprint_addon(cls, config: Dict[str, Any]) -> Optional[str]:
|
|
945
987
|
"""Add a fingerprint of intentless policy for the graph."""
|
|
946
|
-
prompt_template =
|
|
947
|
-
config
|
|
948
|
-
DEFAULT_INTENTLESS_PROMPT_TEMPLATE,
|
|
949
|
-
log_source_component=IntentlessPolicy.__name__,
|
|
950
|
-
log_source_method=LOG_COMPONENT_SOURCE_METHOD_FINGERPRINT_ADDON,
|
|
988
|
+
prompt_template = cls._resolve_prompt_template(
|
|
989
|
+
config, LOG_COMPONENT_SOURCE_METHOD_FINGERPRINT_ADDON
|
|
951
990
|
)
|
|
952
991
|
|
|
953
992
|
llm_config = resolve_model_client_config(
|