rasa-pro 3.12.18.dev1__py3-none-any.whl → 3.13.0a1.dev1__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/__init__.py +0 -6
- rasa/__main__.py +3 -4
- rasa/api.py +1 -1
- rasa/builder/create_openai_vector_store.py +69 -0
- rasa/builder/llm-helper-schema.json +69 -0
- rasa/builder/prompt_to_bot.py +645 -0
- rasa/builder/scrape_rasa_docs.py +97 -0
- rasa/builder/skill_to_bot_prompt.jinja +158 -0
- rasa/cli/dialogue_understanding_test.py +1 -1
- rasa/cli/e2e_test.py +1 -1
- rasa/cli/evaluate.py +2 -2
- rasa/cli/export.py +3 -3
- 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/run.py +1 -1
- rasa/cli/scaffold.py +2 -3
- rasa/cli/studio/download.py +1 -1
- rasa/cli/studio/link.py +53 -0
- rasa/cli/studio/pull.py +78 -0
- rasa/cli/studio/push.py +78 -0
- rasa/cli/studio/studio.py +12 -0
- rasa/cli/studio/upload.py +5 -3
- rasa/cli/train.py +1 -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 +42 -31
- rasa/core/actions/action_repeat_bot_messages.py +18 -22
- rasa/core/actions/action_run_slot_rejections.py +1 -2
- rasa/core/agent.py +18 -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/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-02053cc1.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-7f34db23.js → blockDiagram-38ab4fdb-008b6289.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-948bab2c.js → c4Diagram-3d4e48cf-fb2597be.js} +1 -1
- rasa/core/channels/inspector/dist/assets/channel-078dada8.js +1 -0
- rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-53b0dd0e.js → classDiagram-70f12bd4-7f847e00.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-fdf789e7.js → classDiagram-v2-f2320105-ba1d689b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/clone-5b4516de.js +1 -0
- rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-87c4ece5.js → createText-2e5e7dd3-dd8e67c4.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-5a8b0749.js → edges-e0da2a9e-10784939.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-66da90e2.js → erDiagram-9861fffd-24947ae6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-10044f05.js → flowDb-956e92f1-a9ced505.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-f338f66a.js → flowDiagram-66a62f08-afda9c7c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-f9613071.js +1 -0
- rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-b13140aa.js → flowchart-elk-definition-4a651766-6ef530b8.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-f2b4a55a.js → ganttDiagram-c361ad54-0c7dd39a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-dedc298d.js → gitGraphDiagram-72cf32ee-b57239d6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{graph-4ede11ff.js → graph-9ed57cec.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-3862675e-65549d37.js → index-3862675e-233090de.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-3a23e736.js → index-72184470.js} +123 -123
- rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-65439671.js → infoDiagram-f8f76790-aa116649.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-56d03d98.js → journeyDiagram-49397b02-e51877cc.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-dd48f7f4.js → layout-3ca3798c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{line-1569ad2c.js → line-26ee10d3.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-48bf4935.js → linear-aedded32.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-688504c1.js → mindmap-definition-fc14e90a-d8957261.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-78b6d7e6.js → pieDiagram-8a3498a8-d771f885.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-048b84b3.js → quadrantDiagram-120e2f19-09fdf50c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-dd67f107.js → requirementDiagram-deff3bca-9f0af02e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-8128436e.js → sankeyDiagram-04a897e0-84415b37.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-1a0d1461.js → sequenceDiagram-704730f1-8dec4055.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-46d388ed.js → stateDiagram-587899a1-c5431d07.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-ea42951a.js → stateDiagram-v2-d93cdb3a-274e77d9.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-7427ed0c.js → styles-6aaf32cf-e364a1d7.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-9a916d00-ff5e5a16.js → styles-9a916d00-0dae36f6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-c10674c1-7b3680cf.js → styles-c10674c1-c4641675.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-f860f2ad.js → svgDrawCommon-08f97a94-831fe9a1.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-2eebf0c8.js → timeline-definition-85554ec2-c3304b3a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-5d7f4e96.js → xychartDiagram-e933f94c-da799369.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 +337 -71
- rasa/core/channels/vier_cvg.py +1 -2
- rasa/core/channels/voice_ready/audiocodes.py +4 -11
- rasa/core/channels/voice_stream/audiocodes.py +8 -5
- rasa/core/channels/voice_stream/browser_audio.py +1 -1
- rasa/core/channels/voice_stream/genesys.py +2 -2
- rasa/core/channels/voice_stream/tts/__init__.py +8 -0
- rasa/core/channels/voice_stream/twilio_media_streams.py +10 -5
- rasa/core/channels/voice_stream/voice_channel.py +65 -23
- rasa/core/concurrent_lock_store.py +24 -10
- rasa/core/evaluation/marker_tracker_loader.py +1 -1
- rasa/core/exporter.py +1 -1
- rasa/core/http_interpreter.py +3 -7
- rasa/core/information_retrieval/faiss.py +18 -11
- rasa/core/information_retrieval/ingestion/__init__.py +0 -0
- 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 +262 -62
- rasa/core/policies/enterprise_search_prompt_with_relevancy_check_and_citation_template.jinja2 +63 -0
- rasa/core/policies/flow_policy.py +1 -1
- rasa/core/policies/flows/flow_executor.py +96 -17
- rasa/core/policies/intentless_policy.py +57 -20
- rasa/core/processor.py +114 -54
- 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} +5 -1
- rasa/core/tracker_stores/dynamo_tracker_store.py +218 -0
- rasa/core/tracker_stores/mongo_tracker_store.py +206 -0
- rasa/core/tracker_stores/redis_tracker_store.py +219 -0
- rasa/core/tracker_stores/sql_tracker_store.py +555 -0
- rasa/core/tracker_stores/tracker_store.py +805 -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 +10 -6
- rasa/dialogue_understanding/commands/can_not_handle_command.py +2 -0
- rasa/dialogue_understanding/commands/cancel_flow_command.py +5 -1
- rasa/dialogue_understanding/commands/chit_chat_answer_command.py +2 -0
- rasa/dialogue_understanding/commands/clarify_command.py +4 -0
- rasa/dialogue_understanding/commands/command_syntax_manager.py +1 -0
- rasa/dialogue_understanding/commands/correct_slots_command.py +1 -3
- rasa/dialogue_understanding/commands/human_handoff_command.py +2 -0
- 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 +10 -0
- rasa/dialogue_understanding/commands/skip_question_command.py +2 -0
- rasa/dialogue_understanding/commands/start_flow_command.py +4 -0
- rasa/dialogue_understanding/commands/utils.py +26 -2
- 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 +5 -17
- rasa/dialogue_understanding/generator/llm_command_generator.py +1 -3
- rasa/dialogue_understanding/generator/multi_step/multi_step_llm_command_generator.py +4 -44
- rasa/dialogue_understanding/generator/nlu_command_adapter.py +2 -2
- rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v3_gpt_4o_2024_11_20_template.jinja2 +78 -0
- rasa/dialogue_understanding/generator/single_step/compact_llm_command_generator.py +26 -474
- 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 +477 -0
- rasa/dialogue_understanding/generator/single_step/single_step_llm_command_generator.py +11 -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 +37 -25
- rasa/dialogue_understanding/patterns/domain_for_patterns.py +190 -0
- rasa/dialogue_understanding/processor/command_processor.py +6 -7
- rasa/dialogue_understanding/stack/frames/flow_stack_frame.py +17 -4
- rasa/dialogue_understanding/stack/utils.py +3 -1
- rasa/dialogue_understanding/utils.py +68 -12
- 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/io.py +35 -8
- rasa/e2e_test/e2e_test_runner.py +1 -1
- 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 -85
- rasa/llm_fine_tuning/paraphrasing/conversation_rephraser.py +1 -5
- rasa/llm_fine_tuning/utils.py +2 -4
- rasa/model_manager/model_api.py +90 -2
- rasa/model_manager/socket_bridge.py +0 -7
- rasa/model_manager/trainer_service.py +15 -12
- 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 +340 -0
- rasa/privacy/privacy_manager.py +576 -0
- rasa/server.py +23 -2
- rasa/shared/constants.py +13 -4
- 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 +35 -8
- rasa/shared/core/flows/flow_step.py +26 -4
- 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 +16 -3
- rasa/shared/core/flows/yaml_flows_io.py +106 -5
- rasa/shared/core/slots.py +33 -1
- rasa/shared/core/trackers.py +4 -10
- rasa/shared/core/training_data/story_reader/yaml_story_reader.py +1 -4
- rasa/shared/importers/importer.py +14 -0
- rasa/shared/importers/static.py +63 -0
- rasa/shared/providers/constants.py +0 -9
- rasa/shared/providers/llm/_base_litellm_client.py +4 -14
- rasa/shared/providers/llm/default_litellm_llm_client.py +2 -2
- rasa/shared/providers/llm/litellm_router_llm_client.py +7 -17
- rasa/shared/providers/llm/llm_client.py +15 -24
- rasa/shared/providers/llm/self_hosted_llm_client.py +2 -10
- rasa/shared/utils/common.py +43 -1
- rasa/shared/utils/llm.py +155 -3
- rasa/shared/utils/yaml.py +32 -0
- rasa/studio/data_handler.py +3 -3
- rasa/studio/download/__init__.py +0 -0
- rasa/studio/download/domains.py +49 -0
- rasa/studio/download/download.py +416 -0
- rasa/studio/download/flows.py +351 -0
- rasa/studio/link.py +200 -0
- rasa/studio/pull.py +94 -0
- rasa/studio/push.py +131 -0
- rasa/studio/results_logger.py +6 -1
- rasa/studio/upload.py +185 -71
- rasa/telemetry.py +83 -26
- rasa/tracing/config.py +4 -5
- rasa/tracing/constants.py +19 -1
- rasa/tracing/instrumentation/attribute_extractors.py +49 -11
- 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 +37 -27
- rasa/utils/endpoints.py +22 -1
- rasa/utils/licensing.py +2 -3
- rasa/utils/log_utils.py +1 -45
- rasa/validator.py +9 -11
- rasa/version.py +1 -1
- {rasa_pro-3.12.18.dev1.dist-info → rasa_pro-3.13.0a1.dev1.dist-info}/METADATA +12 -14
- {rasa_pro-3.12.18.dev1.dist-info → rasa_pro-3.13.0a1.dev1.dist-info}/RECORD +318 -294
- 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/monkey_patches.py +0 -91
- rasa/studio/download.py +0 -489
- /rasa/{cli/project_templates/calm/actions → builder}/__init__.py +0 -0
- /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_pro-3.12.18.dev1.dist-info → rasa_pro-3.13.0a1.dev1.dist-info}/NOTICE +0 -0
- {rasa_pro-3.12.18.dev1.dist-info → rasa_pro-3.13.0a1.dev1.dist-info}/WHEEL +0 -0
- {rasa_pro-3.12.18.dev1.dist-info → rasa_pro-3.13.0a1.dev1.dist-info}/entry_points.txt +0 -0
rasa/studio/push.py
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Dict, Text
|
|
6
|
+
|
|
7
|
+
import structlog
|
|
8
|
+
|
|
9
|
+
import rasa.shared.utils.cli
|
|
10
|
+
from rasa.shared.core.flows.yaml_flows_io import YamlFlowsWriter
|
|
11
|
+
from rasa.shared.importers.importer import TrainingDataImporter
|
|
12
|
+
from rasa.shared.nlu.training_data.formats.rasa_yaml import RasaYAMLWriter
|
|
13
|
+
from rasa.shared.utils.io import read_file
|
|
14
|
+
from rasa.shared.utils.yaml import dump_obj_as_yaml_to_string
|
|
15
|
+
from rasa.studio.config import StudioConfig
|
|
16
|
+
from rasa.studio.link import get_studio_config, read_assistant_name
|
|
17
|
+
from rasa.studio.upload import (
|
|
18
|
+
build_import_request,
|
|
19
|
+
make_request,
|
|
20
|
+
run_validation,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
structlogger = structlog.get_logger(__name__)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _send_to_studio(
|
|
27
|
+
assistant_name: Text,
|
|
28
|
+
payload_parts: Dict[Text, Text],
|
|
29
|
+
studio_cfg: StudioConfig,
|
|
30
|
+
) -> None:
|
|
31
|
+
"""Build the GraphQL request and send it.
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
assistant_name: The name of the assistant.
|
|
35
|
+
payload_parts: The parts of the payload to send.
|
|
36
|
+
studio_cfg: The StudioConfig object.
|
|
37
|
+
"""
|
|
38
|
+
graphql_req = build_import_request(
|
|
39
|
+
assistant_name=assistant_name,
|
|
40
|
+
flows_yaml=payload_parts.get("flows"),
|
|
41
|
+
domain_yaml=payload_parts.get("domain"),
|
|
42
|
+
config_yaml=payload_parts.get("config"),
|
|
43
|
+
endpoints=payload_parts.get("endpoints"),
|
|
44
|
+
nlu_yaml=payload_parts.get("nlu"),
|
|
45
|
+
)
|
|
46
|
+
verify = not studio_cfg.disable_verify
|
|
47
|
+
result = make_request(studio_cfg.studio_url, graphql_req, verify)
|
|
48
|
+
if not result.was_successful:
|
|
49
|
+
rasa.shared.utils.cli.print_error_and_exit(result.message)
|
|
50
|
+
|
|
51
|
+
rasa.shared.utils.cli.print_success(f"Pushed data to assistant '{assistant_name}'.")
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def handle_push(args: argparse.Namespace) -> None:
|
|
55
|
+
"""Push the entire assistant.
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
args: The command line arguments.
|
|
59
|
+
"""
|
|
60
|
+
studio_cfg = get_studio_config()
|
|
61
|
+
|
|
62
|
+
run_validation(args)
|
|
63
|
+
|
|
64
|
+
importer = TrainingDataImporter.load_from_dict(
|
|
65
|
+
domain_path=args.domain,
|
|
66
|
+
config_path=args.config,
|
|
67
|
+
expand_env_vars=False,
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
domain_yaml = dump_obj_as_yaml_to_string(importer.get_user_domain().as_dict())
|
|
71
|
+
config_yaml = read_file(Path(args.config))
|
|
72
|
+
endpoints_yaml = read_file(Path(args.endpoints))
|
|
73
|
+
|
|
74
|
+
flow_importer = TrainingDataImporter.load_from_dict(
|
|
75
|
+
training_data_paths=args.data, expand_env_vars=False
|
|
76
|
+
)
|
|
77
|
+
flows_yaml = YamlFlowsWriter().dumps(flow_importer.get_user_flows())
|
|
78
|
+
|
|
79
|
+
nlu_importer = TrainingDataImporter.load_from_dict(
|
|
80
|
+
training_data_paths=args.data, expand_env_vars=False
|
|
81
|
+
)
|
|
82
|
+
nlu_yaml = RasaYAMLWriter().dumps(nlu_importer.get_nlu_data())
|
|
83
|
+
|
|
84
|
+
assistant_name = read_assistant_name()
|
|
85
|
+
_send_to_studio(
|
|
86
|
+
assistant_name,
|
|
87
|
+
{
|
|
88
|
+
"flows": flows_yaml,
|
|
89
|
+
"domain": domain_yaml,
|
|
90
|
+
"config": config_yaml,
|
|
91
|
+
"endpoints": endpoints_yaml,
|
|
92
|
+
"nlu": nlu_yaml,
|
|
93
|
+
},
|
|
94
|
+
studio_cfg,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def handle_push_config(args: argparse.Namespace) -> None:
|
|
99
|
+
"""Push only the assistant configuration (config.yml).
|
|
100
|
+
|
|
101
|
+
Args:
|
|
102
|
+
args: The command line arguments.
|
|
103
|
+
"""
|
|
104
|
+
studio_cfg = get_studio_config()
|
|
105
|
+
assistant_name = read_assistant_name()
|
|
106
|
+
|
|
107
|
+
config_yaml = read_file(Path(args.config))
|
|
108
|
+
if not config_yaml:
|
|
109
|
+
rasa.shared.utils.cli.print_error_and_exit(
|
|
110
|
+
"No configuration data was found in the assistant."
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
_send_to_studio(assistant_name, {"config": config_yaml}, studio_cfg)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def handle_push_endpoints(args: argparse.Namespace) -> None:
|
|
117
|
+
"""Push only the endpoints configuration (endpoints.yml).
|
|
118
|
+
|
|
119
|
+
Args:
|
|
120
|
+
args: The command line arguments.
|
|
121
|
+
"""
|
|
122
|
+
studio_cfg = get_studio_config()
|
|
123
|
+
assistant_name = read_assistant_name()
|
|
124
|
+
|
|
125
|
+
endpoints_yaml = read_file(Path(args.endpoints))
|
|
126
|
+
if not endpoints_yaml:
|
|
127
|
+
rasa.shared.utils.cli.print_error_and_exit(
|
|
128
|
+
"No endpoints data was found in the assistant."
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
_send_to_studio(assistant_name, {"endpoints": endpoints_yaml}, studio_cfg)
|
rasa/studio/results_logger.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
2
|
from functools import wraps
|
|
3
|
-
from typing import Any, Callable, Dict
|
|
3
|
+
from typing import Any, Callable, Dict, Text
|
|
4
4
|
|
|
5
5
|
import structlog
|
|
6
6
|
from keycloak.exceptions import KeycloakError
|
|
@@ -78,6 +78,11 @@ def response_has_errors(response: Dict) -> bool:
|
|
|
78
78
|
)
|
|
79
79
|
|
|
80
80
|
|
|
81
|
+
def response_has_id(response: Dict[Text, Any]) -> bool:
|
|
82
|
+
response_id = response.get("id")
|
|
83
|
+
return isinstance(response_id, str) and bool(response_id)
|
|
84
|
+
|
|
85
|
+
|
|
81
86
|
def _handle_rasa_exception(e: RasaException) -> StudioResult:
|
|
82
87
|
error_msg = "Rasa internal exception was raised while interacting with Studio."
|
|
83
88
|
structlogger.error("studio.rasa_error", event_info=error_msg, exception=str(e))
|
rasa/studio/upload.py
CHANGED
|
@@ -2,11 +2,12 @@ import argparse
|
|
|
2
2
|
import base64
|
|
3
3
|
import re
|
|
4
4
|
import sys
|
|
5
|
-
from typing import Any, Dict, Iterable, List, Set, Text, Tuple, Union
|
|
5
|
+
from typing import Any, Dict, Iterable, List, Optional, Set, Text, Tuple, Union
|
|
6
6
|
|
|
7
7
|
import questionary
|
|
8
8
|
import requests
|
|
9
9
|
import structlog
|
|
10
|
+
from pydantic import BaseModel, Field
|
|
10
11
|
|
|
11
12
|
import rasa.cli.telemetry
|
|
12
13
|
import rasa.cli.utils
|
|
@@ -32,6 +33,7 @@ from rasa.shared.nlu.training_data.formats.rasa_yaml import (
|
|
|
32
33
|
)
|
|
33
34
|
from rasa.shared.utils.yaml import (
|
|
34
35
|
dump_obj_as_yaml_to_string,
|
|
36
|
+
read_yaml,
|
|
35
37
|
read_yaml_file,
|
|
36
38
|
)
|
|
37
39
|
from rasa.studio import results_logger
|
|
@@ -64,6 +66,16 @@ DOMAIN_KEYS = [
|
|
|
64
66
|
]
|
|
65
67
|
|
|
66
68
|
|
|
69
|
+
class CALMImportParts(BaseModel):
|
|
70
|
+
"""All pieces that will be uploaded to Rasa Studio."""
|
|
71
|
+
|
|
72
|
+
flows: Dict[str, Any]
|
|
73
|
+
domain: Dict[str, Any]
|
|
74
|
+
config: Dict[str, Any]
|
|
75
|
+
endpoints: Dict[str, Any]
|
|
76
|
+
nlu: Dict[str, Any] = Field(default_factory=dict)
|
|
77
|
+
|
|
78
|
+
|
|
67
79
|
def _get_selected_entities_and_intents(
|
|
68
80
|
args: argparse.Namespace,
|
|
69
81
|
intents_from_files: Set[Text],
|
|
@@ -158,11 +170,7 @@ def handle_upload(args: argparse.Namespace) -> None:
|
|
|
158
170
|
RasaYAMLReader.expand_env_vars = False
|
|
159
171
|
YAMLFlowsReader.expand_env_vars = False
|
|
160
172
|
|
|
161
|
-
|
|
162
|
-
if hasattr(args, "calm") and args.calm:
|
|
163
|
-
upload_calm_assistant(args, endpoint, verify=verify)
|
|
164
|
-
else:
|
|
165
|
-
upload_nlu_assistant(args, endpoint, verify=verify)
|
|
173
|
+
upload_calm_assistant(args, endpoint, verify=verify)
|
|
166
174
|
|
|
167
175
|
|
|
168
176
|
config_keys = [
|
|
@@ -212,77 +220,93 @@ def _get_assistant_name(config: Dict[Text, Any]) -> str:
|
|
|
212
220
|
return assistant_name
|
|
213
221
|
|
|
214
222
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
223
|
+
def build_calm_import_parts(
|
|
224
|
+
data_path: Union[Text, List[Text]],
|
|
225
|
+
domain_path: Text,
|
|
226
|
+
config_path: Text,
|
|
227
|
+
endpoints_path: Optional[Text] = None,
|
|
228
|
+
assistant_name: Optional[Text] = None,
|
|
229
|
+
) -> Tuple[str, CALMImportParts]:
|
|
230
|
+
"""Builds the parts of the assistant to be uploaded to Studio.
|
|
220
231
|
|
|
221
232
|
Args:
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
endpoint: The studio endpoint
|
|
233
|
+
data_path: The path to the training data
|
|
234
|
+
domain_path: The path to the domain
|
|
235
|
+
config_path: The path to the config
|
|
236
|
+
endpoints_path: The path to the endpoints
|
|
237
|
+
assistant_name: The name of the assistant
|
|
238
|
+
|
|
229
239
|
Returns:
|
|
230
|
-
|
|
240
|
+
The assistant name and the parts to be uploaded
|
|
231
241
|
"""
|
|
232
|
-
run_validation(args)
|
|
233
|
-
|
|
234
|
-
structlogger.info(
|
|
235
|
-
"rasa.studio.upload.loading_data", event_info="Parsing CALM assistant data..."
|
|
236
|
-
)
|
|
237
|
-
|
|
238
242
|
importer = TrainingDataImporter.load_from_dict(
|
|
239
|
-
domain_path=
|
|
240
|
-
config_path=
|
|
243
|
+
domain_path=domain_path,
|
|
244
|
+
config_path=config_path,
|
|
241
245
|
expand_env_vars=False,
|
|
242
246
|
)
|
|
243
247
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
assistant_name = _get_assistant_name(config)
|
|
247
|
-
config_from_files = read_yaml_file(args.config, expand_env_vars=False)
|
|
248
|
-
domain_from_files = importer.get_user_domain().as_dict()
|
|
248
|
+
config = read_yaml_file(config_path, expand_env_vars=False)
|
|
249
|
+
endpoints = read_yaml_file(endpoints_path, expand_env_vars=False)
|
|
250
|
+
assistant_name = assistant_name or _get_assistant_name(config)
|
|
249
251
|
|
|
250
|
-
|
|
252
|
+
domain_from_files = importer.get_user_domain().as_dict()
|
|
251
253
|
domain = extract_values(domain_from_files, DOMAIN_KEYS)
|
|
252
254
|
|
|
253
|
-
# Prepare flows
|
|
254
255
|
flow_importer = FlowSyncImporter.load_from_dict(
|
|
255
|
-
training_data_paths=
|
|
256
|
+
training_data_paths=data_path, expand_env_vars=False
|
|
256
257
|
)
|
|
258
|
+
|
|
257
259
|
flows = list(flow_importer.get_user_flows())
|
|
260
|
+
flows_yaml = YamlFlowsWriter().dumps(flows)
|
|
261
|
+
flows = read_yaml(flows_yaml, expand_env_vars=False)
|
|
258
262
|
|
|
259
|
-
# We instantiate the TrainingDataImporter again on purpose to avoid
|
|
260
|
-
# adding patterns to domain's actions. More info https://t.ly/W8uuc
|
|
261
263
|
nlu_importer = TrainingDataImporter.load_from_dict(
|
|
262
|
-
training_data_paths=
|
|
264
|
+
training_data_paths=data_path, expand_env_vars=False
|
|
263
265
|
)
|
|
264
266
|
nlu_data = nlu_importer.get_nlu_data()
|
|
265
267
|
nlu_examples = nlu_data.filter_training_examples(
|
|
266
268
|
lambda ex: ex.get("intent") in nlu_data.intents
|
|
267
269
|
)
|
|
268
270
|
nlu_examples_yaml = RasaYAMLWriter().dumps(nlu_examples)
|
|
271
|
+
nlu = read_yaml(nlu_examples_yaml, expand_env_vars=False)
|
|
272
|
+
|
|
273
|
+
parts = CALMImportParts(
|
|
274
|
+
flows=flows,
|
|
275
|
+
domain=domain,
|
|
276
|
+
config=config,
|
|
277
|
+
endpoints=endpoints,
|
|
278
|
+
nlu=nlu,
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
return assistant_name, parts
|
|
269
282
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
283
|
+
|
|
284
|
+
@with_studio_error_handler
|
|
285
|
+
def upload_calm_assistant(
|
|
286
|
+
args: argparse.Namespace, endpoint: str, verify: bool = True
|
|
287
|
+
) -> StudioResult:
|
|
288
|
+
def yaml_or_empty(part: Dict[Text, Any]) -> Optional[str]:
|
|
289
|
+
return dump_obj_as_yaml_to_string(part) if part else None
|
|
290
|
+
|
|
291
|
+
run_validation(args)
|
|
292
|
+
structlogger.info(
|
|
293
|
+
"rasa.studio.upload.loading_data", event_info="Parsing CALM assistant data..."
|
|
294
|
+
)
|
|
295
|
+
assistant_name, parts = build_calm_import_parts(
|
|
296
|
+
data_path=args.data,
|
|
297
|
+
domain_path=args.domain,
|
|
298
|
+
config_path=args.config,
|
|
299
|
+
endpoints_path=args.endpoints,
|
|
274
300
|
)
|
|
275
301
|
|
|
276
|
-
# Build GraphQL request
|
|
277
302
|
graphql_req = build_import_request(
|
|
278
303
|
assistant_name,
|
|
279
|
-
flows_yaml=
|
|
280
|
-
domain_yaml=
|
|
281
|
-
config_yaml=
|
|
282
|
-
endpoints=
|
|
283
|
-
nlu_yaml=
|
|
304
|
+
flows_yaml=yaml_or_empty(parts.flows),
|
|
305
|
+
domain_yaml=yaml_or_empty(parts.domain),
|
|
306
|
+
config_yaml=yaml_or_empty(parts.config),
|
|
307
|
+
endpoints=yaml_or_empty(parts.endpoints),
|
|
308
|
+
nlu_yaml=yaml_or_empty(parts.nlu),
|
|
284
309
|
)
|
|
285
|
-
|
|
286
310
|
structlogger.info(
|
|
287
311
|
"rasa.studio.upload.calm", event_info="Uploading to Rasa Studio..."
|
|
288
312
|
)
|
|
@@ -395,7 +419,6 @@ def make_request(endpoint: str, graphql_req: Dict, verify: bool = True) -> Studi
|
|
|
395
419
|
},
|
|
396
420
|
verify=verify,
|
|
397
421
|
)
|
|
398
|
-
|
|
399
422
|
if results_logger.response_has_errors(res.json()):
|
|
400
423
|
track_upload_to_studio_failed(res.json())
|
|
401
424
|
return StudioResult.error(res.json())
|
|
@@ -423,39 +446,64 @@ def _add_missing_entities(
|
|
|
423
446
|
|
|
424
447
|
def build_import_request(
|
|
425
448
|
assistant_name: str,
|
|
426
|
-
flows_yaml: str,
|
|
427
|
-
domain_yaml: str,
|
|
428
|
-
config_yaml: str,
|
|
429
|
-
endpoints: str,
|
|
430
|
-
nlu_yaml: str =
|
|
449
|
+
flows_yaml: Optional[str] = None,
|
|
450
|
+
domain_yaml: Optional[str] = None,
|
|
451
|
+
config_yaml: Optional[str] = None,
|
|
452
|
+
endpoints: Optional[str] = None,
|
|
453
|
+
nlu_yaml: Optional[str] = None,
|
|
431
454
|
) -> Dict:
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
455
|
+
"""Builds the GraphQL request for uploading a modern assistant.
|
|
456
|
+
|
|
457
|
+
Args:
|
|
458
|
+
assistant_name: The name of the assistant
|
|
459
|
+
flows_yaml: The YAML representation of the flows
|
|
460
|
+
domain_yaml: The YAML representation of the domain
|
|
461
|
+
config_yaml: The YAML representation of the config
|
|
462
|
+
endpoints: The YAML representation of the endpoints
|
|
463
|
+
nlu_yaml: The YAML representation of the NLU data
|
|
464
|
+
|
|
465
|
+
Returns:
|
|
466
|
+
A dictionary representing the GraphQL request for uploading the assistant.
|
|
467
|
+
"""
|
|
468
|
+
inputs_map = {
|
|
469
|
+
"domain": domain_yaml,
|
|
470
|
+
"flows": flows_yaml,
|
|
471
|
+
"config": config_yaml,
|
|
472
|
+
"endpoints": endpoints,
|
|
473
|
+
"nlu": nlu_yaml,
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
payload = {
|
|
477
|
+
field: convert_string_to_base64(value)
|
|
478
|
+
for field, value in inputs_map.items()
|
|
479
|
+
if value is not None
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
variables_input = {"assistantName": assistant_name, **payload}
|
|
438
483
|
|
|
439
484
|
graphql_req = {
|
|
440
485
|
"query": (
|
|
441
486
|
"mutation UploadModernAssistant($input: UploadModernAssistantInput!)"
|
|
442
487
|
"{\n uploadModernAssistant(input: $input)\n}"
|
|
443
488
|
),
|
|
444
|
-
"variables": {
|
|
445
|
-
"input": {
|
|
446
|
-
"assistantName": assistant_name,
|
|
447
|
-
"domain": base64_domain,
|
|
448
|
-
"flows": base64_flows,
|
|
449
|
-
"nlu": base64_nlu,
|
|
450
|
-
"config": base64_config,
|
|
451
|
-
"endpoints": base64_endpoints,
|
|
452
|
-
}
|
|
453
|
-
},
|
|
489
|
+
"variables": {"input": variables_input},
|
|
454
490
|
}
|
|
455
491
|
|
|
456
492
|
return graphql_req
|
|
457
493
|
|
|
458
494
|
|
|
495
|
+
def convert_string_to_base64(string: str) -> str:
|
|
496
|
+
"""Converts a string to base64.
|
|
497
|
+
|
|
498
|
+
Args:
|
|
499
|
+
string: The string to convert
|
|
500
|
+
|
|
501
|
+
Returns:
|
|
502
|
+
The base64 encoded string
|
|
503
|
+
"""
|
|
504
|
+
return base64.b64encode(string.encode("utf-8")).decode("utf-8")
|
|
505
|
+
|
|
506
|
+
|
|
459
507
|
def build_request(
|
|
460
508
|
assistant_name: str, nlu_examples_yaml: str, domain_yaml: str
|
|
461
509
|
) -> Dict:
|
|
@@ -563,3 +611,69 @@ def remove_quotes(node: Any) -> Any:
|
|
|
563
611
|
return {k: remove_quotes(v) for k, v in node.items()}
|
|
564
612
|
else:
|
|
565
613
|
return node
|
|
614
|
+
|
|
615
|
+
|
|
616
|
+
def check_if_assistant_already_exists(
|
|
617
|
+
assistant_name: str, endpoint: str, verify: bool = True
|
|
618
|
+
) -> bool:
|
|
619
|
+
"""Checks if the assistant already exists in Studio.
|
|
620
|
+
|
|
621
|
+
Args:
|
|
622
|
+
assistant_name: The name of the assistant
|
|
623
|
+
endpoint: The studio endpoint
|
|
624
|
+
verify: Whether to verify SSL
|
|
625
|
+
|
|
626
|
+
Returns:
|
|
627
|
+
bool: The upload confirmation
|
|
628
|
+
"""
|
|
629
|
+
graphql_req = build_get_assistant_by_name_request(assistant_name)
|
|
630
|
+
|
|
631
|
+
structlogger.info(
|
|
632
|
+
"rasa.studio.upload.assistant_already_exists",
|
|
633
|
+
event_info="Checking if assistant already exists...",
|
|
634
|
+
assistant_name=assistant_name,
|
|
635
|
+
)
|
|
636
|
+
|
|
637
|
+
token = KeycloakTokenReader().get_token()
|
|
638
|
+
res = requests.post(
|
|
639
|
+
endpoint,
|
|
640
|
+
json=graphql_req,
|
|
641
|
+
headers={
|
|
642
|
+
"Authorization": f"{token.token_type} {token.access_token}",
|
|
643
|
+
"Content-Type": "application/json",
|
|
644
|
+
},
|
|
645
|
+
verify=verify,
|
|
646
|
+
)
|
|
647
|
+
response = res.json()["data"]["assistantByName"] or {}
|
|
648
|
+
if results_logger.response_has_id(response):
|
|
649
|
+
structlogger.info(
|
|
650
|
+
"rasa.studio.upload.assistant_already_exists",
|
|
651
|
+
event_info="Assistant already exists.",
|
|
652
|
+
)
|
|
653
|
+
return True
|
|
654
|
+
|
|
655
|
+
structlogger.info(
|
|
656
|
+
"rasa.studio.upload.assistant_already_exists", event_info="Assistant not found."
|
|
657
|
+
)
|
|
658
|
+
return False
|
|
659
|
+
|
|
660
|
+
|
|
661
|
+
def build_get_assistant_by_name_request(
|
|
662
|
+
assistant_name: str,
|
|
663
|
+
) -> Dict:
|
|
664
|
+
graphql_req = {
|
|
665
|
+
"query": (
|
|
666
|
+
"query AssistantByName($input: AssistantByNameInput!) {"
|
|
667
|
+
" assistantByName(input: $input) {"
|
|
668
|
+
" ... on Assistant { id name mode }"
|
|
669
|
+
" ... on AssistantByName_AssistantNotFound { _ }"
|
|
670
|
+
" }"
|
|
671
|
+
"}"
|
|
672
|
+
),
|
|
673
|
+
"variables": {
|
|
674
|
+
"input": {
|
|
675
|
+
"assistantName": assistant_name,
|
|
676
|
+
}
|
|
677
|
+
},
|
|
678
|
+
}
|
|
679
|
+
return graphql_req
|