rasa-pro 3.12.18__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/__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 +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 +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 +56 -17
- rasa/core/processor.py +64 -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} +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 +9 -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 +4 -0
- rasa/dialogue_understanding/commands/skip_question_command.py +2 -0
- rasa/dialogue_understanding/commands/start_flow_command.py +4 -0
- 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/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 -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 +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/utils.py +3 -1
- 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/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 +1 -5
- 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 +14 -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 +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/llm/default_litellm_llm_client.py +2 -2
- 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 +47 -9
- 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.dist-info → rasa_pro-3.13.0a1.dev1.dist-info}/METADATA +12 -13
- {rasa_pro-3.12.18.dist-info → rasa_pro-3.13.0a1.dev1.dist-info}/RECORD +308 -283
- 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/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.dist-info → rasa_pro-3.13.0a1.dev1.dist-info}/NOTICE +0 -0
- {rasa_pro-3.12.18.dist-info → rasa_pro-3.13.0a1.dev1.dist-info}/WHEEL +0 -0
- {rasa_pro-3.12.18.dist-info → rasa_pro-3.13.0a1.dev1.dist-info}/entry_points.txt +0 -0
|
@@ -4,63 +4,63 @@ import {
|
|
|
4
4
|
useBreakpointValue,
|
|
5
5
|
useColorModeValue,
|
|
6
6
|
useToast,
|
|
7
|
-
} from
|
|
8
|
-
import { useEffect, useState } from
|
|
9
|
-
import axios from
|
|
10
|
-
import { useOurTheme } from
|
|
11
|
-
import { Welcome } from
|
|
12
|
-
import { DialogueStack } from
|
|
13
|
-
import { DialougeInformation } from
|
|
14
|
-
import { LoadingSpinner } from
|
|
15
|
-
import { DiagramFlow } from
|
|
16
|
-
import { RecruitmentPanel } from
|
|
17
|
-
import { formatSlots } from
|
|
18
|
-
import { Slot, Stack, Event, Flow, SelectedStack, Tracker } from
|
|
7
|
+
} from '@chakra-ui/react'
|
|
8
|
+
import { useEffect, useState } from 'react'
|
|
9
|
+
import axios from 'axios'
|
|
10
|
+
import { useOurTheme } from './theme'
|
|
11
|
+
import { Welcome } from './components/Welcome'
|
|
12
|
+
import { DialogueStack } from './components/DialogueStack'
|
|
13
|
+
import { DialougeInformation } from './components/DialogueInformation'
|
|
14
|
+
import { LoadingSpinner } from './components/LoadingSpinner'
|
|
15
|
+
import { DiagramFlow } from './components/DiagramFlow'
|
|
16
|
+
import { RecruitmentPanel } from './components/RecruitmentPanel'
|
|
17
|
+
import { formatSlots } from './helpers/formatters'
|
|
18
|
+
import { Slot, Stack, Event, Flow, SelectedStack, Tracker } from './types'
|
|
19
19
|
import {
|
|
20
20
|
createHistoricalStack,
|
|
21
21
|
flowStepTrail,
|
|
22
22
|
updatedActiveFrame,
|
|
23
|
-
} from
|
|
24
|
-
import queryString from
|
|
25
|
-
import { Chat } from
|
|
26
|
-
import useWebSocket, { ReadyState } from
|
|
23
|
+
} from './helpers/utils'
|
|
24
|
+
import queryString from 'query-string'
|
|
25
|
+
import { Chat } from './components/Chat'
|
|
26
|
+
import useWebSocket, { ReadyState } from 'react-use-websocket'
|
|
27
27
|
|
|
28
28
|
export function App() {
|
|
29
|
-
const toast = useToast()
|
|
30
|
-
const { rasaSpace, rasaRadii } = useOurTheme()
|
|
31
|
-
const [rasaChatSessionId, setRasaChatSessionId] = useState<string>(
|
|
32
|
-
const [flows, setFlows] = useState<Flow[]>([])
|
|
33
|
-
const [slots, setSlots] = useState<Slot[]>([])
|
|
34
|
-
const [events, setEvents] = useState<Event[]>([])
|
|
35
|
-
const [story, setStory] = useState<string>(
|
|
36
|
-
const [stack, setStack] = useState<Stack[]>([])
|
|
37
|
-
const [frame, setFrame] = useState<SelectedStack | undefined>(undefined)
|
|
29
|
+
const toast = useToast()
|
|
30
|
+
const { rasaSpace, rasaRadii } = useOurTheme()
|
|
31
|
+
const [rasaChatSessionId, setRasaChatSessionId] = useState<string>('')
|
|
32
|
+
const [flows, setFlows] = useState<Flow[]>([])
|
|
33
|
+
const [slots, setSlots] = useState<Slot[]>([])
|
|
34
|
+
const [events, setEvents] = useState<Event[]>([])
|
|
35
|
+
const [story, setStory] = useState<string>('')
|
|
36
|
+
const [stack, setStack] = useState<Stack[]>([])
|
|
37
|
+
const [frame, setFrame] = useState<SelectedStack | undefined>(undefined)
|
|
38
38
|
|
|
39
39
|
// State to control the visibility of the RecruitmentPanel
|
|
40
|
-
const [showRecruitmentPanel, setShowRecruitmentPanel] = useState(true)
|
|
40
|
+
const [showRecruitmentPanel, setShowRecruitmentPanel] = useState(true)
|
|
41
41
|
|
|
42
42
|
// we only show the transcript if we are not on the socket io channel
|
|
43
43
|
// on the socketio channel, we show the chat component instead
|
|
44
|
-
const shouldShowTranscript = !window.location.href.includes(
|
|
44
|
+
const shouldShowTranscript = !window.location.href.includes('socketio')
|
|
45
45
|
|
|
46
46
|
const inspectWS = window.location.href
|
|
47
|
-
.replace(
|
|
48
|
-
.replace(
|
|
47
|
+
.replace('inspect.html', 'tracker_stream')
|
|
48
|
+
.replace('http', 'ws')
|
|
49
49
|
const { sendJsonMessage, lastJsonMessage, readyState } =
|
|
50
50
|
useWebSocket<Tracker>(inspectWS, {
|
|
51
51
|
share: false,
|
|
52
52
|
shouldReconnect: () => true,
|
|
53
|
-
})
|
|
54
|
-
|
|
53
|
+
})
|
|
54
|
+
const token = new URLSearchParams(window.location.search).get('token')
|
|
55
55
|
|
|
56
56
|
useEffect(() => {
|
|
57
57
|
if (readyState === ReadyState.OPEN && rasaChatSessionId) {
|
|
58
58
|
sendJsonMessage({
|
|
59
|
-
action:
|
|
59
|
+
action: 'retrieve',
|
|
60
60
|
sender_id: rasaChatSessionId,
|
|
61
|
-
})
|
|
61
|
+
})
|
|
62
62
|
}
|
|
63
|
-
}, [readyState, sendJsonMessage, rasaChatSessionId])
|
|
63
|
+
}, [readyState, sendJsonMessage, rasaChatSessionId])
|
|
64
64
|
|
|
65
65
|
useEffect(() => {
|
|
66
66
|
// if we are on a "dynamic" input channel where the user can chat on
|
|
@@ -68,37 +68,37 @@ export function App() {
|
|
|
68
68
|
// support loading an existing conversation. therefore, we don't set
|
|
69
69
|
// the sender id in the url and a reload of the page will start a new
|
|
70
70
|
// conversation.
|
|
71
|
-
if(!shouldShowTranscript) return
|
|
71
|
+
if (!shouldShowTranscript) return
|
|
72
72
|
|
|
73
|
-
const queryParameters = queryString.parse(window.location.search)
|
|
74
|
-
const urlSender = queryParameters.sender as string
|
|
73
|
+
const queryParameters = queryString.parse(window.location.search)
|
|
74
|
+
const urlSender = queryParameters.sender as string
|
|
75
75
|
if (urlSender && urlSender !== rasaChatSessionId) {
|
|
76
|
-
setRasaChatSessionId(urlSender)
|
|
76
|
+
setRasaChatSessionId(urlSender)
|
|
77
77
|
} else if (!urlSender && rasaChatSessionId) {
|
|
78
78
|
// update the sender query parameter
|
|
79
|
-
const url = new URL(window.location.href)
|
|
80
|
-
url.searchParams.set(
|
|
81
|
-
window.history.pushState(null,
|
|
79
|
+
const url = new URL(window.location.href)
|
|
80
|
+
url.searchParams.set('sender', rasaChatSessionId)
|
|
81
|
+
window.history.pushState(null, '', url.toString())
|
|
82
82
|
}
|
|
83
|
-
}, [rasaChatSessionId, shouldShowTranscript])
|
|
83
|
+
}, [rasaChatSessionId, shouldShowTranscript])
|
|
84
84
|
|
|
85
85
|
useEffect(() => {
|
|
86
86
|
axios
|
|
87
|
-
.get(
|
|
87
|
+
.get('/flows', { params: { token } })
|
|
88
88
|
.then((response) => setFlows(response.data))
|
|
89
89
|
.catch((error) => {
|
|
90
90
|
// don't show a new toast if it's already active
|
|
91
|
-
if (toast.isActive(
|
|
91
|
+
if (toast.isActive('flows')) return
|
|
92
92
|
toast({
|
|
93
|
-
id:
|
|
94
|
-
title:
|
|
95
|
-
description: error?.message ||
|
|
96
|
-
status:
|
|
93
|
+
id: 'flows',
|
|
94
|
+
title: 'Flows could not be retrieved',
|
|
95
|
+
description: error?.message || 'An unknown error happened.',
|
|
96
|
+
status: 'error',
|
|
97
97
|
duration: 4000,
|
|
98
98
|
isClosable: true,
|
|
99
|
-
})
|
|
100
|
-
})
|
|
101
|
-
}, [toast])
|
|
99
|
+
})
|
|
100
|
+
})
|
|
101
|
+
}, [toast])
|
|
102
102
|
|
|
103
103
|
function fetchStory() {
|
|
104
104
|
axios
|
|
@@ -106,37 +106,37 @@ export function App() {
|
|
|
106
106
|
.then((response) => setStory(response.data))
|
|
107
107
|
.catch((error) => {
|
|
108
108
|
// don't show a new toast if it's already active
|
|
109
|
-
if (toast.isActive(
|
|
109
|
+
if (toast.isActive('story-error')) return
|
|
110
110
|
toast({
|
|
111
|
-
id:
|
|
112
|
-
title:
|
|
113
|
-
description: error?.message ||
|
|
114
|
-
status:
|
|
111
|
+
id: 'story-error',
|
|
112
|
+
title: 'Stories could not be retrieved',
|
|
113
|
+
description: error?.message || 'An unknown error happened.',
|
|
114
|
+
status: 'error',
|
|
115
115
|
duration: 4000,
|
|
116
116
|
isClosable: true,
|
|
117
|
-
})
|
|
118
|
-
})
|
|
117
|
+
})
|
|
118
|
+
})
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
// Run when a new WebSocket message is received (lastJsonMessage)
|
|
122
122
|
useEffect(() => {
|
|
123
123
|
// if the tracker update that we received is for the current chat session,
|
|
124
124
|
// update the tracker.
|
|
125
|
-
if (!lastJsonMessage) return
|
|
125
|
+
if (!lastJsonMessage) return
|
|
126
126
|
if (
|
|
127
127
|
!rasaChatSessionId ||
|
|
128
128
|
lastJsonMessage?.sender_id === rasaChatSessionId
|
|
129
129
|
) {
|
|
130
|
-
setSlots(formatSlots(lastJsonMessage.slots))
|
|
131
|
-
setEvents(lastJsonMessage.events)
|
|
130
|
+
setSlots(formatSlots(lastJsonMessage.slots))
|
|
131
|
+
setEvents(lastJsonMessage.events)
|
|
132
132
|
const updatedStack = createHistoricalStack(
|
|
133
133
|
lastJsonMessage.stack,
|
|
134
|
-
lastJsonMessage.events
|
|
135
|
-
)
|
|
136
|
-
setStack(updatedStack)
|
|
137
|
-
setFrame(updatedActiveFrame(frame, updatedStack, lastJsonMessage.events))
|
|
138
|
-
setRasaChatSessionId(lastJsonMessage.sender_id)
|
|
139
|
-
fetchStory()
|
|
134
|
+
lastJsonMessage.events,
|
|
135
|
+
)
|
|
136
|
+
setStack(updatedStack)
|
|
137
|
+
setFrame(updatedActiveFrame(frame, updatedStack, lastJsonMessage.events))
|
|
138
|
+
setRasaChatSessionId(lastJsonMessage.sender_id)
|
|
139
|
+
fetchStory()
|
|
140
140
|
} else if (
|
|
141
141
|
rasaChatSessionId &&
|
|
142
142
|
lastJsonMessage.sender_id !== rasaChatSessionId
|
|
@@ -144,51 +144,52 @@ export function App() {
|
|
|
144
144
|
// show a header link with the new sender the user can click a button to
|
|
145
145
|
// switch to the new chat session. the alert should be dissmissable.
|
|
146
146
|
}
|
|
147
|
-
}, [lastJsonMessage, rasaChatSessionId])
|
|
147
|
+
}, [lastJsonMessage, rasaChatSessionId])
|
|
148
148
|
|
|
149
149
|
const borderRadiusSx = {
|
|
150
150
|
borderRadius: rasaRadii.normal,
|
|
151
|
-
}
|
|
151
|
+
}
|
|
152
152
|
const gridTemplateColumns = useBreakpointValue({
|
|
153
|
-
base:
|
|
154
|
-
|
|
155
|
-
})
|
|
153
|
+
base: '21rem minmax(20rem, auto) 21rem',
|
|
154
|
+
'2xl': '25rem auto 25rem',
|
|
155
|
+
})
|
|
156
156
|
const gridSx = {
|
|
157
157
|
gridTemplateColumns,
|
|
158
|
-
gridTemplateRows:
|
|
158
|
+
gridTemplateRows: '1fr',
|
|
159
159
|
gridColumnGap: rasaSpace[1],
|
|
160
|
-
height:
|
|
160
|
+
height: '100vh',
|
|
161
161
|
padding: rasaSpace[2],
|
|
162
|
-
}
|
|
162
|
+
}
|
|
163
163
|
const boxSx = {
|
|
164
164
|
...borderRadiusSx,
|
|
165
165
|
padding: rasaSpace[1],
|
|
166
|
-
bg: useColorModeValue(
|
|
167
|
-
overflow:
|
|
168
|
-
}
|
|
166
|
+
bg: useColorModeValue('neutral.50', 'neutral.50'),
|
|
167
|
+
overflow: 'hidden',
|
|
168
|
+
}
|
|
169
169
|
const leftColumnSx = {
|
|
170
|
-
height:
|
|
171
|
-
overflow:
|
|
172
|
-
gridTemplateColumns:
|
|
170
|
+
height: '100%',
|
|
171
|
+
overflow: 'hidden',
|
|
172
|
+
gridTemplateColumns: '1fr',
|
|
173
173
|
gridTemplateRows: showRecruitmentPanel
|
|
174
|
-
?
|
|
175
|
-
:
|
|
174
|
+
? 'max-content max-content minmax(10rem, auto)'
|
|
175
|
+
: 'max-content minmax(10rem, 17.5rem) minmax(10rem, auto)',
|
|
176
176
|
gridRowGap: rasaSpace[1],
|
|
177
|
-
}
|
|
177
|
+
}
|
|
178
178
|
|
|
179
179
|
const onFrameSelected = (stack: Stack) => {
|
|
180
180
|
setFrame({
|
|
181
181
|
stack,
|
|
182
182
|
activatedSteps: flowStepTrail(events)[stack.flow_id],
|
|
183
183
|
isUserSelected: true,
|
|
184
|
-
})
|
|
185
|
-
}
|
|
184
|
+
})
|
|
185
|
+
}
|
|
186
186
|
|
|
187
187
|
const handleCloseRecruitmentPanel = () => {
|
|
188
|
-
setShowRecruitmentPanel(false)
|
|
189
|
-
}
|
|
188
|
+
setShowRecruitmentPanel(false)
|
|
189
|
+
}
|
|
190
190
|
|
|
191
|
-
if (!rasaChatSessionId && !window.location.href.includes(
|
|
191
|
+
if (!rasaChatSessionId && !window.location.href.includes('socketio'))
|
|
192
|
+
return <LoadingSpinner />
|
|
192
193
|
|
|
193
194
|
return (
|
|
194
195
|
<Grid sx={gridSx}>
|
|
@@ -227,5 +228,5 @@ export function App() {
|
|
|
227
228
|
</GridItem>
|
|
228
229
|
)}
|
|
229
230
|
</Grid>
|
|
230
|
-
)
|
|
231
|
+
)
|
|
231
232
|
}
|
|
@@ -1,67 +1,72 @@
|
|
|
1
|
-
import { DeepChat } from
|
|
2
|
-
import { MessageContent } from
|
|
3
|
-
import { Flex, FlexProps } from
|
|
4
|
-
import { Command, Event } from
|
|
1
|
+
import { DeepChat } from 'deep-chat-react'
|
|
2
|
+
import { MessageContent } from 'deep-chat/dist/types/messages'
|
|
3
|
+
import { Flex, FlexProps } from '@chakra-ui/react'
|
|
4
|
+
import { Command, Event } from '../types'
|
|
5
5
|
|
|
6
6
|
interface Props extends FlexProps {
|
|
7
|
-
events: Event[]
|
|
7
|
+
events: Event[]
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export const Chat = ({ sx, events, ...props }: Props) => {
|
|
11
11
|
const containerSx = {
|
|
12
12
|
...sx,
|
|
13
13
|
p: 0,
|
|
14
|
-
flexDirection:
|
|
15
|
-
}
|
|
14
|
+
flexDirection: 'column',
|
|
15
|
+
}
|
|
16
16
|
|
|
17
|
-
const maxHeight = document.documentElement.scrollHeight - 64
|
|
17
|
+
const maxHeight = document.documentElement.scrollHeight - 64
|
|
18
18
|
// 21 and 25 are the rem number we're using for the columns. We add 0.75rem for the padding
|
|
19
19
|
// A potential improvement would be to add a onresize event for both width and height
|
|
20
|
-
let remReference = 21.75
|
|
20
|
+
let remReference = 21.75
|
|
21
21
|
if (document.documentElement.clientWidth > 1631) {
|
|
22
|
-
remReference = 25.75
|
|
22
|
+
remReference = 25.75
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const columnWidth =
|
|
26
26
|
remReference *
|
|
27
|
-
parseFloat(getComputedStyle(document.documentElement).fontSize)
|
|
27
|
+
parseFloat(getComputedStyle(document.documentElement).fontSize)
|
|
28
28
|
|
|
29
29
|
// function that maps a command dict to a human string to display in the chat
|
|
30
30
|
const mapCommand = (command: Command) => {
|
|
31
|
-
let commandName = command.command
|
|
32
|
-
if (commandName ===
|
|
33
|
-
return `Start (${command.flow})
|
|
31
|
+
let commandName = command.command
|
|
32
|
+
if (commandName === 'start flow') {
|
|
33
|
+
return `Start (${command.flow})`
|
|
34
34
|
}
|
|
35
|
-
if (commandName ===
|
|
36
|
-
return `Set (${command.name} = ${command.value})
|
|
35
|
+
if (commandName === 'set slot') {
|
|
36
|
+
return `Set (${command.name} = ${command.value})`
|
|
37
37
|
}
|
|
38
|
-
return commandName
|
|
39
|
-
}
|
|
38
|
+
return commandName
|
|
39
|
+
}
|
|
40
40
|
|
|
41
41
|
// collect user and bot messages
|
|
42
42
|
const messages: MessageContent[] = events
|
|
43
|
-
.filter(
|
|
44
|
-
|
|
43
|
+
.filter(
|
|
44
|
+
(event: Event) =>
|
|
45
|
+
event.event === 'user' ||
|
|
46
|
+
event.event === 'bot' ||
|
|
47
|
+
event.event === 'session_ended',
|
|
48
|
+
)
|
|
49
|
+
// @ts-expect-error
|
|
45
50
|
.flatMap((event: Event) => {
|
|
46
|
-
if (event.event ===
|
|
51
|
+
if (event.event === 'user') {
|
|
47
52
|
let commands =
|
|
48
53
|
event.parse_data?.commands?.map(
|
|
49
|
-
(command) => `<div>${mapCommand(command)}</div
|
|
50
|
-
) || []
|
|
54
|
+
(command) => `<div>${mapCommand(command)}</div>`,
|
|
55
|
+
) || []
|
|
51
56
|
return [
|
|
52
57
|
{
|
|
53
58
|
role: event.event,
|
|
54
|
-
text: event.text ||
|
|
59
|
+
text: event.text || '',
|
|
55
60
|
},
|
|
56
61
|
{
|
|
57
|
-
role:
|
|
58
|
-
html: `<div>${commands.join(
|
|
62
|
+
role: 'system',
|
|
63
|
+
html: `<div>${commands.join('')}</div>`,
|
|
59
64
|
},
|
|
60
|
-
]
|
|
61
|
-
} else if (event.event ===
|
|
65
|
+
]
|
|
66
|
+
} else if (event.event === 'session_ended') {
|
|
62
67
|
return [
|
|
63
68
|
{
|
|
64
|
-
role:
|
|
69
|
+
role: 'system',
|
|
65
70
|
html: `<div>
|
|
66
71
|
session ended
|
|
67
72
|
<div style="margin-top: 8px;">
|
|
@@ -76,18 +81,17 @@ export const Chat = ({ sx, events, ...props }: Props) => {
|
|
|
76
81
|
</button>
|
|
77
82
|
</div>
|
|
78
83
|
</div>`,
|
|
79
|
-
}
|
|
84
|
+
},
|
|
80
85
|
]
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
86
|
+
} else {
|
|
83
87
|
return [
|
|
84
88
|
{
|
|
85
89
|
role: event.event,
|
|
86
|
-
text: event.text ||
|
|
90
|
+
text: event.text || '',
|
|
87
91
|
},
|
|
88
|
-
]
|
|
92
|
+
]
|
|
89
93
|
}
|
|
90
|
-
})
|
|
94
|
+
})
|
|
91
95
|
|
|
92
96
|
return (
|
|
93
97
|
<Flex sx={containerSx} {...props}>
|
|
@@ -96,15 +100,15 @@ export const Chat = ({ sx, events, ...props }: Props) => {
|
|
|
96
100
|
textInput={{
|
|
97
101
|
disabled: true,
|
|
98
102
|
}}
|
|
99
|
-
inputAreaStyle={{ display:
|
|
103
|
+
inputAreaStyle={{ display: 'none' }}
|
|
100
104
|
messageStyles={{
|
|
101
105
|
html: {
|
|
102
|
-
shared: { bubble: { backgroundColor:
|
|
106
|
+
shared: { bubble: { backgroundColor: 'unset', padding: '0px' } },
|
|
103
107
|
},
|
|
104
108
|
}}
|
|
105
109
|
style={{
|
|
106
|
-
borderRadius:
|
|
107
|
-
border:
|
|
110
|
+
borderRadius: '10px',
|
|
111
|
+
border: 'none',
|
|
108
112
|
width: columnWidth,
|
|
109
113
|
height: maxHeight,
|
|
110
114
|
}}
|
|
@@ -112,5 +116,5 @@ export const Chat = ({ sx, events, ...props }: Props) => {
|
|
|
112
116
|
demo={true}
|
|
113
117
|
/>
|
|
114
118
|
</Flex>
|
|
115
|
-
)
|
|
116
|
-
}
|
|
119
|
+
)
|
|
120
|
+
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { Box, Button, Flex, Heading, Text } from
|
|
2
|
-
import mermaid from
|
|
3
|
-
import { useOurTheme } from
|
|
4
|
-
import { formatFlow } from
|
|
5
|
-
import { restartConversation } from
|
|
6
|
-
import { useEffect, useRef, useState } from
|
|
7
|
-
import { Flow, Slot, Stack } from
|
|
8
|
-
import { NoActiveFlow } from
|
|
1
|
+
import { Box, Button, Flex, Heading, Text } from '@chakra-ui/react'
|
|
2
|
+
import mermaid from 'mermaid'
|
|
3
|
+
import { useOurTheme } from '../theme'
|
|
4
|
+
import { formatFlow } from '../helpers/formatters'
|
|
5
|
+
import { restartConversation } from '../helpers/conversation'
|
|
6
|
+
import { useEffect, useRef, useState } from 'react'
|
|
7
|
+
import { Flow, Slot, Stack } from '../types'
|
|
8
|
+
import { NoActiveFlow } from './NoActiveFlow'
|
|
9
9
|
|
|
10
10
|
interface Props {
|
|
11
|
-
stackFrame?: Stack
|
|
12
|
-
flows: Flow[]
|
|
13
|
-
slots: Slot[]
|
|
14
|
-
stepTrail?: string[]
|
|
11
|
+
stackFrame?: Stack
|
|
12
|
+
flows: Flow[]
|
|
13
|
+
slots: Slot[]
|
|
14
|
+
stepTrail?: string[]
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export const DiagramFlow = ({ stackFrame, stepTrail, flows, slots }: Props) => {
|
|
18
|
-
const { rasaSpace } = useOurTheme()
|
|
19
|
-
const mermaidRef = useRef<HTMLPreElement>(null)
|
|
20
|
-
const [text, setText] = useState<string>(
|
|
18
|
+
const { rasaSpace } = useOurTheme()
|
|
19
|
+
const mermaidRef = useRef<HTMLPreElement>(null)
|
|
20
|
+
const [text, setText] = useState<string>('')
|
|
21
21
|
const flow = flows.find(({ id }) => id === stackFrame?.flow_id)
|
|
22
22
|
|
|
23
23
|
const config = {
|
|
@@ -26,47 +26,47 @@ export const DiagramFlow = ({ stackFrame, stepTrail, flows, slots }: Props) => {
|
|
|
26
26
|
flowchart: {
|
|
27
27
|
useMaxWidth: false,
|
|
28
28
|
},
|
|
29
|
-
}
|
|
29
|
+
}
|
|
30
30
|
|
|
31
31
|
useEffect(() => {
|
|
32
|
-
mermaid.mermaidAPI.initialize(config)
|
|
33
|
-
}, [])
|
|
32
|
+
mermaid.mermaidAPI.initialize(config)
|
|
33
|
+
}, [])
|
|
34
34
|
|
|
35
35
|
useEffect(() => {
|
|
36
|
-
if (!text) return
|
|
36
|
+
if (!text) return
|
|
37
37
|
// mermaid needs to be reloaded every time the text changes but a data-processed
|
|
38
38
|
// attribute prevents it. We need to remove it each time `text` changes
|
|
39
|
-
mermaidRef.current?.removeAttribute(
|
|
40
|
-
mermaid.contentLoaded()
|
|
39
|
+
mermaidRef.current?.removeAttribute('data-processed')
|
|
40
|
+
mermaid.contentLoaded()
|
|
41
41
|
|
|
42
42
|
setTimeout(() => {
|
|
43
|
-
const active = document.querySelectorAll(
|
|
43
|
+
const active = document.querySelectorAll('.active')[0]
|
|
44
44
|
if (active) {
|
|
45
|
-
active.scrollIntoView({ behavior:
|
|
45
|
+
active.scrollIntoView({ behavior: 'smooth' })
|
|
46
46
|
}
|
|
47
|
-
}, 0)
|
|
48
|
-
}, [text])
|
|
47
|
+
}, 0)
|
|
48
|
+
}, [text])
|
|
49
49
|
|
|
50
50
|
useEffect(() => {
|
|
51
|
-
setText(formatFlow(slots, stackFrame, flow, stepTrail))
|
|
52
|
-
}, [text, flow, slots, stackFrame])
|
|
51
|
+
setText(formatFlow(slots, stackFrame, flow, stepTrail))
|
|
52
|
+
}, [text, flow, slots, stackFrame])
|
|
53
53
|
|
|
54
54
|
const handleRestartConversation = () => {
|
|
55
|
-
restartConversation()
|
|
56
|
-
}
|
|
55
|
+
restartConversation()
|
|
56
|
+
}
|
|
57
57
|
|
|
58
58
|
const scrollSx = {
|
|
59
|
-
height:
|
|
60
|
-
overflow:
|
|
61
|
-
width:
|
|
62
|
-
textAlign:
|
|
63
|
-
flexDirection:
|
|
64
|
-
}
|
|
59
|
+
height: '100%',
|
|
60
|
+
overflow: 'auto',
|
|
61
|
+
width: '100%',
|
|
62
|
+
textAlign: 'center',
|
|
63
|
+
flexDirection: 'column',
|
|
64
|
+
}
|
|
65
65
|
const preSx = {
|
|
66
66
|
svg: {
|
|
67
|
-
margin:
|
|
67
|
+
margin: '0 auto',
|
|
68
68
|
},
|
|
69
|
-
}
|
|
69
|
+
}
|
|
70
70
|
|
|
71
71
|
return (
|
|
72
72
|
<Flex direction="column" height="100%">
|
|
@@ -74,7 +74,7 @@ export const DiagramFlow = ({ stackFrame, stepTrail, flows, slots }: Props) => {
|
|
|
74
74
|
Flow
|
|
75
75
|
{flow ? (
|
|
76
76
|
<Text as="span" fontWeight="normal">
|
|
77
|
-
{
|
|
77
|
+
{':'} {flow.id}
|
|
78
78
|
</Text>
|
|
79
79
|
) : null}
|
|
80
80
|
</Heading>
|
|
@@ -101,5 +101,5 @@ export const DiagramFlow = ({ stackFrame, stepTrail, flows, slots }: Props) => {
|
|
|
101
101
|
</Button>
|
|
102
102
|
</Flex>
|
|
103
103
|
</Flex>
|
|
104
|
-
)
|
|
105
|
-
}
|
|
104
|
+
)
|
|
105
|
+
}
|