quickblox-react-ui-kit 0.2.2 → 0.2.4

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.
Files changed (85) hide show
  1. package/dist/CommonTypes/FunctionResult.d.ts +5 -1
  2. package/dist/Data/DefaultConfigurations.d.ts +2 -2
  3. package/dist/Data/source/remote/Mapper/MessageDTOMapper.d.ts +3 -1
  4. package/dist/Domain/use_cases/ai/AIAnswerAssistUseCase.d.ts +13 -0
  5. package/dist/Domain/use_cases/ai/AIAnswerAssistWithProxyUseCase.d.ts +13 -0
  6. package/dist/Domain/use_cases/ai/AIRephraseUseCase.d.ts +15 -0
  7. package/dist/Domain/use_cases/ai/AIRephraseWithProxyUseCase.d.ts +15 -0
  8. package/dist/Domain/use_cases/ai/AITranslateUseCase.d.ts +14 -0
  9. package/dist/Domain/use_cases/ai/AITranslateWithProxyUseCase.d.ts +14 -0
  10. package/dist/Presentation/Views/Base/BaseViewModel.d.ts +2 -0
  11. package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIMessageWidget.d.ts +10 -1
  12. package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIWidgetActions/AIWidgetActions.d.ts +3 -2
  13. package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone.d.ts +5 -13
  14. package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidget.d.ts +2 -10
  15. package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidgetWithProxy.d.ts +2 -0
  16. package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidget.d.ts +2 -10
  17. package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidgetWithProxy.d.ts +2 -0
  18. package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidget.d.ts +2 -10
  19. package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidgetWithProxy.d.ts +2 -0
  20. package/dist/Presentation/components/UI/Dialogs/MessagesView/DefaultAttachmentComponent/DefaultAttachmentComponent.d.ts +7 -0
  21. package/dist/Presentation/components/UI/Dialogs/MessagesView/ErrorToast/ErrorToast.d.ts +7 -0
  22. package/dist/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.d.ts +3 -1
  23. package/dist/Presentation/components/UI/Dialogs/PreviewDialog/PreviewAudioFile/PreviewAudioFile.d.ts +7 -0
  24. package/dist/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDefaultFile/PreviewDefaultFile.d.ts +7 -0
  25. package/dist/Presentation/components/UI/Dialogs/PreviewDialog/PreviewImageFile/PreviewImageFile.d.ts +8 -0
  26. package/dist/Presentation/components/UI/Dialogs/PreviewDialog/PreviewVideoFile/PreviewVideoFile.d.ts +7 -0
  27. package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/BotIcon/BotIcon.d.ts +4 -0
  28. package/dist/QBconfig.d.ts +14 -3
  29. package/dist/index-ui.js +384 -35
  30. package/dist/utils/utils.d.ts +9 -0
  31. package/global.d.ts +12 -4
  32. package/package.json +5 -1
  33. package/src/App.tsx +3 -1
  34. package/src/CommonTypes/FunctionResult.ts +6 -1
  35. package/src/Data/DefaultConfigurations.ts +155 -19
  36. package/src/Data/source/remote/Mapper/DialogDTOMapper.ts +3 -0
  37. package/src/Data/source/remote/Mapper/MessageDTOMapper.ts +55 -2
  38. package/src/Data/source/remote/RemoteDataSource.ts +2 -1
  39. package/src/Domain/use_cases/ai/AIAnswerAssistUseCase.ts +69 -0
  40. package/src/Domain/use_cases/ai/AIAnswerAssistWithProxyUseCase.ts +71 -0
  41. package/src/Domain/use_cases/ai/AIRephraseUseCase.ts +89 -0
  42. package/src/Domain/use_cases/ai/AIRephraseWithProxyUseCase.ts +75 -0
  43. package/src/Domain/use_cases/ai/AITranslateUseCase.ts +76 -0
  44. package/src/Domain/use_cases/ai/AITranslateWithProxyUseCase.ts +79 -0
  45. package/src/Presentation/Views/Base/BaseViewModel.ts +2 -0
  46. package/src/Presentation/Views/Dialogs/Dialogs.tsx +2 -2
  47. package/src/Presentation/Views/Dialogs/useDialogsViewModel.ts +4 -1
  48. package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIMessageWidget.ts +18 -2
  49. package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIWidgetActions/AIWidgetActions.tsx +10 -4
  50. package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone.ts +29 -15
  51. package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidget.tsx +24 -40
  52. package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidgetWithProxy.tsx +83 -0
  53. package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidget.tsx +40 -41
  54. package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidgetWithProxy.tsx +102 -0
  55. package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidget.tsx +27 -44
  56. package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidgetWithProxy.tsx +89 -0
  57. package/src/Presentation/components/UI/Dialogs/MessagesView/DefaultAttachmentComponent/DefaultAttachmentComponent.scss +76 -0
  58. package/src/Presentation/components/UI/Dialogs/MessagesView/DefaultAttachmentComponent/DefaultAttachmentComponent.tsx +34 -0
  59. package/src/Presentation/components/UI/Dialogs/MessagesView/ErrorToast/ErrorToast.scss +26 -0
  60. package/src/Presentation/components/UI/Dialogs/MessagesView/ErrorToast/ErrorToast.tsx +25 -0
  61. package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.scss +4 -6
  62. package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.tsx +93 -405
  63. package/src/Presentation/components/UI/Dialogs/MessagesView/MessagesView.scss +2 -3
  64. package/src/Presentation/components/UI/Dialogs/MessagesView/MessagesView.tsx +578 -415
  65. package/src/Presentation/components/UI/Dialogs/MessagesView/VideoAttachmentComponent/VideoAttachmentComponent.scss +6 -2
  66. package/src/Presentation/components/UI/Dialogs/MessagesView/useMessagesViewModel.ts +13 -3
  67. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewAudioFile/PreviewAudioFile.scss +62 -0
  68. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewAudioFile/PreviewAudioFile.tsx +25 -0
  69. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDefaultFile/PreviewDefaultFile.scss +61 -0
  70. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDefaultFile/PreviewDefaultFile.tsx +32 -0
  71. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDialog.scss +2 -2
  72. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDialog.tsx +50 -2
  73. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewImageFile/PreviewImageFile.scss +40 -0
  74. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewImageFile/PreviewImageFile.tsx +26 -0
  75. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewVideoFile/PreviewVideoFile.scss +62 -0
  76. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewVideoFile/PreviewVideoFile.tsx +25 -0
  77. package/src/Presentation/components/UI/svgs/Icons/AIWidgets/BotIcon/BotIcon.svg +5 -0
  78. package/src/Presentation/components/UI/svgs/Icons/AIWidgets/BotIcon/BotIcon.tsx +50 -0
  79. package/src/Presentation/components/layouts/Desktop/QuickBloxUIKitDesktopLayout.tsx +41 -42
  80. package/src/Presentation/components/providers/QuickBloxUIKitProvider/QuickBloxUIKitProvider.tsx +1 -1
  81. package/src/Presentation/components/providers/QuickBloxUIKitProvider/useQbInitializedDataContext.ts +15 -14
  82. package/src/QBconfig.ts +156 -10
  83. package/src/package_artan_react_ui.json +13 -9
  84. package/src/package_original.json +5 -1
  85. package/src/utils/utils.ts +63 -0
