quickblox-react-ui-kit 0.2.0 → 0.2.1
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/Data/DefaultConfigurations.d.ts +11 -0
- package/dist/Data/Stubs.d.ts +1 -1
- package/dist/Data/source/AISource.d.ts +13 -0
- package/dist/Domain/entity/MessageEntity.d.ts +1 -1
- package/dist/Presentation/Views/Base/BaseViewModel.d.ts +10 -6
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIMessageWidget.d.ts +16 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIWidgetActions/AIWidgetActions.d.ts +14 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/SliderMenu.d.ts +23 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone.d.ts +15 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidget.d.ts +10 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidget.d.ts +10 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidget.d.ts +10 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/useDefaultVoiceInputWidget.d.ts +2 -2
- package/dist/Presentation/components/UI/Dialogs/MessagesView/ContextMenu.d.ts +2 -1
- package/dist/Presentation/components/UI/Dialogs/MessagesView/DropDownMenu/DropDownMenu.d.ts +26 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/DropDownMenu/ItemDropDownMenu/ItemDropDownMenu.d.ts +11 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/AvatarContentIncomingUser/AvatarContentIncomingUser.d.ts +3 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.d.ts +15 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/MessagesView.d.ts +5 -5
- package/dist/Presentation/components/UI/Dialogs/MessagesView/OutGoingMessage/OutGoingMessage.d.ts +9 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/BookIcon/BookIcon.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/HammerIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/HandshakeIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/MuscleIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/NecktieIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/NeutralFaceIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/PalmsUpTogetherIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/PerformingArtsIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/PointUpIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/SmileyIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/SmirkIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/WhiteCheckMarkIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/Actions/AssistAnswer/index.d.ts +4 -0
- package/dist/Presentation/components/UI/svgs/Icons/Actions/Summarize/index.d.ts +4 -0
- package/dist/Presentation/components/UI/svgs/Icons/Actions/Tone/index.d.ts +4 -0
- package/dist/Presentation/components/UI/svgs/Icons/Media/Translate/index.d.ts +4 -0
- package/dist/Presentation/components/layouts/Desktop/QuickBloxUIKitDesktopLayout.d.ts +5 -5
- package/dist/QBconfig.d.ts +22 -0
- package/dist/index-ui.d.ts +5 -1
- package/dist/index-ui.js +360 -41
- package/package.json +1 -1
- package/src/App.tsx +14 -1
- package/src/Data/DefaultConfigurations.ts +128 -0
- package/src/Data/Stubs.ts +15 -15
- package/src/Data/mapper/MessageLocalDTOMapper.ts +3 -2
- package/src/Data/mapper/MessageRemoteDTOMapper.ts +3 -2
- package/src/Data/source/AISource.ts +133 -0
- package/src/Data/source/remote/Mapper/MessageDTOMapper.ts +1 -1
- package/src/Domain/entity/MessageEntity.ts +1 -1
- package/src/Presentation/Views/Base/BaseViewModel.ts +9 -4
- package/src/Presentation/Views/Dialogs/Dialogs.tsx +37 -21
- package/src/Presentation/components/UI/Dialogs/HeaderDialogs/HeaderDialogs.scss +2 -2
- package/src/Presentation/components/UI/Dialogs/HeaderDialogs/HeaderDialogs.tsx +5 -5
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/{AIWidget.ts → AIMessageWidget.ts} +14 -3
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIWidgetActions/AIWidgetActions.scss +55 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIWidgetActions/AIWidgetActions.tsx +116 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/SliderMenu.tsx +172 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone.ts +21 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidget.tsx +99 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidget.tsx +105 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidget.tsx +106 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/useDefaultVoiceInputWidget.tsx +7 -6
- package/src/Presentation/components/UI/Dialogs/MessagesView/ContextMenu.tsx +5 -6
- package/src/Presentation/components/UI/Dialogs/MessagesView/DropDownMenu/DropDownMenu.scss +84 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/DropDownMenu/DropDownMenu.tsx +105 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/DropDownMenu/ItemDropDownMenu/ItemDropDownMenu.scss +50 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/DropDownMenu/ItemDropDownMenu/ItemDropDownMenu.tsx +43 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/HeaderMessages/HeaderMessages.tsx +14 -11
- package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/AvatarContentIncomingUser/AvatarContentIncomingUser.scss +39 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/AvatarContentIncomingUser/AvatarContentIncomingUser.tsx +26 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.scss +394 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.tsx +747 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/MessagesView.scss +88 -4
- package/src/Presentation/components/UI/Dialogs/MessagesView/MessagesView.tsx +589 -246
- package/src/Presentation/components/UI/Dialogs/MessagesView/OutGoingMessage/OutGoingMessage.scss +7 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/OutGoingMessage/OutGoingMessage.tsx +99 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/useMessagesViewModel.ts +2 -2
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/BookIcon/BookIcon.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/HammerIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/HandshakeIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/MuscleIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/NecktieIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/NeutralFaceIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/PalmsUpTogetherIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/PerformingArtsIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/PointUpIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/SmileyIcon/index.tsx +20 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/SmirkIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/WhiteCheckMarkIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/Actions/AssistAnswer/AssistAnswer.svg +3 -0
- package/src/Presentation/components/UI/svgs/Icons/Actions/AssistAnswer/index.tsx +93 -0
- package/src/Presentation/components/UI/svgs/Icons/Actions/Summarize/Summarize.svg +6 -0
- package/src/Presentation/components/UI/svgs/Icons/Actions/Summarize/index.tsx +58 -0
- package/src/Presentation/components/UI/svgs/Icons/Actions/Tone/Tone.svg +3 -0
- package/src/Presentation/components/UI/svgs/Icons/Actions/Tone/index.tsx +34 -0
- package/src/Presentation/components/UI/svgs/Icons/Media/Translate/Translate.svg +3 -0
- package/src/Presentation/components/UI/svgs/Icons/Media/Translate/index.tsx +35 -0
- package/src/Presentation/components/layouts/Desktop/QuickBloxUIKitDesktopLayout.tsx +110 -29
- package/src/QBconfig.ts +32 -3
- package/src/index-ui.ts +9 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIWidget.d.ts +0 -8
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidgetWithProxy.d.ts +0 -9
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultTextInputWidget.d.ts +0 -2
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidgetWithProxy.tsx +0 -136
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultTextInputWidget.tsx +0 -60
- /package/dist/Presentation/components/UI/svgs/Icons/{Media → AIWidgets}/AIWidget/index.d.ts +0 -0
- /package/src/Presentation/components/UI/svgs/Icons/{Media → AIWidgets}/AIWidget/Send.svg +0 -0
- /package/src/Presentation/components/UI/svgs/Icons/{Media → AIWidgets}/AIWidget/index.tsx +0 -0
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -193,6 +193,12 @@ function App() {
|
|
|
193
193
|
console.log('0. APP INIT');
|
|
194
194
|
prepareSDK(currentUser).catch();
|
|
195
195
|
}, []);
|
|
196
|
+
//
|
|
197
|
+
// const { proxyConfig } = QBConfig.configAIApi.AIAnswerAssistWidgetConfig;
|
|
198
|
+
//
|
|
199
|
+
// const defaultAIAnswer = UseDefaultAIAssistAnswerWidget({
|
|
200
|
+
// ...proxyConfig,
|
|
201
|
+
// });
|
|
196
202
|
|
|
197
203
|
// todo: uncomment authSecret
|
|
198
204
|
return (
|
|
@@ -221,7 +227,14 @@ function App() {
|
|
|
221
227
|
<Route
|
|
222
228
|
path="/desktop-test-mock"
|
|
223
229
|
element={
|
|
224
|
-
<QuickBloxUIKitDesktopLayout
|
|
230
|
+
<QuickBloxUIKitDesktopLayout
|
|
231
|
+
theme={new DefaultTheme()}
|
|
232
|
+
// AIAssist={{
|
|
233
|
+
// enabled: true,
|
|
234
|
+
// default: true,
|
|
235
|
+
// AIWidget: defaultAIAnswer,
|
|
236
|
+
// }}
|
|
237
|
+
/>
|
|
225
238
|
}
|
|
226
239
|
/>
|
|
227
240
|
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { QBConfig } from '../QBconfig';
|
|
2
|
+
|
|
3
|
+
const supportedLanguagesForIATranslate: string[] = [
|
|
4
|
+
'English',
|
|
5
|
+
'Ukrainian',
|
|
6
|
+
'Spanish',
|
|
7
|
+
'Portuguese',
|
|
8
|
+
'French',
|
|
9
|
+
'German',
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
const languageBCP47: Record<string, string> = {
|
|
13
|
+
'ar-SA': 'Arabic',
|
|
14
|
+
'bn-BD': 'Bangla',
|
|
15
|
+
'bn-IN': 'Bangla',
|
|
16
|
+
'cs-CZ': 'Czech',
|
|
17
|
+
'da-DK': 'Danish',
|
|
18
|
+
'de-AT': 'German',
|
|
19
|
+
'de-CH': 'German',
|
|
20
|
+
'de-DE': 'German',
|
|
21
|
+
'el-GR': 'Greek',
|
|
22
|
+
'en-AU': 'English',
|
|
23
|
+
'en-CA': 'English',
|
|
24
|
+
'en-GB': 'English',
|
|
25
|
+
'en-IE': 'English',
|
|
26
|
+
'en-IN': 'English',
|
|
27
|
+
'en-NZ': 'English',
|
|
28
|
+
'en-US': 'English',
|
|
29
|
+
'en-ZA': 'English',
|
|
30
|
+
'es-AR': 'Spanish',
|
|
31
|
+
'es-CL': 'Spanish',
|
|
32
|
+
'es-CO': 'Spanish',
|
|
33
|
+
'es-ES': 'Spanish',
|
|
34
|
+
'es-MX': 'Spanish',
|
|
35
|
+
'es-US': 'Spanish',
|
|
36
|
+
'fi-FI': 'Finnish',
|
|
37
|
+
'fr-BE': 'French',
|
|
38
|
+
'fr-CA': 'French',
|
|
39
|
+
'fr-CH': 'French',
|
|
40
|
+
'fr-FR': 'French',
|
|
41
|
+
'he-IL': 'Hebrew',
|
|
42
|
+
'hi-IN': 'Hindi',
|
|
43
|
+
'hu-HU': 'Hungarian',
|
|
44
|
+
'id-ID': 'Indonesian',
|
|
45
|
+
'it-CH': 'Italian',
|
|
46
|
+
'it-IT': 'Italian',
|
|
47
|
+
'ja-JP': 'Japanese',
|
|
48
|
+
'ko-KR': 'Korean',
|
|
49
|
+
'nl-BE': 'Dutch',
|
|
50
|
+
'nl-NL': 'Dutch',
|
|
51
|
+
'no-NO': 'Norwegian',
|
|
52
|
+
'pl-PL': 'Polish',
|
|
53
|
+
'pt-BR': 'Portuguese',
|
|
54
|
+
'pt-PT': 'Portuguese',
|
|
55
|
+
'ro-RO': 'Romanian',
|
|
56
|
+
'ru-RU': 'Russian',
|
|
57
|
+
'sk-SK': 'Slovak',
|
|
58
|
+
'sv-SE': 'Swedish',
|
|
59
|
+
'ta-IN': 'Tamil',
|
|
60
|
+
'ta-LK': 'Tamil',
|
|
61
|
+
'th-TH': 'Thai',
|
|
62
|
+
'tr-TR': 'Turkish',
|
|
63
|
+
'zh-CN': 'Chinese',
|
|
64
|
+
'zh-HK': 'Chinese',
|
|
65
|
+
'zh-TW': 'Chinese',
|
|
66
|
+
'uk-UA': 'Ukrainian',
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const getDefaultSystemLanguage = () => {
|
|
70
|
+
const sysLanguage = navigator.language;
|
|
71
|
+
|
|
72
|
+
const language: string = languageBCP47[sysLanguage] || 'English';
|
|
73
|
+
|
|
74
|
+
return language;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export type ProxyConfig = {
|
|
78
|
+
api: string;
|
|
79
|
+
servername: string;
|
|
80
|
+
port: string;
|
|
81
|
+
sessionToken: string;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export class DefaultConfigurations {
|
|
85
|
+
static getDefaultProxyConfig(): ProxyConfig {
|
|
86
|
+
return {
|
|
87
|
+
api: 'v1/chat/completions',
|
|
88
|
+
servername: 'https://api.openai.com',
|
|
89
|
+
port: '',
|
|
90
|
+
sessionToken: '',
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
static getDefaultLanguageForAITranslate(): string {
|
|
95
|
+
let languageForAITranslate = 'English';
|
|
96
|
+
const { defaultLanguage } = QBConfig.configAIApi.AITranslateWidgetConfig;
|
|
97
|
+
|
|
98
|
+
if (
|
|
99
|
+
defaultLanguage.length > 0 &&
|
|
100
|
+
supportedLanguagesForIATranslate.includes(defaultLanguage)
|
|
101
|
+
) {
|
|
102
|
+
languageForAITranslate = defaultLanguage;
|
|
103
|
+
} else {
|
|
104
|
+
const sysLanguage = getDefaultSystemLanguage();
|
|
105
|
+
|
|
106
|
+
if (supportedLanguagesForIATranslate.includes(sysLanguage)) {
|
|
107
|
+
languageForAITranslate = sysLanguage;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return languageForAITranslate;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
static getAdditionalLanguagesForAITranslate(): string[] {
|
|
115
|
+
const additionalLanguages: string[] = [];
|
|
116
|
+
const { languages } = QBConfig.configAIApi.AITranslateWidgetConfig;
|
|
117
|
+
|
|
118
|
+
languages.forEach((item) => {
|
|
119
|
+
if (supportedLanguagesForIATranslate.includes(item)) {
|
|
120
|
+
additionalLanguages.push(item);
|
|
121
|
+
} else {
|
|
122
|
+
additionalLanguages.push('English');
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
return additionalLanguages;
|
|
127
|
+
}
|
|
128
|
+
}
|
package/src/Data/Stubs.ts
CHANGED
|
@@ -145,7 +145,7 @@ export class Stubs {
|
|
|
145
145
|
for (let i = 0; i < 47; i += 1) {
|
|
146
146
|
const newMessageEntity: MessageEntity =
|
|
147
147
|
Stubs.createMessageEntityWithParams(
|
|
148
|
-
i,
|
|
148
|
+
i.toString(),
|
|
149
149
|
'103',
|
|
150
150
|
i % 9 === 0
|
|
151
151
|
? `${
|
|
@@ -171,7 +171,7 @@ export class Stubs {
|
|
|
171
171
|
for (let i = 47; i < 100; i += 1) {
|
|
172
172
|
const newMessageEntity: MessageEntity =
|
|
173
173
|
Stubs.createMessageEntityWithParams(
|
|
174
|
-
i,
|
|
174
|
+
i.toString(),
|
|
175
175
|
'103',
|
|
176
176
|
`${i + 1} test message for dialog 103`,
|
|
177
177
|
'31.03.2023',
|
|
@@ -744,7 +744,7 @@ export class Stubs {
|
|
|
744
744
|
}
|
|
745
745
|
|
|
746
746
|
static createMessageEntityWithParams(
|
|
747
|
-
id:
|
|
747
|
+
id: string,
|
|
748
748
|
dialogId: string,
|
|
749
749
|
message: string,
|
|
750
750
|
created_at: string,
|
|
@@ -876,7 +876,7 @@ export class Stubs {
|
|
|
876
876
|
const messages: Array<MessageEntity> = new Array<MessageEntity>();
|
|
877
877
|
// shot text message
|
|
878
878
|
const message102_1 = Stubs.createMessageEntityWithParams(
|
|
879
|
-
1021,
|
|
879
|
+
'1021',
|
|
880
880
|
'102',
|
|
881
881
|
'1 test message for dialog 102',
|
|
882
882
|
'31.03.2023',
|
|
@@ -890,7 +890,7 @@ export class Stubs {
|
|
|
890
890
|
);
|
|
891
891
|
// long text message
|
|
892
892
|
const message102_2 = Stubs.createMessageEntityWithParams(
|
|
893
|
-
1022,
|
|
893
|
+
'1022',
|
|
894
894
|
'102',
|
|
895
895
|
'2 test message for dialog 102',
|
|
896
896
|
'31.03.2023',
|
|
@@ -917,7 +917,7 @@ export class Stubs {
|
|
|
917
917
|
};
|
|
918
918
|
const photoAttachments: ChatMessageAttachmentEntity[] = [photo];
|
|
919
919
|
const message102_3 = Stubs.createMessageEntityWithParams(
|
|
920
|
-
1023,
|
|
920
|
+
'1023',
|
|
921
921
|
'102',
|
|
922
922
|
'3 test message for dialog 102',
|
|
923
923
|
'31.03.2023',
|
|
@@ -945,7 +945,7 @@ export class Stubs {
|
|
|
945
945
|
};
|
|
946
946
|
const videoAttachments: ChatMessageAttachmentEntity[] = [video];
|
|
947
947
|
const message102_4 = Stubs.createMessageEntityWithParams(
|
|
948
|
-
1024,
|
|
948
|
+
'1024',
|
|
949
949
|
'102',
|
|
950
950
|
'3 test message for dialog 102',
|
|
951
951
|
'31.03.2023',
|
|
@@ -973,7 +973,7 @@ export class Stubs {
|
|
|
973
973
|
};
|
|
974
974
|
const audioAttachments: ChatMessageAttachmentEntity[] = [audio];
|
|
975
975
|
const message102_5 = Stubs.createMessageEntityWithParams(
|
|
976
|
-
1025,
|
|
976
|
+
'1025',
|
|
977
977
|
'102',
|
|
978
978
|
'3 test message for dialog 102',
|
|
979
979
|
'31.03.2023',
|
|
@@ -1001,7 +1001,7 @@ export class Stubs {
|
|
|
1001
1001
|
};
|
|
1002
1002
|
const textAttachments: ChatMessageAttachmentEntity[] = [text];
|
|
1003
1003
|
const message102_6 = Stubs.createMessageEntityWithParams(
|
|
1004
|
-
1026,
|
|
1004
|
+
'1026',
|
|
1005
1005
|
'102',
|
|
1006
1006
|
'3 test message for dialog 102',
|
|
1007
1007
|
'31.03.2023',
|
|
@@ -1023,7 +1023,7 @@ export class Stubs {
|
|
|
1023
1023
|
messages.push(message102_6); // text
|
|
1024
1024
|
|
|
1025
1025
|
const message112_1 = Stubs.createMessageEntityWithParams(
|
|
1026
|
-
1121,
|
|
1026
|
+
'1121',
|
|
1027
1027
|
'112',
|
|
1028
1028
|
'1 test message for dialog 112',
|
|
1029
1029
|
'31.03.2023',
|
|
@@ -1037,7 +1037,7 @@ export class Stubs {
|
|
|
1037
1037
|
);
|
|
1038
1038
|
|
|
1039
1039
|
const message112_2 = Stubs.createMessageEntityWithParams(
|
|
1040
|
-
1122,
|
|
1040
|
+
'1122',
|
|
1041
1041
|
'112',
|
|
1042
1042
|
'2 test message for dialog 112',
|
|
1043
1043
|
'31.03.2023',
|
|
@@ -1051,7 +1051,7 @@ export class Stubs {
|
|
|
1051
1051
|
);
|
|
1052
1052
|
|
|
1053
1053
|
const message112_3 = Stubs.createMessageEntityWithParams(
|
|
1054
|
-
1123,
|
|
1054
|
+
'1123',
|
|
1055
1055
|
'112',
|
|
1056
1056
|
'3 test message for dialog 112',
|
|
1057
1057
|
'31.03.2023',
|
|
@@ -1069,7 +1069,7 @@ export class Stubs {
|
|
|
1069
1069
|
messages.push(message112_3);
|
|
1070
1070
|
|
|
1071
1071
|
const message113_1 = Stubs.createMessageEntityWithParams(
|
|
1072
|
-
1131,
|
|
1072
|
+
'1131',
|
|
1073
1073
|
'113',
|
|
1074
1074
|
'1 test message for dialog 113',
|
|
1075
1075
|
'31.03.2023',
|
|
@@ -1083,7 +1083,7 @@ export class Stubs {
|
|
|
1083
1083
|
);
|
|
1084
1084
|
|
|
1085
1085
|
const message113_2 = Stubs.createMessageEntityWithParams(
|
|
1086
|
-
1132,
|
|
1086
|
+
'1132',
|
|
1087
1087
|
'113',
|
|
1088
1088
|
'2 test message for dialog 113',
|
|
1089
1089
|
'31.03.2023',
|
|
@@ -1097,7 +1097,7 @@ export class Stubs {
|
|
|
1097
1097
|
);
|
|
1098
1098
|
|
|
1099
1099
|
const message113_3 = Stubs.createMessageEntityWithParams(
|
|
1100
|
-
1133,
|
|
1100
|
+
'1133',
|
|
1101
1101
|
'113',
|
|
1102
1102
|
'3 test message for dialog 113',
|
|
1103
1103
|
'31.03.2023',
|
|
@@ -67,7 +67,8 @@ export class MessageLocalDTOMapper implements IMapper {
|
|
|
67
67
|
const messageEntity: MessageEntity =
|
|
68
68
|
MessageLocalDTOMapper.createDefaultMessageEntity();
|
|
69
69
|
|
|
70
|
-
messageEntity.id = parseInt(messageDTO.id, 10);
|
|
70
|
+
// messageEntity.id = parseInt(messageDTO.id, 10);
|
|
71
|
+
messageEntity.id = messageDTO.id;
|
|
71
72
|
messageEntity.dialogId = messageDTO.dialogId;
|
|
72
73
|
messageEntity.created_at = messageDTO.created_at;
|
|
73
74
|
messageEntity.date_sent = messageDTO.date_sent;
|
|
@@ -409,7 +410,7 @@ export class MessageLocalDTOMapper implements IMapper {
|
|
|
409
410
|
|
|
410
411
|
private static createDefaultMessageEntity() {
|
|
411
412
|
return {
|
|
412
|
-
id:
|
|
413
|
+
id: '',
|
|
413
414
|
dialogId: '',
|
|
414
415
|
created_at: '',
|
|
415
416
|
date_sent: 0,
|
|
@@ -74,7 +74,8 @@ export class MessageRemoteDTOMapper implements IMapper {
|
|
|
74
74
|
const messageEntity: MessageEntity =
|
|
75
75
|
MessageRemoteDTOMapper.createDefaultMessageEntity();
|
|
76
76
|
|
|
77
|
-
messageEntity.id = parseInt(messageDTO.id, 10);
|
|
77
|
+
// messageEntity.id = parseInt(messageDTO.id, 10);
|
|
78
|
+
messageEntity.id = messageDTO.id;
|
|
78
79
|
messageEntity.dialogId = messageDTO.dialogId;
|
|
79
80
|
messageEntity.created_at = messageDTO.created_at;
|
|
80
81
|
messageEntity.date_sent = messageDTO.date_sent;
|
|
@@ -419,7 +420,7 @@ export class MessageRemoteDTOMapper implements IMapper {
|
|
|
419
420
|
date_sent: 0,
|
|
420
421
|
delivered_ids: new Array<number>(),
|
|
421
422
|
dialogId: '',
|
|
422
|
-
id:
|
|
423
|
+
id: '',
|
|
423
424
|
message: '',
|
|
424
425
|
read: 0,
|
|
425
426
|
read_ids: new Array<number>(),
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { stringifyError } from '../../utils/parse';
|
|
2
|
+
import RepositoryException from './exception/RepositoryException';
|
|
3
|
+
|
|
4
|
+
export interface IChatMessage {
|
|
5
|
+
role: string;
|
|
6
|
+
content: string;
|
|
7
|
+
}
|
|
8
|
+
export type AIParam = {
|
|
9
|
+
textToAI: string;
|
|
10
|
+
context: IChatMessage[];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export class AISource {
|
|
14
|
+
static async getData(
|
|
15
|
+
prompt: string,
|
|
16
|
+
dialogMessages: IChatMessage[],
|
|
17
|
+
servername: string,
|
|
18
|
+
api: string,
|
|
19
|
+
port: string,
|
|
20
|
+
sessionToken: string,
|
|
21
|
+
openAIModel = 'gpt-3.5-turbo',
|
|
22
|
+
): Promise<string> {
|
|
23
|
+
const apiEndpoint = `${servername}/${api}`;
|
|
24
|
+
const apiKey = sessionToken;
|
|
25
|
+
const model = openAIModel; // 'gpt-3.5-turbo';
|
|
26
|
+
|
|
27
|
+
const requestOptions = {
|
|
28
|
+
method: 'POST',
|
|
29
|
+
headers: {
|
|
30
|
+
'Content-Type': 'application/json',
|
|
31
|
+
Authorization: `Bearer ${apiKey}`,
|
|
32
|
+
},
|
|
33
|
+
body: JSON.stringify({
|
|
34
|
+
messages: [...dialogMessages, { role: 'user', content: prompt }],
|
|
35
|
+
model,
|
|
36
|
+
temperature: 0.5,
|
|
37
|
+
}),
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
const response = await fetch(apiEndpoint, requestOptions);
|
|
42
|
+
const data = await response.json();
|
|
43
|
+
|
|
44
|
+
const outputMessage = data.choices[0].message?.content || '';
|
|
45
|
+
|
|
46
|
+
return outputMessage;
|
|
47
|
+
} catch (err) {
|
|
48
|
+
const outputMessage = stringifyError(err);
|
|
49
|
+
|
|
50
|
+
throw new RepositoryException(outputMessage, -1);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static async getDataWithOpenAI(
|
|
55
|
+
prompt: string,
|
|
56
|
+
dialogMessages: IChatMessage[],
|
|
57
|
+
servername: string,
|
|
58
|
+
api: string,
|
|
59
|
+
port: string,
|
|
60
|
+
sessionToken: string,
|
|
61
|
+
openAIModel = 'gpt-3.5-turbo',
|
|
62
|
+
): Promise<string> {
|
|
63
|
+
const apiEndpoint = `${servername}/${api}`;
|
|
64
|
+
const apiKey = sessionToken;
|
|
65
|
+
const model = openAIModel; // 'gpt-3.5-turbo';
|
|
66
|
+
|
|
67
|
+
const requestOptions = {
|
|
68
|
+
method: 'POST',
|
|
69
|
+
headers: {
|
|
70
|
+
'Content-Type': 'application/json',
|
|
71
|
+
Authorization: `Bearer ${apiKey}`,
|
|
72
|
+
},
|
|
73
|
+
body: JSON.stringify({
|
|
74
|
+
messages: [...dialogMessages, { role: 'user', content: prompt }],
|
|
75
|
+
model,
|
|
76
|
+
temperature: 0.5,
|
|
77
|
+
}),
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
const response = await fetch(apiEndpoint, requestOptions);
|
|
82
|
+
const data = await response.json();
|
|
83
|
+
|
|
84
|
+
const outputMessage = data.choices[0].message?.content || '';
|
|
85
|
+
|
|
86
|
+
return outputMessage;
|
|
87
|
+
} catch (err) {
|
|
88
|
+
const outputMessage = stringifyError(err);
|
|
89
|
+
|
|
90
|
+
throw new RepositoryException(outputMessage, -1);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
static async getDataWithProxyServer(
|
|
95
|
+
prompt: string,
|
|
96
|
+
dialogMessages: IChatMessage[],
|
|
97
|
+
servername: string,
|
|
98
|
+
api: string,
|
|
99
|
+
port: string,
|
|
100
|
+
sessionToken: string,
|
|
101
|
+
openAIModel = 'gpt-3.5-turbo',
|
|
102
|
+
): Promise<string> {
|
|
103
|
+
const apiEndpoint = `${servername}:${port}/${api}`;
|
|
104
|
+
const apiKey = sessionToken;
|
|
105
|
+
const model = openAIModel; // 'gpt-3.5-turbo';
|
|
106
|
+
|
|
107
|
+
const requestOptions = {
|
|
108
|
+
method: 'POST',
|
|
109
|
+
headers: {
|
|
110
|
+
'Content-Type': 'application/json',
|
|
111
|
+
'qb-token': apiKey,
|
|
112
|
+
},
|
|
113
|
+
body: JSON.stringify({
|
|
114
|
+
messages: [...dialogMessages, { role: 'user', content: prompt }],
|
|
115
|
+
model,
|
|
116
|
+
temperature: 0.5,
|
|
117
|
+
}),
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
const response = await fetch(apiEndpoint, requestOptions);
|
|
122
|
+
const data = await response.json();
|
|
123
|
+
|
|
124
|
+
const outputMessage = data.choices[0].message?.content || '';
|
|
125
|
+
|
|
126
|
+
return outputMessage;
|
|
127
|
+
} catch (err) {
|
|
128
|
+
const outputMessage = stringifyError(err);
|
|
129
|
+
|
|
130
|
+
throw new RepositoryException(outputMessage, -1);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -76,7 +76,7 @@ export class MessageDTOMapper implements IDTOMapper {
|
|
|
76
76
|
dto.dialogId = qbMessage.chat_dialog_id;
|
|
77
77
|
dto.message = qbMessage.message;
|
|
78
78
|
dto.created_at = qbMessage.created_at;
|
|
79
|
-
dto.date_sent = qbMessage.date_sent;
|
|
79
|
+
dto.date_sent = qbMessage.date_sent * 1000;
|
|
80
80
|
dto.delivered_ids = qbMessage.delivered_ids ? qbMessage.delivered_ids : [];
|
|
81
81
|
dto.read_ids = qbMessage.read_ids ? qbMessage.read_ids : [];
|
|
82
82
|
|
|
@@ -2,6 +2,7 @@ import { Pagination } from '../../../Domain/repository/Pagination';
|
|
|
2
2
|
import { GroupDialogEntity } from '../../../Domain/entity/GroupDialogEntity';
|
|
3
3
|
import { DialogEntity } from '../../../Domain/entity/DialogEntity';
|
|
4
4
|
import { FileEntity } from '../../../Domain/entity/FileEntity';
|
|
5
|
+
import { IChatMessage } from '../../../Data/source/AISource';
|
|
5
6
|
|
|
6
7
|
export default class BaseViewModel<TResult> {
|
|
7
8
|
get entity(): TResult {
|
|
@@ -49,10 +50,7 @@ export type EditDialogParams = {
|
|
|
49
50
|
dialogTitle: string;
|
|
50
51
|
dialogAvatar: File | string | null;
|
|
51
52
|
};
|
|
52
|
-
|
|
53
|
-
role: string;
|
|
54
|
-
content: string;
|
|
55
|
-
}
|
|
53
|
+
|
|
56
54
|
export type FunctionTypeFileToToVoid = (file: File) => void;
|
|
57
55
|
export type FunctionTypePaginationToVoid = (pagination: Pagination) => void;
|
|
58
56
|
export type FunctionTypeVoidToVoid = () => void;
|
|
@@ -76,8 +74,15 @@ export type FunctionTypeJSXElement = () => JSX.Element;
|
|
|
76
74
|
export type FunctionTypeFileWithContextToToVoid = (
|
|
77
75
|
file: File,
|
|
78
76
|
context: IChatMessage[],
|
|
77
|
+
additionalSettings?: { [key: string]: any },
|
|
79
78
|
) => void;
|
|
80
79
|
export type FunctionTypeStringWithContextToVoid = (
|
|
81
80
|
value: string,
|
|
82
81
|
context: IChatMessage[],
|
|
82
|
+
additionalSettings?: { [key: string]: any },
|
|
83
83
|
) => void;
|
|
84
|
+
export type FunctionTypeStringWithContextToString = (
|
|
85
|
+
value: string,
|
|
86
|
+
context: IChatMessage[],
|
|
87
|
+
additionalSettings?: { [key: string]: any },
|
|
88
|
+
) => Promise<string>;
|
|
@@ -266,9 +266,9 @@ const DialogsComponent: React.FC<DialogsProps> = ({
|
|
|
266
266
|
};
|
|
267
267
|
|
|
268
268
|
const loaderTheme: IconTheme = {
|
|
269
|
-
color: 'var(--
|
|
270
|
-
width: '
|
|
271
|
-
height: '
|
|
269
|
+
color: 'var(--color-background-info)',
|
|
270
|
+
width: '44',
|
|
271
|
+
height: '44',
|
|
272
272
|
};
|
|
273
273
|
|
|
274
274
|
const renderSearchDialogs = () => {
|
|
@@ -315,26 +315,42 @@ const DialogsComponent: React.FC<DialogsProps> = ({
|
|
|
315
315
|
{useUpContent && upHeaderContent}
|
|
316
316
|
{useHeader && HeaderContent}
|
|
317
317
|
{useSubContent && subHeaderContent}
|
|
318
|
-
{dialogsViewModel?.loading && (
|
|
319
|
-
// <div style={{ maxHeight: '44px', minHeight: '44px', height: '44px' }}>
|
|
320
|
-
// <LoaderComponent width="44" height="44" color="var(--divider)" />
|
|
321
|
-
// </div>
|
|
322
|
-
<LoaderComponent
|
|
323
|
-
width={loaderTheme.width}
|
|
324
|
-
height={loaderTheme.height}
|
|
325
|
-
color={loaderTheme.color}
|
|
326
|
-
/>
|
|
327
|
-
)}
|
|
328
|
-
{dialogsViewModel?.error && (
|
|
329
|
-
<ErrorComponent
|
|
330
|
-
title="Something is wrong."
|
|
331
|
-
ClickActionHandler={() => {
|
|
332
|
-
alert('call click retry');
|
|
333
|
-
}}
|
|
334
|
-
/>
|
|
335
|
-
)}
|
|
336
318
|
{/* <div className="scroll-box"> */}
|
|
337
319
|
<div className="scroll-box">
|
|
320
|
+
{dialogsViewModel?.loading && (
|
|
321
|
+
// <div style={{ maxHeight: '44px', minHeight: '44px', height: '44px' }}>
|
|
322
|
+
// <LoaderComponent width="44" height="44" color="var(--divider)" />
|
|
323
|
+
// </div>
|
|
324
|
+
<div
|
|
325
|
+
style={{
|
|
326
|
+
display: 'flex',
|
|
327
|
+
flexDirection: 'row',
|
|
328
|
+
alignItems: 'center',
|
|
329
|
+
justifyContent: 'center',
|
|
330
|
+
}}
|
|
331
|
+
>
|
|
332
|
+
<div
|
|
333
|
+
style={{
|
|
334
|
+
height: '44px',
|
|
335
|
+
width: '44px',
|
|
336
|
+
}}
|
|
337
|
+
>
|
|
338
|
+
<LoaderComponent
|
|
339
|
+
width={loaderTheme.width}
|
|
340
|
+
height={loaderTheme.height}
|
|
341
|
+
color={loaderTheme.color}
|
|
342
|
+
/>
|
|
343
|
+
</div>
|
|
344
|
+
</div>
|
|
345
|
+
)}
|
|
346
|
+
{dialogsViewModel?.error && (
|
|
347
|
+
<ErrorComponent
|
|
348
|
+
title="Something is wrong."
|
|
349
|
+
ClickActionHandler={() => {
|
|
350
|
+
alert('call click retry');
|
|
351
|
+
}}
|
|
352
|
+
/>
|
|
353
|
+
)}
|
|
338
354
|
{showSearchDialogs ? renderSearchDialogs() : null}
|
|
339
355
|
{nameDialogForSearch.length > 0 &&
|
|
340
356
|
dialogsToView
|
|
@@ -10,8 +10,8 @@ $header-container-title-font-size: 20px;
|
|
|
10
10
|
$header-container-title-line-height: 24px;
|
|
11
11
|
$header-container-title-width: 180px;
|
|
12
12
|
$header-container-buttons-gap-width: 29px;
|
|
13
|
-
$header-container-svg-icon-width:
|
|
14
|
-
$header-container-svg-icon-height:
|
|
13
|
+
$header-container-svg-icon-width: 24px;
|
|
14
|
+
$header-container-svg-icon-height: 24px;
|
|
15
15
|
$header-container-color-icon: var(--color-icon);
|
|
16
16
|
|
|
17
17
|
.header-dialogs-container{
|
|
@@ -54,9 +54,9 @@ const HeaderDialogs: React.FC<HeaderDialogsProps> = ({
|
|
|
54
54
|
const buttonsStyle = {
|
|
55
55
|
background: 'none',
|
|
56
56
|
svg: {
|
|
57
|
-
width: '
|
|
58
|
-
height: '
|
|
59
|
-
viewBox: '0 0
|
|
57
|
+
width: '24',
|
|
58
|
+
height: '24',
|
|
59
|
+
viewBox: '0 0 24 24',
|
|
60
60
|
path: {
|
|
61
61
|
fill: theme?.mainElements(),
|
|
62
62
|
},
|
|
@@ -83,7 +83,7 @@ const HeaderDialogs: React.FC<HeaderDialogsProps> = ({
|
|
|
83
83
|
</div>
|
|
84
84
|
<div style={buttonsStyle} className="header-dialogs-container__buttons">
|
|
85
85
|
<ActiveSvg
|
|
86
|
-
content={<Search />}
|
|
86
|
+
content={<Search width="24" height="24" applyZoom />}
|
|
87
87
|
touchAction={() => {
|
|
88
88
|
console.log('touchSearchDialogsHandler');
|
|
89
89
|
if (touchSearchHandler) touchSearchHandler();
|
|
@@ -94,7 +94,7 @@ const HeaderDialogs: React.FC<HeaderDialogsProps> = ({
|
|
|
94
94
|
}}
|
|
95
95
|
/>
|
|
96
96
|
<ActiveSvg
|
|
97
|
-
content={<NewChat />}
|
|
97
|
+
content={<NewChat width="24" height="24" applyZoom />}
|
|
98
98
|
touchAction={() => {
|
|
99
99
|
console.log('touchAction: Hello from component 1');
|
|
100
100
|
if (TouchActionHandler) TouchActionHandler();
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FunctionTypeFileWithContextToToVoid,
|
|
3
3
|
FunctionTypeJSXElement,
|
|
4
|
-
|
|
4
|
+
FunctionTypeStringWithContextToString,
|
|
5
5
|
} from '../../../../../Views/Base/BaseViewModel';
|
|
6
6
|
|
|
7
7
|
export interface AIWidget {
|
|
8
8
|
renderWidget: FunctionTypeJSXElement;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
}
|
|
10
|
+
export interface AITextWidget extends AIWidget {
|
|
11
11
|
textToContent: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface AIFileWidget extends AIWidget {
|
|
12
15
|
fileToContent: File | undefined;
|
|
13
16
|
}
|
|
17
|
+
|
|
18
|
+
export interface AIMessageWidget extends AITextWidget {
|
|
19
|
+
textToWidget: FunctionTypeStringWithContextToString;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface AIAttachmentWidget extends AIFileWidget {
|
|
23
|
+
fileToWidget: FunctionTypeFileWithContextToToVoid;
|
|
24
|
+
}
|