quickblox-react-ui-kit 0.2.3 → 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.
- package/dist/CommonTypes/FunctionResult.d.ts +5 -1
- package/dist/Data/DefaultConfigurations.d.ts +2 -2
- package/dist/Domain/use_cases/ai/AIAnswerAssistUseCase.d.ts +13 -0
- package/dist/Domain/use_cases/ai/AIAnswerAssistWithProxyUseCase.d.ts +13 -0
- package/dist/Domain/use_cases/ai/AITranslateUseCase.d.ts +14 -0
- package/dist/Domain/use_cases/ai/AITranslateWithProxyUseCase.d.ts +14 -0
- package/dist/Presentation/Views/Base/BaseViewModel.d.ts +2 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIMessageWidget.d.ts +4 -1
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIWidgetActions/AIWidgetActions.d.ts +3 -2
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone.d.ts +5 -13
- package/dist/Presentation/components/UI/Dialogs/MessagesView/DefaultAttachmentComponent/DefaultAttachmentComponent.d.ts +7 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/ErrorToast/ErrorToast.d.ts +7 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.d.ts +3 -1
- package/dist/Presentation/components/UI/Dialogs/PreviewDialog/PreviewAudioFile/PreviewAudioFile.d.ts +7 -0
- package/dist/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDefaultFile/PreviewDefaultFile.d.ts +7 -0
- package/dist/Presentation/components/UI/Dialogs/PreviewDialog/PreviewImageFile/PreviewImageFile.d.ts +8 -0
- package/dist/Presentation/components/UI/Dialogs/PreviewDialog/PreviewVideoFile/PreviewVideoFile.d.ts +7 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/BotIcon/BotIcon.d.ts +4 -0
- package/dist/QBconfig.d.ts +14 -3
- package/dist/index-ui.js +316 -33
- package/dist/utils/utils.d.ts +9 -0
- package/global.d.ts +12 -4
- package/package.json +5 -1
- package/src/CommonTypes/FunctionResult.ts +6 -1
- package/src/Data/DefaultConfigurations.ts +155 -19
- package/src/Domain/use_cases/ai/AIAnswerAssistUseCase.ts +69 -0
- package/src/Domain/use_cases/ai/AIAnswerAssistWithProxyUseCase.ts +71 -0
- package/src/Domain/use_cases/ai/AIRephraseUseCase.ts +38 -36
- package/src/Domain/use_cases/ai/AIRephraseWithProxyUseCase.ts +25 -21
- package/src/Domain/use_cases/ai/AITranslateUseCase.ts +76 -0
- package/src/Domain/use_cases/ai/AITranslateWithProxyUseCase.ts +79 -0
- package/src/Presentation/Views/Base/BaseViewModel.ts +2 -0
- package/src/Presentation/Views/Dialogs/Dialogs.tsx +1 -1
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIMessageWidget.ts +7 -2
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIWidgetActions/AIWidgetActions.tsx +10 -4
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone.ts +29 -15
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidget.tsx +10 -6
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidgetWithProxy.tsx +10 -6
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidget.tsx +17 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidgetWithProxy.tsx +16 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidget.tsx +13 -12
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidgetWithProxy.tsx +13 -12
- package/src/Presentation/components/UI/Dialogs/MessagesView/DefaultAttachmentComponent/DefaultAttachmentComponent.scss +76 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/DefaultAttachmentComponent/DefaultAttachmentComponent.tsx +34 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/ErrorToast/ErrorToast.scss +26 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/ErrorToast/ErrorToast.tsx +25 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.scss +4 -6
- package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.tsx +93 -405
- package/src/Presentation/components/UI/Dialogs/MessagesView/MessagesView.scss +2 -3
- package/src/Presentation/components/UI/Dialogs/MessagesView/MessagesView.tsx +561 -400
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewAudioFile/PreviewAudioFile.scss +62 -0
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewAudioFile/PreviewAudioFile.tsx +25 -0
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDefaultFile/PreviewDefaultFile.scss +61 -0
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDefaultFile/PreviewDefaultFile.tsx +32 -0
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDialog.scss +2 -2
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDialog.tsx +50 -2
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewImageFile/PreviewImageFile.scss +40 -0
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewImageFile/PreviewImageFile.tsx +26 -0
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewVideoFile/PreviewVideoFile.scss +62 -0
- package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewVideoFile/PreviewVideoFile.tsx +25 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/BotIcon/BotIcon.svg +5 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/BotIcon/BotIcon.tsx +50 -0
- package/src/Presentation/components/layouts/Desktop/QuickBloxUIKitDesktopLayout.tsx +3 -15
- package/src/Presentation/components/providers/QuickBloxUIKitProvider/useQbInitializedDataContext.ts +15 -14
- package/src/QBconfig.ts +156 -10
- package/src/package_artan_react_ui.json +13 -9
- package/src/package_original.json +5 -1
- package/src/utils/utils.ts +63 -0
package/dist/utils/utils.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
import { MessageEntity } from '../Domain/entity/MessageEntity';
|
|
2
|
+
import { IChatMessage } from '../Data/source/AISource';
|
|
3
|
+
import { Tone } from '../Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone';
|
|
1
4
|
export declare const completeSentence: (text?: string) => string;
|
|
2
5
|
export declare const tokenCounter: (text?: string) => number;
|
|
3
6
|
export declare const loopToLimitTokens: <T>(limit: number, data: T[], getValue?: (item: T) => string, tokens?: number) => T[];
|
|
7
|
+
export declare class AIUtils {
|
|
8
|
+
static createTranslatePrompt(textToSend: string, language?: string): string;
|
|
9
|
+
static createAnswerAssistPrompt(textToSend: string): string;
|
|
10
|
+
static createRephrasePrompt(textToSend: string, tone?: Tone): string;
|
|
11
|
+
static messageEntitiesToIChatMessageCollection(messageEntities: MessageEntity[], currentUserId: number | undefined, MAX_TOKENS?: number): IChatMessage[];
|
|
12
|
+
}
|
package/global.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
interface Tone {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
iconEmoji: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
1
7
|
type Dictionary<T> = Record<string, T>;
|
|
2
8
|
|
|
3
9
|
type DictionaryByKey<T, V> = {
|
|
@@ -21,20 +27,22 @@ type ProxyConfig = {
|
|
|
21
27
|
api: string;
|
|
22
28
|
servername: string;
|
|
23
29
|
port: string;
|
|
24
|
-
sessionToken: string;
|
|
25
30
|
};
|
|
26
31
|
interface WidgetConfig {
|
|
27
32
|
apiKey: string;
|
|
28
33
|
useDefault: boolean;
|
|
34
|
+
maxTokens: number;
|
|
29
35
|
proxyConfig: ProxyConfig;
|
|
30
36
|
}
|
|
31
37
|
|
|
32
|
-
interface AITranslateWidgetConfig extends WidgetConfig{
|
|
33
|
-
defaultLanguage: string;
|
|
38
|
+
interface AITranslateWidgetConfig extends WidgetConfig {
|
|
39
|
+
defaultLanguage: string;
|
|
40
|
+
languages: string[];
|
|
34
41
|
}
|
|
35
42
|
|
|
36
43
|
interface AIRephraseWidgetConfig extends WidgetConfig {
|
|
37
|
-
defaultTone: string
|
|
44
|
+
defaultTone: string;
|
|
45
|
+
Tones: Tone[];
|
|
38
46
|
}
|
|
39
47
|
|
|
40
48
|
interface QBConfig {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quickblox-react-ui-kit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
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",
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import {Tone} from "../Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone";
|
|
2
|
+
|
|
1
3
|
export type FunctionResult<T> = {
|
|
2
4
|
result: T | T[] | boolean;
|
|
3
5
|
error: any;
|
|
@@ -7,10 +9,12 @@ export type ProxyConfig = {
|
|
|
7
9
|
api: string;
|
|
8
10
|
servername: string;
|
|
9
11
|
port: string;
|
|
10
|
-
sessionToken: string;
|
|
11
12
|
};
|
|
12
13
|
export interface WidgetConfig {
|
|
14
|
+
organizationName: string;
|
|
15
|
+
openAIModel: string;
|
|
13
16
|
apiKey: string;
|
|
17
|
+
maxTokens: number;
|
|
14
18
|
useDefault: boolean;
|
|
15
19
|
proxyConfig: ProxyConfig;
|
|
16
20
|
}
|
|
@@ -22,6 +26,7 @@ export interface AITranslateWidgetConfig extends WidgetConfig {
|
|
|
22
26
|
|
|
23
27
|
export interface AIRephraseWidgetConfig extends WidgetConfig {
|
|
24
28
|
defaultTone: string;
|
|
29
|
+
Tones: Tone[];
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
export interface QBConfig {
|
|
@@ -9,6 +9,7 @@ const supportedLanguagesForIATranslate: string[] = [
|
|
|
9
9
|
'German',
|
|
10
10
|
];
|
|
11
11
|
|
|
12
|
+
// ["en-US", "zh-CN", "ja-JP"]
|
|
12
13
|
const languageBCP47: Record<string, string> = {
|
|
13
14
|
'ar-SA': 'Arabic',
|
|
14
15
|
'bn-BD': 'Bangla',
|
|
@@ -80,15 +81,17 @@ export class DefaultConfigurations {
|
|
|
80
81
|
api: 'v1/chat/completions',
|
|
81
82
|
servername: 'https://api.openai.com',
|
|
82
83
|
port: '',
|
|
83
|
-
sessionToken: '',
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
static getDefaultLanguageForAITranslate(
|
|
87
|
+
static getDefaultLanguageForAITranslate(
|
|
88
|
+
configAITranslate: AITranslateWidgetConfig,
|
|
89
|
+
): string {
|
|
88
90
|
let languageForAITranslate = 'English';
|
|
89
|
-
const
|
|
91
|
+
const defaultLanguage: string =
|
|
92
|
+
configAITranslate.defaultLanguage ||
|
|
90
93
|
DefaultConfigurations.getDefaultQBConfig().configAIApi
|
|
91
|
-
.AITranslateWidgetConfig;
|
|
94
|
+
.AITranslateWidgetConfig.defaultLanguage;
|
|
92
95
|
|
|
93
96
|
if (
|
|
94
97
|
defaultLanguage.length > 0 &&
|
|
@@ -106,11 +109,14 @@ export class DefaultConfigurations {
|
|
|
106
109
|
return languageForAITranslate;
|
|
107
110
|
}
|
|
108
111
|
|
|
109
|
-
static getAdditionalLanguagesForAITranslate(
|
|
112
|
+
static getAdditionalLanguagesForAITranslate(
|
|
113
|
+
configAITranslate: AITranslateWidgetConfig,
|
|
114
|
+
): string[] {
|
|
110
115
|
const additionalLanguages: string[] = [];
|
|
111
|
-
const
|
|
116
|
+
const languages: string[] =
|
|
117
|
+
configAITranslate.languages ||
|
|
112
118
|
DefaultConfigurations.getDefaultQBConfig().configAIApi
|
|
113
|
-
.AITranslateWidgetConfig;
|
|
119
|
+
.AITranslateWidgetConfig.languages;
|
|
114
120
|
|
|
115
121
|
languages.forEach((item) => {
|
|
116
122
|
if (supportedLanguagesForIATranslate.includes(item)) {
|
|
@@ -135,43 +141,109 @@ export class DefaultConfigurations {
|
|
|
135
141
|
},
|
|
136
142
|
configAIApi: {
|
|
137
143
|
AIAnswerAssistWidgetConfig: {
|
|
144
|
+
organizationName: 'Quickblox',
|
|
145
|
+
openAIModel: 'gpt-3.5-turbo',
|
|
138
146
|
apiKey: '',
|
|
147
|
+
maxTokens: 3584,
|
|
139
148
|
useDefault: true,
|
|
140
149
|
proxyConfig: {
|
|
141
150
|
api: 'v1/chat/completions',
|
|
142
151
|
servername: 'https://api.openai.com/',
|
|
143
152
|
port: '',
|
|
144
|
-
sessionToken: '',
|
|
145
153
|
},
|
|
146
154
|
},
|
|
147
155
|
AITranslateWidgetConfig: {
|
|
156
|
+
organizationName: 'Quickblox',
|
|
157
|
+
openAIModel: 'gpt-3.5-turbo',
|
|
148
158
|
apiKey: '',
|
|
159
|
+
maxTokens: 3584,
|
|
149
160
|
useDefault: true,
|
|
150
161
|
defaultLanguage: 'English',
|
|
151
|
-
languages: [
|
|
152
|
-
'English',
|
|
153
|
-
'Spanish',
|
|
154
|
-
'French',
|
|
155
|
-
'Portuguese',
|
|
156
|
-
'German',
|
|
157
|
-
'Ukrainian',
|
|
158
|
-
],
|
|
162
|
+
languages: ['English', 'French', 'Portuguese', 'German', 'Ukrainian'],
|
|
159
163
|
proxyConfig: {
|
|
160
164
|
api: 'v1/chat/completions',
|
|
161
|
-
servername: '
|
|
165
|
+
servername: '',
|
|
162
166
|
port: '',
|
|
163
|
-
sessionToken: '',
|
|
164
167
|
},
|
|
168
|
+
// proxyConfig: {
|
|
169
|
+
// api: 'v1/chat/completions',
|
|
170
|
+
// servername: 'http://localhost',
|
|
171
|
+
// port: '3012',
|
|
172
|
+
// },
|
|
165
173
|
},
|
|
166
174
|
AIRephraseWidgetConfig: {
|
|
175
|
+
organizationName: 'Quickblox',
|
|
176
|
+
openAIModel: 'gpt-3.5-turbo',
|
|
167
177
|
apiKey: '',
|
|
178
|
+
maxTokens: 3584,
|
|
168
179
|
useDefault: true,
|
|
169
180
|
defaultTone: 'Professional',
|
|
181
|
+
Tones: [
|
|
182
|
+
{
|
|
183
|
+
name: 'Professional Tone',
|
|
184
|
+
description:
|
|
185
|
+
'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',
|
|
186
|
+
iconEmoji: '👔',
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
name: 'Friendly Tone',
|
|
190
|
+
description:
|
|
191
|
+
'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.',
|
|
192
|
+
iconEmoji: '🤝',
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
name: 'Encouraging Tone',
|
|
196
|
+
description:
|
|
197
|
+
'This tone would be useful for motivation and encouragement. It would include positive words, affirmations, and express support and belief in the recipient.',
|
|
198
|
+
iconEmoji: '💪',
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
name: 'Empathetic Tone',
|
|
202
|
+
description:
|
|
203
|
+
'This tone would be utilized to display understanding and empathy. It would involve softer language, acknowledging feelings, and demonstrating compassion and support.',
|
|
204
|
+
iconEmoji: '🤲',
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: 'Neutral Tone',
|
|
208
|
+
description:
|
|
209
|
+
'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.',
|
|
210
|
+
iconEmoji: '😐',
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
name: 'Assertive Tone',
|
|
214
|
+
description:
|
|
215
|
+
'This tone is beneficial for making clear points, standing ground, or in negotiations. It uses direct language, is confident, and does not mince words.',
|
|
216
|
+
iconEmoji: '🔨',
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
name: 'Instructive Tone',
|
|
220
|
+
description:
|
|
221
|
+
'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.',
|
|
222
|
+
iconEmoji: '📖',
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
name: 'Persuasive Tone',
|
|
226
|
+
description:
|
|
227
|
+
'This tone can be used when trying to convince someone or argue a point. It uses persuasive language, powerful words, and logical reasoning.',
|
|
228
|
+
iconEmoji: '☝️',
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
name: 'Sarcastic/Ironic Tone',
|
|
232
|
+
description:
|
|
233
|
+
'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.',
|
|
234
|
+
iconEmoji: '😏',
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
name: 'Poetic Tone',
|
|
238
|
+
description:
|
|
239
|
+
'This would add an artistic touch to messages, using figurative language, rhymes, and rhythm to create a more expressive text.',
|
|
240
|
+
iconEmoji: '🎭',
|
|
241
|
+
},
|
|
242
|
+
],
|
|
170
243
|
proxyConfig: {
|
|
171
244
|
api: 'v1/chat/completions',
|
|
172
245
|
servername: 'https://api.openai.com/',
|
|
173
246
|
port: '',
|
|
174
|
-
sessionToken: '',
|
|
175
247
|
},
|
|
176
248
|
},
|
|
177
249
|
},
|
|
@@ -190,6 +262,70 @@ export class DefaultConfigurations {
|
|
|
190
262
|
enable: true,
|
|
191
263
|
},
|
|
192
264
|
},
|
|
265
|
+
// credentials: {
|
|
266
|
+
// appId: -1,
|
|
267
|
+
// accountKey: '',
|
|
268
|
+
// authKey: '',
|
|
269
|
+
// authSecret: '',
|
|
270
|
+
// sessionToken: '',
|
|
271
|
+
// },
|
|
272
|
+
// configAIApi: {
|
|
273
|
+
// AIAnswerAssistWidgetConfig: {
|
|
274
|
+
// apiKey: '',
|
|
275
|
+
// useDefault: true,
|
|
276
|
+
// proxyConfig: {
|
|
277
|
+
// api: 'v1/chat/completions',
|
|
278
|
+
// servername: 'https://api.openai.com/',
|
|
279
|
+
// port: '',
|
|
280
|
+
// sessionToken: '',
|
|
281
|
+
// },
|
|
282
|
+
// },
|
|
283
|
+
// AITranslateWidgetConfig: {
|
|
284
|
+
// apiKey: '',
|
|
285
|
+
// useDefault: true,
|
|
286
|
+
// defaultLanguage: 'English',
|
|
287
|
+
// languages: [
|
|
288
|
+
// 'English',
|
|
289
|
+
// 'Spanish',
|
|
290
|
+
// 'French',
|
|
291
|
+
// 'Portuguese',
|
|
292
|
+
// 'German',
|
|
293
|
+
// 'Ukrainian',
|
|
294
|
+
// ],
|
|
295
|
+
// proxyConfig: {
|
|
296
|
+
// api: 'v1/chat/completions',
|
|
297
|
+
// servername: 'https://api.openai.com/',
|
|
298
|
+
// port: '',
|
|
299
|
+
// sessionToken: '',
|
|
300
|
+
// },
|
|
301
|
+
// },
|
|
302
|
+
// AIRephraseWidgetConfig: {
|
|
303
|
+
// apiKey: '',
|
|
304
|
+
// useDefault: true,
|
|
305
|
+
// defaultTone: 'Professional',
|
|
306
|
+
// proxyConfig: {
|
|
307
|
+
// api: 'v1/chat/completions',
|
|
308
|
+
// servername: 'https://api.openai.com/',
|
|
309
|
+
// port: '',
|
|
310
|
+
// sessionToken: '',
|
|
311
|
+
// },
|
|
312
|
+
// },
|
|
313
|
+
// },
|
|
314
|
+
// appConfig: {
|
|
315
|
+
// maxFileSize: 10 * 1024 * 1024,
|
|
316
|
+
// sessionTimeOut: 122,
|
|
317
|
+
// chatProtocol: {
|
|
318
|
+
// active: 2,
|
|
319
|
+
// },
|
|
320
|
+
// debug: true,
|
|
321
|
+
// endpoints: {
|
|
322
|
+
// api: 'api.quickblox.com',
|
|
323
|
+
// chat: 'chat.quickblox.com',
|
|
324
|
+
// },
|
|
325
|
+
// streamManagement: {
|
|
326
|
+
// enable: true,
|
|
327
|
+
// },
|
|
328
|
+
// },
|
|
193
329
|
};
|
|
194
330
|
}
|
|
195
331
|
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// eslint-disable-next-line import/extensions
|
|
2
|
+
import { QBAIAnswerAssistant } from 'qb-ai-answer-assistant';
|
|
3
|
+
import { IChatMessage } from '../../../Data/source/AISource';
|
|
4
|
+
import { IUseCase } from '../base/IUseCase';
|
|
5
|
+
|
|
6
|
+
export class AIAnswerAssistUseCase implements IUseCase<void, string> {
|
|
7
|
+
private textToSend: string;
|
|
8
|
+
|
|
9
|
+
private dialogMessages: IChatMessage[];
|
|
10
|
+
|
|
11
|
+
private servername: string;
|
|
12
|
+
|
|
13
|
+
private api: string;
|
|
14
|
+
|
|
15
|
+
private port: string;
|
|
16
|
+
|
|
17
|
+
private sessionToken: string;
|
|
18
|
+
|
|
19
|
+
private openAIModel: string;
|
|
20
|
+
|
|
21
|
+
constructor(
|
|
22
|
+
textToSend: string,
|
|
23
|
+
dialogMessages: IChatMessage[],
|
|
24
|
+
servername: string,
|
|
25
|
+
api: string,
|
|
26
|
+
port: string,
|
|
27
|
+
sessionToken: string,
|
|
28
|
+
openAIModel = 'gpt-3.5-turbo',
|
|
29
|
+
) {
|
|
30
|
+
console.log('CONSTRUCTOR AIRephraseUseCase');
|
|
31
|
+
this.api = api;
|
|
32
|
+
this.openAIModel = openAIModel;
|
|
33
|
+
this.port = port;
|
|
34
|
+
this.sessionToken = sessionToken;
|
|
35
|
+
this.textToSend = textToSend;
|
|
36
|
+
this.servername = servername;
|
|
37
|
+
this.dialogMessages = dialogMessages;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async execute(): Promise<string> {
|
|
41
|
+
console.log('execute AIRephraseUseCase');
|
|
42
|
+
const settings =
|
|
43
|
+
QBAIAnswerAssistant.createDefaultAIAnswerAssistantSettings();
|
|
44
|
+
|
|
45
|
+
settings.apiKey = this.sessionToken;
|
|
46
|
+
// settings.organization = 'Quickblox';
|
|
47
|
+
settings.model = this.openAIModel;
|
|
48
|
+
|
|
49
|
+
return QBAIAnswerAssistant.createAnswer(
|
|
50
|
+
this.textToSend,
|
|
51
|
+
this.dialogMessages,
|
|
52
|
+
settings,
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
// const prompt = AIUtils.createAnswerAssistPrompt(this.textToSend);
|
|
56
|
+
//
|
|
57
|
+
// //
|
|
58
|
+
// return AISource.getData(
|
|
59
|
+
// prompt,
|
|
60
|
+
// // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
61
|
+
// this.dialogMessages,
|
|
62
|
+
// this.servername,
|
|
63
|
+
// this.api,
|
|
64
|
+
// this.port,
|
|
65
|
+
// this.sessionToken,
|
|
66
|
+
// this.openAIModel,
|
|
67
|
+
// );
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// eslint-disable-next-line import/extensions
|
|
2
|
+
import { QBAIAnswerAssistant } from 'qb-ai-answer-assistant';
|
|
3
|
+
import { IChatMessage } from '../../../Data/source/AISource';
|
|
4
|
+
import { IUseCase } from '../base/IUseCase';
|
|
5
|
+
|
|
6
|
+
export class AIAnswerAssistWithProxyUseCase implements IUseCase<void, string> {
|
|
7
|
+
private textToSend: string;
|
|
8
|
+
|
|
9
|
+
private dialogMessages: IChatMessage[];
|
|
10
|
+
|
|
11
|
+
private servername: string;
|
|
12
|
+
|
|
13
|
+
private api: string;
|
|
14
|
+
|
|
15
|
+
private port: string;
|
|
16
|
+
|
|
17
|
+
private sessionToken: string;
|
|
18
|
+
|
|
19
|
+
private openAIModel: string;
|
|
20
|
+
|
|
21
|
+
constructor(
|
|
22
|
+
textToSend: string,
|
|
23
|
+
dialogMessages: IChatMessage[],
|
|
24
|
+
servername: string,
|
|
25
|
+
api: string,
|
|
26
|
+
port: string,
|
|
27
|
+
sessionToken: string,
|
|
28
|
+
openAIModel = 'gpt-3.5-turbo',
|
|
29
|
+
) {
|
|
30
|
+
console.log('CONSTRUCTOR AIRephraseUseCase');
|
|
31
|
+
this.api = api;
|
|
32
|
+
this.openAIModel = openAIModel;
|
|
33
|
+
this.port = port;
|
|
34
|
+
this.sessionToken = sessionToken;
|
|
35
|
+
this.textToSend = textToSend;
|
|
36
|
+
this.servername = servername;
|
|
37
|
+
this.dialogMessages = dialogMessages;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async execute(): Promise<string> {
|
|
41
|
+
console.log('execute AIRephraseUseCase');
|
|
42
|
+
|
|
43
|
+
const settings =
|
|
44
|
+
QBAIAnswerAssistant.createDefaultAIAnswerAssistantSettings();
|
|
45
|
+
|
|
46
|
+
settings.token = this.sessionToken;
|
|
47
|
+
// settings.organization = 'Quickblox';
|
|
48
|
+
settings.model = this.openAIModel;
|
|
49
|
+
settings.serverPath = `${this.servername}:${this.port}/${this.api}`;
|
|
50
|
+
|
|
51
|
+
return QBAIAnswerAssistant.createAnswer(
|
|
52
|
+
this.textToSend,
|
|
53
|
+
this.dialogMessages,
|
|
54
|
+
settings,
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
// const prompt = AIUtils.createAnswerAssistPrompt(this.textToSend);
|
|
58
|
+
//
|
|
59
|
+
// //
|
|
60
|
+
// return AISource.getDataWithProxyServer(
|
|
61
|
+
// prompt,
|
|
62
|
+
// // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
63
|
+
// this.dialogMessages,
|
|
64
|
+
// this.servername,
|
|
65
|
+
// this.api,
|
|
66
|
+
// this.port,
|
|
67
|
+
// this.sessionToken,
|
|
68
|
+
// this.openAIModel,
|
|
69
|
+
// );
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
// eslint-disable-next-line import/extensions
|
|
2
|
-
import {
|
|
2
|
+
import { QBAIRephrase } from 'qb-ai-rephrase';
|
|
3
|
+
import { IChatMessage } from '../../../Data/source/AISource';
|
|
3
4
|
import { IUseCase } from '../base/IUseCase';
|
|
4
|
-
import {
|
|
5
|
-
Tone,
|
|
6
|
-
toneToString,
|
|
7
|
-
} from '../../../Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone';
|
|
5
|
+
import { Tone } from '../../../Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone';
|
|
8
6
|
|
|
9
7
|
export class AIRephraseUseCase implements IUseCase<void, string> {
|
|
10
8
|
private textToSend: string;
|
|
@@ -47,41 +45,45 @@ export class AIRephraseUseCase implements IUseCase<void, string> {
|
|
|
47
45
|
async execute(): Promise<string> {
|
|
48
46
|
console.log('execute AIRephraseUseCase');
|
|
49
47
|
|
|
50
|
-
|
|
48
|
+
const settings = QBAIRephrase.createDefaultAIRephraseSettings();
|
|
51
49
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
this.textToSend
|
|
57
|
-
}"`;
|
|
58
|
-
}
|
|
59
|
-
//
|
|
50
|
+
settings.apiKey = this.sessionToken;
|
|
51
|
+
// settings.organization = 'Quickblox';
|
|
52
|
+
settings.model = this.openAIModel;
|
|
53
|
+
settings.tone = this.tone;
|
|
60
54
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// api,
|
|
67
|
-
// port,
|
|
68
|
-
// apiKeyOrSessionToken,
|
|
69
|
-
// ).then((data) => {
|
|
70
|
-
// setTextFromWidgetToContent(data);
|
|
71
|
-
//
|
|
72
|
-
// return data;
|
|
73
|
-
// });
|
|
55
|
+
return QBAIRephrase.rephrase(
|
|
56
|
+
this.textToSend,
|
|
57
|
+
this.dialogMessages,
|
|
58
|
+
settings,
|
|
59
|
+
);
|
|
74
60
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
61
|
+
/*
|
|
62
|
+
const settings: AITranslateSettings =
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
64
|
+
QBAITranslate.createDefaultAITranslateSettings();
|
|
65
|
+
|
|
66
|
+
settings.apiKey = this.sessionToken;
|
|
67
|
+
settings.language = this.language;
|
|
68
|
+
|
|
69
|
+
return QBAITranslate.translate(
|
|
70
|
+
this.textToSend,
|
|
79
71
|
this.dialogMessages,
|
|
80
|
-
|
|
81
|
-
this.api,
|
|
82
|
-
this.port,
|
|
83
|
-
this.sessionToken,
|
|
84
|
-
this.openAIModel,
|
|
72
|
+
settings,
|
|
85
73
|
);
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
// const prompt = AIUtils.createRephrasePrompt(this.textToSend, this.tone);
|
|
77
|
+
//
|
|
78
|
+
// return AISource.getData(
|
|
79
|
+
// prompt,
|
|
80
|
+
// // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
81
|
+
// this.dialogMessages,
|
|
82
|
+
// this.servername,
|
|
83
|
+
// this.api,
|
|
84
|
+
// this.port,
|
|
85
|
+
// this.sessionToken,
|
|
86
|
+
// this.openAIModel,
|
|
87
|
+
// );
|
|
86
88
|
}
|
|
87
89
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
// eslint-disable-next-line import/extensions
|
|
2
|
-
import {
|
|
2
|
+
import { QBAIRephrase } from 'qb-ai-rephrase';
|
|
3
|
+
import { IChatMessage } from '../../../Data/source/AISource';
|
|
3
4
|
import { IUseCase } from '../base/IUseCase';
|
|
4
|
-
import {
|
|
5
|
-
Tone,
|
|
6
|
-
toneToString,
|
|
7
|
-
} from '../../../Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone';
|
|
5
|
+
import { Tone } from '../../../Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone';
|
|
8
6
|
|
|
9
7
|
export class AIRephraseWithProxyUseCase implements IUseCase<void, string> {
|
|
10
8
|
private textToSend: string;
|
|
@@ -47,25 +45,31 @@ export class AIRephraseWithProxyUseCase implements IUseCase<void, string> {
|
|
|
47
45
|
async execute(): Promise<string> {
|
|
48
46
|
console.log('execute AIRephraseUseCase');
|
|
49
47
|
|
|
50
|
-
|
|
48
|
+
const settings = QBAIRephrase.createDefaultAIRephraseSettings();
|
|
51
49
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}"`;
|
|
58
|
-
}
|
|
50
|
+
settings.token = this.sessionToken;
|
|
51
|
+
// settings.organization = 'Quickblox';
|
|
52
|
+
settings.model = this.openAIModel;
|
|
53
|
+
settings.tone = this.tone;
|
|
54
|
+
settings.serverPath = `${this.servername}:${this.port}/${this.api}`;
|
|
59
55
|
|
|
60
|
-
return
|
|
61
|
-
|
|
62
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
56
|
+
return QBAIRephrase.rephrase(
|
|
57
|
+
this.textToSend,
|
|
63
58
|
this.dialogMessages,
|
|
64
|
-
|
|
65
|
-
this.api,
|
|
66
|
-
this.port,
|
|
67
|
-
this.sessionToken,
|
|
68
|
-
this.openAIModel,
|
|
59
|
+
settings,
|
|
69
60
|
);
|
|
61
|
+
|
|
62
|
+
// const prompt = AIUtils.createRephrasePrompt(this.textToSend, this.tone);
|
|
63
|
+
//
|
|
64
|
+
// return AISource.getDataWithProxyServer(
|
|
65
|
+
// prompt,
|
|
66
|
+
// // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
67
|
+
// this.dialogMessages,
|
|
68
|
+
// this.servername,
|
|
69
|
+
// this.api,
|
|
70
|
+
// this.port,
|
|
71
|
+
// this.sessionToken,
|
|
72
|
+
// this.openAIModel,
|
|
73
|
+
// );
|
|
70
74
|
}
|
|
71
75
|
}
|