@@ -15,6 +15,9 @@ import UseDefaultAIAssistAnswerWidget from '../../UI/Dialogs/MessagesView/AIWidg
15
15
  import UseDefaultAITranslateWidget from '../../UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidget';
16
16
  import UseDefaultAIRephraseMessageWidget from '../../UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidget';
17
17
  import { DefaultConfigurations } from '../../../../Data/DefaultConfigurations';
18
+ import UseDefaultAIAssistAnswerWidgetWithProxy from '../../UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidgetWithProxy';
19
+ import UseDefaultAITranslateWidgetWithProxy from '../../UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidgetWithProxy';
20
+ import UseDefaultAIRephraseMessageWidgetWithProxy from '../../UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidgetWithProxy';
18
21
 
19
22
  type AIWidgetPlaceHolder = {
20
23
  enabled: boolean;
@@ -80,25 +83,24 @@ const QuickBloxUIKitDesktopLayout: React.FC<
80
83
  } else {
81
84
  const { apiKey } = QBConfig.configAIApi.AIAnswerAssistWidgetConfig;
82
85
  let token = '';
86
+ const proxyConfig: ProxyConfig =
87
+ QBConfig.configAIApi.AIAnswerAssistWidgetConfig.proxyConfig ||
88
+ DefaultConfigurations.getDefaultProxyConfig();
83
89
 
84
90
  if (apiKey) {
85
91
  token = apiKey;
92
+ defaultAIAnswerToMessageWidget = UseDefaultAIAssistAnswerWidget({
93
+ ...proxyConfig,
94
+ apiKeyOrSessionToken: token,
95
+ });
86
96
  } else {
87
- token =
88
- QBConfig.configAIApi.AIAnswerAssistWidgetConfig.proxyConfig
89
- .sessionToken ||
90
- sessionToken ||
91
- '';
97
+ token = sessionToken || '';
98
+ defaultAIAnswerToMessageWidget =
99
+ UseDefaultAIAssistAnswerWidgetWithProxy({
100
+ ...proxyConfig,
101
+ apiKeyOrSessionToken: token,
102
+ });
92
103
  }
93
- const proxyConfig: ProxyConfig =
94
- QBConfig.configAIApi.AIAnswerAssistWidgetConfig.proxyConfig ||
95
- DefaultConfigurations.getDefaultProxyConfig();
96
-
97
- defaultAIAnswerToMessageWidget = UseDefaultAIAssistAnswerWidget({
98
- ...proxyConfig,
99
- sessionToken: token,
100
- apiKey,
101
- });
102
104
  }
