rasa-pro 3.13.0.dev3__py3-none-any.whl → 3.13.0.dev7__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 -1
- rasa/api.py +4 -0
- rasa/cli/arguments/default_arguments.py +13 -1
- rasa/cli/arguments/train.py +2 -0
- rasa/cli/evaluate.py +1 -1
- rasa/cli/export.py +2 -2
- rasa/cli/inspect.py +8 -4
- 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/scaffold.py +3 -4
- rasa/cli/studio/download.py +1 -1
- rasa/cli/studio/upload.py +0 -6
- rasa/cli/train.py +1 -0
- rasa/constants.py +2 -0
- rasa/core/agent.py +2 -2
- rasa/core/brokers/kafka.py +4 -0
- rasa/core/brokers/pika.py +4 -0
- rasa/core/brokers/sql.py +1 -1
- rasa/core/channels/channel.py +68 -5
- rasa/core/channels/inspector/.eslintrc.cjs +12 -6
- rasa/core/channels/inspector/.prettierrc +5 -0
- rasa/core/channels/inspector/README.md +10 -4
- rasa/core/channels/inspector/dist/assets/{arc-c7691751.js → arc-c4b064fc.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{blockDiagram-38ab4fdb-ab99dff7.js → blockDiagram-38ab4fdb-215b5026.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-3d4e48cf-08c35a6b.js → c4Diagram-3d4e48cf-2b54a0a3.js} +1 -1
- rasa/core/channels/inspector/dist/assets/channel-3730f5fd.js +1 -0
- rasa/core/channels/inspector/dist/assets/{classDiagram-70f12bd4-9e9c71c9.js → classDiagram-70f12bd4-daacea5f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{classDiagram-v2-f2320105-15e7e2bf.js → classDiagram-v2-f2320105-930d4dc2.js} +1 -1
- rasa/core/channels/inspector/dist/assets/clone-e847561e.js +1 -0
- rasa/core/channels/inspector/dist/assets/{createText-2e5e7dd3-9c105cb1.js → createText-2e5e7dd3-83c206ba.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{edges-e0da2a9e-77e89e48.js → edges-e0da2a9e-b0eb01d0.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-9861fffd-7a011646.js → erDiagram-9861fffd-17586500.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDb-956e92f1-b6f105ac.js → flowDb-956e92f1-be2a1776.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{flowDiagram-66a62f08-ce4f18c2.js → flowDiagram-66a62f08-c2120ebd.js} +1 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-efbbfe00.js +1 -0
- rasa/core/channels/inspector/dist/assets/{flowchart-elk-definition-4a651766-cb5f6da4.js → flowchart-elk-definition-4a651766-a6ab5c48.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-c361ad54-e4d19e28.js → ganttDiagram-c361ad54-ef613457.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-72cf32ee-727b1c33.js → gitGraphDiagram-72cf32ee-d59185b3.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{graph-6e2ab9a7.js → graph-0f155405.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-3862675e-84ec700f.js → index-3862675e-d5f1d1b7.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-098a1a24.js → index-47737d3a.js} +162 -149
- rasa/core/channels/inspector/dist/assets/{infoDiagram-f8f76790-78dda442.js → infoDiagram-f8f76790-b07d141f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-49397b02-f1cc6dd1.js → journeyDiagram-49397b02-1936d429.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-d98dcd0c.js → layout-dde8d0f3.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{line-838e3d82.js → line-0c2c7ee0.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-eae72406.js → linear-35dd89a4.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-fc14e90a-c96fd84b.js → mindmap-definition-fc14e90a-56192851.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{pieDiagram-8a3498a8-c936d4e2.js → pieDiagram-8a3498a8-fc21ed78.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-120e2f19-b338eb8f.js → quadrantDiagram-120e2f19-25e98518.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-deff3bca-c6b6c0d5.js → requirementDiagram-deff3bca-546ff1f5.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-04a897e0-b9372e19.js → sankeyDiagram-04a897e0-02d8b82d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-704730f1-479e0a3f.js → sequenceDiagram-704730f1-3ca5a92e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-587899a1-fd26eebc.js → stateDiagram-587899a1-128ea07c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-v2-d93cdb3a-3233e0ae.js → stateDiagram-v2-d93cdb3a-95f290af.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-6aaf32cf-1fdd392b.js → styles-6aaf32cf-4984898a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-9a916d00-6d7bfa1b.js → styles-9a916d00-1bf266ba.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{styles-c10674c1-f86aab11.js → styles-c10674c1-60521c63.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{svgDrawCommon-08f97a94-e3e49d7a.js → svgDrawCommon-08f97a94-a25b6e12.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{timeline-definition-85554ec2-6fe08b4d.js → timeline-definition-85554ec2-0fc086bf.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-e933f94c-c2e06fd6.js → xychartDiagram-e933f94c-44ee592e.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 +92 -90
- rasa/core/channels/inspector/src/components/Chat.tsx +61 -36
- rasa/core/channels/inspector/src/components/DiagramFlow.tsx +40 -43
- 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 +16 -0
- 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/voice_ready/audiocodes.py +75 -32
- rasa/core/channels/voice_ready/twilio_voice.py +48 -1
- rasa/core/channels/voice_stream/tts/azure.py +11 -2
- rasa/core/channels/voice_stream/twilio_media_streams.py +101 -26
- rasa/core/channels/voice_stream/voice_channel.py +28 -2
- 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/lock_store.py +151 -60
- rasa/core/nlg/contextual_response_rephraser.py +4 -2
- rasa/core/nlg/summarize.py +1 -1
- rasa/core/persistor.py +55 -20
- rasa/core/policies/enterprise_search_policy.py +7 -4
- rasa/core/policies/intentless_policy.py +15 -9
- rasa/core/processor.py +2 -2
- rasa/core/run.py +7 -2
- 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/utils.py +6 -0
- rasa/dialogue_understanding/coexistence/llm_based_router.py +8 -3
- rasa/dialogue_understanding/commands/clarify_command.py +2 -2
- rasa/dialogue_understanding/commands/knowledge_answer_command.py +2 -2
- rasa/dialogue_understanding/generator/constants.py +2 -2
- rasa/dialogue_understanding/generator/llm_based_command_generator.py +1 -1
- rasa/dialogue_understanding/generator/prompt_templates/command_prompt_v2_gpt_4o_2024_11_20_template.jinja2 +33 -12
- rasa/dialogue_understanding/generator/single_step/compact_llm_command_generator.py +2 -2
- rasa/dialogue_understanding_test/du_test_case.py +16 -8
- rasa/hooks.py +2 -2
- rasa/keys +1 -0
- rasa/llm_fine_tuning/paraphrasing/conversation_rephraser.py +4 -2
- rasa/model_manager/config.py +3 -1
- rasa/model_manager/model_api.py +1 -2
- rasa/model_manager/runner_service.py +8 -4
- rasa/model_manager/trainer_service.py +1 -0
- rasa/model_training.py +12 -3
- rasa/nlu/extractors/crf_entity_extractor.py +66 -16
- rasa/plugin.py +1 -4
- rasa/server.py +6 -2
- rasa/shared/constants.py +4 -0
- rasa/shared/core/domain.py +165 -11
- rasa/shared/core/events.py +68 -2
- rasa/shared/core/flows/flow.py +155 -131
- 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/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 +27 -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/yaml_flows_io.py +106 -5
- rasa/shared/importers/importer.py +8 -0
- rasa/shared/providers/_configs/azure_openai_client_config.py +4 -0
- rasa/shared/providers/_configs/openai_client_config.py +4 -0
- rasa/shared/providers/_utils.py +83 -0
- rasa/shared/providers/embedding/_base_litellm_embedding_client.py +3 -0
- rasa/shared/providers/llm/_base_litellm_client.py +11 -5
- rasa/shared/providers/llm/azure_openai_llm_client.py +6 -68
- rasa/shared/providers/router/_base_litellm_router_client.py +53 -1
- rasa/shared/utils/common.py +42 -0
- rasa/studio/download/__init__.py +0 -0
- rasa/studio/download/domains.py +49 -0
- rasa/studio/download/download.py +439 -0
- rasa/studio/download/flows.py +359 -0
- rasa/studio/results_logger.py +6 -1
- rasa/studio/upload.py +69 -5
- rasa/telemetry.py +2 -2
- rasa/tracing/config.py +1 -1
- rasa/tracing/instrumentation/attribute_extractors.py +1 -1
- rasa/tracing/instrumentation/instrumentation.py +1 -1
- rasa/utils/common.py +36 -0
- rasa/utils/endpoints.py +22 -1
- rasa/utils/licensing.py +2 -3
- rasa/validator.py +1 -2
- rasa/version.py +1 -1
- {rasa_pro-3.13.0.dev3.dist-info → rasa_pro-3.13.0.dev7.dist-info}/METADATA +10 -10
- {rasa_pro-3.13.0.dev3.dist-info → rasa_pro-3.13.0.dev7.dist-info}/RECORD +213 -210
- 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-11268142.js +0 -1
- rasa/core/channels/inspector/dist/assets/clone-ff7f2ce7.js +0 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-v2-96b9c2cf-cba7ae20.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 → 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/tracker_stores}/__init__.py +0 -0
- {rasa_pro-3.13.0.dev3.dist-info → rasa_pro-3.13.0.dev7.dist-info}/NOTICE +0 -0
- {rasa_pro-3.13.0.dev3.dist-info → rasa_pro-3.13.0.dev7.dist-info}/WHEEL +0 -0
- {rasa_pro-3.13.0.dev3.dist-info → rasa_pro-3.13.0.dev7.dist-info}/entry_points.txt +0 -0
|
@@ -4,62 +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
|
-
})
|
|
53
|
+
})
|
|
54
|
+
const token = new URLSearchParams(window.location.search).get('token')
|
|
54
55
|
|
|
55
56
|
useEffect(() => {
|
|
56
57
|
if (readyState === ReadyState.OPEN && rasaChatSessionId) {
|
|
57
58
|
sendJsonMessage({
|
|
58
|
-
action:
|
|
59
|
+
action: 'retrieve',
|
|
59
60
|
sender_id: rasaChatSessionId,
|
|
60
|
-
})
|
|
61
|
+
})
|
|
61
62
|
}
|
|
62
|
-
}, [readyState, sendJsonMessage, rasaChatSessionId])
|
|
63
|
+
}, [readyState, sendJsonMessage, rasaChatSessionId])
|
|
63
64
|
|
|
64
65
|
useEffect(() => {
|
|
65
66
|
// if we are on a "dynamic" input channel where the user can chat on
|
|
@@ -67,75 +68,75 @@ export function App() {
|
|
|
67
68
|
// support loading an existing conversation. therefore, we don't set
|
|
68
69
|
// the sender id in the url and a reload of the page will start a new
|
|
69
70
|
// conversation.
|
|
70
|
-
if(!shouldShowTranscript) return
|
|
71
|
+
if (!shouldShowTranscript) return
|
|
71
72
|
|
|
72
|
-
const queryParameters = queryString.parse(window.location.search)
|
|
73
|
-
const urlSender = queryParameters.sender as string
|
|
73
|
+
const queryParameters = queryString.parse(window.location.search)
|
|
74
|
+
const urlSender = queryParameters.sender as string
|
|
74
75
|
if (urlSender && urlSender !== rasaChatSessionId) {
|
|
75
|
-
setRasaChatSessionId(urlSender)
|
|
76
|
+
setRasaChatSessionId(urlSender)
|
|
76
77
|
} else if (!urlSender && rasaChatSessionId) {
|
|
77
78
|
// update the sender query parameter
|
|
78
|
-
const url = new URL(window.location.href)
|
|
79
|
-
url.searchParams.set(
|
|
80
|
-
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())
|
|
81
82
|
}
|
|
82
|
-
}, [rasaChatSessionId, shouldShowTranscript])
|
|
83
|
+
}, [rasaChatSessionId, shouldShowTranscript])
|
|
83
84
|
|
|
84
85
|
useEffect(() => {
|
|
85
86
|
axios
|
|
86
|
-
.get(
|
|
87
|
+
.get('/flows', { params: { token } })
|
|
87
88
|
.then((response) => setFlows(response.data))
|
|
88
89
|
.catch((error) => {
|
|
89
90
|
// don't show a new toast if it's already active
|
|
90
|
-
if (toast.isActive(
|
|
91
|
+
if (toast.isActive('flows')) return
|
|
91
92
|
toast({
|
|
92
|
-
id:
|
|
93
|
-
title:
|
|
94
|
-
description: error?.message ||
|
|
95
|
-
status:
|
|
93
|
+
id: 'flows',
|
|
94
|
+
title: 'Flows could not be retrieved',
|
|
95
|
+
description: error?.message || 'An unknown error happened.',
|
|
96
|
+
status: 'error',
|
|
96
97
|
duration: 4000,
|
|
97
98
|
isClosable: true,
|
|
98
|
-
})
|
|
99
|
-
})
|
|
100
|
-
}, [toast])
|
|
99
|
+
})
|
|
100
|
+
})
|
|
101
|
+
}, [toast])
|
|
101
102
|
|
|
102
103
|
function fetchStory() {
|
|
103
104
|
axios
|
|
104
|
-
.get(`/conversations/${rasaChatSessionId}/story
|
|
105
|
+
.get(`/conversations/${rasaChatSessionId}/story`, { params: { token } })
|
|
105
106
|
.then((response) => setStory(response.data))
|
|
106
107
|
.catch((error) => {
|
|
107
108
|
// don't show a new toast if it's already active
|
|
108
|
-
if (toast.isActive(
|
|
109
|
+
if (toast.isActive('story-error')) return
|
|
109
110
|
toast({
|
|
110
|
-
id:
|
|
111
|
-
title:
|
|
112
|
-
description: error?.message ||
|
|
113
|
-
status:
|
|
111
|
+
id: 'story-error',
|
|
112
|
+
title: 'Stories could not be retrieved',
|
|
113
|
+
description: error?.message || 'An unknown error happened.',
|
|
114
|
+
status: 'error',
|
|
114
115
|
duration: 4000,
|
|
115
116
|
isClosable: true,
|
|
116
|
-
})
|
|
117
|
-
})
|
|
117
|
+
})
|
|
118
|
+
})
|
|
118
119
|
}
|
|
119
120
|
|
|
120
121
|
// Run when a new WebSocket message is received (lastJsonMessage)
|
|
121
122
|
useEffect(() => {
|
|
122
123
|
// if the tracker update that we received is for the current chat session,
|
|
123
124
|
// update the tracker.
|
|
124
|
-
if (!lastJsonMessage) return
|
|
125
|
+
if (!lastJsonMessage) return
|
|
125
126
|
if (
|
|
126
127
|
!rasaChatSessionId ||
|
|
127
128
|
lastJsonMessage?.sender_id === rasaChatSessionId
|
|
128
129
|
) {
|
|
129
|
-
setSlots(formatSlots(lastJsonMessage.slots))
|
|
130
|
-
setEvents(lastJsonMessage.events)
|
|
130
|
+
setSlots(formatSlots(lastJsonMessage.slots))
|
|
131
|
+
setEvents(lastJsonMessage.events)
|
|
131
132
|
const updatedStack = createHistoricalStack(
|
|
132
133
|
lastJsonMessage.stack,
|
|
133
|
-
lastJsonMessage.events
|
|
134
|
-
)
|
|
135
|
-
setStack(updatedStack)
|
|
136
|
-
setFrame(updatedActiveFrame(frame, updatedStack, lastJsonMessage.events))
|
|
137
|
-
setRasaChatSessionId(lastJsonMessage.sender_id)
|
|
138
|
-
fetchStory()
|
|
134
|
+
lastJsonMessage.events,
|
|
135
|
+
)
|
|
136
|
+
setStack(updatedStack)
|
|
137
|
+
setFrame(updatedActiveFrame(frame, updatedStack, lastJsonMessage.events))
|
|
138
|
+
setRasaChatSessionId(lastJsonMessage.sender_id)
|
|
139
|
+
fetchStory()
|
|
139
140
|
} else if (
|
|
140
141
|
rasaChatSessionId &&
|
|
141
142
|
lastJsonMessage.sender_id !== rasaChatSessionId
|
|
@@ -143,51 +144,52 @@ export function App() {
|
|
|
143
144
|
// show a header link with the new sender the user can click a button to
|
|
144
145
|
// switch to the new chat session. the alert should be dissmissable.
|
|
145
146
|
}
|
|
146
|
-
}, [lastJsonMessage, rasaChatSessionId])
|
|
147
|
+
}, [lastJsonMessage, rasaChatSessionId])
|
|
147
148
|
|
|
148
149
|
const borderRadiusSx = {
|
|
149
150
|
borderRadius: rasaRadii.normal,
|
|
150
|
-
}
|
|
151
|
+
}
|
|
151
152
|
const gridTemplateColumns = useBreakpointValue({
|
|
152
|
-
base:
|
|
153
|
-
|
|
154
|
-
})
|
|
153
|
+
base: '21rem minmax(20rem, auto) 21rem',
|
|
154
|
+
'2xl': '25rem auto 25rem',
|
|
155
|
+
})
|
|
155
156
|
const gridSx = {
|
|
156
157
|
gridTemplateColumns,
|
|
157
|
-
gridTemplateRows:
|
|
158
|
+
gridTemplateRows: '1fr',
|
|
158
159
|
gridColumnGap: rasaSpace[1],
|
|
159
|
-
height:
|
|
160
|
+
height: '100vh',
|
|
160
161
|
padding: rasaSpace[2],
|
|
161
|
-
}
|
|
162
|
+
}
|
|
162
163
|
const boxSx = {
|
|
163
164
|
...borderRadiusSx,
|
|
164
165
|
padding: rasaSpace[1],
|
|
165
|
-
bg: useColorModeValue(
|
|
166
|
-
overflow:
|
|
167
|
-
}
|
|
166
|
+
bg: useColorModeValue('neutral.50', 'neutral.50'),
|
|
167
|
+
overflow: 'hidden',
|
|
168
|
+
}
|
|
168
169
|
const leftColumnSx = {
|
|
169
|
-
height:
|
|
170
|
-
overflow:
|
|
171
|
-
gridTemplateColumns:
|
|
170
|
+
height: '100%',
|
|
171
|
+
overflow: 'hidden',
|
|
172
|
+
gridTemplateColumns: '1fr',
|
|
172
173
|
gridTemplateRows: showRecruitmentPanel
|
|
173
|
-
?
|
|
174
|
-
:
|
|
174
|
+
? 'max-content max-content minmax(10rem, auto)'
|
|
175
|
+
: 'max-content minmax(10rem, 17.5rem) minmax(10rem, auto)',
|
|
175
176
|
gridRowGap: rasaSpace[1],
|
|
176
|
-
}
|
|
177
|
+
}
|
|
177
178
|
|
|
178
179
|
const onFrameSelected = (stack: Stack) => {
|
|
179
180
|
setFrame({
|
|
180
181
|
stack,
|
|
181
182
|
activatedSteps: flowStepTrail(events)[stack.flow_id],
|
|
182
183
|
isUserSelected: true,
|
|
183
|
-
})
|
|
184
|
-
}
|
|
184
|
+
})
|
|
185
|
+
}
|
|
185
186
|
|
|
186
187
|
const handleCloseRecruitmentPanel = () => {
|
|
187
|
-
setShowRecruitmentPanel(false)
|
|
188
|
-
}
|
|
188
|
+
setShowRecruitmentPanel(false)
|
|
189
|
+
}
|
|
189
190
|
|
|
190
|
-
if (!rasaChatSessionId && !window.location.href.includes(
|
|
191
|
+
if (!rasaChatSessionId && !window.location.href.includes('socketio'))
|
|
192
|
+
return <LoadingSpinner />
|
|
191
193
|
|
|
192
194
|
return (
|
|
193
195
|
<Grid sx={gridSx}>
|
|
@@ -226,5 +228,5 @@ export function App() {
|
|
|
226
228
|
</GridItem>
|
|
227
229
|
)}
|
|
228
230
|
</Grid>
|
|
229
|
-
)
|
|
231
|
+
)
|
|
230
232
|
}
|
|
@@ -1,72 +1,97 @@
|
|
|
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 || '',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
role: 'system',
|
|
63
|
+
html: `<div>${commands.join('')}</div>`,
|
|
55
64
|
},
|
|
65
|
+
]
|
|
66
|
+
} else if (event.event === 'session_ended') {
|
|
67
|
+
return [
|
|
56
68
|
{
|
|
57
|
-
role:
|
|
58
|
-
html: `<div
|
|
69
|
+
role: 'system',
|
|
70
|
+
html: `<div>
|
|
71
|
+
session ended
|
|
72
|
+
<div style="margin-top: 8px;">
|
|
73
|
+
<button
|
|
74
|
+
onclick="(() => {
|
|
75
|
+
window.restartConversation();
|
|
76
|
+
return false;
|
|
77
|
+
})()"
|
|
78
|
+
style="background-color: transparent; border: 1px solid #ccc; border-radius: 4px; padding: 4px 12px; cursor: pointer; font-size: 14px;"
|
|
79
|
+
>
|
|
80
|
+
Start a new conversation
|
|
81
|
+
</button>
|
|
82
|
+
</div>
|
|
83
|
+
</div>`,
|
|
59
84
|
},
|
|
60
|
-
]
|
|
85
|
+
]
|
|
61
86
|
} else {
|
|
62
87
|
return [
|
|
63
88
|
{
|
|
64
89
|
role: event.event,
|
|
65
|
-
text: event.text ||
|
|
90
|
+
text: event.text || '',
|
|
66
91
|
},
|
|
67
|
-
]
|
|
92
|
+
]
|
|
68
93
|
}
|
|
69
|
-
})
|
|
94
|
+
})
|
|
70
95
|
|
|
71
96
|
return (
|
|
72
97
|
<Flex sx={containerSx} {...props}>
|
|
@@ -75,15 +100,15 @@ export const Chat = ({ sx, events, ...props }: Props) => {
|
|
|
75
100
|
textInput={{
|
|
76
101
|
disabled: true,
|
|
77
102
|
}}
|
|
78
|
-
inputAreaStyle={{ display:
|
|
103
|
+
inputAreaStyle={{ display: 'none' }}
|
|
79
104
|
messageStyles={{
|
|
80
105
|
html: {
|
|
81
|
-
shared: { bubble: { backgroundColor:
|
|
106
|
+
shared: { bubble: { backgroundColor: 'unset', padding: '0px' } },
|
|
82
107
|
},
|
|
83
108
|
}}
|
|
84
109
|
style={{
|
|
85
|
-
borderRadius:
|
|
86
|
-
border:
|
|
110
|
+
borderRadius: '10px',
|
|
111
|
+
border: 'none',
|
|
87
112
|
width: columnWidth,
|
|
88
113
|
height: maxHeight,
|
|
89
114
|
}}
|
|
@@ -91,5 +116,5 @@ export const Chat = ({ sx, events, ...props }: Props) => {
|
|
|
91
116
|
demo={true}
|
|
92
117
|
/>
|
|
93
118
|
</Flex>
|
|
94
|
-
)
|
|
95
|
-
}
|
|
119
|
+
)
|
|
120
|
+
}
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import { Box, Button, Flex, Heading, Text } from
|
|
2
|
-
import mermaid from
|
|
3
|
-
import { useOurTheme } from
|
|
4
|
-
import { formatFlow } from
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
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'
|
|
8
9
|
|
|
9
10
|
interface Props {
|
|
10
|
-
stackFrame?: Stack
|
|
11
|
-
flows: Flow[]
|
|
12
|
-
slots: Slot[]
|
|
13
|
-
stepTrail?: string[]
|
|
11
|
+
stackFrame?: Stack
|
|
12
|
+
flows: Flow[]
|
|
13
|
+
slots: Slot[]
|
|
14
|
+
stepTrail?: string[]
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export const DiagramFlow = ({ stackFrame, stepTrail, flows, slots }: Props) => {
|
|
17
|
-
const { rasaSpace } = useOurTheme()
|
|
18
|
-
const mermaidRef = useRef<HTMLPreElement>(null)
|
|
19
|
-
const [text, setText] = useState<string>(
|
|
18
|
+
const { rasaSpace } = useOurTheme()
|
|
19
|
+
const mermaidRef = useRef<HTMLPreElement>(null)
|
|
20
|
+
const [text, setText] = useState<string>('')
|
|
20
21
|
const flow = flows.find(({ id }) => id === stackFrame?.flow_id)
|
|
21
22
|
|
|
22
23
|
const config = {
|
|
@@ -25,51 +26,47 @@ export const DiagramFlow = ({ stackFrame, stepTrail, flows, slots }: Props) => {
|
|
|
25
26
|
flowchart: {
|
|
26
27
|
useMaxWidth: false,
|
|
27
28
|
},
|
|
28
|
-
}
|
|
29
|
+
}
|
|
29
30
|
|
|
30
31
|
useEffect(() => {
|
|
31
|
-
mermaid.mermaidAPI.initialize(config)
|
|
32
|
-
}, [])
|
|
32
|
+
mermaid.mermaidAPI.initialize(config)
|
|
33
|
+
}, [])
|
|
33
34
|
|
|
34
35
|
useEffect(() => {
|
|
35
|
-
if (!text) return
|
|
36
|
+
if (!text) return
|
|
36
37
|
// mermaid needs to be reloaded every time the text changes but a data-processed
|
|
37
38
|
// attribute prevents it. We need to remove it each time `text` changes
|
|
38
|
-
mermaidRef.current?.removeAttribute(
|
|
39
|
-
mermaid.contentLoaded()
|
|
39
|
+
mermaidRef.current?.removeAttribute('data-processed')
|
|
40
|
+
mermaid.contentLoaded()
|
|
40
41
|
|
|
41
42
|
setTimeout(() => {
|
|
42
|
-
const active = document.querySelectorAll(
|
|
43
|
+
const active = document.querySelectorAll('.active')[0]
|
|
43
44
|
if (active) {
|
|
44
|
-
active.scrollIntoView({ behavior:
|
|
45
|
+
active.scrollIntoView({ behavior: 'smooth' })
|
|
45
46
|
}
|
|
46
|
-
}, 0)
|
|
47
|
-
}, [text])
|
|
47
|
+
}, 0)
|
|
48
|
+
}, [text])
|
|
48
49
|
|
|
49
50
|
useEffect(() => {
|
|
50
|
-
setText(formatFlow(slots, stackFrame, flow, stepTrail))
|
|
51
|
-
}, [text, flow, slots, stackFrame])
|
|
51
|
+
setText(formatFlow(slots, stackFrame, flow, stepTrail))
|
|
52
|
+
}, [text, flow, slots, stackFrame])
|
|
52
53
|
|
|
53
54
|
const handleRestartConversation = () => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
url.searchParams.delete("sender");
|
|
57
|
-
window.history.pushState(null, "", url.toString());
|
|
58
|
-
location.reload();
|
|
59
|
-
};
|
|
55
|
+
restartConversation()
|
|
56
|
+
}
|
|
60
57
|
|
|
61
58
|
const scrollSx = {
|
|
62
|
-
height:
|
|
63
|
-
overflow:
|
|
64
|
-
width:
|
|
65
|
-
textAlign:
|
|
66
|
-
flexDirection:
|
|
67
|
-
}
|
|
59
|
+
height: '100%',
|
|
60
|
+
overflow: 'auto',
|
|
61
|
+
width: '100%',
|
|
62
|
+
textAlign: 'center',
|
|
63
|
+
flexDirection: 'column',
|
|
64
|
+
}
|
|
68
65
|
const preSx = {
|
|
69
66
|
svg: {
|
|
70
|
-
margin:
|
|
67
|
+
margin: '0 auto',
|
|
71
68
|
},
|
|
72
|
-
}
|
|
69
|
+
}
|
|
73
70
|
|
|
74
71
|
return (
|
|
75
72
|
<Flex direction="column" height="100%">
|
|
@@ -77,7 +74,7 @@ export const DiagramFlow = ({ stackFrame, stepTrail, flows, slots }: Props) => {
|
|
|
77
74
|
Flow
|
|
78
75
|
{flow ? (
|
|
79
76
|
<Text as="span" fontWeight="normal">
|
|
80
|
-
{
|
|
77
|
+
{':'} {flow.id}
|
|
81
78
|
</Text>
|
|
82
79
|
) : null}
|
|
83
80
|
</Heading>
|
|
@@ -104,5 +101,5 @@ export const DiagramFlow = ({ stackFrame, stepTrail, flows, slots }: Props) => {
|
|
|
104
101
|
</Button>
|
|
105
102
|
</Flex>
|
|
106
103
|
</Flex>
|
|
107
|
-
)
|
|
108
|
-
}
|
|
104
|
+
)
|
|
105
|
+
}
|