@magmamath/students-features 0.3.2 → 0.4.0-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/chatbot/components/ChatControls/ChatControls.js +12 -4
- package/dist/commonjs/features/chatbot/components/ChatControls/ChatControls.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatMessage/ChatMessage.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatMessage/ReceivedMessage.js +6 -4
- package/dist/commonjs/features/chatbot/components/ChatMessage/ReceivedMessage.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.js +12 -1
- package/dist/commonjs/features/chatbot/components/ChatMessages/ChatbotMessages.js.map +1 -1
- package/dist/commonjs/features/chatbot/components/Chatbot.js +5 -1
- package/dist/commonjs/features/chatbot/components/Chatbot.js.map +1 -1
- package/dist/commonjs/features/chatbot/context/ChatBotContext.js +17 -0
- package/dist/commonjs/features/chatbot/context/ChatBotContext.js.map +1 -0
- package/dist/commonjs/features/chatbot/errorSpotting/ErrorSpottingButton.js +58 -0
- package/dist/commonjs/features/chatbot/errorSpotting/ErrorSpottingButton.js.map +1 -0
- package/dist/commonjs/features/chatbot/errorSpotting/ErrorSpottingModel.js +99 -0
- package/dist/commonjs/features/chatbot/errorSpotting/ErrorSpottingModel.js.map +1 -0
- package/dist/commonjs/features/chatbot/index.js +0 -7
- package/dist/commonjs/features/chatbot/index.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/ChatBotModel.js +136 -117
- package/dist/commonjs/features/chatbot/model/ChatBotModel.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/{ChatBotMessageHandler.js → ChatBotThreadManager.js} +28 -17
- package/dist/commonjs/features/chatbot/model/ChatBotThreadManager.js.map +1 -0
- package/dist/commonjs/features/chatbot/model/{api.js → ChatbotApi.js} +16 -1
- package/dist/commonjs/features/chatbot/model/ChatbotApi.js.map +1 -0
- package/dist/commonjs/features/chatbot/model/ChatsCacheModel.js +110 -0
- package/dist/commonjs/features/chatbot/model/ChatsCacheModel.js.map +1 -0
- package/dist/commonjs/features/chatbot/model/DefaultMessageCreator.js +0 -1
- package/dist/commonjs/features/chatbot/model/DefaultMessageCreator.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/ThreadItem.js +21 -8
- package/dist/commonjs/features/chatbot/model/ThreadItem.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/messagesHelper.js +1 -5
- package/dist/commonjs/features/chatbot/model/messagesHelper.js.map +1 -1
- package/dist/commonjs/features/chatbot/model/t2s.js +0 -6
- 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 +54 -45
- package/dist/commonjs/features/chatbot/model/translation.js.map +1 -1
- package/dist/commonjs/features/chatbot/types/api.types.js +4 -0
- package/dist/commonjs/features/chatbot/types/model.types.js.map +1 -1
- package/dist/commonjs/features/chatbot/types/units.types.js +2 -0
- package/dist/commonjs/features/chatbot/types/units.types.js.map +1 -0
- package/dist/commonjs/features/feedback/components/TeacherFeedbackButton/colorSchemes.js +18 -9
- package/dist/commonjs/features/feedback/components/TeacherFeedbackButton/colorSchemes.js.map +1 -1
- package/dist/commonjs/lib/effector/createEntityFieldStore.js +4 -0
- package/dist/commonjs/lib/effector/createEntityFieldStore.js.map +1 -1
- package/dist/commonjs/lib/helpers/randomElements.js +24 -0
- package/dist/commonjs/lib/helpers/randomElements.js.map +1 -0
- package/dist/commonjs/shared/icons/HighlighterIcon.js +36 -0
- package/dist/commonjs/shared/icons/HighlighterIcon.js.map +1 -0
- package/dist/commonjs/shared/icons/StopIcon.js +33 -0
- package/dist/commonjs/shared/icons/StopIcon.js.map +1 -0
- package/dist/commonjs/shared/icons/icon.types.js +4 -0
- package/dist/module/features/chatbot/components/ChatControls/ChatControls.js +12 -4
- package/dist/module/features/chatbot/components/ChatControls/ChatControls.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatMessage/ChatMessage.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatMessage/ReceivedMessage.js +6 -4
- package/dist/module/features/chatbot/components/ChatMessage/ReceivedMessage.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatMessages/ChatbotMessages.js +12 -1
- package/dist/module/features/chatbot/components/ChatMessages/ChatbotMessages.js.map +1 -1
- package/dist/module/features/chatbot/components/Chatbot.js +6 -2
- package/dist/module/features/chatbot/components/Chatbot.js.map +1 -1
- package/dist/module/features/chatbot/context/ChatBotContext.js +12 -0
- package/dist/module/features/chatbot/context/ChatBotContext.js.map +1 -0
- package/dist/module/features/chatbot/errorSpotting/ErrorSpottingButton.js +52 -0
- package/dist/module/features/chatbot/errorSpotting/ErrorSpottingButton.js.map +1 -0
- package/dist/module/features/chatbot/errorSpotting/ErrorSpottingModel.js +94 -0
- package/dist/module/features/chatbot/errorSpotting/ErrorSpottingModel.js.map +1 -0
- package/dist/module/features/chatbot/index.js +0 -1
- package/dist/module/features/chatbot/index.js.map +1 -1
- package/dist/module/features/chatbot/model/ChatBotModel.js +138 -119
- package/dist/module/features/chatbot/model/ChatBotModel.js.map +1 -1
- package/dist/module/features/chatbot/model/{ChatBotMessageHandler.js → ChatBotThreadManager.js} +26 -15
- package/dist/module/features/chatbot/model/ChatBotThreadManager.js.map +1 -0
- package/dist/module/features/chatbot/model/{api.js → ChatbotApi.js} +16 -1
- package/dist/module/features/chatbot/model/ChatbotApi.js.map +1 -0
- package/dist/module/features/chatbot/model/ChatsCacheModel.js +104 -0
- package/dist/module/features/chatbot/model/ChatsCacheModel.js.map +1 -0
- package/dist/module/features/chatbot/model/DefaultMessageCreator.js +0 -1
- package/dist/module/features/chatbot/model/DefaultMessageCreator.js.map +1 -1
- package/dist/module/features/chatbot/model/ThreadItem.js +21 -8
- package/dist/module/features/chatbot/model/ThreadItem.js.map +1 -1
- package/dist/module/features/chatbot/model/messagesHelper.js +1 -5
- package/dist/module/features/chatbot/model/messagesHelper.js.map +1 -1
- package/dist/module/features/chatbot/model/t2s.js +1 -7
- 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 +54 -45
- package/dist/module/features/chatbot/model/translation.js.map +1 -1
- package/dist/module/features/chatbot/types/api.types.js +2 -0
- package/dist/module/features/chatbot/types/model.types.js.map +1 -1
- package/dist/module/features/chatbot/types/units.types.js +2 -0
- package/dist/module/features/chatbot/types/units.types.js.map +1 -0
- package/dist/module/features/feedback/components/TeacherFeedbackButton/colorSchemes.js +18 -9
- package/dist/module/features/feedback/components/TeacherFeedbackButton/colorSchemes.js.map +1 -1
- package/dist/module/lib/effector/createEntityFieldStore.js +4 -0
- package/dist/module/lib/effector/createEntityFieldStore.js.map +1 -1
- package/dist/module/lib/helpers/randomElements.js +20 -0
- package/dist/module/lib/helpers/randomElements.js.map +1 -0
- package/dist/module/shared/icons/HighlighterIcon.js +29 -0
- package/dist/module/shared/icons/HighlighterIcon.js.map +1 -0
- package/dist/module/shared/icons/StopIcon.js +26 -0
- package/dist/module/shared/icons/StopIcon.js.map +1 -0
- package/dist/module/shared/icons/icon.types.js +2 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatControls/ChatControls.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/ChatMessage.d.ts +1 -0
- package/dist/typescript/commonjs/features/chatbot/components/ChatMessage/ChatMessage.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/ChatMessages/ChatbotMessages.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/Chatbot.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/context/ChatBotContext.d.ts +8 -0
- package/dist/typescript/commonjs/features/chatbot/context/ChatBotContext.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/errorSpotting/ErrorSpottingButton.d.ts +3 -0
- package/dist/typescript/commonjs/features/chatbot/errorSpotting/ErrorSpottingButton.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/errorSpotting/ErrorSpottingModel.d.ts +28 -0
- package/dist/typescript/commonjs/features/chatbot/errorSpotting/ErrorSpottingModel.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/index.d.ts +4 -3
- package/dist/typescript/commonjs/features/chatbot/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotModel.d.ts +19 -14
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotModel.d.ts.map +1 -1
- package/dist/typescript/{module/features/chatbot/model/ChatBotMessageHandler.d.ts → commonjs/features/chatbot/model/ChatBotThreadManager.d.ts} +11 -8
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotThreadManager.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/model/{api.d.ts → ChatbotApi.d.ts} +4 -3
- package/dist/typescript/commonjs/features/chatbot/model/ChatbotApi.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/model/ChatsCacheModel.d.ts +26 -0
- package/dist/typescript/commonjs/features/chatbot/model/ChatsCacheModel.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/chatbot/model/DefaultMessageCreator.d.ts +3 -2
- package/dist/typescript/commonjs/features/chatbot/model/DefaultMessageCreator.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/ThreadItem.d.ts +12 -6
- package/dist/typescript/commonjs/features/chatbot/model/ThreadItem.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/messagesHelper.d.ts +3 -4
- package/dist/typescript/commonjs/features/chatbot/model/messagesHelper.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/t2s.d.ts +2 -4
- package/dist/typescript/commonjs/features/chatbot/model/t2s.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/model/translation.d.ts +7 -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 +2 -1
- 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 +2 -11
- 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 +26 -19
- package/dist/typescript/commonjs/features/chatbot/types/model.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/types/translation.types.d.ts +2 -1
- package/dist/typescript/commonjs/features/chatbot/types/translation.types.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/types/units.types.d.ts +31 -0
- package/dist/typescript/commonjs/features/chatbot/types/units.types.d.ts.map +1 -0
- package/dist/typescript/commonjs/features/feedback/components/TeacherFeedbackButton/colorSchemes.d.ts.map +1 -1
- package/dist/typescript/commonjs/lib/effector/createEntityFieldStore.d.ts +2 -0
- package/dist/typescript/commonjs/lib/effector/createEntityFieldStore.d.ts.map +1 -1
- package/dist/typescript/commonjs/lib/helpers/randomElements.d.ts +2 -0
- package/dist/typescript/commonjs/lib/helpers/randomElements.d.ts.map +1 -0
- package/dist/typescript/commonjs/shared/icons/HighlighterIcon.d.ts +4 -0
- package/dist/typescript/commonjs/shared/icons/HighlighterIcon.d.ts.map +1 -0
- package/dist/typescript/commonjs/shared/icons/StopIcon.d.ts +4 -0
- package/dist/typescript/commonjs/shared/icons/StopIcon.d.ts.map +1 -0
- package/dist/typescript/commonjs/shared/icons/icon.types.d.ts +2 -0
- package/dist/typescript/commonjs/shared/icons/icon.types.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatControls/ChatControls.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatMessage/ChatMessage.d.ts +1 -0
- package/dist/typescript/module/features/chatbot/components/ChatMessage/ChatMessage.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/ChatMessages/ChatbotMessages.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/Chatbot.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/context/ChatBotContext.d.ts +8 -0
- package/dist/typescript/module/features/chatbot/context/ChatBotContext.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/errorSpotting/ErrorSpottingButton.d.ts +3 -0
- package/dist/typescript/module/features/chatbot/errorSpotting/ErrorSpottingButton.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/errorSpotting/ErrorSpottingModel.d.ts +28 -0
- package/dist/typescript/module/features/chatbot/errorSpotting/ErrorSpottingModel.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/index.d.ts +4 -3
- package/dist/typescript/module/features/chatbot/index.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/ChatBotModel.d.ts +19 -14
- package/dist/typescript/module/features/chatbot/model/ChatBotModel.d.ts.map +1 -1
- package/dist/typescript/{commonjs/features/chatbot/model/ChatBotMessageHandler.d.ts → module/features/chatbot/model/ChatBotThreadManager.d.ts} +11 -8
- package/dist/typescript/module/features/chatbot/model/ChatBotThreadManager.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/model/{api.d.ts → ChatbotApi.d.ts} +4 -3
- package/dist/typescript/module/features/chatbot/model/ChatbotApi.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/model/ChatsCacheModel.d.ts +26 -0
- package/dist/typescript/module/features/chatbot/model/ChatsCacheModel.d.ts.map +1 -0
- package/dist/typescript/module/features/chatbot/model/DefaultMessageCreator.d.ts +3 -2
- package/dist/typescript/module/features/chatbot/model/DefaultMessageCreator.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/ThreadItem.d.ts +12 -6
- package/dist/typescript/module/features/chatbot/model/ThreadItem.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/messagesHelper.d.ts +3 -4
- package/dist/typescript/module/features/chatbot/model/messagesHelper.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/t2s.d.ts +2 -4
- package/dist/typescript/module/features/chatbot/model/t2s.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/model/translation.d.ts +7 -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 +2 -1
- 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 +2 -11
- 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 +26 -19
- package/dist/typescript/module/features/chatbot/types/model.types.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/types/translation.types.d.ts +2 -1
- package/dist/typescript/module/features/chatbot/types/translation.types.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/types/units.types.d.ts +31 -0
- package/dist/typescript/module/features/chatbot/types/units.types.d.ts.map +1 -0
- package/dist/typescript/module/features/feedback/components/TeacherFeedbackButton/colorSchemes.d.ts.map +1 -1
- package/dist/typescript/module/lib/effector/createEntityFieldStore.d.ts +2 -0
- package/dist/typescript/module/lib/effector/createEntityFieldStore.d.ts.map +1 -1
- package/dist/typescript/module/lib/helpers/randomElements.d.ts +2 -0
- package/dist/typescript/module/lib/helpers/randomElements.d.ts.map +1 -0
- package/dist/typescript/module/shared/icons/HighlighterIcon.d.ts +4 -0
- package/dist/typescript/module/shared/icons/HighlighterIcon.d.ts.map +1 -0
- package/dist/typescript/module/shared/icons/StopIcon.d.ts +4 -0
- package/dist/typescript/module/shared/icons/StopIcon.d.ts.map +1 -0
- package/dist/typescript/module/shared/icons/icon.types.d.ts +2 -0
- package/dist/typescript/module/shared/icons/icon.types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/features/chatbot/components/ChatControls/ChatControls.tsx +10 -3
- package/src/features/chatbot/components/ChatMessage/ChatMessage.tsx +1 -0
- package/src/features/chatbot/components/ChatMessage/ReceivedMessage.tsx +3 -0
- package/src/features/chatbot/components/ChatMessages/ChatbotMessages.tsx +14 -0
- package/src/features/chatbot/components/Chatbot.tsx +3 -2
- package/src/features/chatbot/context/ChatBotContext.ts +18 -0
- package/src/features/chatbot/errorSpotting/ErrorSpottingButton.tsx +53 -0
- package/src/features/chatbot/errorSpotting/ErrorSpottingModel.ts +116 -0
- package/src/features/chatbot/index.ts +3 -3
- package/src/features/chatbot/model/ChatBotModel.ts +123 -124
- package/src/features/chatbot/model/{ChatBotMessageHandler.ts → ChatBotThreadManager.ts} +28 -16
- package/src/features/chatbot/model/{api.ts → ChatbotApi.ts} +19 -2
- package/src/features/chatbot/model/ChatsCacheModel.ts +94 -0
- package/src/features/chatbot/model/DefaultMessageCreator.ts +3 -3
- package/src/features/chatbot/model/ThreadItem.ts +20 -9
- package/src/features/chatbot/model/messagesHelper.ts +2 -6
- package/src/features/chatbot/model/t2s.ts +3 -10
- package/src/features/chatbot/model/translation.helpers.ts +2 -1
- package/src/features/chatbot/model/translation.ts +52 -46
- package/src/features/chatbot/types/api.types.ts +2 -12
- package/src/features/chatbot/types/model.types.ts +38 -26
- package/src/features/chatbot/types/translation.types.ts +2 -1
- package/src/features/chatbot/types/units.types.ts +34 -0
- package/src/features/feedback/components/TeacherFeedbackButton/colorSchemes.ts +9 -0
- package/src/lib/effector/createEntityFieldStore.ts +9 -1
- package/src/lib/helpers/randomElements.ts +22 -0
- package/src/shared/icons/HighlighterIcon.tsx +21 -0
- package/src/shared/icons/StopIcon.tsx +17 -0
- package/src/shared/icons/icon.types.ts +9 -6
- package/dist/commonjs/features/chatbot/model/ChatBotMessageHandler.js.map +0 -1
- package/dist/commonjs/features/chatbot/model/api.js.map +0 -1
- package/dist/module/features/chatbot/model/ChatBotMessageHandler.js.map +0 -1
- package/dist/module/features/chatbot/model/api.js.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/model/ChatBotMessageHandler.d.ts.map +0 -1
- package/dist/typescript/commonjs/features/chatbot/model/api.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/model/ChatBotMessageHandler.d.ts.map +0 -1
- package/dist/typescript/module/features/chatbot/model/api.d.ts.map +0 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { createEvent } from 'effector'
|
|
2
|
+
import { createEntityFieldStore } from '../../../lib/effector'
|
|
3
|
+
import { ChatAnswer, ChatItem, ConversationMessage, IThreadItem } from '../types/units.types'
|
|
4
|
+
|
|
5
|
+
type ReinitChatThreadSettings = {
|
|
6
|
+
initialOption: ChatAnswer
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type UpdateProps = {
|
|
10
|
+
key: string
|
|
11
|
+
data: Partial<ChatItem>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type AddMessagesProps = {
|
|
15
|
+
messages: ConversationMessage[]
|
|
16
|
+
thread?: IThreadItem | null
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function defaultChatData(props: Partial<ChatItem> = {}): ChatItem {
|
|
20
|
+
return {
|
|
21
|
+
messages: [],
|
|
22
|
+
isAvailable: false,
|
|
23
|
+
currentThread: null,
|
|
24
|
+
...props,
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export class ChatsCacheModel {
|
|
29
|
+
public readonly update = createEvent<UpdateProps>()
|
|
30
|
+
private readonly cache = createEntityFieldStore<ChatItem>().on(
|
|
31
|
+
this.update,
|
|
32
|
+
(state, { key, data }) => {
|
|
33
|
+
const currentData = state[key] ?? defaultChatData()
|
|
34
|
+
return { ...state, [key]: { ...currentData, ...data } }
|
|
35
|
+
},
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
public readonly $data = this.cache.$state
|
|
39
|
+
public readonly reset = this.cache.reset
|
|
40
|
+
|
|
41
|
+
public disableChat(key: string) {
|
|
42
|
+
this.cache.setField({
|
|
43
|
+
key,
|
|
44
|
+
fn: (current) =>
|
|
45
|
+
current ? { ...current, isAvailable: false } : defaultChatData({ isAvailable: false }),
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public reinitChatThread(key: string, { initialOption }: ReinitChatThreadSettings) {
|
|
50
|
+
this.cache.setField({
|
|
51
|
+
key,
|
|
52
|
+
fn: (current) => {
|
|
53
|
+
if (!current || current.messages.length <= 1) return
|
|
54
|
+
const copy = [...current.messages]
|
|
55
|
+
while (copy.at(-1)?.endMessage) {
|
|
56
|
+
copy.pop()
|
|
57
|
+
}
|
|
58
|
+
const lastMessage = copy.at(-1)
|
|
59
|
+
if (!lastMessage) return
|
|
60
|
+
copy.splice(copy.length - 1, 1, {
|
|
61
|
+
...lastMessage,
|
|
62
|
+
options: [initialOption],
|
|
63
|
+
})
|
|
64
|
+
return { ...current, messages: copy }
|
|
65
|
+
},
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public setSingleMessage(key: string, message: ConversationMessage) {
|
|
70
|
+
this.cache.setField({
|
|
71
|
+
key,
|
|
72
|
+
fn: (current) => {
|
|
73
|
+
if (!current || current.messages.length > 1) return
|
|
74
|
+
return { ...current, messages: [message] }
|
|
75
|
+
},
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public addMessages(key: string, { messages, thread = null }: AddMessagesProps) {
|
|
80
|
+
this.cache.setField({
|
|
81
|
+
key,
|
|
82
|
+
fn: (current) => {
|
|
83
|
+
if (!current) return defaultChatData({ messages, currentThread: thread })
|
|
84
|
+
const result = { ...current, messages: [...current.messages, ...messages] }
|
|
85
|
+
if (thread) result.currentThread = thread
|
|
86
|
+
return result
|
|
87
|
+
},
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public add(key: string, data: ChatItem) {
|
|
92
|
+
this.cache.setField({ key, data })
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PostMessageResponse } from '../types/api.types'
|
|
2
2
|
import { createEvent } from 'effector'
|
|
3
|
+
import { ChatAnswer } from '../types/units.types'
|
|
3
4
|
|
|
4
|
-
type ChatMessage = PostMessageResponse & {
|
|
5
|
+
type ChatMessage = Omit<PostMessageResponse, 'thread'> & {
|
|
5
6
|
id: string
|
|
6
7
|
isOwnMessage: boolean
|
|
7
8
|
}
|
|
@@ -38,7 +39,6 @@ export class DefaultMessagesCreator<K extends string> {
|
|
|
38
39
|
const message: ChatMessage = {
|
|
39
40
|
id: this.list.size.toString(),
|
|
40
41
|
message: this.getter(key),
|
|
41
|
-
threadId: '',
|
|
42
42
|
options: [],
|
|
43
43
|
isOwnMessage: isOwn,
|
|
44
44
|
}
|
|
@@ -1,28 +1,39 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FullStrokeData, IThreadItem } from '../types/units.types'
|
|
2
2
|
|
|
3
3
|
type ThreadItemProps = {
|
|
4
|
-
strokes
|
|
4
|
+
strokes: FullStrokeData[]
|
|
5
|
+
key: string
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
export class ThreadItem {
|
|
8
|
-
public readonly
|
|
9
|
-
public readonly
|
|
9
|
+
public readonly key: string | null = null
|
|
10
|
+
public readonly strokes: FullStrokeData[] | null
|
|
11
|
+
public readonly history: string[] = []
|
|
10
12
|
|
|
11
|
-
public constructor(
|
|
12
|
-
this.strokes = strokes ?? null
|
|
13
|
+
public constructor(props?: ThreadItemProps | null) {
|
|
14
|
+
this.strokes = props?.strokes ?? null
|
|
15
|
+
this.key = props?.key ?? null
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
public getNextHintProps() {
|
|
16
|
-
if (this.
|
|
19
|
+
if (this.history.length) {
|
|
17
20
|
return {
|
|
18
|
-
previousHint: this.
|
|
21
|
+
previousHint: this.history[this.history.length - 1],
|
|
19
22
|
}
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
if (this.strokes) {
|
|
23
|
-
return { stroke: this.strokes }
|
|
26
|
+
return { stroke: this.strokes.map(({ x, y }) => ({ x, y })) }
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
return {}
|
|
27
30
|
}
|
|
31
|
+
|
|
32
|
+
public toObject(): IThreadItem {
|
|
33
|
+
return {
|
|
34
|
+
key: this.key,
|
|
35
|
+
strokes: this.strokes,
|
|
36
|
+
history: [...this.history],
|
|
37
|
+
}
|
|
38
|
+
}
|
|
28
39
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { generateRandomId } from '../../../lib/helpers/helpers'
|
|
2
|
-
import {
|
|
2
|
+
import { CreateMessageResponse } from '../types/model.types'
|
|
3
|
+
import { ConversationMessage } from '../types/units.types'
|
|
3
4
|
|
|
4
5
|
type OwnMessageProps = {
|
|
5
6
|
message?: string
|
|
6
7
|
translatedMessage?: string
|
|
7
|
-
threadId?: string | null
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export class messagesHelper {
|
|
@@ -13,7 +13,6 @@ export class messagesHelper {
|
|
|
13
13
|
id: generateRandomId(),
|
|
14
14
|
isOwnMessage: false,
|
|
15
15
|
message: data.message,
|
|
16
|
-
threadId: data.threadId,
|
|
17
16
|
options: data.options,
|
|
18
17
|
translatedMessage: data.translatedMessage,
|
|
19
18
|
}
|
|
@@ -26,7 +25,6 @@ export class messagesHelper {
|
|
|
26
25
|
translatedMessage: data.translatedMessage,
|
|
27
26
|
isOwnMessage: false,
|
|
28
27
|
options: [],
|
|
29
|
-
threadId: '',
|
|
30
28
|
endMessage: true,
|
|
31
29
|
}
|
|
32
30
|
}
|
|
@@ -34,13 +32,11 @@ export class messagesHelper {
|
|
|
34
32
|
public static createOwn({
|
|
35
33
|
message = '',
|
|
36
34
|
translatedMessage,
|
|
37
|
-
threadId,
|
|
38
35
|
}: OwnMessageProps): ConversationMessage {
|
|
39
36
|
return {
|
|
40
37
|
id: generateRandomId(),
|
|
41
38
|
message,
|
|
42
39
|
translatedMessage,
|
|
43
|
-
threadId: threadId || '',
|
|
44
40
|
isOwnMessage: true,
|
|
45
41
|
options: [],
|
|
46
42
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { restore, createEvent,
|
|
1
|
+
import { restore, createEvent, 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 './ChatbotApi'
|
|
5
5
|
|
|
6
6
|
type ChatTextToSpeechModelProps = {
|
|
7
|
-
$isOpen: Store<boolean>
|
|
8
7
|
api: ChatbotAPI
|
|
9
8
|
}
|
|
10
9
|
|
|
@@ -18,14 +17,8 @@ export class ChatTextToSpeechModel {
|
|
|
18
17
|
readonly setStatus = createEvent<AudioStatus>()
|
|
19
18
|
readonly $status = restore(this.setStatus, AudioStatus.STOPPED)
|
|
20
19
|
|
|
21
|
-
constructor({
|
|
20
|
+
constructor({ api }: ChatTextToSpeechModelProps) {
|
|
22
21
|
this.api = api
|
|
23
|
-
|
|
24
|
-
sample({
|
|
25
|
-
source: $isOpen.updates,
|
|
26
|
-
filter: isOpen => !isOpen,
|
|
27
|
-
target: this.reset,
|
|
28
|
-
})
|
|
29
22
|
}
|
|
30
23
|
|
|
31
24
|
public setAudioProvider(audioProvider: AudioProvider) {
|
|
@@ -3,7 +3,8 @@ import {
|
|
|
3
3
|
GetOptionsProps,
|
|
4
4
|
GetOptionsResult,
|
|
5
5
|
} from '../types/translation.types'
|
|
6
|
-
import {
|
|
6
|
+
import { GetAlternativesResponse } from '../types/api.types'
|
|
7
|
+
import { ChatAnswer } from '../types/units.types'
|
|
7
8
|
|
|
8
9
|
export function getOptionsForTranslation({
|
|
9
10
|
lastMessage,
|
|
@@ -5,27 +5,29 @@ import {
|
|
|
5
5
|
TranslateMessageFxProps,
|
|
6
6
|
TranslateRequestProps,
|
|
7
7
|
} from '../types/translation.types'
|
|
8
|
-
import { ChatbotContext, ChatbotMessages
|
|
8
|
+
import { ChatbotContext, ChatbotMessages } from '../types/model.types'
|
|
9
9
|
import { GetAlternativesResponse } from '../types/api.types'
|
|
10
10
|
import { decodeHTMLEntities } from '../helpers'
|
|
11
|
-
import { ChatbotAPI } from './
|
|
12
|
-
import { EntityFieldStore } from '../../../lib/effector/createEntityFieldStore'
|
|
11
|
+
import { ChatbotAPI } from './ChatbotApi'
|
|
13
12
|
import {
|
|
14
13
|
addTranslationsToAlternative,
|
|
15
14
|
addTranslationToOptions,
|
|
16
15
|
getOptionsForTranslation,
|
|
17
16
|
} from './translation.helpers'
|
|
18
17
|
|
|
18
|
+
import { ChatsCacheModel } from './ChatsCacheModel'
|
|
19
|
+
import { ConversationMessage } from '../types/units.types'
|
|
20
|
+
|
|
19
21
|
type ChatbotTranslationProps = {
|
|
20
22
|
api: ChatbotAPI
|
|
21
23
|
$key: Store<string>
|
|
22
24
|
defaultMessages: ChatbotMessages
|
|
23
|
-
messagesModel: EntityFieldStore<ConversationMessage[]>
|
|
24
25
|
$context: Store<ChatbotContext | null>
|
|
25
26
|
alternativesModel: {
|
|
26
27
|
set: EventCallable<GetAlternativesResponse | null>
|
|
27
28
|
$store: Store<GetAlternativesResponse | null>
|
|
28
29
|
}
|
|
30
|
+
chats: ChatsCacheModel
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
export class ChatbotTranslation {
|
|
@@ -33,7 +35,6 @@ export class ChatbotTranslation {
|
|
|
33
35
|
private readonly $key
|
|
34
36
|
private readonly $context
|
|
35
37
|
private readonly defaultMessages
|
|
36
|
-
private readonly messagesModel
|
|
37
38
|
private readonly alternativesModel
|
|
38
39
|
|
|
39
40
|
readonly setIsTranslated = createEvent<boolean>()
|
|
@@ -45,27 +46,32 @@ export class ChatbotTranslation {
|
|
|
45
46
|
api,
|
|
46
47
|
$key,
|
|
47
48
|
defaultMessages,
|
|
48
|
-
messagesModel,
|
|
49
49
|
alternativesModel,
|
|
50
50
|
$context,
|
|
51
|
+
chats,
|
|
51
52
|
}: ChatbotTranslationProps) {
|
|
52
53
|
this.api = api
|
|
53
54
|
this.$key = $key
|
|
54
55
|
this.$context = $context
|
|
55
56
|
this.defaultMessages = defaultMessages
|
|
56
|
-
this.messagesModel = messagesModel
|
|
57
57
|
this.alternativesModel = alternativesModel
|
|
58
58
|
|
|
59
59
|
this.translateAllMessagesFx = attach({
|
|
60
|
-
source: [this.$key,
|
|
61
|
-
mapParams: (_: void, [key,
|
|
60
|
+
source: [this.$key, chats.$data, this.alternativesModel.$store, this.$context],
|
|
61
|
+
mapParams: (_: void, [key, chats, alternatives, context]) => ({
|
|
62
62
|
targetLanguage: context?.translationTargetLanguage ?? '',
|
|
63
|
-
messages:
|
|
63
|
+
messages: chats[key]?.messages ?? [],
|
|
64
64
|
alternatives,
|
|
65
65
|
}),
|
|
66
66
|
effect: this.translateBatchFx,
|
|
67
67
|
})
|
|
68
|
-
|
|
68
|
+
|
|
69
|
+
sample({
|
|
70
|
+
clock: this.translateAllMessagesFx.doneData,
|
|
71
|
+
source: [this.$key] as const,
|
|
72
|
+
fn: ([key], translatedMessages) => ({ key, data: { messages: translatedMessages } }),
|
|
73
|
+
target: chats.update,
|
|
74
|
+
})
|
|
69
75
|
}
|
|
70
76
|
|
|
71
77
|
private shouldSkipTranslation(messages: ConversationMessage[]) {
|
|
@@ -83,15 +89,6 @@ export class ChatbotTranslation {
|
|
|
83
89
|
return false
|
|
84
90
|
}
|
|
85
91
|
|
|
86
|
-
private initTranslationSamples() {
|
|
87
|
-
sample({
|
|
88
|
-
clock: this.translateAllMessagesFx.doneData,
|
|
89
|
-
source: [this.$key] as const,
|
|
90
|
-
fn: ([key], translatedMessages) => ({ key, data: translatedMessages }),
|
|
91
|
-
target: this.messagesModel.setField,
|
|
92
|
-
})
|
|
93
|
-
}
|
|
94
|
-
|
|
95
92
|
private async translateRequest<List extends Record<string, string[]>>({
|
|
96
93
|
textList,
|
|
97
94
|
targetLanguage,
|
|
@@ -167,33 +164,42 @@ export class ChatbotTranslation {
|
|
|
167
164
|
},
|
|
168
165
|
)
|
|
169
166
|
|
|
170
|
-
public readonly
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
167
|
+
public readonly applyTranslationFx = attach({
|
|
168
|
+
source: { isTranslated: this.$isTranslated },
|
|
169
|
+
mapParams: (props: Omit<TranslateMessageFxProps, 'isTranslated'>, source) => ({
|
|
170
|
+
...props,
|
|
171
|
+
...source,
|
|
172
|
+
}),
|
|
173
|
+
effect: createEffect(
|
|
174
|
+
async ({
|
|
175
|
+
messages,
|
|
176
|
+
targetLanguage,
|
|
177
|
+
preventTranslate,
|
|
178
|
+
}: TranslateMessageFxProps): Promise<ConversationMessage[]> => {
|
|
179
|
+
if (!preventTranslate) return messages
|
|
180
|
+
const text = messages
|
|
181
|
+
.map(({ options, message }) => {
|
|
182
|
+
return [message, ...options.map(({ text }) => text)]
|
|
183
|
+
})
|
|
184
|
+
.flat()
|
|
185
|
+
|
|
186
|
+
const response = await this.api.translateTextFx({ text, targetLanguage })
|
|
187
|
+
const translatedTexts = response.data.translations.map(({ translatedText }) =>
|
|
188
|
+
decodeHTMLEntities(translatedText),
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
return messages.map((message): ConversationMessage => {
|
|
192
|
+
const options = message.options
|
|
193
|
+
const translatedMessage = translatedTexts.shift()
|
|
194
|
+
return {
|
|
195
|
+
...message,
|
|
196
|
+
translatedMessage,
|
|
197
|
+
options: addTranslationToOptions(options, translatedTexts.splice(0, options.length)),
|
|
198
|
+
}
|
|
178
199
|
})
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
const translatedTexts = response.data.translations.map(({ translatedText }) =>
|
|
183
|
-
decodeHTMLEntities(translatedText),
|
|
184
|
-
)
|
|
185
|
-
|
|
186
|
-
return messages.map((message): ConversationMessage => {
|
|
187
|
-
const options = message.options
|
|
188
|
-
const translatedMessage = translatedTexts.shift()
|
|
189
|
-
return {
|
|
190
|
-
...message,
|
|
191
|
-
translatedMessage,
|
|
192
|
-
options: addTranslationToOptions(options, translatedTexts.splice(0, options.length)),
|
|
193
|
-
}
|
|
194
|
-
})
|
|
195
|
-
},
|
|
196
|
-
)
|
|
200
|
+
},
|
|
201
|
+
),
|
|
202
|
+
})
|
|
197
203
|
|
|
198
204
|
public reset() {
|
|
199
205
|
this.setIsTranslated(false)
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
text: string
|
|
3
|
-
promptKey: string
|
|
4
|
-
translatedText?: string
|
|
5
|
-
}
|
|
1
|
+
import { ChatAnswer, IThreadItem, Stroke } from './units.types'
|
|
6
2
|
|
|
7
3
|
export type GetAlternativesPayload = {
|
|
8
4
|
municipalityId: string
|
|
@@ -21,16 +17,15 @@ export type PostMessagePayload = {
|
|
|
21
17
|
language: string
|
|
22
18
|
problemAnswer: string[]
|
|
23
19
|
answer?: string | string[]
|
|
24
|
-
threadId?: string | null
|
|
25
20
|
problem: string
|
|
26
21
|
imageAltText?: string
|
|
27
22
|
}
|
|
28
23
|
|
|
29
24
|
export type PostMessageResponse = {
|
|
30
25
|
message: string
|
|
31
|
-
threadId: string
|
|
32
26
|
options: ChatAnswer[]
|
|
33
27
|
endMessage?: boolean
|
|
28
|
+
thread: IThreadItem
|
|
34
29
|
}
|
|
35
30
|
|
|
36
31
|
export type GoogleTranslatePayload = {
|
|
@@ -61,11 +56,6 @@ export type GoogleText2SpeechPayload = {
|
|
|
61
56
|
|
|
62
57
|
export type GoogleText2SpeechResponse = string | undefined | { audioContent?: string }
|
|
63
58
|
|
|
64
|
-
export type Stroke = {
|
|
65
|
-
x: number[]
|
|
66
|
-
y: number[]
|
|
67
|
-
}
|
|
68
|
-
|
|
69
59
|
export type ChatHintPayload = {
|
|
70
60
|
problemDescription: string
|
|
71
61
|
correctAnswer: string[]
|
|
@@ -1,27 +1,18 @@
|
|
|
1
1
|
import type { Store } from 'effector'
|
|
2
2
|
import {
|
|
3
|
+
ChatHintPayload,
|
|
4
|
+
ChatHintResponse,
|
|
5
|
+
GetAlternativesPayload,
|
|
3
6
|
GetAlternativesResponse,
|
|
4
|
-
PostMessagePayload,
|
|
5
|
-
PostMessageResponse,
|
|
6
|
-
GoogleTranslatePayload,
|
|
7
|
-
GoogleTranslateResponse,
|
|
8
7
|
GoogleText2SpeechPayload,
|
|
9
8
|
GoogleText2SpeechResponse,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
GoogleTranslatePayload,
|
|
10
|
+
GoogleTranslateResponse,
|
|
11
|
+
PostMessagePayload,
|
|
12
|
+
PostMessageResponse,
|
|
13
13
|
} from './api.types'
|
|
14
14
|
import { ExtendWithOptional } from '../../../lib/helpers/types'
|
|
15
|
-
|
|
16
|
-
export type ConversationMessage = {
|
|
17
|
-
id: string
|
|
18
|
-
message: string
|
|
19
|
-
threadId: string
|
|
20
|
-
options: ChatAnswer[]
|
|
21
|
-
isOwnMessage: boolean
|
|
22
|
-
translatedMessage?: string
|
|
23
|
-
endMessage?: boolean
|
|
24
|
-
}
|
|
15
|
+
import { ChatAnswer, ConversationMessage, FullStrokeData } from './units.types'
|
|
25
16
|
|
|
26
17
|
export type ChatbotMessages = {
|
|
27
18
|
error: ConversationMessage
|
|
@@ -30,15 +21,29 @@ export type ChatbotMessages = {
|
|
|
30
21
|
anotherHintOption: ChatAnswer
|
|
31
22
|
}
|
|
32
23
|
|
|
24
|
+
export type SpotErrorPayload = {
|
|
25
|
+
strokes: FullStrokeData[]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type SpotErrorResponse = {
|
|
29
|
+
strokesIds: string[]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type ChatbotApiRequests = {
|
|
33
|
+
getAlternatives: (props: GetAlternativesPayload) => Promise<GetAlternativesResponse>
|
|
34
|
+
postMessage: (props: PostMessagePayload) => Promise<PostMessageResponse>
|
|
35
|
+
postTranslateText: (props: GoogleTranslatePayload) => Promise<GoogleTranslateResponse>
|
|
36
|
+
postTextToSpeech: (props: GoogleText2SpeechPayload) => Promise<GoogleText2SpeechResponse>
|
|
37
|
+
spotError: (props: SpotErrorPayload) => Promise<SpotErrorResponse>
|
|
38
|
+
}
|
|
39
|
+
|
|
33
40
|
export type ChatbotModelProps = {
|
|
34
41
|
$key?: Store<string>
|
|
35
|
-
api: {
|
|
36
|
-
|
|
37
|
-
postMessage: (props: PostMessagePayload) => Promise<PostMessageResponse>
|
|
38
|
-
postTranslateText: (props: GoogleTranslatePayload) => Promise<GoogleTranslateResponse>
|
|
39
|
-
postTextToSpeech: (props: GoogleText2SpeechPayload) => Promise<GoogleText2SpeechResponse>
|
|
42
|
+
api: Omit<ChatbotApiRequests, 'postMessage'> & {
|
|
43
|
+
requestHint: (props: ChatHintPayload) => Promise<ChatHintResponse>
|
|
40
44
|
}
|
|
41
45
|
messages: ChatbotMessages
|
|
46
|
+
threadMessagesLimit?: number
|
|
42
47
|
}
|
|
43
48
|
|
|
44
49
|
export type SendHelpParams = {
|
|
@@ -48,8 +53,6 @@ export type SendHelpParams = {
|
|
|
48
53
|
|
|
49
54
|
export type SendHelpProps = SendHelpParams & {
|
|
50
55
|
key: string
|
|
51
|
-
isTranslated: boolean
|
|
52
|
-
threadId: string
|
|
53
56
|
context: ChatbotContext | null
|
|
54
57
|
}
|
|
55
58
|
|
|
@@ -77,10 +80,19 @@ export type ChatbotRenderer = {
|
|
|
77
80
|
withTextToSpeech: boolean
|
|
78
81
|
}
|
|
79
82
|
|
|
80
|
-
export type CreateMessageResponse = ExtendWithOptional<
|
|
83
|
+
export type CreateMessageResponse = ExtendWithOptional<
|
|
84
|
+
Omit<PostMessageResponse, 'thread'>,
|
|
85
|
+
ConversationMessage
|
|
86
|
+
>
|
|
87
|
+
|
|
88
|
+
type GetVisibleStrokesResponse = {
|
|
89
|
+
strokes: FullStrokeData[]
|
|
90
|
+
validationKey: string
|
|
91
|
+
}
|
|
81
92
|
|
|
82
93
|
export type IChatDrawBoardAdapter = {
|
|
83
|
-
|
|
94
|
+
$strokesValidationKey: Store<string | null>
|
|
95
|
+
getVisibleStrokes(): Promise<GetVisibleStrokesResponse | null>
|
|
84
96
|
}
|
|
85
97
|
|
|
86
98
|
export type ChatbotContext = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ConversationMessage } from './model.types'
|
|
2
1
|
import { GetAlternativesResponse } from './api.types'
|
|
2
|
+
import { ConversationMessage } from './units.types'
|
|
3
3
|
|
|
4
4
|
export type TranslateBatchFxProps = {
|
|
5
5
|
messages: ConversationMessage[]
|
|
@@ -8,6 +8,7 @@ export type TranslateBatchFxProps = {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export type TranslateMessageFxProps = {
|
|
11
|
+
preventTranslate?: boolean
|
|
11
12
|
messages: ConversationMessage[]
|
|
12
13
|
targetLanguage: string
|
|
13
14
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type Stroke = {
|
|
2
|
+
x: number[]
|
|
3
|
+
y: number[]
|
|
4
|
+
}
|
|
5
|
+
export type FullStrokeData = Stroke & {
|
|
6
|
+
id?: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type IThreadItem = {
|
|
10
|
+
key: string | null
|
|
11
|
+
strokes: FullStrokeData[] | null
|
|
12
|
+
history: string[]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type ChatAnswer = {
|
|
16
|
+
text: string
|
|
17
|
+
promptKey: string
|
|
18
|
+
translatedText?: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type ConversationMessage = {
|
|
22
|
+
id: string
|
|
23
|
+
message: string
|
|
24
|
+
options: ChatAnswer[]
|
|
25
|
+
isOwnMessage: boolean
|
|
26
|
+
translatedMessage?: string
|
|
27
|
+
endMessage?: boolean
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type ChatItem = {
|
|
31
|
+
messages: ConversationMessage[]
|
|
32
|
+
isAvailable: boolean
|
|
33
|
+
currentThread: IThreadItem | null
|
|
34
|
+
}
|
|
@@ -6,16 +6,19 @@ export const COLOR_SCHEMES: Record<string, Partial<Record<ButtonStates, ButtonEl
|
|
|
6
6
|
borderColor: COLORS.PURPLE_6,
|
|
7
7
|
raiseColor: COLORS.PURPLE_6,
|
|
8
8
|
backgroundColor: COLORS.PRIMARY_PURPLE,
|
|
9
|
+
color: COLORS.NEUTRAL_1,
|
|
9
10
|
},
|
|
10
11
|
[ButtonStates.PRESSED]: {
|
|
11
12
|
borderColor: COLORS.PURPLE_6,
|
|
12
13
|
raiseColor: COLORS.PURPLE_6,
|
|
13
14
|
backgroundColor: COLORS.PRIMARY_PURPLE,
|
|
15
|
+
color: COLORS.NEUTRAL_1,
|
|
14
16
|
},
|
|
15
17
|
[ButtonStates.HOVER]: {
|
|
16
18
|
borderColor: COLORS.PURPLE_6,
|
|
17
19
|
raiseColor: COLORS.PURPLE_6,
|
|
18
20
|
backgroundColor: COLORS.PRIMARY_PURPLE,
|
|
21
|
+
color: COLORS.NEUTRAL_1,
|
|
19
22
|
},
|
|
20
23
|
},
|
|
21
24
|
BLUE: {
|
|
@@ -23,16 +26,19 @@ export const COLOR_SCHEMES: Record<string, Partial<Record<ButtonStates, ButtonEl
|
|
|
23
26
|
borderColor: COLORS.BLUE_6,
|
|
24
27
|
raiseColor: COLORS.BLUE_6,
|
|
25
28
|
backgroundColor: COLORS.PRIMARY_BLUE,
|
|
29
|
+
color: COLORS.NEUTRAL_1,
|
|
26
30
|
},
|
|
27
31
|
[ButtonStates.PRESSED]: {
|
|
28
32
|
borderColor: COLORS.BLUE_6,
|
|
29
33
|
raiseColor: COLORS.BLUE_6,
|
|
30
34
|
backgroundColor: COLORS.PRIMARY_BLUE,
|
|
35
|
+
color: COLORS.NEUTRAL_1,
|
|
31
36
|
},
|
|
32
37
|
[ButtonStates.HOVER]: {
|
|
33
38
|
borderColor: COLORS.BLUE_6,
|
|
34
39
|
raiseColor: COLORS.BLUE_6,
|
|
35
40
|
backgroundColor: COLORS.PRIMARY_BLUE,
|
|
41
|
+
color: COLORS.NEUTRAL_1,
|
|
36
42
|
},
|
|
37
43
|
},
|
|
38
44
|
GREY: {
|
|
@@ -40,16 +46,19 @@ export const COLOR_SCHEMES: Record<string, Partial<Record<ButtonStates, ButtonEl
|
|
|
40
46
|
borderColor: COLORS.NEUTRAL_5,
|
|
41
47
|
raiseColor: COLORS.NEUTRAL_5,
|
|
42
48
|
backgroundColor: COLORS.NEUTRAL_1,
|
|
49
|
+
color: COLORS.NEUTRAL_10,
|
|
43
50
|
},
|
|
44
51
|
[ButtonStates.PRESSED]: {
|
|
45
52
|
borderColor: COLORS.NEUTRAL_5,
|
|
46
53
|
raiseColor: COLORS.NEUTRAL_5,
|
|
47
54
|
backgroundColor: COLORS.NEUTRAL_1,
|
|
55
|
+
color: COLORS.NEUTRAL_10,
|
|
48
56
|
},
|
|
49
57
|
[ButtonStates.HOVER]: {
|
|
50
58
|
borderColor: COLORS.NEUTRAL_5,
|
|
51
59
|
raiseColor: COLORS.NEUTRAL_5,
|
|
52
60
|
backgroundColor: COLORS.NEUTRAL_1,
|
|
61
|
+
color: COLORS.NEUTRAL_10,
|
|
53
62
|
},
|
|
54
63
|
},
|
|
55
64
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createEvent, createStore } from 'effector'
|
|
1
|
+
import { createEvent, createStore, Event } from 'effector'
|
|
2
2
|
|
|
3
3
|
type UpdateField<T> = {
|
|
4
4
|
key: string
|
|
@@ -19,6 +19,14 @@ export class EntityFieldStore<T> {
|
|
|
19
19
|
return { ...state, [key]: data }
|
|
20
20
|
})
|
|
21
21
|
.reset(this.reset)
|
|
22
|
+
|
|
23
|
+
public on<EV>(
|
|
24
|
+
event: Event<EV>,
|
|
25
|
+
fn: (state: Record<string, T>, payload: EV) => Record<string, T> | void,
|
|
26
|
+
) {
|
|
27
|
+
this.$state.on(event, fn)
|
|
28
|
+
return this
|
|
29
|
+
}
|
|
22
30
|
}
|
|
23
31
|
|
|
24
32
|
export function createEntityFieldStore<T>() {
|