103
105
  }
104
106
  };
@@ -117,25 +119,23 @@ const QuickBloxUIKitDesktopLayout: React.FC<
117
119
  } else {
118
120
  const { apiKey } = QBConfig.configAIApi.AITranslateWidgetConfig;
119
121
  let token = '';
122
+ const proxyConfig: ProxyConfig =
123
+ QBConfig.configAIApi.AITranslateWidgetConfig.proxyConfig ||
124
+ DefaultConfigurations.getDefaultProxyConfig();
120
125
 
121
126
  if (apiKey) {
122
127
  token = apiKey;
128
+ defaultAITranslateWidget = UseDefaultAITranslateWidget({
129
+ ...proxyConfig,
130
+ apiKeyOrSessionToken: token,
131
+ });
123
132
  } else {
124
- token =
125
- QBConfig.configAIApi.AITranslateWidgetConfig.proxyConfig
126
- .sessionToken ||
127
- sessionToken ||
128
- '';
133
+ token = sessionToken || '';
134
+ defaultAITranslateWidget = UseDefaultAITranslateWidgetWithProxy({
135
+ ...proxyConfig,
136
+ apiKeyOrSessionToken: token,
137
+ });
129
138
  }
130
- const proxyConfig: ProxyConfig =
131
- QBConfig.configAIApi.AITranslateWidgetConfig.proxyConfig ||
132
- DefaultConfigurations.getDefaultProxyConfig();
133
-
134
- defaultAITranslateWidget = UseDefaultAITranslateWidget({
135
- ...proxyConfig,
136
- sessionToken: token,
137
- apiKey,
138
- });
139
139
  }
140
140
  }
141
141
  };
@@ -154,25 +154,24 @@ const QuickBloxUIKitDesktopLayout: React.FC<
154
154
  } else {
155
155
  const { apiKey } = QBConfig.configAIApi.AIRephraseWidgetConfig;
156
156
  let token = '';
157
+ const proxyConfig: ProxyConfig =
158
+ QBConfig.configAIApi.AIRephraseWidgetConfig.proxyConfig ||
159
+ DefaultConfigurations.getDefaultProxyConfig();
157
160
 
158
161
  if (apiKey) {
159
162
  token = apiKey;
163
+ defaultAIEditMessageWidget = UseDefaultAIRephraseMessageWidget({
164
+ ...proxyConfig,
165
+ apiKeyOrSessionToken: token,
166
+ });
160
167
  } else {
161
- token =
162
- QBConfig.configAIApi.AIRephraseWidgetConfig.proxyConfig
163
- .sessionToken ||
164
- sessionToken ||
165
- '';
168
+ token = sessionToken || '';
169
+ defaultAIEditMessageWidget =
170
+ UseDefaultAIRephraseMessageWidgetWithProxy({
171
+ ...proxyConfig,
172
+ apiKeyOrSessionToken: token,
173
+ });
166
174
  }
167
- const proxyConfig: ProxyConfig =
168
- QBConfig.configAIApi.AIRephraseWidgetConfig.proxyConfig ||
169
- DefaultConfigurations.getDefaultProxyConfig();
170
-
171
- defaultAIEditMessageWidget = UseDefaultAIRephraseMessageWidget({
172
- ...proxyConfig,
173
- sessionToken: token,
174
- apiKey,
175
- });
176
175
  }
