@magmamath/students-features 0.5.0 → 0.5.1-rc-0
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.
- package/dist/commonjs/features/celebrations/config.js +4 -4
- package/dist/commonjs/features/celebrations/config.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/Alternatives/Alternatives.js +1 -2
- package/dist/commonjs/features/chatbot/components/Alternatives/Alternatives.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatMessage/ChatMessage.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatMessage/MessageTextToSpeech.js +47 -30
- package/dist/commonjs/features/chatbot/components/ChatMessage/MessageTextToSpeech.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatMessage/ReceivedMessage.js +42 -22
- package/dist/commonjs/features/chatbot/components/ChatMessage/ReceivedMessage.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatMessage/SentMessage.js +14 -11
- package/dist/commonjs/features/chatbot/components/ChatMessage/SentMessage.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.js +32 -17
- package/dist/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/Chatbot.js +7 -5
- package/dist/commonjs/features/chatbot/components/Chatbot.js.map +1 -1
- package/dist/commonjs/features/chatbot/index.js +7 -0
- package/dist/commonjs/features/chatbot/index.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/{ChatBotThreadManager.js → ChatBotMessageHandler.js} +22 -44
- package/dist/commonjs/features/chatbot/model/ChatBotMessageHandler.js.map +1 -0
- package/dist/commonjs/features/chatbot/model/ChatBotModel.js +125 -146
- package/dist/commonjs/features/chatbot/model/ChatBotModel.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/DefaultMessageCreator.js +12 -12
- package/dist/commonjs/features/chatbot/model/DefaultMessageCreator.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/ThreadItem.js +8 -16
- package/dist/commonjs/features/chatbot/model/ThreadItem.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/{ChatbotApi.js → api.js} +1 -2
- package/dist/commonjs/features/chatbot/model/api.js.map +1 -0
- package/dist/commonjs/features/chatbot/model/constants.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/messagesHelper.js +7 -7
- package/dist/commonjs/features/chatbot/model/messagesHelper.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/t2s.js +13 -18
- package/dist/commonjs/features/chatbot/model/t2s.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/translation.helpers.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/translation.js +19 -28
- package/dist/commonjs/features/chatbot/model/translation.js.map +1 -1
- package/dist/commonjs/features/chatbot/types/api.types.js +0 -4
- package/dist/commonjs/features/chatbot/types/model.types.js.map +1 -1
- package/dist/commonjs/features/endOfAssignment/components/CorrectAnswer/AnimatedCard.js +2 -4
- package/dist/commonjs/features/endOfAssignment/components/CorrectAnswer/AnimatedCard.js.map +1 -1
- package/dist/commonjs/features/endOfAssignment/ui/PracticeButtonGroup.js.map +1 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/lib/effector/createEntityFieldStore.js +0 -4
- package/dist/commonjs/lib/effector/createEntityFieldStore.js.map +1 -1
- package/{src/shared/translation → dist/commonjs/lib}/localization/en.json +1 -8
- package/dist/{module/shared/translation → commonjs/lib}/localization/gb.json +1 -8
- package/dist/commonjs/{shared/translation → lib}/localization/sw.json +1 -8
- package/dist/commonjs/shared/icons/icon.types.js +0 -4
- package/dist/commonjs/shared/translation/constants.js +3 -3
- package/dist/commonjs/shared/translation/constants.js.map +1 -1
- package/dist/commonjs/shared/translation/helpers.js +6 -22
- package/dist/commonjs/shared/translation/helpers.js.map +1 -1
- package/dist/commonjs/shared/translation/hooks.js +5 -3
- package/dist/commonjs/shared/translation/hooks.js.map +1 -1
- package/dist/commonjs/shared/translation/model.js +1 -1
- package/dist/commonjs/shared/translation/model.js.map +1 -1
- package/dist/commonjs/shared/translation/types.js +1 -1
- package/dist/commonjs/shared/translation/types.js.map +1 -1
- package/dist/module/features/celebrations/config.js +4 -4
- package/dist/module/features/celebrations/config.js.map +1 -1
- package/dist/module/features/chatbot/components/Alternatives/Alternatives.js +1 -2
- package/dist/module/features/chatbot/components/Alternatives/Alternatives.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatMessage/ChatMessage.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatMessage/MessageTextToSpeech.js +48 -31
- package/dist/module/features/chatbot/components/ChatMessage/MessageTextToSpeech.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatMessage/ReceivedMessage.js +43 -23
- package/dist/module/features/chatbot/components/ChatMessage/ReceivedMessage.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatMessage/SentMessage.js +13 -11
- package/dist/module/features/chatbot/components/ChatMessage/SentMessage.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatMessages/ChatbotMessages.js +32 -17
- package/dist/module/features/chatbot/components/ChatMessages/ChatbotMessages.js.map +1 -1
- package/dist/module/features/chatbot/components/Chatbot.js +8 -6
- package/dist/module/features/chatbot/components/Chatbot.js.map +1 -1
- package/dist/module/features/chatbot/index.js +1 -0
- package/dist/module/features/chatbot/index.js.map +1 -1
- package/dist/module/features/chatbot/model/{ChatBotThreadManager.js → ChatBotMessageHandler.js} +20 -42
- package/dist/module/features/chatbot/model/ChatBotMessageHandler.js.map +1 -0
- package/dist/module/features/chatbot/model/ChatBotModel.js +126 -147
- package/dist/module/features/chatbot/model/ChatBotModel.js.map +1 -1
- package/dist/module/features/chatbot/model/DefaultMessageCreator.js +12 -12
- package/dist/module/features/chatbot/model/DefaultMessageCreator.js.map +1 -1
- package/dist/module/features/chatbot/model/ThreadItem.js +8 -16
- package/dist/module/features/chatbot/model/ThreadItem.js.map +1 -1
- package/dist/module/features/chatbot/model/{ChatbotApi.js → api.js} +1 -2
- package/dist/module/features/chatbot/model/api.js.map +1 -0
- package/dist/module/features/chatbot/model/constants.js.map +1 -1
- package/dist/module/features/chatbot/model/messagesHelper.js +7 -7
- package/dist/module/features/chatbot/model/messagesHelper.js.map +1 -1
- package/dist/module/features/chatbot/model/t2s.js +14 -19
- package/dist/module/features/chatbot/model/t2s.js.map +1 -1
- package/dist/module/features/chatbot/model/translation.helpers.js.map +1 -1
- package/dist/module/features/chatbot/model/translation.js +19 -28
- package/dist/module/features/chatbot/model/translation.js.map +1 -1
- package/dist/module/features/chatbot/types/api.types.js +0 -2
- package/dist/module/features/chatbot/types/model.types.js.map +1 -1
- package/dist/module/features/endOfAssignment/components/CorrectAnswer/AnimatedCard.js +2 -4
- package/dist/module/features/endOfAssignment/components/CorrectAnswer/AnimatedCard.js.map +1 -1
- package/dist/module/features/endOfAssignment/ui/PracticeButtonGroup.js.map +1 -1
- package/dist/module/index.js.map +1 -1
- package/dist/module/lib/effector/createEntityFieldStore.js +0 -4
- package/dist/module/lib/effector/createEntityFieldStore.js.map +1 -1
- package/dist/module/{shared/translation → lib}/localization/en.json +1 -8
- package/dist/{commonjs/shared/translation → module/lib}/localization/gb.json +1 -8
- package/dist/module/{shared/translation → lib}/localization/sw.json +1 -8
- package/dist/module/shared/icons/icon.types.js +0 -2
- package/dist/module/shared/translation/constants.js +3 -3
- package/dist/module/shared/translation/constants.js.map +1 -1
- package/dist/module/shared/translation/helpers.js +5 -19
- package/dist/module/shared/translation/helpers.js.map +1 -1
- package/dist/module/shared/translation/hooks.js +6 -4
- package/dist/module/shared/translation/hooks.js.map +1 -1
- package/dist/module/shared/translation/model.js +1 -1
- package/dist/module/shared/translation/model.js.map +1 -1
- package/dist/module/shared/translation/types.js +0 -2
- package/dist/module/shared/translation/types.js.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/Alternatives/Alternatives.d.ts +3 -1
- package/dist/typescript/commonjs/features/chatbot/components/Alternatives/Alternatives.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/ChatMessage.d.ts +10 -7
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/ChatMessage.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageTextToSpeech.d.ts +7 -5
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageTextToSpeech.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/ReceivedMessage.d.ts +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/ReceivedMessage.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/SentMessage.d.ts +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/SentMessage.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts +10 -2
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/Chatbot.d.ts +5 -2
- package/dist/typescript/commonjs/features/chatbot/components/Chatbot.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/index.d.ts +3 -4
- package/dist/typescript/commonjs/features/chatbot/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotMessageHandler.d.ts +31 -0
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotMessageHandler.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotModel.d.ts +18 -24
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotModel.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/DefaultMessageCreator.d.ts +3 -5
- package/dist/typescript/commonjs/features/chatbot/model/DefaultMessageCreator.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/ThreadItem.d.ts +7 -13
- package/dist/typescript/commonjs/features/chatbot/model/ThreadItem.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/{ChatbotApi.d.ts → api.d.ts} +3 -4
- package/dist/typescript/commonjs/features/chatbot/model/api.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/model/constants.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/messagesHelper.d.ts +5 -7
- package/dist/typescript/commonjs/features/chatbot/model/messagesHelper.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/t2s.d.ts +6 -16
- package/dist/typescript/commonjs/features/chatbot/model/t2s.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/translation.d.ts +9 -8
- package/dist/typescript/commonjs/features/chatbot/model/translation.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/translation.helpers.d.ts +1 -2
- package/dist/typescript/commonjs/features/chatbot/model/translation.helpers.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/types/api.types.d.ts +11 -12
- package/dist/typescript/commonjs/features/chatbot/types/api.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts +24 -19
- package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/types/t2s.types.d.ts +7 -9
- package/dist/typescript/commonjs/features/chatbot/types/t2s.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/types/translation.types.d.ts +2 -3
- package/dist/typescript/commonjs/features/chatbot/types/translation.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/endOfAssignment/components/CorrectAnswer/AnimatedCard.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/endOfAssignment/ui/PracticeButtonGroup.d.ts.map +1 -1
- package/dist/typescript/commonjs/index.d.ts +1 -0
- package/dist/typescript/commonjs/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/lib/effector/createEntityFieldStore.d.ts +0 -2
- package/dist/typescript/commonjs/lib/effector/createEntityFieldStore.d.ts.map +1 -1
- package/dist/typescript/commonjs/shared/icons/icon.types.d.ts +0 -2
- package/dist/typescript/commonjs/shared/icons/icon.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/shared/translation/constants.d.ts +0 -21
- package/dist/typescript/commonjs/shared/translation/constants.d.ts.map +1 -1
- package/dist/typescript/commonjs/shared/translation/helpers.d.ts +2 -3
- package/dist/typescript/commonjs/shared/translation/helpers.d.ts.map +1 -1
- package/dist/typescript/commonjs/shared/translation/hooks.d.ts +2 -2
- package/dist/typescript/commonjs/shared/translation/hooks.d.ts.map +1 -1
- package/dist/typescript/commonjs/shared/translation/index.d.ts +1 -0
- package/dist/typescript/commonjs/shared/translation/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/shared/translation/model.d.ts +3 -43
- package/dist/typescript/commonjs/shared/translation/model.d.ts.map +1 -1
- package/dist/typescript/commonjs/shared/translation/types.d.ts +4 -4
- package/dist/typescript/commonjs/shared/translation/types.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/Alternatives/Alternatives.d.ts +3 -1
- package/dist/typescript/module/features/chatbot/components/Alternatives/Alternatives.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessage/ChatMessage.d.ts +10 -7
- package/dist/typescript/module/features/chatbot/components/ChatMessage/ChatMessage.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageTextToSpeech.d.ts +7 -5
- package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageTextToSpeech.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessage/ReceivedMessage.d.ts +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessage/ReceivedMessage.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessage/SentMessage.d.ts +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessage/SentMessage.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts +10 -2
- package/dist/typescript/module/features/chatbot/components/ChatMessages/ChatbotMessages.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/Chatbot.d.ts +5 -2
- package/dist/typescript/module/features/chatbot/components/Chatbot.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/index.d.ts +3 -4
- package/dist/typescript/module/features/chatbot/index.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/ChatBotMessageHandler.d.ts +31 -0
- package/dist/typescript/module/features/chatbot/model/ChatBotMessageHandler.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/model/ChatBotModel.d.ts +18 -24
- package/dist/typescript/module/features/chatbot/model/ChatBotModel.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/DefaultMessageCreator.d.ts +3 -5
- package/dist/typescript/module/features/chatbot/model/DefaultMessageCreator.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/ThreadItem.d.ts +7 -13
- package/dist/typescript/module/features/chatbot/model/ThreadItem.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/{ChatbotApi.d.ts → api.d.ts} +3 -4
- package/dist/typescript/module/features/chatbot/model/api.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/model/constants.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/messagesHelper.d.ts +5 -7
- package/dist/typescript/module/features/chatbot/model/messagesHelper.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/t2s.d.ts +6 -16
- package/dist/typescript/module/features/chatbot/model/t2s.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/translation.d.ts +9 -8
- package/dist/typescript/module/features/chatbot/model/translation.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/translation.helpers.d.ts +1 -2
- package/dist/typescript/module/features/chatbot/model/translation.helpers.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/types/api.types.d.ts +11 -12
- package/dist/typescript/module/features/chatbot/types/api.types.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/types/model.types.d.ts +24 -19
- package/dist/typescript/module/features/chatbot/types/model.types.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/types/t2s.types.d.ts +7 -9
- package/dist/typescript/module/features/chatbot/types/t2s.types.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/types/translation.types.d.ts +2 -3
- package/dist/typescript/module/features/chatbot/types/translation.types.d.ts.map +1 -1
- package/dist/typescript/module/features/endOfAssignment/components/CorrectAnswer/AnimatedCard.d.ts.map +1 -1
- package/dist/typescript/module/features/endOfAssignment/ui/PracticeButtonGroup.d.ts.map +1 -1
- package/dist/typescript/module/index.d.ts +1 -0
- package/dist/typescript/module/index.d.ts.map +1 -1
- package/dist/typescript/module/lib/effector/createEntityFieldStore.d.ts +0 -2
- package/dist/typescript/module/lib/effector/createEntityFieldStore.d.ts.map +1 -1
- package/dist/typescript/module/shared/icons/icon.types.d.ts +0 -2
- package/dist/typescript/module/shared/icons/icon.types.d.ts.map +1 -1
- package/dist/typescript/module/shared/translation/constants.d.ts +0 -21
- package/dist/typescript/module/shared/translation/constants.d.ts.map +1 -1
- package/dist/typescript/module/shared/translation/helpers.d.ts +2 -3
- package/dist/typescript/module/shared/translation/helpers.d.ts.map +1 -1
- package/dist/typescript/module/shared/translation/hooks.d.ts +2 -2
- package/dist/typescript/module/shared/translation/hooks.d.ts.map +1 -1
- package/dist/typescript/module/shared/translation/index.d.ts +1 -0
- package/dist/typescript/module/shared/translation/index.d.ts.map +1 -1
- package/dist/typescript/module/shared/translation/model.d.ts +3 -43
- package/dist/typescript/module/shared/translation/model.d.ts.map +1 -1
- package/dist/typescript/module/shared/translation/types.d.ts +4 -4
- package/dist/typescript/module/shared/translation/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/features/celebrations/config.ts +4 -4
- package/src/features/chatbot/components/Alternatives/Alternatives.tsx +4 -2
- package/src/features/chatbot/components/ChatMessage/ChatMessage.tsx +10 -7
- package/src/features/chatbot/components/ChatMessage/MessageTextToSpeech.tsx +51 -34
- package/src/features/chatbot/components/ChatMessage/ReceivedMessage.tsx +40 -15
- package/src/features/chatbot/components/ChatMessage/SentMessage.tsx +10 -9
- package/src/features/chatbot/components/ChatMessages/ChatbotMessages.tsx +34 -17
- package/src/features/chatbot/components/Chatbot.tsx +11 -5
- package/src/features/chatbot/index.ts +4 -3
- package/src/features/chatbot/model/{ChatBotThreadManager.ts → ChatBotMessageHandler.ts} +27 -53
- package/src/features/chatbot/model/ChatBotModel.ts +149 -151
- package/src/features/chatbot/model/DefaultMessageCreator.ts +16 -17
- package/src/features/chatbot/model/ThreadItem.ts +10 -15
- package/src/features/chatbot/model/{ChatbotApi.ts → api.ts} +2 -5
- package/src/features/chatbot/model/constants.ts +0 -2
- package/src/features/chatbot/model/messagesHelper.ts +7 -12
- package/src/features/chatbot/model/t2s.ts +13 -28
- package/src/features/chatbot/model/translation.helpers.ts +1 -2
- package/src/features/chatbot/model/translation.ts +24 -34
- package/src/features/chatbot/types/api.types.ts +12 -12
- package/src/features/chatbot/types/model.types.ts +32 -31
- package/src/features/chatbot/types/t2s.types.ts +15 -18
- package/src/features/chatbot/types/translation.types.ts +2 -3
- package/src/features/endOfAssignment/components/CorrectAnswer/AnimatedCard.tsx +2 -3
- package/src/features/endOfAssignment/ui/PracticeButtonGroup.tsx +1 -0
- package/src/index.ts +1 -0
- package/src/lib/effector/createEntityFieldStore.ts +1 -9
- package/{dist/commonjs/shared/translation → src/lib}/localization/en.json +1 -8
- package/src/{shared/translation → lib}/localization/gb.json +1 -8
- package/src/{shared/translation → lib}/localization/sw.json +1 -8
- package/src/shared/icons/icon.types.ts +6 -9
- package/src/shared/translation/constants.ts +3 -3
- package/src/shared/translation/helpers.ts +9 -22
- package/src/shared/translation/hooks.ts +16 -12
- package/src/shared/translation/index.ts +1 -0
- package/src/shared/translation/model.ts +8 -8
- package/src/shared/translation/types.ts +8 -11
- package/dist/commonjs/features/chatbot/components/ChatMessage/MessageButtonsBlock.js +0 -44
- package/dist/commonjs/features/chatbot/components/ChatMessage/MessageButtonsBlock.js.map +0 -1
- package/dist/commonjs/features/chatbot/components/ChatMessage/MessageContent.js +0 -62
- package/dist/commonjs/features/chatbot/components/ChatMessage/MessageContent.js.map +0 -1
- package/dist/commonjs/features/chatbot/components/ChatMessage/helpers.js +0 -13
- package/dist/commonjs/features/chatbot/components/ChatMessage/helpers.js.map +0 -1
- package/dist/commonjs/features/chatbot/context/ChatBotModelContext.js +0 -17
- package/dist/commonjs/features/chatbot/context/ChatBotModelContext.js.map +0 -1
- package/dist/commonjs/features/chatbot/errorSpotting/ErrorSpottingButton.js +0 -57
- package/dist/commonjs/features/chatbot/errorSpotting/ErrorSpottingButton.js.map +0 -1
- package/dist/commonjs/features/chatbot/errorSpotting/ErrorSpottingModel.js +0 -130
- package/dist/commonjs/features/chatbot/errorSpotting/ErrorSpottingModel.js.map +0 -1
- package/dist/commonjs/features/chatbot/model/ChatBotThreadManager.js.map +0 -1
- package/dist/commonjs/features/chatbot/model/ChatBoxTextManager.js +0 -22
- package/dist/commonjs/features/chatbot/model/ChatBoxTextManager.js.map +0 -1
- package/dist/commonjs/features/chatbot/model/ChatbotApi.js.map +0 -1
- package/dist/commonjs/features/chatbot/model/ChatsCacheModel.js +0 -110
- package/dist/commonjs/features/chatbot/model/ChatsCacheModel.js.map +0 -1
- package/dist/commonjs/features/chatbot/types/units.types.js +0 -2
- package/dist/commonjs/features/chatbot/types/units.types.js.map +0 -1
- package/dist/commonjs/lib/effector/withEvent.js +0 -13
- package/dist/commonjs/lib/effector/withEvent.js.map +0 -1
- package/dist/commonjs/lib/types/keys.js +0 -2
- package/dist/commonjs/lib/types/keys.js.map +0 -1
- package/dist/commonjs/shared/icons/HighlighterIcon.js +0 -36
- package/dist/commonjs/shared/icons/HighlighterIcon.js.map +0 -1
- package/dist/commonjs/shared/icons/StopIcon.js +0 -33
- package/dist/commonjs/shared/icons/StopIcon.js.map +0 -1
- package/dist/commonjs/shared/translation/validation.types.js +0 -6
- package/dist/commonjs/shared/translation/validation.types.js.map +0 -1
- package/dist/module/features/chatbot/components/ChatMessage/MessageButtonsBlock.js +0 -38
- package/dist/module/features/chatbot/components/ChatMessage/MessageButtonsBlock.js.map +0 -1
- package/dist/module/features/chatbot/components/ChatMessage/MessageContent.js +0 -57
- package/dist/module/features/chatbot/components/ChatMessage/MessageContent.js.map +0 -1
- package/dist/module/features/chatbot/components/ChatMessage/helpers.js +0 -9
- package/dist/module/features/chatbot/components/ChatMessage/helpers.js.map +0 -1
- package/dist/module/features/chatbot/context/ChatBotModelContext.js +0 -12
- package/dist/module/features/chatbot/context/ChatBotModelContext.js.map +0 -1
- package/dist/module/features/chatbot/errorSpotting/ErrorSpottingButton.js +0 -51
- package/dist/module/features/chatbot/errorSpotting/ErrorSpottingButton.js.map +0 -1
- package/dist/module/features/chatbot/errorSpotting/ErrorSpottingModel.js +0 -125
- package/dist/module/features/chatbot/errorSpotting/ErrorSpottingModel.js.map +0 -1
- package/dist/module/features/chatbot/model/ChatBotThreadManager.js.map +0 -1
- package/dist/module/features/chatbot/model/ChatBoxTextManager.js +0 -17
- package/dist/module/features/chatbot/model/ChatBoxTextManager.js.map +0 -1
- package/dist/module/features/chatbot/model/ChatbotApi.js.map +0 -1
- package/dist/module/features/chatbot/model/ChatsCacheModel.js +0 -104
- package/dist/module/features/chatbot/model/ChatsCacheModel.js.map +0 -1
- package/dist/module/features/chatbot/types/units.types.js +0 -2
- package/dist/module/features/chatbot/types/units.types.js.map +0 -1
- package/dist/module/lib/effector/withEvent.js +0 -9
- package/dist/module/lib/effector/withEvent.js.map +0 -1
- package/dist/module/lib/types/keys.js +0 -2
- package/dist/module/lib/types/keys.js.map +0 -1
- package/dist/module/shared/icons/HighlighterIcon.js +0 -29
- package/dist/module/shared/icons/HighlighterIcon.js.map +0 -1
- package/dist/module/shared/icons/StopIcon.js +0 -26
- package/dist/module/shared/icons/StopIcon.js.map +0 -1
- package/dist/module/shared/translation/validation.types.js +0 -4
- package/dist/module/shared/translation/validation.types.js.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageButtonsBlock.d.ts +0 -10
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageButtonsBlock.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageContent.d.ts +0 -11
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/MessageContent.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/helpers.d.ts +0 -4
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/helpers.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/context/ChatBotModelContext.d.ts +0 -4
- package/dist/typescript/commonjs/features/chatbot/context/ChatBotModelContext.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/errorSpotting/ErrorSpottingButton.d.ts +0 -8
- package/dist/typescript/commonjs/features/chatbot/errorSpotting/ErrorSpottingButton.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/errorSpotting/ErrorSpottingModel.d.ts +0 -35
- package/dist/typescript/commonjs/features/chatbot/errorSpotting/ErrorSpottingModel.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotThreadManager.d.ts +0 -33
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotThreadManager.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/model/ChatBoxTextManager.d.ts +0 -6
- package/dist/typescript/commonjs/features/chatbot/model/ChatBoxTextManager.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/model/ChatbotApi.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/model/ChatsCacheModel.d.ts +0 -27
- package/dist/typescript/commonjs/features/chatbot/model/ChatsCacheModel.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/types/units.types.d.ts +0 -34
- package/dist/typescript/commonjs/features/chatbot/types/units.types.d.ts.map +0 -1
- package/dist/typescript/commonjs/lib/effector/withEvent.d.ts +0 -2
- package/dist/typescript/commonjs/lib/effector/withEvent.d.ts.map +0 -1
- package/dist/typescript/commonjs/lib/types/keys.d.ts +0 -8
- package/dist/typescript/commonjs/lib/types/keys.d.ts.map +0 -1
- package/dist/typescript/commonjs/shared/icons/HighlighterIcon.d.ts +0 -4
- package/dist/typescript/commonjs/shared/icons/HighlighterIcon.d.ts.map +0 -1
- package/dist/typescript/commonjs/shared/icons/StopIcon.d.ts +0 -4
- package/dist/typescript/commonjs/shared/icons/StopIcon.d.ts.map +0 -1
- package/dist/typescript/commonjs/shared/translation/validation.types.d.ts +0 -17
- package/dist/typescript/commonjs/shared/translation/validation.types.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageButtonsBlock.d.ts +0 -10
- package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageButtonsBlock.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageContent.d.ts +0 -11
- package/dist/typescript/module/features/chatbot/components/ChatMessage/MessageContent.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessage/helpers.d.ts +0 -4
- package/dist/typescript/module/features/chatbot/components/ChatMessage/helpers.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/context/ChatBotModelContext.d.ts +0 -4
- package/dist/typescript/module/features/chatbot/context/ChatBotModelContext.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/errorSpotting/ErrorSpottingButton.d.ts +0 -8
- package/dist/typescript/module/features/chatbot/errorSpotting/ErrorSpottingButton.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/errorSpotting/ErrorSpottingModel.d.ts +0 -35
- package/dist/typescript/module/features/chatbot/errorSpotting/ErrorSpottingModel.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/model/ChatBotThreadManager.d.ts +0 -33
- package/dist/typescript/module/features/chatbot/model/ChatBotThreadManager.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/model/ChatBoxTextManager.d.ts +0 -6
- package/dist/typescript/module/features/chatbot/model/ChatBoxTextManager.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/model/ChatbotApi.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/model/ChatsCacheModel.d.ts +0 -27
- package/dist/typescript/module/features/chatbot/model/ChatsCacheModel.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/types/units.types.d.ts +0 -34
- package/dist/typescript/module/features/chatbot/types/units.types.d.ts.map +0 -1
- package/dist/typescript/module/lib/effector/withEvent.d.ts +0 -2
- package/dist/typescript/module/lib/effector/withEvent.d.ts.map +0 -1
- package/dist/typescript/module/lib/types/keys.d.ts +0 -8
- package/dist/typescript/module/lib/types/keys.d.ts.map +0 -1
- package/dist/typescript/module/shared/icons/HighlighterIcon.d.ts +0 -4
- package/dist/typescript/module/shared/icons/HighlighterIcon.d.ts.map +0 -1
- package/dist/typescript/module/shared/icons/StopIcon.d.ts +0 -4
- package/dist/typescript/module/shared/icons/StopIcon.d.ts.map +0 -1
- package/dist/typescript/module/shared/translation/validation.types.d.ts +0 -17
- package/dist/typescript/module/shared/translation/validation.types.d.ts.map +0 -1
- package/src/features/chatbot/components/ChatMessage/MessageButtonsBlock.tsx +0 -38
- package/src/features/chatbot/components/ChatMessage/MessageContent.tsx +0 -52
- package/src/features/chatbot/components/ChatMessage/helpers.ts +0 -9
- package/src/features/chatbot/context/ChatBotModelContext.ts +0 -14
- package/src/features/chatbot/errorSpotting/ErrorSpottingButton.tsx +0 -53
- package/src/features/chatbot/errorSpotting/ErrorSpottingModel.ts +0 -150
- package/src/features/chatbot/model/ChatBoxTextManager.ts +0 -18
- package/src/features/chatbot/model/ChatsCacheModel.ts +0 -95
- package/src/features/chatbot/types/units.types.ts +0 -37
- package/src/lib/effector/withEvent.ts +0 -7
- package/src/lib/types/keys.ts +0 -18
- package/src/shared/icons/HighlighterIcon.tsx +0 -21
- package/src/shared/icons/StopIcon.tsx +0 -17
- package/src/shared/translation/validation.types.ts +0 -26
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
attach,
|
|
3
|
-
combine,
|
|
4
|
-
createEffect,
|
|
5
3
|
createEvent,
|
|
6
|
-
createStore,
|
|
7
4
|
restore,
|
|
8
5
|
sample,
|
|
9
6
|
type Store,
|
|
7
|
+
createStore,
|
|
8
|
+
createEffect,
|
|
9
|
+
combine,
|
|
10
10
|
} from 'effector'
|
|
11
|
+
import { createControllerEffect, createEntityFieldStore } from '../../../lib/effector'
|
|
11
12
|
import {
|
|
12
13
|
ChatbotContext,
|
|
13
14
|
ChatbotModelProps,
|
|
14
|
-
|
|
15
|
+
ConversationMessage,
|
|
15
16
|
SendHelpParams,
|
|
16
17
|
SendHelpProps,
|
|
17
18
|
SetHintMessageProps,
|
|
@@ -19,32 +20,20 @@ import {
|
|
|
19
20
|
StartConversationProps,
|
|
20
21
|
} from '../types/model.types'
|
|
21
22
|
import { GetAlternativesResponse } from '../types/api.types'
|
|
22
|
-
import { ChatbotAPI } from './
|
|
23
|
+
import { ChatbotAPI } from './api'
|
|
23
24
|
import { ChatbotTranslation } from './translation'
|
|
24
|
-
import { ChatTextToSpeechModel
|
|
25
|
+
import { ChatTextToSpeechModel } from './t2s'
|
|
26
|
+
import { AudioProvider } from '../types/t2s.types'
|
|
25
27
|
import { messagesHelper } from './messagesHelper'
|
|
26
|
-
import { ChatBotThreadManager } from './ChatBotThreadManager'
|
|
27
|
-
import { ChatsCacheModel, defaultChatData } from './ChatsCacheModel'
|
|
28
|
-
import { ErrorSpottingModel } from '../errorSpotting/ErrorSpottingModel'
|
|
29
|
-
import { withEvent } from '../../../lib/effector/withEvent'
|
|
30
|
-
import { ChatBotTextManager } from './ChatBoxTextManager'
|
|
31
28
|
|
|
32
29
|
type ReinitConversationProps = {
|
|
33
30
|
key: string
|
|
34
31
|
}
|
|
35
32
|
|
|
36
33
|
export class ChatbotModel {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
public readonly threadManager = new ChatBotThreadManager({
|
|
41
|
-
messages: this.defaultMessages,
|
|
42
|
-
})
|
|
43
|
-
public readonly api: ChatbotAPI
|
|
44
|
-
|
|
45
|
-
public readonly translation: ChatbotTranslation
|
|
46
|
-
public readonly t2s: ChatTextToSpeechModel
|
|
47
|
-
public readonly errorSpotting: ErrorSpottingModel
|
|
34
|
+
readonly api: ChatbotAPI
|
|
35
|
+
readonly translation: ChatbotTranslation
|
|
36
|
+
readonly t2s: ChatTextToSpeechModel
|
|
48
37
|
|
|
49
38
|
public readonly $currentKey = createStore('')
|
|
50
39
|
|
|
@@ -63,142 +52,151 @@ export class ChatbotModel {
|
|
|
63
52
|
public readonly setContext = createEvent<null | ChatbotContext>()
|
|
64
53
|
public readonly $context = restore(this.setContext, null)
|
|
65
54
|
|
|
66
|
-
|
|
67
|
-
|
|
55
|
+
readonly setScrollActive = createEvent<boolean>()
|
|
56
|
+
readonly $isScrollActive = restore(this.setScrollActive, false)
|
|
57
|
+
|
|
58
|
+
readonly sendHelpRequestFx
|
|
68
59
|
|
|
69
|
-
|
|
60
|
+
readonly defaultMessages: ChatbotModelProps['messages']
|
|
61
|
+
|
|
62
|
+
readonly messages = createEntityFieldStore<ConversationMessage[]>()
|
|
63
|
+
readonly threadIds = createEntityFieldStore<string>()
|
|
64
|
+
readonly availableChats = createEntityFieldStore<boolean>()
|
|
70
65
|
|
|
71
66
|
public readonly $currentChatData = combine(
|
|
72
|
-
{
|
|
73
|
-
|
|
67
|
+
{
|
|
68
|
+
messages: this.messages.$state,
|
|
69
|
+
threadIds: this.threadIds.$state,
|
|
70
|
+
availableChats: this.availableChats.$state,
|
|
71
|
+
key: this.$currentKey,
|
|
72
|
+
},
|
|
73
|
+
({ messages, threadIds, availableChats, key }) => {
|
|
74
|
+
return {
|
|
75
|
+
messages: messages[key] ?? [],
|
|
76
|
+
threadId: threadIds[key] ?? null,
|
|
77
|
+
isAvailable: availableChats[key] ?? false,
|
|
78
|
+
key,
|
|
79
|
+
}
|
|
80
|
+
},
|
|
74
81
|
)
|
|
75
82
|
|
|
76
|
-
constructor({ api, $key
|
|
77
|
-
this.api = new ChatbotAPI(
|
|
83
|
+
constructor({ api, messages, $key }: ChatbotModelProps) {
|
|
84
|
+
this.api = new ChatbotAPI(api)
|
|
78
85
|
|
|
79
|
-
this.
|
|
80
|
-
if (
|
|
81
|
-
this.threadManager.setMessagesLimit(threadMessagesLimit)
|
|
82
|
-
}
|
|
86
|
+
this.defaultMessages = messages
|
|
87
|
+
if ($key) sample({ source: $key, target: this.$currentKey })
|
|
83
88
|
|
|
84
89
|
this.$alternatives = restore(this.api.getAlternativesFx.doneData, null)
|
|
85
90
|
.on(this.setAlternatives, (_, payload) => payload)
|
|
86
91
|
.reset(this.resetAlternatives)
|
|
87
92
|
|
|
88
|
-
this.t2s = new ChatTextToSpeechModel({ api: this.api })
|
|
89
93
|
this.translation = new ChatbotTranslation({
|
|
90
94
|
$context: this.$context,
|
|
91
|
-
defaultMessages:
|
|
95
|
+
defaultMessages: messages,
|
|
92
96
|
$key: this.$currentKey,
|
|
93
97
|
api: this.api,
|
|
98
|
+
messagesModel: this.messages,
|
|
94
99
|
alternativesModel: {
|
|
95
100
|
$store: this.$alternatives,
|
|
96
101
|
set: this.setAlternatives,
|
|
97
102
|
},
|
|
98
|
-
chats: this.cache,
|
|
99
103
|
})
|
|
100
104
|
|
|
101
|
-
this.
|
|
102
|
-
api: this.api,
|
|
103
|
-
$currentChatData: this.$currentChatData,
|
|
104
|
-
$currentChatContext: this.$context,
|
|
105
|
-
})
|
|
105
|
+
this.t2s = new ChatTextToSpeechModel({ $isOpen: this.$isOpen, api: this.api })
|
|
106
106
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
sample({
|
|
110
|
-
source: this.$isOpen.updates,
|
|
111
|
-
filter: (isOpen) => !isOpen,
|
|
112
|
-
target: [this.t2s.reset, this.errorSpotting.spottingHidden],
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
sample({
|
|
116
|
-
clock: this.removeLastMessage,
|
|
117
|
-
source: [this.$lastMessageKey, this.cache.$data] as const,
|
|
118
|
-
fn: ([lastMessageKey, chatsData]) => {
|
|
119
|
-
const chat = chatsData[lastMessageKey ?? '']
|
|
120
|
-
if (!chat) return { key: '', data: {} }
|
|
121
|
-
const updatedMessages = [...chat.messages]
|
|
122
|
-
updatedMessages.pop()
|
|
123
|
-
return { key: lastMessageKey ?? '', data: { messages: updatedMessages } }
|
|
124
|
-
},
|
|
125
|
-
filter: ([lastMessageKey]) => !!lastMessageKey,
|
|
126
|
-
target: this.cache.update,
|
|
127
|
-
})
|
|
107
|
+
this.sendHelpRequestFx = this.createSendHelpRequestFx()
|
|
108
|
+
this.initChatReplyWatcher()
|
|
128
109
|
}
|
|
129
110
|
|
|
130
111
|
private createSendHelpRequestFx() {
|
|
131
112
|
const effect = attach({
|
|
132
|
-
source: [
|
|
133
|
-
|
|
113
|
+
source: [
|
|
114
|
+
this.$currentKey,
|
|
115
|
+
this.translation.$isTranslated,
|
|
116
|
+
this.$currentChatData,
|
|
117
|
+
this.$context,
|
|
118
|
+
],
|
|
119
|
+
mapParams: (params: SendHelpParams, [key, isTranslated, currentData, context]) => ({
|
|
134
120
|
message: params.message,
|
|
135
121
|
translatedMessage: params.translatedMessage,
|
|
136
122
|
context,
|
|
137
123
|
key,
|
|
124
|
+
isTranslated,
|
|
125
|
+
threadId: currentData.threadId,
|
|
138
126
|
}),
|
|
139
|
-
effect:
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
127
|
+
effect: createControllerEffect(
|
|
128
|
+
async ({
|
|
129
|
+
message,
|
|
130
|
+
translatedMessage,
|
|
131
|
+
key,
|
|
132
|
+
isTranslated,
|
|
133
|
+
threadId,
|
|
134
|
+
context,
|
|
135
|
+
}: SendHelpProps) => {
|
|
136
|
+
if (!context) throw new Error('Context is required')
|
|
137
|
+
this.setLastMessageKey(key)
|
|
138
|
+
this.messages.setField({
|
|
139
|
+
key,
|
|
140
|
+
fn: (currentMessages) => [
|
|
141
|
+
...(currentMessages || []),
|
|
142
|
+
messagesHelper.createOwn({ message, translatedMessage, threadId }),
|
|
143
|
+
],
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
const response = await this.api.postMessageFx({
|
|
147
|
+
problem: context.problem,
|
|
148
|
+
language: context.language,
|
|
149
|
+
problemAnswer: context.problemAnswer,
|
|
150
|
+
answer: context.answer,
|
|
151
|
+
threadId,
|
|
152
|
+
imageAltText: context.imageDescription,
|
|
153
|
+
})
|
|
154
|
+
let messages = [messagesHelper.createAnswer(response)]
|
|
155
|
+
if (response.endMessage) {
|
|
156
|
+
messages.push(messagesHelper.createLast(this.defaultMessages.endMessage))
|
|
157
|
+
}
|
|
158
|
+
if (isTranslated) {
|
|
159
|
+
messages = await this.translation.translateMessagesFx({
|
|
160
|
+
targetLanguage: context.translationTargetLanguage,
|
|
161
|
+
messages,
|
|
162
|
+
})
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
this.messages.setField({
|
|
166
|
+
key,
|
|
167
|
+
fn: (currentMessages) => [...(currentMessages || []), ...messages],
|
|
168
|
+
})
|
|
169
|
+
this.threadIds.setField({ key, data: response.threadId })
|
|
170
|
+
},
|
|
171
|
+
),
|
|
164
172
|
})
|
|
165
173
|
|
|
166
174
|
sample({
|
|
167
175
|
clock: effect.fail,
|
|
168
176
|
source: this.$currentChatData,
|
|
169
|
-
fn: ({ key, messages }) => ({
|
|
170
|
-
key,
|
|
171
|
-
data: { messages: [...messages, this.defaultMessages.error] },
|
|
172
|
-
}),
|
|
177
|
+
fn: ({ key, messages }) => ({ key, data: [...messages, this.defaultMessages.error] }),
|
|
173
178
|
filter: (_, { error }) => error.message !== 'Request aborted manually',
|
|
174
|
-
target: this.
|
|
179
|
+
target: this.messages.setField,
|
|
175
180
|
})
|
|
176
181
|
|
|
177
182
|
return effect
|
|
178
183
|
}
|
|
179
184
|
|
|
180
|
-
|
|
185
|
+
private initChatReplyWatcher() {
|
|
181
186
|
sample({
|
|
182
|
-
|
|
183
|
-
|
|
187
|
+
clock: this.removeLastMessage,
|
|
188
|
+
source: [this.$lastMessageKey, this.messages.$state] as const,
|
|
189
|
+
fn: ([lastMessageKey, messages]) => {
|
|
190
|
+
if (!lastMessageKey) return { key: '', data: [] }
|
|
191
|
+
const updatedMessages = [...messages[lastMessageKey]]
|
|
192
|
+
updatedMessages.pop()
|
|
193
|
+
return { key: lastMessageKey, data: updatedMessages }
|
|
194
|
+
},
|
|
195
|
+
filter: ([lastMessageKey]) => !!lastMessageKey,
|
|
196
|
+
target: this.messages.setField,
|
|
184
197
|
})
|
|
185
|
-
this.threadManager.bindKeyStore($store)
|
|
186
|
-
return this
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
public setUpT2S(config: T2SConfig) {
|
|
190
|
-
this.t2s.setConfig(config)
|
|
191
|
-
return this
|
|
192
198
|
}
|
|
193
199
|
|
|
194
|
-
public setDrawBoardAdapter(adapter: IChatDrawBoardAdapter) {
|
|
195
|
-
this.threadManager.setDrawBoardAdapter(adapter)
|
|
196
|
-
this.errorSpotting.bindStrokesValidation(adapter.$strokesValidationKey)
|
|
197
|
-
return this
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
public readonly sendHelpRequestFx = this.createSendHelpRequestFx()
|
|
201
|
-
|
|
202
200
|
public readonly startConversation = attach({
|
|
203
201
|
source: this.$currentChatData,
|
|
204
202
|
mapParams: (props: StartConversationProps | void, source) => ({
|
|
@@ -210,54 +208,54 @@ export class ChatbotModel {
|
|
|
210
208
|
if (initOnly) return
|
|
211
209
|
return this.reinitConversation({ key })
|
|
212
210
|
}
|
|
213
|
-
this.
|
|
214
|
-
|
|
215
|
-
isAvailable: true,
|
|
216
|
-
currentThread: null,
|
|
217
|
-
})
|
|
211
|
+
this.messages.setField({ key, data: [this.defaultMessages.start] })
|
|
212
|
+
this.availableChats.setField({ key, data: true })
|
|
218
213
|
}),
|
|
219
214
|
})
|
|
220
215
|
|
|
221
216
|
public setHintMessage({ key, ...message }: SetHintMessageProps) {
|
|
222
217
|
const options = this.$alternatives.getState()?.options.hints ?? message.options
|
|
223
|
-
this.
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
218
|
+
this.messages.setField({
|
|
219
|
+
key,
|
|
220
|
+
fn: (messages) => {
|
|
221
|
+
if (!messages || messages.length > 1) return
|
|
222
|
+
return [{ ...message, options }]
|
|
223
|
+
},
|
|
224
|
+
})
|
|
229
225
|
}
|
|
230
226
|
|
|
231
|
-
public
|
|
232
|
-
this.
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
227
|
+
public readonly reinitConversation = createEffect(({ key }: ReinitConversationProps) => {
|
|
228
|
+
this.messages.setField({
|
|
229
|
+
key,
|
|
230
|
+
fn: (messages) => {
|
|
231
|
+
if (!messages?.length || messages.length === 1) return
|
|
232
|
+
const copy = [...messages]
|
|
233
|
+
while (copy.at(-1)?.endMessage) {
|
|
234
|
+
copy.pop()
|
|
235
|
+
}
|
|
236
236
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
isLoading: this.sendHelpRequestFx.pending,
|
|
240
|
-
lastMessageKey: this.$lastMessageKey,
|
|
241
|
-
},
|
|
242
|
-
mapParams: (_: void, { isLoading, lastMessageKey }) => !!(isLoading && lastMessageKey),
|
|
243
|
-
effect: createEffect((hasPendingMessage: boolean) => {
|
|
244
|
-
if (hasPendingMessage) {
|
|
245
|
-
this.api.postMessageFx.controller.abort()
|
|
246
|
-
this.removeLastMessage()
|
|
247
|
-
}
|
|
248
|
-
this.errorSpotting.abortPendingRequest()
|
|
237
|
+
const lastMessage = copy.at(-1)
|
|
238
|
+
if (!lastMessage) return
|
|
249
239
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
240
|
+
copy.splice(copy.length - 1, 1, {
|
|
241
|
+
...lastMessage,
|
|
242
|
+
options: [this.defaultMessages.anotherHintOption],
|
|
243
|
+
})
|
|
244
|
+
return copy
|
|
245
|
+
},
|
|
246
|
+
})
|
|
255
247
|
})
|
|
256
248
|
|
|
257
|
-
public
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
249
|
+
public bindKey($store: Store<string>) {
|
|
250
|
+
sample({
|
|
251
|
+
source: $store,
|
|
252
|
+
target: this.$currentKey,
|
|
253
|
+
})
|
|
254
|
+
return this
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
public setT2SAudioProvider(audioProvider: AudioProvider) {
|
|
258
|
+
this.t2s.setAudioProvider(audioProvider)
|
|
259
|
+
return this
|
|
260
|
+
}
|
|
263
261
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { PostMessageResponse } from '../types/api.types'
|
|
2
|
-
import {
|
|
3
|
-
import { ChatAnswer } from '../types/units.types'
|
|
1
|
+
import { ChatAnswer, PostMessageResponse } from '../types/api.types'
|
|
2
|
+
import { createEvent } from 'effector'
|
|
4
3
|
|
|
5
|
-
type ChatMessage =
|
|
4
|
+
type ChatMessage = PostMessageResponse & {
|
|
6
5
|
id: string
|
|
7
6
|
isOwnMessage: boolean
|
|
8
7
|
}
|
|
@@ -16,17 +15,30 @@ type DefaultMessageCreatorProps<K extends string> = {
|
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
export class DefaultMessagesCreator<K extends string> {
|
|
18
|
+
public readonly languageChanged = createEvent()
|
|
19
|
+
|
|
19
20
|
private readonly list = new Map<ChatMessage | ChatAnswer, K>()
|
|
20
21
|
private readonly getter
|
|
21
22
|
|
|
22
23
|
constructor({ textGetter }: DefaultMessageCreatorProps<K>) {
|
|
23
24
|
this.getter = textGetter
|
|
25
|
+
|
|
26
|
+
this.languageChanged.watch(() => {
|
|
27
|
+
this.list.forEach((key, chatMessage) => {
|
|
28
|
+
if ('message' in chatMessage) {
|
|
29
|
+
chatMessage.message = this.getter(key)
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
chatMessage.text = this.getter(key)
|
|
33
|
+
})
|
|
34
|
+
})
|
|
24
35
|
}
|
|
25
36
|
|
|
26
37
|
public createMessage(key: K, { isOwn = false }: DefaultMessageSettings = {}) {
|
|
27
38
|
const message: ChatMessage = {
|
|
28
39
|
id: this.list.size.toString(),
|
|
29
40
|
message: this.getter(key),
|
|
41
|
+
threadId: '',
|
|
30
42
|
options: [],
|
|
31
43
|
isOwnMessage: isOwn,
|
|
32
44
|
}
|
|
@@ -42,17 +54,4 @@ export class DefaultMessagesCreator<K extends string> {
|
|
|
42
54
|
this.list.set(option, key)
|
|
43
55
|
return option
|
|
44
56
|
}
|
|
45
|
-
|
|
46
|
-
public bindToLanguageChanged(event: Event<unknown>) {
|
|
47
|
-
event.watch(() => {
|
|
48
|
-
this.list.forEach((key, chatMessage) => {
|
|
49
|
-
if ('message' in chatMessage) {
|
|
50
|
-
chatMessage.message = this.getter(key)
|
|
51
|
-
return
|
|
52
|
-
}
|
|
53
|
-
chatMessage.text = this.getter(key)
|
|
54
|
-
})
|
|
55
|
-
})
|
|
56
|
-
return this
|
|
57
|
-
}
|
|
58
57
|
}
|
|
@@ -1,31 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { generateRandomId } from '../../../lib/helpers/helpers'
|
|
1
|
+
import { Stroke } from '../types/api.types'
|
|
3
2
|
|
|
4
3
|
type ThreadItemProps = {
|
|
5
|
-
strokes
|
|
6
|
-
key: string
|
|
4
|
+
strokes?: Stroke[] | null
|
|
7
5
|
}
|
|
8
6
|
|
|
9
|
-
export class ThreadItem
|
|
10
|
-
public readonly
|
|
11
|
-
public readonly
|
|
12
|
-
public readonly strokes: FullStrokeData[] | null
|
|
13
|
-
public readonly history: string[] = []
|
|
7
|
+
export class ThreadItem {
|
|
8
|
+
public readonly strokes: Stroke[] | null
|
|
9
|
+
public readonly hints: string[] = []
|
|
14
10
|
|
|
15
|
-
public constructor(
|
|
16
|
-
this.strokes =
|
|
17
|
-
this.strokesValidationKey = props?.key ?? null
|
|
11
|
+
public constructor({ strokes }: ThreadItemProps = {}) {
|
|
12
|
+
this.strokes = strokes ?? null
|
|
18
13
|
}
|
|
19
14
|
|
|
20
15
|
public getNextHintProps() {
|
|
21
|
-
if (this.
|
|
16
|
+
if (this.hints.length) {
|
|
22
17
|
return {
|
|
23
|
-
previousHint: this.
|
|
18
|
+
previousHint: this.hints[this.hints.length - 1],
|
|
24
19
|
}
|
|
25
20
|
}
|
|
26
21
|
|
|
27
22
|
if (this.strokes) {
|
|
28
|
-
return { stroke: this.strokes
|
|
23
|
+
return { stroke: this.strokes }
|
|
29
24
|
}
|
|
30
25
|
|
|
31
26
|
return {}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createEffect } from 'effector'
|
|
2
2
|
import { createControllerEffect } from '../../../lib/effector'
|
|
3
|
-
import {
|
|
3
|
+
import { ChatbotModelProps } from '../types/model.types'
|
|
4
4
|
import { GoogleTranslatePayload, GoogleTranslateResponse } from '../types/api.types'
|
|
5
5
|
import { replaceKatexSyntax } from '../helpers'
|
|
6
6
|
|
|
@@ -10,10 +10,7 @@ export class ChatbotAPI {
|
|
|
10
10
|
public readonly translateTextFx
|
|
11
11
|
public readonly textToSpeechTextFx
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
constructor(api: ChatbotApiRequests) {
|
|
16
|
-
this.spotErrorFx = createControllerEffect(api.spotError)
|
|
13
|
+
constructor(api: ChatbotModelProps['api']) {
|
|
17
14
|
this.postMessageFx = createControllerEffect(api.postMessage)
|
|
18
15
|
this.getAlternativesFx = createEffect(api.getAlternatives)
|
|
19
16
|
this.translateTextFx = createEffect(
|
|
@@ -1,29 +1,21 @@
|
|
|
1
1
|
import { generateRandomId } from '../../../lib/helpers/helpers'
|
|
2
|
-
import { CreateMessageResponse } from '../types/model.types'
|
|
3
|
-
import { ConversationMessage } from '../types/units.types'
|
|
2
|
+
import { ConversationMessage, CreateMessageResponse } from '../types/model.types'
|
|
4
3
|
|
|
5
4
|
type OwnMessageProps = {
|
|
6
5
|
message?: string
|
|
7
6
|
translatedMessage?: string
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
type CreateAnswerSettings = {
|
|
11
|
-
isInitial?: boolean
|
|
7
|
+
threadId?: string | null
|
|
12
8
|
}
|
|
13
9
|
|
|
14
10
|
export class messagesHelper {
|
|
15
|
-
public static createAnswer(
|
|
16
|
-
data: CreateMessageResponse,
|
|
17
|
-
{ isInitial }: CreateAnswerSettings = {},
|
|
18
|
-
): ConversationMessage {
|
|
11
|
+
public static createAnswer(data: CreateMessageResponse): ConversationMessage {
|
|
19
12
|
return {
|
|
20
13
|
id: generateRandomId(),
|
|
21
14
|
isOwnMessage: false,
|
|
22
15
|
message: data.message,
|
|
23
|
-
options: data.options,
|
|
24
16
|
threadId: data.threadId,
|
|
17
|
+
options: data.options,
|
|
25
18
|
translatedMessage: data.translatedMessage,
|
|
26
|
-
isInitial,
|
|
27
19
|
}
|
|
28
20
|
}
|
|
29
21
|
|
|
@@ -34,6 +26,7 @@ export class messagesHelper {
|
|
|
34
26
|
translatedMessage: data.translatedMessage,
|
|
35
27
|
isOwnMessage: false,
|
|
36
28
|
options: [],
|
|
29
|
+
threadId: '',
|
|
37
30
|
endMessage: true,
|
|
38
31
|
}
|
|
39
32
|
}
|
|
@@ -41,11 +34,13 @@ export class messagesHelper {
|
|
|
41
34
|
public static createOwn({
|
|
42
35
|
message = '',
|
|
43
36
|
translatedMessage,
|
|
37
|
+
threadId,
|
|
44
38
|
}: OwnMessageProps): ConversationMessage {
|
|
45
39
|
return {
|
|
46
40
|
id: generateRandomId(),
|
|
47
41
|
message,
|
|
48
42
|
translatedMessage,
|
|
43
|
+
threadId: threadId || '',
|
|
49
44
|
isOwnMessage: true,
|
|
50
45
|
options: [],
|
|
51
46
|
}
|
|
@@ -1,22 +1,13 @@
|
|
|
1
|
-
import { restore, createEvent, createEffect } from 'effector'
|
|
1
|
+
import { restore, createEvent, Store, sample, createEffect } from 'effector'
|
|
2
2
|
import { AUDIO_CONFIG, DEFAULT_VOICE } from '../constants'
|
|
3
3
|
import { AudioProvider, AudioStatus, PlayTextToSpeechProps } from '../types/t2s.types'
|
|
4
|
-
import { ChatbotAPI } from './
|
|
4
|
+
import { ChatbotAPI } from './api'
|
|
5
5
|
|
|
6
6
|
type ChatTextToSpeechModelProps = {
|
|
7
|
+
$isOpen: Store<boolean>
|
|
7
8
|
api: ChatbotAPI
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
export type T2SConfig = {
|
|
11
|
-
audioProvider?: AudioProvider
|
|
12
|
-
textSanitizer?: (speech: string) => string
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
type AudioConfig = {
|
|
16
|
-
voice?: typeof DEFAULT_VOICE
|
|
17
|
-
audioConfig?: typeof AUDIO_CONFIG
|
|
18
|
-
}
|
|
19
|
-
|
|
20
11
|
export class ChatTextToSpeechModel {
|
|
21
12
|
private readonly api: ChatbotAPI
|
|
22
13
|
private readonly audioCache: Record<string, string> = {}
|
|
@@ -27,31 +18,26 @@ export class ChatTextToSpeechModel {
|
|
|
27
18
|
readonly setStatus = createEvent<AudioStatus>()
|
|
28
19
|
readonly $status = restore(this.setStatus, AudioStatus.STOPPED)
|
|
29
20
|
|
|
30
|
-
|
|
31
|
-
private textSanitizer = (value: string) => value
|
|
32
|
-
|
|
33
|
-
constructor({ api }: ChatTextToSpeechModelProps) {
|
|
21
|
+
constructor({ $isOpen, api }: ChatTextToSpeechModelProps) {
|
|
34
22
|
this.api = api
|
|
35
|
-
}
|
|
36
23
|
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
sample({
|
|
25
|
+
source: $isOpen.updates,
|
|
26
|
+
filter: isOpen => !isOpen,
|
|
27
|
+
target: this.reset,
|
|
28
|
+
})
|
|
39
29
|
}
|
|
40
30
|
|
|
41
|
-
public
|
|
42
|
-
|
|
43
|
-
if (textSanitizer) this.textSanitizer = textSanitizer
|
|
31
|
+
public setAudioProvider(audioProvider: AudioProvider) {
|
|
32
|
+
this.audioProvider = audioProvider
|
|
44
33
|
}
|
|
45
34
|
|
|
46
35
|
private getCacheKey = (messageId: string, isTranslated: boolean) => {
|
|
47
36
|
return `${messageId}-${isTranslated ? 'translated' : 'original'}`
|
|
48
37
|
}
|
|
49
38
|
|
|
50
|
-
|
|
51
|
-
if (!this.audioProvider) throw new Error('Audio provider is not set. Use
|
|
52
|
-
const messageText = isTranslated ? message.translatedMessage! : message.message
|
|
53
|
-
const messageId = message.id
|
|
54
|
-
const text = this.textSanitizer(messageText)
|
|
39
|
+
async play({ text, messageId, isTranslated, config }: PlayTextToSpeechProps) {
|
|
40
|
+
if (!this.audioProvider) throw new Error('Audio provider is not set. Use setAudioProvider.')
|
|
55
41
|
|
|
56
42
|
try {
|
|
57
43
|
const status = this.$status.getState()
|
|
@@ -81,7 +67,6 @@ export class ChatTextToSpeechModel {
|
|
|
81
67
|
this.setCurrentPlayingId(messageId)
|
|
82
68
|
|
|
83
69
|
if (!audioPath) {
|
|
84
|
-
const config = this.audioConfig
|
|
85
70
|
const response = await this.api.textToSpeechTextFx({
|
|
86
71
|
input: { text },
|
|
87
72
|
voice: config?.voice ?? DEFAULT_VOICE,
|
|
@@ -3,8 +3,7 @@ import {
|
|
|
3
3
|
GetOptionsProps,
|
|
4
4
|
GetOptionsResult,
|
|
5
5
|
} from '../types/translation.types'
|
|
6
|
-
import { GetAlternativesResponse } from '../types/api.types'
|
|
7
|
-
import { ChatAnswer } from '../types/units.types'
|
|
6
|
+
import { ChatAnswer, GetAlternativesResponse } from '../types/api.types'
|
|
8
7
|
|
|
9
8
|
export function getOptionsForTranslation({
|
|
10
9
|
lastMessage,
|