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/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: '
|
|
16
|
-
port: '
|
|
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: '
|
|
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: '
|
|
35
|
-
port: '
|
|
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: '
|
|
46
|
-
port: '
|
|
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.
|
|
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.
|
|
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",
|
package/src/utils/utils.ts
CHANGED
|
@@ -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
|
+
}
|