177
176
  }
178
177
  };
@@ -291,7 +291,7 @@ function QuickBloxUIKitProvider({
291
291
  // eslint-disable-next-line @typescript-eslint/no-empty-function
292
292
  // storage.SYNC_DIALOGS_USE_CASE.execute(() => {});
293
293
 
294
- // todo: MUST use sessionToken or login/pass to re-init
294
+ // todo: MUST use apiKeyOrSessionToken or login/pass to re-init
295
295
  // const remoteDataSourceMock: RemoteDataSource =
296
296
  // storage.REMOTE_DATA_SOURCE as RemoteDataSource;
297
297
  // // remoteDataSourceMock
@@ -4,23 +4,24 @@ import { qbDataContext, QBDataContextType } from './QuickBloxUIKitProvider';
4
4
  const useQbInitializedDataContext = (): QBDataContextType => {
5
5
  const currentQbDataContext = React.useContext(qbDataContext);
6
6
 
7
- console.log(
8
- `call useQbDataContext with init param: ${JSON.stringify(
9
- currentQbDataContext.InitParams,
10
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
11
- )}`,
12
- );
7
+ // console.log(
8
+ // `call useQbDataContext with init param: ${JSON.stringify(
9
+ // currentQbDataContext.InitParams,
10
+ // // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
11
+ // )}`,
12
+ // );
13
13
  // todo: throw exception if we have not enough data to start session or login
14
- let QuickBloxVersion = '';
14
+ // let QuickBloxVersion = '';
15
15
 
16
16
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
17
17
  // @ts-ignore
18
18
  if (!window.QB) {
19
19
  throw new Error('HAVE NO SDK');
20
- } else {
21
- QuickBloxVersion = `Have SDK lib: version ${QB.version} build ${QB.buildNumber}`;
22
- console.log(QuickBloxVersion);
23
20
  }
21
+ // else {
22
+ // QuickBloxVersion = `Have SDK lib: version ${QB.version} build ${QB.buildNumber}`;
23
+ // console.log(QuickBloxVersion);
24
+ // }
24
25
  if (!currentQbDataContext) {
25
26
  throw new Error('HAVE NO DATA CONTEXT');
26
27
  }
@@ -29,10 +30,10 @@ const useQbInitializedDataContext = (): QBDataContextType => {
29
30
  }
30
31
  // проверять был ли обработан логин
31
32
  // если сведения для логина - ник, пароль или токен сессии
32
- console.log(
33
- 'data context: update init param: ',
34
- JSON.stringify(currentQbDataContext.InitParams),
35
- );
33
+ // console.log(
34
+ // 'data context: update init param: ',
35
+ // JSON.stringify(currentQbDataContext.InitParams),
36
+ // );
36
37
  if (
37
38
  currentQbDataContext.InitParams.accountData.appId &&
38
39
  currentQbDataContext.InitParams.accountData.accountKey &&
package/src/QBconfig.ts CHANGED
@@ -8,19 +8,24 @@ export const QBConfig = {
8
8
  },
9
9
  configAIApi: {
10
10
  AIAnswerAssistWidgetConfig: {
11
+ organizationName: 'Quickblox',
12
+ openAIModel: 'gpt-3.5-turbo',
11
13
  apiKey: '',
14
+ maxTokens: 3584,
12
15
  useDefault: true,
13
16
  proxyConfig: {
14
17
  api: 'v1/chat/completions',
15
- servername: 'http://localhost',
16
- port: '3011',
17
- sessionToken: '',
18
+ servername: 'https://api.openai.com/',
19
+ port: '',
18
20
  },
19
21
  },
20
22
  AITranslateWidgetConfig: {
23
+ organizationName: 'Quickblox',
24
+ openAIModel: 'gpt-3.5-turbo',
21
25
  apiKey: '',
26
+ maxTokens: 3584,
22
27
  useDefault: true,
23
- defaultLanguage: 'English',
28
+ defaultLanguage: '',
24
29
  languages: [
25
30
  'English',
26
31
  'Spanish',
@@ -31,20 +36,88 @@ export const QBConfig = {
31
36
  ],
32
37
  proxyConfig: {
33
38
  api: 'v1/chat/completions',
34
- servername: 'http://localhost',
35
- port: '3011',
36
- sessionToken: '',
39
+ servername: 'https://api.openai.com/',
40
+ port: '',
37
41
  },
42
+ // proxyConfig: {
43
+ // api: 'v1/chat/completions',
44
+ // servername: 'http://localhost',
45
+ // port: '3012',
46
+ // },
38
47
  },
39
48
  AIRephraseWidgetConfig: {
49
+ organizationName: 'Quickblox',
50
+ openAIModel: 'gpt-3.5-turbo',
40
51
  apiKey: '',
52
+ maxTokens: 3584,
41
53
  useDefault: true,
42
54
  defaultTone: 'Professional',
55
+ Tones: [
56
+ {
57
+ name: 'Professional Tone',
58
+ description:
59
+ 'This would edit messages to sound more formal, using technical vocabulary, clear sentence structures, and maintaining a respectful tone. It would avoid colloquial language and ensure appropriate salutations and sign-offs',
60
+ iconEmoji: '👔',
61
+ },
62
+ {
63
+ name: 'Friendly Tone',
64
+ description:
65
+ 'This would adjust messages to reflect a casual, friendly tone. It would incorporate casual language, use emoticons, exclamation points, and other informalities to make the message seem more friendly and approachable.',
66
+ iconEmoji: '🤝',
67
+ },
68
+ {
69
+ name: 'Encouraging Tone',
70
+ description:
71
+ 'This tone would be useful for motivation and encouragement. It would include positive words, affirmations, and express support and belief in the recipient.',
72
+ iconEmoji: '💪',
73
+ },
74
+ {
75
+ name: 'Empathetic Tone',
76
+ description:
77
+ 'This tone would be utilized to display understanding and empathy. It would involve softer language, acknowledging feelings, and demonstrating compassion and support.',
78
+ iconEmoji: '🤲',
79
+ },
80
+ {
81
+ name: 'Neutral Tone',
82
+ description:
83
+ 'For times when you want to maintain an even, unbiased, and objective tone. It would avoid extreme language and emotive words, opting for clear, straightforward communication.',
84
+ iconEmoji: '😐',
85
+ },
86
+ {
87
+ name: 'Assertive Tone',
88
+ description:
89
+ 'This tone is beneficial for making clear points, standing ground, or in negotiations. It uses direct language, is confident, and does not mince words.',
90
+ iconEmoji: '🔨',
91
+ },
92
+ {
93
+ name: 'Instructive Tone',
94
+ description:
95
+ 'This tone would be useful for tutorials, guides, or other teaching and training materials. It is clear, concise, and walks the reader through steps or processes in a logical manner.',
96
+ iconEmoji: '📖',
97
+ },
98
+ {
99
+ name: 'Persuasive Tone',
100
+ description:
101
+ 'This tone can be used when trying to convince someone or argue a point. It uses persuasive language, powerful words, and logical reasoning.',
102
+ iconEmoji: '☝️',
103
+ },
104
+ {
105
+ name: 'Sarcastic/Ironic Tone',
106
+ description:
107
+ 'This tone can make the communication more humorous or show an ironic stance. It is harder to implement as it requires the AI to understand nuanced language and may not always be taken as intended by the reader.',
108
+ iconEmoji: '😏',
109
+ },
110
+ {
111
+ name: 'Poetic Tone',
112
+ description:
113
+ 'This would add an artistic touch to messages, using figurative language, rhymes, and rhythm to create a more expressive text.',
114
+ iconEmoji: '🎭',
115
+ },
116
+ ],
43
117
  proxyConfig: {
44
118
  api: 'v1/chat/completions',
45
- servername: 'http://localhost',
46
- port: '3011',
47
- sessionToken: '',
119
+ servername: 'https://api.openai.com/',
120
+ port: '',
48
121
  },
49
122
  },
50
123
  },
@@ -72,4 +145,77 @@ export const QBConfig = {
72
145
  enable: true,
73
146
  },
74
147
  },
148
+ // credentials: {
149
+ // appId: -1,
150
+ // accountKey: '',
151
+ // authKey: '',
152
+ // authSecret: '',
153
+ // sessionToken: '',
154
+ // },
155
+ // configAIApi: {
156
+ // AIAnswerAssistWidgetConfig: {
157
+ // apiKey: '',
158
+ // useDefault: true,
159
+ // proxyConfig: {
160
+ // api: 'v1/chat/completions',
161
+ // servername: 'http://localhost',
162
+ // port: '3011',
163
+ // sessionToken: '',
164
+ // },
165
+ // },
166
+ // AITranslateWidgetConfig: {
167
+ // apiKey: '',
168
+ // useDefault: true,
169
+ // defaultLanguage: 'English',
170
+ // languages: [
171
+ // 'English',
172
+ // 'Spanish',
173
+ // 'French',
174
+ // 'Portuguese',
175
+ // 'German',
176
+ // 'Ukrainian',
177
+ // ],
178
+ // proxyConfig: {
179
+ // api: 'v1/chat/completions',
180
+ // servername: 'http://localhost',
181
+ // port: '3011',
182
+ // sessionToken: '',
183
+ // },
184
+ // },
185
+ // AIRephraseWidgetConfig: {
186
+ // apiKey: '',
187
+ // useDefault: true,
188
+ // defaultTone: 'Professional',
189
+ // proxyConfig: {
190
+ // api: 'v1/chat/completions',
191
+ // servername: 'http://localhost',
192
+ // port: '3011',
193
+ // sessionToken: '',
194
+ // },
195
+ // },
196
+ // },
197
+ // appConfig: {
198
+ // maxFileSize: 10 * 1024 * 1024,
199
+ // sessionTimeOut: 122,
200
+ // chatProtocol: {
201
+ // active: 2,
202
+ // },
203
+ // debug: true,
204
+ // endpoints: {
205
+ // api: 'api.quickblox.com',
206
+ // chat: 'chat.quickblox.com',
207
+ // },
208
+ // on: {
209
+ // // eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/require-await
210
+ // async sessionExpired(handleResponse: any, retry: any) {
211
+ // console.log(
212
+ // // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
213
+ // `QBconfig sessionExpired handle: ${handleResponse} ${retry}`,
214
+ // );
215
+ // },
216
+ // },
217
+ // streamManagement: {
218
+ // enable: true,
219
+ // },
220
+ // },
75
221
  };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "artan-react-ui-sample",
3
- "version": "0.0.10",
3
+ "version": "0.0.51",
4
4
  "main": "dist/index-ui.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -8,6 +8,10 @@
8
8
  "@types/react": "^18.0.26",
9
9
  "@types/react-dom": "^18.0.9",
10
10
  "classnames": "^2.3.2",
11
+ "qb-ai-answer-assistant": "^0.1.0",
12
+ "qb-ai-core": "^0.1.0",
13
+ "qb-ai-rephrase": "^0.1.0",
14
+ "qb-ai-translate": "^0.1.0",
11
15
  "react": "^18.2.0",
12
16
  "react-dom": "^18.2.0",
13
17
  "react-router-dom": "^6.11.1",
@@ -17,9 +21,17 @@
17
21
  "web-vitals": "^2.1.4"
18
22
  },
19
23
  "devDependencies": {
24
+ "@testing-library/jest-dom": "^5.16.5",
25
+ "@testing-library/react": "^13.4.0",
26
+ "@testing-library/user-event": "^13.5.0",
27
+ "@types/jest": "^27.5.2",
28
+ "@types/node": "^16.18.6",
29
+ "@types/react": "^18.0.26",
30
+ "@types/react-dom": "^18.0.9",
20
31
  "@typescript-eslint/eslint-plugin-tslint": "^5.45.1",
21
32
  "@typescript-eslint/parser": "^5.45.1",
22
33
  "classnames": "^2.3.2",
34
+ "css-loader": "^6.7.3",
23
35
  "eslint": "^8.29.0",
24
36
  "eslint-config-airbnb": "^19.0.4",
25
37
  "eslint-config-prettier": "^8.5.0",
@@ -33,14 +45,6 @@
33
45
  "eslint-plugin-react": "^7.31.11",
34
46
  "eslint-plugin-react-hooks": "^4.6.0",
35
47
  "prettier": "^2.8.0",
36
- "@testing-library/jest-dom": "^5.16.5",
37
- "@testing-library/react": "^13.4.0",
38
- "@testing-library/user-event": "^13.5.0",
39
- "@types/jest": "^27.5.2",
40
- "@types/node": "^16.18.6",
41
- "@types/react": "^18.0.26",
42
- "@types/react-dom": "^18.0.9",
43
- "css-loader": "^6.7.3",
44
48
  "react": "^18.2.0",
45
49
  "react-dom": "^18.2.0",
46
50
  "react-router-dom": "^6.4.3",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quickblox-react-ui-kit",
3
- "version": "0.1.3",
3
+ "version": "0.2.4",
4
4
  "main": "dist/index-ui.js",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -25,6 +25,10 @@
25
25
  "@types/react": "^18.0.26",
26
26
  "@types/react-dom": "^18.0.9",
27
27
  "classnames": "^2.3.2",
28
+ "qb-ai-answer-assistant": "^0.1.0",
29
+ "qb-ai-core": "^0.1.0",
30
+ "qb-ai-rephrase": "^0.1.0",
31
+ "qb-ai-translate": "^0.1.0",
28
32
  "react": "^18.2.0",
29
33
  "react-dom": "^18.2.0",
30
34
  "react-router-dom": "^6.11.1",
@@ -1,5 +1,12 @@
1
1
  // import { encode } from 'gpt-3-encoder';
2
2
 
3
+ import { MessageEntity } from '../Domain/entity/MessageEntity';
4
+ import { IChatMessage } from '../Data/source/AISource';
5
+ import {
6
+ Tone,
7
+ toneToString,
8
+ } from '../Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone';
9
+
3
10
  export const completeSentence = (text?: string) =>
4
11
  text?.replace(/([^.!?;]+)[^.!?;]*$/, ' ...') || '';
5
12
 
@@ -37,3 +44,59 @@ export const loopToLimitTokens = <T>(
37
44
 
38
45
  return [];
39
46
  };
47
+
48
+ export class AIUtils {
49
+ public static createTranslatePrompt(textToSend: string, language?: string) {
50
+ let prompt = `Please, translate the next text in english and give me just only translated text. Text to translate is: "${textToSend}"`;
51
+
52
+ if (language) {
53
+ prompt = `Please, translate the next text in ${language} and give me just only translated text. Text to translate is: "${textToSend}"`;
54
+ }
55
+
56
+ return prompt;
57
+ }
58
+
59
+ public static createAnswerAssistPrompt(textToSend: string) {
60
+ const prompt = `You are a customer support chat operator. Your goal is to provide helpful and informative responses to customer inquiries. Give a response to the next user's query, considering the entire conversation context, and use grammar and vocabulary at the A2-B2 level. Answer in the format of simple sentences. Do not include question in answer. Please, provide answer for this issue:"${textToSend}"`;
61
+
62
+ return prompt;
63
+ }
64
+
65
+ public static createRephrasePrompt(textToSend: string, tone?: Tone) {
66
+ let prompt = `Analyze the entire context of our conversation – all the messages – and create a brief summary of our discussion. Based on this analysis, rephrase the following text in a style and tone that is typical for most of the dialogue messages. Provide only the rephrased text in as the message text to rephrase and nothing more.Give me only rephrase text in brackets and nothing more. Here is the message text to rephrase:"${textToSend}"`;
67
+
68
+ if (tone) {
69
+ prompt = `Analyze the entire context of our conversation – all the messages – and create a brief summary of our discussion. Based on this analysis, rephrase the following text in a ${toneToString(
70
+ tone,
71
+ )} style. Provide only the rephrased text in the same language as the message text to rephrase and nothing more.Give me only rephrase text in brackets and nothing more. Here is the message text to rephrase:"${textToSend}"`;
72
+ }
73
+
74
+ return prompt;
75
+ }
76
+
77
+ public static messageEntitiesToIChatMessageCollection(
78
+ messageEntities: MessageEntity[],
79
+ currentUserId: number | undefined,
80
+ MAX_TOKENS = 3584,
81
+ ): IChatMessage[] {
82
+ const items = messageEntities.filter(
83
+ (it) =>
84
+ !it.notification_type ||
85
+ (it.notification_type && it.notification_type.length === 0),
86
+ );
87
+ const messages = loopToLimitTokens(
88
+ MAX_TOKENS,
89
+ items,
90
+ ({ message }) => message || '',
91
+ ).reverse();
92
+ const chatCompletionMessages: IChatMessage[] = messages.map(
93
+ ({ message, sender_id }) => ({
94
+ role: sender_id === currentUserId ? 'user' : 'assistant',
95
+ content: message,
96
+ }),
97
+ );
98
+
99
+ //
100
+ return chatCompletionMessages;
101
+ }
102
+ }