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
rasa/shared/utils/llm.py
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
import importlib.resources
|
|
2
4
|
import json
|
|
3
5
|
import logging
|
|
4
6
|
from copy import deepcopy
|
|
5
7
|
from datetime import datetime
|
|
6
8
|
from functools import wraps
|
|
9
|
+
from pathlib import Path
|
|
7
10
|
from typing import (
|
|
8
11
|
TYPE_CHECKING,
|
|
9
12
|
Any,
|
|
@@ -20,15 +23,27 @@ from typing import (
|
|
|
20
23
|
)
|
|
21
24
|
|
|
22
25
|
import structlog
|
|
26
|
+
from pydantic import BaseModel, Field
|
|
23
27
|
|
|
28
|
+
import rasa.cli.telemetry
|
|
29
|
+
import rasa.cli.utils
|
|
30
|
+
import rasa.shared.utils.cli
|
|
24
31
|
import rasa.shared.utils.io
|
|
25
|
-
from rasa.core.
|
|
32
|
+
from rasa.core.available_endpoints import AvailableEndpoints
|
|
26
33
|
from rasa.shared.constants import (
|
|
34
|
+
CONFIG_NAME_KEY,
|
|
35
|
+
CONFIG_PIPELINE_KEY,
|
|
36
|
+
CONFIG_POLICIES_KEY,
|
|
27
37
|
DEFAULT_PROMPT_PACKAGE_NAME,
|
|
38
|
+
ENDPOINTS_NLG_KEY,
|
|
39
|
+
LLM_CONFIG_KEY,
|
|
28
40
|
MODEL_CONFIG_KEY,
|
|
29
41
|
MODEL_GROUP_CONFIG_KEY,
|
|
30
42
|
MODEL_GROUP_ID_CONFIG_KEY,
|
|
43
|
+
MODEL_GROUPS_CONFIG_KEY,
|
|
31
44
|
MODELS_CONFIG_KEY,
|
|
45
|
+
PROMPT_CONFIG_KEY,
|
|
46
|
+
PROMPT_TEMPLATE_CONFIG_KEY,
|
|
32
47
|
PROVIDER_CONFIG_KEY,
|
|
33
48
|
RASA_PATTERN_INTERNAL_ERROR_USER_INPUT_EMPTY,
|
|
34
49
|
RASA_PATTERN_INTERNAL_ERROR_USER_INPUT_TOO_LONG,
|
|
@@ -63,6 +78,7 @@ from rasa.shared.providers.mappings import (
|
|
|
63
78
|
get_embedding_client_from_provider,
|
|
64
79
|
get_llm_client_from_provider,
|
|
65
80
|
)
|
|
81
|
+
from rasa.shared.utils.common import all_subclasses
|
|
66
82
|
from rasa.shared.utils.constants import LOG_COMPONENT_SOURCE_METHOD_INIT
|
|
67
83
|
|
|
68
84
|
if TYPE_CHECKING:
|
|
@@ -76,13 +92,15 @@ USER = "USER"
|
|
|
76
92
|
|
|
77
93
|
AI = "AI"
|
|
78
94
|
|
|
79
|
-
DEFAULT_OPENAI_GENERATE_MODEL_NAME = "gpt-
|
|
95
|
+
DEFAULT_OPENAI_GENERATE_MODEL_NAME = "gpt-4o-2024-11-20"
|
|
96
|
+
|
|
97
|
+
DEFAULT_OPENAI_CHAT_MODEL_NAME = "gpt-4o-2024-11-20"
|
|
80
98
|
|
|
81
|
-
|
|
99
|
+
DEFAULT_ENTERPRISE_SEARCH_POLICY_MODEL_NAME = "gpt-4.1-mini-2025-04-14"
|
|
82
100
|
|
|
83
101
|
DEFAULT_OPENAI_CHAT_MODEL_NAME_ADVANCED = "gpt-4-0613"
|
|
84
102
|
|
|
85
|
-
DEFAULT_OPENAI_EMBEDDING_MODEL_NAME = "text-embedding-
|
|
103
|
+
DEFAULT_OPENAI_EMBEDDING_MODEL_NAME = "text-embedding-3-large"
|
|
86
104
|
|
|
87
105
|
DEFAULT_OPENAI_TEMPERATURE = 0.7
|
|
88
106
|
|
|
@@ -110,6 +128,18 @@ _CombineConfigs_F = TypeVar(
|
|
|
110
128
|
)
|
|
111
129
|
|
|
112
130
|
|
|
131
|
+
class SystemPrompts(BaseModel):
|
|
132
|
+
command_generator: str = Field(
|
|
133
|
+
..., description="Prompt used by the LLM command generator."
|
|
134
|
+
)
|
|
135
|
+
enterprise_search: str = Field(
|
|
136
|
+
..., description="Prompt for standard enterprise search requests."
|
|
137
|
+
)
|
|
138
|
+
contextual_response_rephraser: str = Field(
|
|
139
|
+
..., description="Prompt used for re-phrasing assistant responses."
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
|
|
113
143
|
def _compute_hash_for_cache_from_configs(
|
|
114
144
|
config_x: Dict[str, Any], config_y: Dict[str, Any]
|
|
115
145
|
) -> int:
|
|
@@ -553,7 +583,7 @@ def embedder_factory(
|
|
|
553
583
|
```
|
|
554
584
|
{
|
|
555
585
|
"provider": "openai",
|
|
556
|
-
"model": "text-embedding-3-
|
|
586
|
+
"model": "text-embedding-3-large",
|
|
557
587
|
"timeout": 10,
|
|
558
588
|
"num_retries": 3,
|
|
559
589
|
}
|
|
@@ -566,7 +596,7 @@ def embedder_factory(
|
|
|
566
596
|
"models": [
|
|
567
597
|
{
|
|
568
598
|
"provider": "openai",
|
|
569
|
-
"model": "test-embedding-3-
|
|
599
|
+
"model": "test-embedding-3-large",
|
|
570
600
|
"api_key": "test"
|
|
571
601
|
},
|
|
572
602
|
],
|
|
@@ -821,7 +851,9 @@ def allowed_values_for_slot(slot: Slot) -> Union[str, None]:
|
|
|
821
851
|
|
|
822
852
|
|
|
823
853
|
def resolve_model_client_config(
|
|
824
|
-
model_config: Optional[Dict[str, Any]],
|
|
854
|
+
model_config: Optional[Dict[str, Any]],
|
|
855
|
+
component_name: Optional[str] = None,
|
|
856
|
+
model_groups: Optional[List[Dict[str, Any]]] = None,
|
|
825
857
|
) -> Optional[Dict[str, Any]]:
|
|
826
858
|
"""Resolve the model group in the model config.
|
|
827
859
|
|
|
@@ -835,6 +867,7 @@ def resolve_model_client_config(
|
|
|
835
867
|
model_config: The model config to be resolved.
|
|
836
868
|
component_name: The name of the component.
|
|
837
869
|
component_name: The method of the component.
|
|
870
|
+
model_groups: Model groups from endpoints.yml.
|
|
838
871
|
|
|
839
872
|
Returns:
|
|
840
873
|
The resolved llm config.
|
|
@@ -861,7 +894,12 @@ def resolve_model_client_config(
|
|
|
861
894
|
|
|
862
895
|
model_group_id = model_config.get(MODEL_GROUP_CONFIG_KEY)
|
|
863
896
|
|
|
864
|
-
|
|
897
|
+
# If `model_groups` is provided, use it to initialise `AvailableEndpoints`,
|
|
898
|
+
# since `get_instance()` reads from the local endpoints file instead.
|
|
899
|
+
if model_groups:
|
|
900
|
+
endpoints = AvailableEndpoints(model_groups=model_groups)
|
|
901
|
+
else:
|
|
902
|
+
endpoints = AvailableEndpoints.get_instance()
|
|
865
903
|
if endpoints.model_groups is None:
|
|
866
904
|
_raise_invalid_config_exception(
|
|
867
905
|
reason=(
|
|
@@ -919,3 +957,202 @@ async def create_tracker_for_user_step(
|
|
|
919
957
|
|
|
920
958
|
# store the tracker with the unique sender id
|
|
921
959
|
await agent.tracker_store.save(tracker)
|
|
960
|
+
|
|
961
|
+
|
|
962
|
+
def check_prompt_config_keys_and_warn_if_deprecated(
|
|
963
|
+
config: dict, component_source: str
|
|
964
|
+
) -> None:
|
|
965
|
+
"""Checks and warns about deprecated config parameters."""
|
|
966
|
+
if PROMPT_CONFIG_KEY in config and PROMPT_TEMPLATE_CONFIG_KEY in config:
|
|
967
|
+
structlogger.warning(
|
|
968
|
+
f"{component_source}.init"
|
|
969
|
+
".both_deprecated_and_non_deprecated_config_keys_used_at_the_same_time",
|
|
970
|
+
event_info=(
|
|
971
|
+
f"Both '{PROMPT_CONFIG_KEY}' and '{PROMPT_TEMPLATE_CONFIG_KEY}' "
|
|
972
|
+
f"are present in the config. '{PROMPT_CONFIG_KEY}' will be ignored "
|
|
973
|
+
f"in favor of {PROMPT_TEMPLATE_CONFIG_KEY}."
|
|
974
|
+
),
|
|
975
|
+
)
|
|
976
|
+
|
|
977
|
+
# 'prompt' config key is deprecated in favor of 'prompt_template'
|
|
978
|
+
if PROMPT_CONFIG_KEY in config:
|
|
979
|
+
structlogger.warning(
|
|
980
|
+
f"{component_source}.init.deprecated_config_key",
|
|
981
|
+
event_info=(
|
|
982
|
+
f"The config parameter '{PROMPT_CONFIG_KEY}' is deprecated "
|
|
983
|
+
"and will be removed in Rasa 4.0.0. "
|
|
984
|
+
f"Please use the config parameter '{PROMPT_TEMPLATE_CONFIG_KEY}'"
|
|
985
|
+
f" instead. "
|
|
986
|
+
),
|
|
987
|
+
)
|
|
988
|
+
|
|
989
|
+
|
|
990
|
+
def _get_llm_command_generator_config(
|
|
991
|
+
config: Dict[Text, Any],
|
|
992
|
+
) -> Optional[Dict[Text, Any]]:
|
|
993
|
+
"""Get the llm command generator config from config.yml.
|
|
994
|
+
|
|
995
|
+
Args:
|
|
996
|
+
config: The config.yml file data.
|
|
997
|
+
|
|
998
|
+
Returns:
|
|
999
|
+
The llm command generator config.
|
|
1000
|
+
"""
|
|
1001
|
+
from rasa.dialogue_understanding.generator import LLMBasedCommandGenerator
|
|
1002
|
+
|
|
1003
|
+
# Collect all LLM based Command Generator class names.
|
|
1004
|
+
command_generator_subclasses = all_subclasses(LLMBasedCommandGenerator)
|
|
1005
|
+
command_generator_class_names = [
|
|
1006
|
+
command_generator.__name__ for command_generator in command_generator_subclasses
|
|
1007
|
+
]
|
|
1008
|
+
|
|
1009
|
+
# Read the LLM config of the Command Generator from the config.yml file.
|
|
1010
|
+
pipelines = config.get(CONFIG_PIPELINE_KEY, [])
|
|
1011
|
+
for pipeline in pipelines:
|
|
1012
|
+
if pipeline.get(CONFIG_NAME_KEY) in command_generator_class_names:
|
|
1013
|
+
return pipeline.get(LLM_CONFIG_KEY)
|
|
1014
|
+
|
|
1015
|
+
return None
|
|
1016
|
+
|
|
1017
|
+
|
|
1018
|
+
def _get_command_generator_prompt(
|
|
1019
|
+
config: Dict[Text, Any], endpoints: Dict[Text, Any]
|
|
1020
|
+
) -> Text:
|
|
1021
|
+
"""Get the command generator prompt based on the config."""
|
|
1022
|
+
from rasa.dialogue_understanding.generator.single_step.compact_llm_command_generator import ( # noqa: E501
|
|
1023
|
+
DEFAULT_COMMAND_PROMPT_TEMPLATE_FILE_NAME,
|
|
1024
|
+
FALLBACK_COMMAND_PROMPT_TEMPLATE_FILE_NAME,
|
|
1025
|
+
MODEL_PROMPT_MAPPER,
|
|
1026
|
+
)
|
|
1027
|
+
|
|
1028
|
+
model_config = _get_llm_command_generator_config(config)
|
|
1029
|
+
llm_config = resolve_model_client_config(
|
|
1030
|
+
model_config=model_config,
|
|
1031
|
+
model_groups=endpoints.get(MODEL_GROUPS_CONFIG_KEY),
|
|
1032
|
+
)
|
|
1033
|
+
return get_default_prompt_template_based_on_model(
|
|
1034
|
+
llm_config=llm_config or {},
|
|
1035
|
+
model_prompt_mapping=MODEL_PROMPT_MAPPER,
|
|
1036
|
+
default_prompt_path=DEFAULT_COMMAND_PROMPT_TEMPLATE_FILE_NAME,
|
|
1037
|
+
fallback_prompt_path=FALLBACK_COMMAND_PROMPT_TEMPLATE_FILE_NAME,
|
|
1038
|
+
)
|
|
1039
|
+
|
|
1040
|
+
|
|
1041
|
+
def _get_enterprise_search_prompt(config: Dict[Text, Any]) -> Text:
|
|
1042
|
+
"""Get the enterprise search prompt based on the config."""
|
|
1043
|
+
from rasa.core.policies.enterprise_search_policy import EnterpriseSearchPolicy
|
|
1044
|
+
|
|
1045
|
+
def get_enterprise_search_config() -> Dict[Text, Any]:
|
|
1046
|
+
policies = config.get(CONFIG_POLICIES_KEY, [])
|
|
1047
|
+
for policy in policies:
|
|
1048
|
+
if policy.get(CONFIG_NAME_KEY) == EnterpriseSearchPolicy.__name__:
|
|
1049
|
+
return policy
|
|
1050
|
+
|
|
1051
|
+
return {}
|
|
1052
|
+
|
|
1053
|
+
enterprise_search_config = get_enterprise_search_config()
|
|
1054
|
+
return EnterpriseSearchPolicy.get_system_default_prompt_based_on_config(
|
|
1055
|
+
enterprise_search_config
|
|
1056
|
+
)
|
|
1057
|
+
|
|
1058
|
+
|
|
1059
|
+
def get_system_default_prompts(
|
|
1060
|
+
config: Dict[Text, Any], endpoints: Dict[Text, Any]
|
|
1061
|
+
) -> SystemPrompts:
|
|
1062
|
+
"""Returns the system default prompts for the component.
|
|
1063
|
+
|
|
1064
|
+
Args:
|
|
1065
|
+
config: The config.yml file data.
|
|
1066
|
+
endpoints: The endpoints.yml file data.
|
|
1067
|
+
|
|
1068
|
+
Returns:
|
|
1069
|
+
SystemPrompts: A Pydantic model containing all default prompts.
|
|
1070
|
+
"""
|
|
1071
|
+
from rasa.core.nlg.contextual_response_rephraser import (
|
|
1072
|
+
DEFAULT_RESPONSE_VARIATION_PROMPT_TEMPLATE,
|
|
1073
|
+
)
|
|
1074
|
+
|
|
1075
|
+
return SystemPrompts(
|
|
1076
|
+
command_generator=_get_command_generator_prompt(config, endpoints),
|
|
1077
|
+
enterprise_search=_get_enterprise_search_prompt(config),
|
|
1078
|
+
contextual_response_rephraser=DEFAULT_RESPONSE_VARIATION_PROMPT_TEMPLATE,
|
|
1079
|
+
)
|
|
1080
|
+
|
|
1081
|
+
|
|
1082
|
+
def collect_custom_prompts(
|
|
1083
|
+
config: Dict[Text, Any],
|
|
1084
|
+
endpoints: Dict[Text, Any],
|
|
1085
|
+
project_root: Optional[Path] = None,
|
|
1086
|
+
) -> Dict[Text, Text]:
|
|
1087
|
+
"""Collects custom prompts from the project configuration and endpoints.
|
|
1088
|
+
|
|
1089
|
+
Args:
|
|
1090
|
+
config: The configuration dictionary of the project.
|
|
1091
|
+
endpoints: The endpoints configuration dictionary.
|
|
1092
|
+
project_root: The root directory of the project.
|
|
1093
|
+
|
|
1094
|
+
Returns:
|
|
1095
|
+
A dictionary containing custom prompts.
|
|
1096
|
+
The keys are:
|
|
1097
|
+
- 'contextual_response_rephraser'
|
|
1098
|
+
- 'command_generator'
|
|
1099
|
+
- 'enterprise_search'
|
|
1100
|
+
"""
|
|
1101
|
+
from rasa.core.policies.enterprise_search_policy import EnterpriseSearchPolicy
|
|
1102
|
+
from rasa.dialogue_understanding.generator.llm_based_command_generator import (
|
|
1103
|
+
LLMBasedCommandGenerator,
|
|
1104
|
+
)
|
|
1105
|
+
from rasa.studio.prompts import (
|
|
1106
|
+
COMMAND_GENERATOR_NAME,
|
|
1107
|
+
CONTEXTUAL_RESPONSE_REPHRASER_NAME,
|
|
1108
|
+
ENTERPRISE_SEARCH_NAME,
|
|
1109
|
+
)
|
|
1110
|
+
|
|
1111
|
+
prompts: Dict[Text, Text] = {}
|
|
1112
|
+
project_root = project_root or Path(".").resolve()
|
|
1113
|
+
|
|
1114
|
+
def _read_prompt(root: Path, path_in_yaml: Text) -> Optional[Text]:
|
|
1115
|
+
if not path_in_yaml:
|
|
1116
|
+
return None
|
|
1117
|
+
|
|
1118
|
+
prompt_path = (
|
|
1119
|
+
(root / path_in_yaml).resolve()
|
|
1120
|
+
if not Path(path_in_yaml).is_absolute()
|
|
1121
|
+
else Path(path_in_yaml)
|
|
1122
|
+
)
|
|
1123
|
+
if prompt_path.exists():
|
|
1124
|
+
return prompt_path.read_text(encoding="utf-8")
|
|
1125
|
+
|
|
1126
|
+
structlogger.warning(
|
|
1127
|
+
"utils.llm.collect_custom_prompts.prompt_not_found",
|
|
1128
|
+
event_info=(f"Prompt file '{prompt_path}' not found. "),
|
|
1129
|
+
prompt_path=prompt_path,
|
|
1130
|
+
project_root=root,
|
|
1131
|
+
)
|
|
1132
|
+
return None
|
|
1133
|
+
|
|
1134
|
+
# contextual_response_rephraser
|
|
1135
|
+
nlg_conf = endpoints.get(ENDPOINTS_NLG_KEY) or {}
|
|
1136
|
+
if prompt_text := _read_prompt(project_root, nlg_conf.get(PROMPT_CONFIG_KEY)):
|
|
1137
|
+
prompts[CONTEXTUAL_RESPONSE_REPHRASER_NAME] = prompt_text
|
|
1138
|
+
|
|
1139
|
+
# command_generator
|
|
1140
|
+
command_generator_classes = {
|
|
1141
|
+
cls.__name__ for cls in all_subclasses(LLMBasedCommandGenerator)
|
|
1142
|
+
}
|
|
1143
|
+
for component in config.get(CONFIG_PIPELINE_KEY, []):
|
|
1144
|
+
if component.get(CONFIG_NAME_KEY) in command_generator_classes:
|
|
1145
|
+
if prompt_text := _read_prompt(
|
|
1146
|
+
project_root, component.get(PROMPT_TEMPLATE_CONFIG_KEY)
|
|
1147
|
+
):
|
|
1148
|
+
prompts[COMMAND_GENERATOR_NAME] = prompt_text
|
|
1149
|
+
break
|
|
1150
|
+
|
|
1151
|
+
# enterprise_search
|
|
1152
|
+
for policy in config.get(CONFIG_POLICIES_KEY, []):
|
|
1153
|
+
if policy.get(CONFIG_NAME_KEY) == EnterpriseSearchPolicy.__name__:
|
|
1154
|
+
if prompt_text := _read_prompt(project_root, policy.get(PROMPT_CONFIG_KEY)):
|
|
1155
|
+
prompts[ENTERPRISE_SEARCH_NAME] = prompt_text
|
|
1156
|
+
break
|
|
1157
|
+
|
|
1158
|
+
return prompts
|
|
@@ -8,11 +8,6 @@ from typing import Any, Dict, List, Text, Union
|
|
|
8
8
|
|
|
9
9
|
from pykwalify.errors import SchemaError
|
|
10
10
|
|
|
11
|
-
from rasa.shared.utils.constants import (
|
|
12
|
-
RASA_PRO_BETA_PREDICATES_IN_RESPONSE_CONDITIONS_ENV_VAR_NAME,
|
|
13
|
-
)
|
|
14
|
-
from rasa.utils.beta import ensure_beta_feature_is_enabled
|
|
15
|
-
|
|
16
11
|
|
|
17
12
|
def require_response_keys(
|
|
18
13
|
responses: List[Dict[Text, Any]], _: Dict, __: Text
|
|
@@ -31,10 +26,6 @@ def require_response_keys(
|
|
|
31
26
|
|
|
32
27
|
conditions = response.get("condition", [])
|
|
33
28
|
if isinstance(conditions, str):
|
|
34
|
-
ensure_beta_feature_is_enabled(
|
|
35
|
-
"predicates in response conditions",
|
|
36
|
-
RASA_PRO_BETA_PREDICATES_IN_RESPONSE_CONDITIONS_ENV_VAR_NAME,
|
|
37
|
-
)
|
|
38
29
|
continue
|
|
39
30
|
|
|
40
31
|
for condition in conditions:
|
rasa/shared/utils/yaml.py
CHANGED
|
@@ -21,6 +21,7 @@ from ruamel.yaml import YAML, RoundTripRepresenter, YAMLError
|
|
|
21
21
|
from ruamel.yaml.comments import CommentedMap, CommentedSeq
|
|
22
22
|
from ruamel.yaml.constructor import BaseConstructor, DuplicateKeyError, ScalarNode
|
|
23
23
|
from ruamel.yaml.loader import SafeLoader
|
|
24
|
+
from ruamel.yaml.scalarstring import LiteralScalarString
|
|
24
25
|
|
|
25
26
|
from rasa.shared.constants import (
|
|
26
27
|
ASSERTIONS_SCHEMA_EXTENSIONS_FILE,
|
|
@@ -794,6 +795,25 @@ def write_yaml(
|
|
|
794
795
|
should_preserve_key_order: Whether to force preserve key order in `data`.
|
|
795
796
|
transform: A function to transform the data before writing it to the file.
|
|
796
797
|
"""
|
|
798
|
+
|
|
799
|
+
def multiline_str_representer(self: Any, value: str) -> Any:
|
|
800
|
+
"""Dump multi-line strings as readable YAML block scalars where possible."""
|
|
801
|
+
if "\n" in value:
|
|
802
|
+
# First line after the newline decides: paragraph vs. snippet
|
|
803
|
+
first_line = value.split("\n", 1)[1]
|
|
804
|
+
|
|
805
|
+
# If the first line after the newline is not indented, treat the value
|
|
806
|
+
# as plain text. Indented text is likely pre-formatted YAML/JSON/etc.
|
|
807
|
+
if not first_line.startswith((" ", "\t")):
|
|
808
|
+
return self.represent_scalar(
|
|
809
|
+
"tag:yaml.org,2002:str",
|
|
810
|
+
LiteralScalarString(value),
|
|
811
|
+
style="|",
|
|
812
|
+
)
|
|
813
|
+
|
|
814
|
+
# Fallback: keep default YAML scalar style (plain/quoted)
|
|
815
|
+
return self.represent_scalar("tag:yaml.org,2002:str", value)
|
|
816
|
+
|
|
797
817
|
_enable_ordered_dict_yaml_dumping()
|
|
798
818
|
|
|
799
819
|
if should_preserve_key_order:
|
|
@@ -808,6 +828,7 @@ def write_yaml(
|
|
|
808
828
|
type(None),
|
|
809
829
|
lambda self, _: self.represent_scalar("tag:yaml.org,2002:null", "null"),
|
|
810
830
|
)
|
|
831
|
+
dumper.representer.add_representer(str, multiline_str_representer)
|
|
811
832
|
|
|
812
833
|
if isinstance(target, StringIO):
|
|
813
834
|
dumper.dump(data, target, transform=transform)
|
|
@@ -1025,6 +1046,17 @@ def validate_yaml_with_jsonschema(
|
|
|
1025
1046
|
except (YAMLError, DuplicateKeyError) as e:
|
|
1026
1047
|
raise YamlSyntaxException(underlying_yaml_exception=e)
|
|
1027
1048
|
|
|
1049
|
+
validate_data_with_jsonschema(source_data, schema_content, humanize_error)
|
|
1050
|
+
|
|
1051
|
+
|
|
1052
|
+
def validate_data_with_jsonschema(
|
|
1053
|
+
source_data: Any,
|
|
1054
|
+
schema_content: Any,
|
|
1055
|
+
humanize_error: Callable[
|
|
1056
|
+
[jsonschema.ValidationError], str
|
|
1057
|
+
] = default_error_humanizer,
|
|
1058
|
+
) -> None:
|
|
1059
|
+
"""Validate Python object against the provided jsonschema content."""
|
|
1028
1060
|
try:
|
|
1029
1061
|
jsonschema.validate(source_data, schema_content)
|
|
1030
1062
|
except jsonschema.ValidationError as error:
|
rasa/studio/constants.py
CHANGED
|
@@ -14,6 +14,7 @@ RASA_STUDIO_CLI_DISABLE_VERIFY_KEY_ENV = "RASA_STUDIO_CLI_DISABLE_VERIFY_KEY"
|
|
|
14
14
|
|
|
15
15
|
STUDIO_NLU_FILENAME = "studio_nlu.yml"
|
|
16
16
|
STUDIO_DOMAIN_FILENAME = "studio_domain.yml"
|
|
17
|
+
DOMAIN_FILENAME = "domain.yml"
|
|
17
18
|
STUDIO_FLOWS_FILENAME = "studio_flows.yml"
|
|
18
19
|
STUDIO_CONFIG_FILENAME = "studio_config.yml"
|
|
19
20
|
STUDIO_ENDPOINTS_FILENAME = "studio_endpoints.yml"
|
rasa/studio/data_handler.py
CHANGED
|
@@ -45,15 +45,33 @@ class StudioDataHandler:
|
|
|
45
45
|
intent_names: Optional[List[str]] = None,
|
|
46
46
|
entity_names: Optional[List[str]] = None,
|
|
47
47
|
) -> dict:
|
|
48
|
+
from rasa.studio.prompts import (
|
|
49
|
+
COMMAND_GENERATOR_NAME,
|
|
50
|
+
CONTEXTUAL_RESPONSE_REPHRASER_NAME,
|
|
51
|
+
ENTERPRISE_SEARCH_NAME,
|
|
52
|
+
)
|
|
53
|
+
|
|
48
54
|
request = {
|
|
49
|
-
"query": (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
"query": "query ExportAsEncodedYaml($input: ExportAsEncodedYamlInput!) {\n"
|
|
56
|
+
" exportAsEncodedYaml(input: $input) {\n"
|
|
57
|
+
" ... on ExportModernAsEncodedYamlOutput {\n"
|
|
58
|
+
" nlu\n"
|
|
59
|
+
" flows\n"
|
|
60
|
+
" domain\n"
|
|
61
|
+
" endpoints\n"
|
|
62
|
+
" config\n"
|
|
63
|
+
" prompts {\n"
|
|
64
|
+
f" {COMMAND_GENERATOR_NAME}\n"
|
|
65
|
+
f" {CONTEXTUAL_RESPONSE_REPHRASER_NAME}\n"
|
|
66
|
+
f" {ENTERPRISE_SEARCH_NAME}\n"
|
|
67
|
+
" }\n"
|
|
68
|
+
" }\n"
|
|
69
|
+
" ... on ExportClassicAsEncodedYamlOutput {\n"
|
|
70
|
+
" nlu\n"
|
|
71
|
+
" domain\n"
|
|
72
|
+
" }\n"
|
|
73
|
+
" }\n"
|
|
74
|
+
"}\n",
|
|
57
75
|
"variables": {"input": {"assistantName": self.assistant_name}},
|
|
58
76
|
}
|
|
59
77
|
if intent_names or entity_names:
|
|
@@ -97,7 +115,6 @@ class StudioDataHandler:
|
|
|
97
115
|
},
|
|
98
116
|
verify=verify,
|
|
99
117
|
)
|
|
100
|
-
|
|
101
118
|
if res.status_code != 200:
|
|
102
119
|
raise RasaException(
|
|
103
120
|
f"Download from Studio with URL: "
|
|
@@ -161,6 +178,9 @@ class StudioDataHandler:
|
|
|
161
178
|
def get_endpoints(self) -> Optional[str]:
|
|
162
179
|
return self.endpoints
|
|
163
180
|
|
|
181
|
+
def get_prompts(self) -> Optional[dict]:
|
|
182
|
+
return self.prompts
|
|
183
|
+
|
|
164
184
|
def _validate_response(self, response: dict) -> bool:
|
|
165
185
|
"""Validates the response from Rasa Studio.
|
|
166
186
|
|
|
@@ -199,6 +219,7 @@ class StudioDataHandler:
|
|
|
199
219
|
self.flows = self._decode_response(return_data.get("flows"))
|
|
200
220
|
self.config = self._decode_response(return_data.get("config"))
|
|
201
221
|
self.endpoints = self._decode_response(return_data.get("endpoints"))
|
|
222
|
+
self.prompts = return_data.get("prompts")
|
|
202
223
|
|
|
203
224
|
if not self.has_nlu() and not self.has_flows():
|
|
204
225
|
raise RasaException("No nlu or flows data in Studio response.")
|
|
@@ -320,14 +341,14 @@ def create_new_flows_from_diff(
|
|
|
320
341
|
|
|
321
342
|
|
|
322
343
|
def import_data_from_studio(
|
|
323
|
-
handler: StudioDataHandler, domain_path: Path,
|
|
344
|
+
handler: StudioDataHandler, domain_path: Path, data_path: Path
|
|
324
345
|
) -> Tuple[TrainingDataImporter, TrainingDataImporter]:
|
|
325
346
|
"""Construct TrainingDataImporter from Studio data and original data.
|
|
326
347
|
|
|
327
348
|
Args:
|
|
328
349
|
handler (StudioDataHandler): handler with data from studio
|
|
329
350
|
domain_path (Path): Path to a domain file
|
|
330
|
-
|
|
351
|
+
data_path (List[Path]): List of paths to training data files
|
|
331
352
|
|
|
332
353
|
Returns:
|
|
333
354
|
Tuple[TrainingDataImporter, TrainingDataImporter]:
|
|
@@ -335,7 +356,7 @@ def import_data_from_studio(
|
|
|
335
356
|
"""
|
|
336
357
|
tmp_dir = get_temp_dir_name()
|
|
337
358
|
data_original = TrainingDataImporter.load_from_dict(
|
|
338
|
-
domain_path=domain_path, training_data_paths=
|
|
359
|
+
domain_path=str(domain_path), training_data_paths=[str(data_path)]
|
|
339
360
|
)
|
|
340
361
|
|
|
341
362
|
data_paths = []
|