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.
- package/dist/CommonTypes/FunctionResult.d.ts +5 -1
- package/dist/Data/DefaultConfigurations.d.ts +2 -2
- package/dist/Data/source/remote/Mapper/MessageDTOMapper.d.ts +3 -1
- 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/AIRephraseUseCase.d.ts +15 -0
- package/dist/Domain/use_cases/ai/AIRephraseWithProxyUseCase.d.ts +15 -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 +10 -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/AIWidgets/UseDefaultAIAssistAnswerWidget.d.ts +2 -10
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidgetWithProxy.d.ts +2 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidget.d.ts +2 -10
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidgetWithProxy.d.ts +2 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidget.d.ts +2 -10
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidgetWithProxy.d.ts +2 -0
- 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 +384 -35
- package/dist/utils/utils.d.ts +9 -0
- package/global.d.ts +12 -4
- package/package.json +5 -1
- package/src/App.tsx +3 -1
- package/src/CommonTypes/FunctionResult.ts +6 -1
- package/src/Data/DefaultConfigurations.ts +155 -19
- package/src/Data/source/remote/Mapper/DialogDTOMapper.ts +3 -0
- package/src/Data/source/remote/Mapper/MessageDTOMapper.ts +55 -2
- package/src/Data/source/remote/RemoteDataSource.ts +2 -1
- 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 +89 -0
- package/src/Domain/use_cases/ai/AIRephraseWithProxyUseCase.ts +75 -0
- 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 +2 -2
- package/src/Presentation/Views/Dialogs/useDialogsViewModel.ts +4 -1
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIMessageWidget.ts +18 -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 +24 -40
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidgetWithProxy.tsx +83 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidget.tsx +40 -41
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidgetWithProxy.tsx +102 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidget.tsx +27 -44
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidgetWithProxy.tsx +89 -0
- 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 +578 -415
- package/src/Presentation/components/UI/Dialogs/MessagesView/VideoAttachmentComponent/VideoAttachmentComponent.scss +6 -2
- package/src/Presentation/components/UI/Dialogs/MessagesView/useMessagesViewModel.ts +13 -3
- 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 +41 -42
- package/src/Presentation/components/providers/QuickBloxUIKitProvider/QuickBloxUIKitProvider.tsx +1 -1
- 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
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// eslint-disable-next-line import/extensions
|
|
2
|
+
import { QBAIRephrase } from 'qb-ai-rephrase';
|
|
3
|
+
import { IChatMessage } from '../../../Data/source/AISource';
|
|
4
|
+
import { IUseCase } from '../base/IUseCase';
|
|
5
|
+
import { Tone } from '../../../Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone';
|
|
6
|
+
|
|
7
|
+
export class AIRephraseUseCase implements IUseCase<void, string> {
|
|
8
|
+
private textToSend: string;
|
|
9
|
+
|
|
10
|
+
private tone: Tone;
|
|
11
|
+
|
|
12
|
+
private dialogMessages: IChatMessage[];
|
|
13
|
+
|
|
14
|
+
private servername: string;
|
|
15
|
+
|
|
16
|
+
private api: string;
|
|
17
|
+
|
|
18
|
+
private port: string;
|
|
19
|
+
|
|
20
|
+
private sessionToken: string;
|
|
21
|
+
|
|
22
|
+
private openAIModel: string;
|
|
23
|
+
|
|
24
|
+
constructor(
|
|
25
|
+
textToSend: string,
|
|
26
|
+
tone: Tone,
|
|
27
|
+
dialogMessages: IChatMessage[],
|
|
28
|
+
servername: string,
|
|
29
|
+
api: string,
|
|
30
|
+
port: string,
|
|
31
|
+
sessionToken: string,
|
|
32
|
+
openAIModel = 'gpt-3.5-turbo',
|
|
33
|
+
) {
|
|
34
|
+
console.log('CONSTRUCTOR AIRephraseUseCase');
|
|
35
|
+
this.api = api;
|
|
36
|
+
this.openAIModel = openAIModel;
|
|
37
|
+
this.port = port;
|
|
38
|
+
this.sessionToken = sessionToken;
|
|
39
|
+
this.textToSend = textToSend;
|
|
40
|
+
this.tone = tone;
|
|
41
|
+
this.servername = servername;
|
|
42
|
+
this.dialogMessages = dialogMessages;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async execute(): Promise<string> {
|
|
46
|
+
console.log('execute AIRephraseUseCase');
|
|
47
|
+
|
|
48
|
+
const settings = QBAIRephrase.createDefaultAIRephraseSettings();
|
|
49
|
+
|
|
50
|
+
settings.apiKey = this.sessionToken;
|
|
51
|
+
// settings.organization = 'Quickblox';
|
|
52
|
+
settings.model = this.openAIModel;
|
|
53
|
+
settings.tone = this.tone;
|
|
54
|
+
|
|
55
|
+
return QBAIRephrase.rephrase(
|
|
56
|
+
this.textToSend,
|
|
57
|
+
this.dialogMessages,
|
|
58
|
+
settings,
|
|
59
|
+
);
|
|
60
|
+
|
|
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,
|
|
71
|
+
this.dialogMessages,
|
|
72
|
+
settings,
|
|
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
|
+
// );
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// eslint-disable-next-line import/extensions
|
|
2
|
+
import { QBAIRephrase } from 'qb-ai-rephrase';
|
|
3
|
+
import { IChatMessage } from '../../../Data/source/AISource';
|
|
4
|
+
import { IUseCase } from '../base/IUseCase';
|
|
5
|
+
import { Tone } from '../../../Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone';
|
|
6
|
+
|
|
7
|
+
export class AIRephraseWithProxyUseCase implements IUseCase<void, string> {
|
|
8
|
+
private textToSend: string;
|
|
9
|
+
|
|
10
|
+
private tone: Tone;
|
|
11
|
+
|
|
12
|
+
private dialogMessages: IChatMessage[];
|
|
13
|
+
|
|
14
|
+
private servername: string;
|
|
15
|
+
|
|
16
|
+
private api: string;
|
|
17
|
+
|
|
18
|
+
private port: string;
|
|
19
|
+
|
|
20
|
+
private sessionToken: string;
|
|
21
|
+
|
|
22
|
+
private openAIModel: string;
|
|
23
|
+
|
|
24
|
+
constructor(
|
|
25
|
+
textToSend: string,
|
|
26
|
+
tone: Tone,
|
|
27
|
+
dialogMessages: IChatMessage[],
|
|
28
|
+
servername: string,
|
|
29
|
+
api: string,
|
|
30
|
+
port: string,
|
|
31
|
+
sessionToken: string,
|
|
32
|
+
openAIModel = 'gpt-3.5-turbo',
|
|
33
|
+
) {
|
|
34
|
+
console.log('CONSTRUCTOR AIRephraseUseCase');
|
|
35
|
+
this.api = api;
|
|
36
|
+
this.openAIModel = openAIModel;
|
|
37
|
+
this.port = port;
|
|
38
|
+
this.sessionToken = sessionToken;
|
|
39
|
+
this.textToSend = textToSend;
|
|
40
|
+
this.tone = tone;
|
|
41
|
+
this.servername = servername;
|
|
42
|
+
this.dialogMessages = dialogMessages;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async execute(): Promise<string> {
|
|
46
|
+
console.log('execute AIRephraseUseCase');
|
|
47
|
+
|
|
48
|
+
const settings = QBAIRephrase.createDefaultAIRephraseSettings();
|
|
49
|
+
|
|
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}`;
|
|
55
|
+
|
|
56
|
+
return QBAIRephrase.rephrase(
|
|
57
|
+
this.textToSend,
|
|
58
|
+
this.dialogMessages,
|
|
59
|
+
settings,
|
|
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
|
+
// );
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { AITranslateSettings, QBAITranslate } from 'qb-ai-translate';
|
|
2
|
+
import { IChatMessage } from '../../../Data/source/AISource';
|
|
3
|
+
import { IUseCase } from '../base/IUseCase';
|
|
4
|
+
|
|
5
|
+
export class AITranslateUseCase implements IUseCase<void, string> {
|
|
6
|
+
private textToSend: string;
|
|
7
|
+
|
|
8
|
+
private language: string;
|
|
9
|
+
|
|
10
|
+
private dialogMessages: IChatMessage[];
|
|
11
|
+
|
|
12
|
+
private servername: string;
|
|
13
|
+
|
|
14
|
+
private api: string;
|
|
15
|
+
|
|
16
|
+
private port: string;
|
|
17
|
+
|
|
18
|
+
private sessionToken: string;
|
|
19
|
+
|
|
20
|
+
private openAIModel: string;
|
|
21
|
+
|
|
22
|
+
constructor(
|
|
23
|
+
textToSend: string,
|
|
24
|
+
language: string,
|
|
25
|
+
dialogMessages: IChatMessage[],
|
|
26
|
+
servername: string,
|
|
27
|
+
api: string,
|
|
28
|
+
port: string,
|
|
29
|
+
sessionToken: string,
|
|
30
|
+
openAIModel = 'gpt-3.5-turbo',
|
|
31
|
+
) {
|
|
32
|
+
console.log('CONSTRUCTOR AIRephraseUseCase');
|
|
33
|
+
this.api = api;
|
|
34
|
+
this.openAIModel = openAIModel;
|
|
35
|
+
this.port = port;
|
|
36
|
+
this.sessionToken = sessionToken;
|
|
37
|
+
this.textToSend = textToSend;
|
|
38
|
+
this.language = language;
|
|
39
|
+
this.servername = servername;
|
|
40
|
+
this.dialogMessages = dialogMessages;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async execute(): Promise<string> {
|
|
44
|
+
console.log('execute AIRephraseUseCase');
|
|
45
|
+
const settings: AITranslateSettings =
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
47
|
+
QBAITranslate.createDefaultAITranslateSettings();
|
|
48
|
+
|
|
49
|
+
settings.apiKey = this.sessionToken;
|
|
50
|
+
// settings.organization = 'Quickblox';
|
|
51
|
+
settings.model = this.openAIModel;
|
|
52
|
+
settings.language = this.language;
|
|
53
|
+
|
|
54
|
+
return QBAITranslate.translate(
|
|
55
|
+
this.textToSend,
|
|
56
|
+
this.dialogMessages,
|
|
57
|
+
settings,
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
// const prompt = AIUtils.createTranslatePrompt(
|
|
61
|
+
// this.textToSend,
|
|
62
|
+
// this.language,
|
|
63
|
+
// );
|
|
64
|
+
//
|
|
65
|
+
// return AISource.getData(
|
|
66
|
+
// prompt,
|
|
67
|
+
// // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
68
|
+
// this.dialogMessages,
|
|
69
|
+
// this.servername,
|
|
70
|
+
// this.api,
|
|
71
|
+
// this.port,
|
|
72
|
+
// this.sessionToken,
|
|
73
|
+
// this.openAIModel,
|
|
74
|
+
// );
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// eslint-disable-next-line import/extensions
|
|
2
|
+
import { AITranslateSettings, QBAITranslate } from 'qb-ai-translate';
|
|
3
|
+
import { IChatMessage } from '../../../Data/source/AISource';
|
|
4
|
+
import { IUseCase } from '../base/IUseCase';
|
|
5
|
+
|
|
6
|
+
export class AITranslateWithProxyUseCase implements IUseCase<void, string> {
|
|
7
|
+
private textToSend: string;
|
|
8
|
+
|
|
9
|
+
private language: string;
|
|
10
|
+
|
|
11
|
+
private dialogMessages: IChatMessage[];
|
|
12
|
+
|
|
13
|
+
private servername: string;
|
|
14
|
+
|
|
15
|
+
private api: string;
|
|
16
|
+
|
|
17
|
+
private port: string;
|
|
18
|
+
|
|
19
|
+
private sessionToken: string;
|
|
20
|
+
|
|
21
|
+
private openAIModel: string;
|
|
22
|
+
|
|
23
|
+
constructor(
|
|
24
|
+
textToSend: string,
|
|
25
|
+
language: string,
|
|
26
|
+
dialogMessages: IChatMessage[],
|
|
27
|
+
servername: string,
|
|
28
|
+
api: string,
|
|
29
|
+
port: string,
|
|
30
|
+
sessionToken: string,
|
|
31
|
+
openAIModel = 'gpt-3.5-turbo',
|
|
32
|
+
) {
|
|
33
|
+
console.log('CONSTRUCTOR AIRephraseUseCase');
|
|
34
|
+
this.api = api;
|
|
35
|
+
this.openAIModel = openAIModel;
|
|
36
|
+
this.port = port;
|
|
37
|
+
this.sessionToken = sessionToken;
|
|
38
|
+
this.textToSend = textToSend;
|
|
39
|
+
this.language = language;
|
|
40
|
+
this.servername = servername;
|
|
41
|
+
this.dialogMessages = dialogMessages;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async execute(): Promise<string> {
|
|
45
|
+
console.log('execute AIRephraseUseCase');
|
|
46
|
+
|
|
47
|
+
const settings: AITranslateSettings =
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
49
|
+
QBAITranslate.createDefaultAITranslateSettings();
|
|
50
|
+
|
|
51
|
+
settings.token = this.sessionToken;
|
|
52
|
+
// settings.organization = 'Quickblox';
|
|
53
|
+
settings.model = this.openAIModel;
|
|
54
|
+
settings.language = this.language;
|
|
55
|
+
settings.serverPath = `${this.servername}:${this.port}/${this.api}`;
|
|
56
|
+
|
|
57
|
+
return QBAITranslate.translate(
|
|
58
|
+
this.textToSend,
|
|
59
|
+
this.dialogMessages,
|
|
60
|
+
settings,
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
// const prompt = AIUtils.createTranslatePrompt(
|
|
64
|
+
// this.textToSend,
|
|
65
|
+
// this.language,
|
|
66
|
+
// );
|
|
67
|
+
//
|
|
68
|
+
// return AISource.getDataWithProxyServer(
|
|
69
|
+
// prompt,
|
|
70
|
+
// // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
71
|
+
// this.dialogMessages,
|
|
72
|
+
// this.servername,
|
|
73
|
+
// this.api,
|
|
74
|
+
// this.port,
|
|
75
|
+
// this.sessionToken,
|
|
76
|
+
// this.openAIModel,
|
|
77
|
+
// );
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -3,6 +3,7 @@ import { GroupDialogEntity } from '../../../Domain/entity/GroupDialogEntity';
|
|
|
3
3
|
import { DialogEntity } from '../../../Domain/entity/DialogEntity';
|
|
4
4
|
import { FileEntity } from '../../../Domain/entity/FileEntity';
|
|
5
5
|
import { IChatMessage } from '../../../Data/source/AISource';
|
|
6
|
+
import { Tone } from '../../components/UI/Dialogs/MessagesView/AIWidgets/Tone';
|
|
6
7
|
|
|
7
8
|
export default class BaseViewModel<TResult> {
|
|
8
9
|
get entity(): TResult {
|
|
@@ -86,3 +87,4 @@ export type FunctionTypeStringWithContextToString = (
|
|
|
86
87
|
context: IChatMessage[],
|
|
87
88
|
additionalSettings?: { [key: string]: any },
|
|
88
89
|
) => Promise<string>;
|
|
90
|
+
export type FunctionTypeVoidToTones = () => Tone[];
|
|
@@ -191,7 +191,7 @@ const DialogsComponent: React.FC<DialogsProps> = ({
|
|
|
191
191
|
if (Number.isNaN(dateInt)) {
|
|
192
192
|
return formattedValue;
|
|
193
193
|
}
|
|
194
|
-
formattedValue = getTimeShort24hFormat(dateInt);
|
|
194
|
+
formattedValue = getTimeShort24hFormat(dateInt * 1000);
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
return formattedValue;
|
|
@@ -213,7 +213,7 @@ const DialogsComponent: React.FC<DialogsProps> = ({
|
|
|
213
213
|
) {
|
|
214
214
|
const imagePhoto = (currentDialog.entity as GroupDialogEntity).photo;
|
|
215
215
|
|
|
216
|
-
console.log('Dialogs: avatar: ', imagePhoto || 'NO FOTO');
|
|
216
|
+
// console.log('Dialogs: avatar: ', imagePhoto || 'NO FOTO');
|
|
217
217
|
AvatarComponent = imagePhoto ? (
|
|
218
218
|
<img
|
|
219
219
|
style={{ width: '55px', height: '55px', borderRadius: '50%' }}
|
|
@@ -67,7 +67,10 @@ export default function useDialogsViewModel(
|
|
|
67
67
|
|
|
68
68
|
const dialogUpdateHandler = (dialogInfo: DialogEventInfo) => {
|
|
69
69
|
console.log('call dialogUpdateHandler in useDialogsViewModel');
|
|
70
|
-
if (
|
|
70
|
+
if (
|
|
71
|
+
dialogInfo.eventMessageType === EventMessageType.SystemMessage
|
|
72
|
+
// || dialogInfo.eventMessageType === EventMessageType.RegularMessage
|
|
73
|
+
) {
|
|
71
74
|
if (dialogInfo.notificationTypes === NotificationTypes.UPDATE_DIALOG) {
|
|
72
75
|
if (dialogInfo.messageInfo) {
|
|
73
76
|
const { dialogId } = dialogInfo.messageInfo;
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FunctionTypeFileWithContextToToVoid,
|
|
3
3
|
FunctionTypeJSXElement,
|
|
4
|
-
FunctionTypeStringWithContextToString,
|
|
4
|
+
FunctionTypeStringWithContextToString, FunctionTypeVoidToTones,
|
|
5
5
|
} from '../../../../../Views/Base/BaseViewModel';
|
|
6
|
+
import {Tone} from "./Tone";
|
|
7
|
+
|
|
8
|
+
export interface MessageWidgetProps {
|
|
9
|
+
// https://api.openai.com/v1/chat/completions'
|
|
10
|
+
// api: 'v1/chat/completions',
|
|
11
|
+
// servername: 'https://myproxy.com',
|
|
12
|
+
// https://func270519800.azurewebsites.net/api/TranslateTextToEng
|
|
13
|
+
servername: string;
|
|
14
|
+
api: string;
|
|
15
|
+
port: string;
|
|
16
|
+
apiKeyOrSessionToken: string;
|
|
17
|
+
}
|
|
6
18
|
|
|
7
19
|
export interface AIWidget {
|
|
8
20
|
renderWidget: FunctionTypeJSXElement;
|
|
@@ -18,7 +30,11 @@ export interface AIFileWidget extends AIWidget {
|
|
|
18
30
|
export interface AIMessageWidget extends AITextWidget {
|
|
19
31
|
textToWidget: FunctionTypeStringWithContextToString;
|
|
20
32
|
}
|
|
21
|
-
|
|
33
|
+
//
|
|
34
|
+
export interface AIRephraseWidget extends AIMessageWidget {
|
|
35
|
+
tonesToWidget: FunctionTypeVoidToTones;
|
|
36
|
+
}
|
|
37
|
+
//
|
|
22
38
|
export interface AIAttachmentWidget extends AIFileWidget {
|
|
23
39
|
fileToWidget: FunctionTypeFileWithContextToToVoid;
|
|
24
40
|
}
|
|
@@ -2,7 +2,7 @@ import React, { useState, CSSProperties, useRef, useEffect } from 'react';
|
|
|
2
2
|
import './AIWidgetActions.scss';
|
|
3
3
|
import EditDots from '../../../../svgs/Icons/Actions/EditDots';
|
|
4
4
|
|
|
5
|
-
type MenuItem = {
|
|
5
|
+
export type MenuItem = {
|
|
6
6
|
title: string;
|
|
7
7
|
icon?: JSX.Element; // Добавлено поле для иконки пункта меню
|
|
8
8
|
action: () => void;
|
|
@@ -12,6 +12,7 @@ type ContextMenuProps = {
|
|
|
12
12
|
widgetToRender?: JSX.Element;
|
|
13
13
|
items?: MenuItem[];
|
|
14
14
|
title?: string | null;
|
|
15
|
+
disabled?: boolean;
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
const ContextMenuStyles: { [key: string]: CSSProperties } = {
|
|
@@ -20,7 +21,7 @@ const ContextMenuStyles: { [key: string]: CSSProperties } = {
|
|
|
20
21
|
position: 'relative',
|
|
21
22
|
maxWidth: '42px',
|
|
22
23
|
maxHeight: '42px',
|
|
23
|
-
cursor: 'pointer',
|
|
24
|
+
// cursor: 'pointer',
|
|
24
25
|
},
|
|
25
26
|
contextMenuContent: {
|
|
26
27
|
position: 'absolute',
|
|
@@ -50,12 +51,13 @@ function AIWidgetActions({
|
|
|
50
51
|
items,
|
|
51
52
|
widgetToRender,
|
|
52
53
|
title = null,
|
|
54
|
+
disabled = true,
|
|
53
55
|
}: ContextMenuProps) {
|
|
54
56
|
const [menuVisible, setMenuVisible] = useState(false);
|
|
55
57
|
const contextMenuRef = useRef<HTMLDivElement | null>(null);
|
|
56
58
|
|
|
57
59
|
const handleClick = () => {
|
|
58
|
-
setMenuVisible(!menuVisible);
|
|
60
|
+
if (disabled) setMenuVisible(!menuVisible);
|
|
59
61
|
};
|
|
60
62
|
|
|
61
63
|
const handleMenuItemClick = (action: () => void) => {
|
|
@@ -85,7 +87,11 @@ function AIWidgetActions({
|
|
|
85
87
|
<div onClick={handleClick}>{widgetToRender || <EditDots />}</div>
|
|
86
88
|
{menuVisible && (
|
|
87
89
|
// <div ref={contextMenuRef} style={ContextMenuStyles.contextMenuContent}>
|
|
88
|
-
<div
|
|
90
|
+
<div
|
|
91
|
+
ref={contextMenuRef}
|
|
92
|
+
className="dropdown-context-menu-tone"
|
|
93
|
+
style={{ cursor: 'pointer' }}
|
|
94
|
+
>
|
|
89
95
|
{title && <div style={ContextMenuStyles.menuTitle}>{title}</div>}
|
|
90
96
|
{items?.map((item, index) => (
|
|
91
97
|
<div
|
|
@@ -1,21 +1,35 @@
|
|
|
1
|
-
export enum Tone {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
// export enum Tone {
|
|
2
|
+
// Professional = 'Professional Tone',
|
|
3
|
+
// Friendly = 'Friendly Tone',
|
|
4
|
+
// Encouraging = 'Encouraging Tone',
|
|
5
|
+
// Empathetic = 'Empathetic Tone',
|
|
6
|
+
// Neutral = 'Neutral Tone',
|
|
7
|
+
// Assertive = 'Assertive Tone',
|
|
8
|
+
// Instructive = 'Instructive Tone',
|
|
9
|
+
// Persuasive = 'Persuasive Tone',
|
|
10
|
+
// Sarcastic = 'Sarcastic/Ironic Tone',
|
|
11
|
+
// Poetic = 'Poetic Tone',
|
|
12
|
+
// Unchanged = 'Unchanged',
|
|
13
|
+
// }
|
|
14
|
+
|
|
15
|
+
export interface Tone {
|
|
16
|
+
name: string;
|
|
17
|
+
description: string;
|
|
18
|
+
iconEmoji: string;
|
|
13
19
|
}
|
|
14
20
|
|
|
15
21
|
export const toneToString = (tone: Tone): string => {
|
|
16
|
-
return tone;
|
|
22
|
+
return tone.name;
|
|
17
23
|
};
|
|
18
24
|
|
|
19
|
-
export const stringToTone = (
|
|
20
|
-
|
|
25
|
+
export const stringToTone = (
|
|
26
|
+
toneStr: string,
|
|
27
|
+
description?: string,
|
|
28
|
+
emoji?: string,
|
|
29
|
+
): Tone | undefined => {
|
|
30
|
+
return {
|
|
31
|
+
name: toneStr,
|
|
32
|
+
description: description || '',
|
|
33
|
+
iconEmoji: emoji || '',
|
|
34
|
+
};
|
|
21
35
|
};
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import { AIMessageWidget } from './AIMessageWidget';
|
|
2
|
+
import { AIMessageWidget, MessageWidgetProps } from './AIMessageWidget';
|
|
3
3
|
import AIWidgetIcon from '../../../svgs/Icons/AIWidgets/AIWidget';
|
|
4
4
|
import ErrorMessageIcon from './ErrorMessageIcon';
|
|
5
|
-
import {
|
|
5
|
+
import { IChatMessage } from '../../../../../../Data/source/AISource';
|
|
6
|
+
import { AIAnswerAssistUseCase } from '../../../../../../Domain/use_cases/ai/AIAnswerAssistUseCase';
|
|
6
7
|
|
|
7
|
-
interface MessageWidgetProps {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
8
|
+
// interface MessageWidgetProps {
|
|
9
|
+
// // https://api.openai.com/v1/chat/completions'
|
|
10
|
+
// // api: 'v1/chat/completions',
|
|
11
|
+
// // servername: 'https://myproxy.com',
|
|
12
|
+
// // https://func270519800.azurewebsites.net/api/TranslateTextToEng
|
|
13
|
+
// servername: string;
|
|
14
|
+
// api: string;
|
|
15
|
+
// port: string;
|
|
16
|
+
// apiKeyOrSessionToken: string;
|
|
17
|
+
// apiKey: string;
|
|
18
|
+
// }
|
|
18
19
|
export default function UseDefaultAIAssistAnswerWidget({
|
|
19
20
|
servername,
|
|
20
21
|
api,
|
|
21
22
|
port,
|
|
22
|
-
|
|
23
|
-
apiKey,
|
|
23
|
+
apiKeyOrSessionToken,
|
|
24
24
|
}: MessageWidgetProps): AIMessageWidget {
|
|
25
25
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
26
26
|
const [errorMessage, setErrorMessage] = useState<string>('');
|
|
@@ -51,41 +51,25 @@ export default function UseDefaultAIAssistAnswerWidget({
|
|
|
51
51
|
context: IChatMessage[],
|
|
52
52
|
): Promise<string> => {
|
|
53
53
|
if (textToSend && textToSend.length > 0) {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
if (apiKey.length > 0) {
|
|
57
|
-
// eslint-disable-next-line no-return-await
|
|
58
|
-
return await AISource.getData(
|
|
59
|
-
prompt,
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
61
|
-
context,
|
|
62
|
-
servername,
|
|
63
|
-
api,
|
|
64
|
-
port,
|
|
65
|
-
sessionToken,
|
|
66
|
-
).then((data) => {
|
|
67
|
-
setTextFromWidgetToContent(data);
|
|
68
|
-
|
|
69
|
-
return data;
|
|
70
|
-
});
|
|
71
|
-
}
|
|
54
|
+
const openAIModel = 'gpt-3.5-turbo';
|
|
72
55
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
prompt,
|
|
56
|
+
const useCaseAIAnswerAssist = new AIAnswerAssistUseCase(
|
|
57
|
+
textToSend,
|
|
76
58
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
77
59
|
context,
|
|
78
60
|
servername,
|
|
79
61
|
api,
|
|
80
62
|
port,
|
|
81
|
-
|
|
82
|
-
|
|
63
|
+
apiKeyOrSessionToken,
|
|
64
|
+
openAIModel,
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
// eslint-disable-next-line no-return-await
|
|
68
|
+
return await useCaseAIAnswerAssist.execute().then((data) => {
|
|
83
69
|
setTextFromWidgetToContent(data);
|
|
84
70
|
|
|
85
71
|
return data;
|
|
86
72
|
});
|
|
87
|
-
|
|
88
|
-
// eslint-disable-next-line no-return-await
|
|
89
73
|
}
|
|
90
74
|
|
|
91
75
|
return '';
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { AIMessageWidget, MessageWidgetProps } from './AIMessageWidget';
|
|
3
|
+
import AIWidgetIcon from '../../../svgs/Icons/AIWidgets/AIWidget';
|
|
4
|
+
import ErrorMessageIcon from './ErrorMessageIcon';
|
|
5
|
+
import { IChatMessage } from '../../../../../../Data/source/AISource';
|
|
6
|
+
import { AIAnswerAssistWithProxyUseCase } from '../../../../../../Domain/use_cases/ai/AIAnswerAssistWithProxyUseCase';
|
|
7
|
+
|
|
8
|
+
// interface MessageWidgetProps {
|
|
9
|
+
// // https://api.openai.com/v1/chat/completions'
|
|
10
|
+
// // api: 'v1/chat/completions',
|
|
11
|
+
// // servername: 'https://myproxy.com',
|
|
12
|
+
// // https://func270519800.azurewebsites.net/api/TranslateTextToEng
|
|
13
|
+
// servername: string;
|
|
14
|
+
// api: string;
|
|
15
|
+
// port: string;
|
|
16
|
+
// apiKeyOrSessionToken: string;
|
|
17
|
+
// apiKey: string;
|
|
18
|
+
// }
|
|
19
|
+
export default function UseDefaultAIAssistAnswerWidgetWithProxy({
|
|
20
|
+
servername,
|
|
21
|
+
api,
|
|
22
|
+
port,
|
|
23
|
+
apiKeyOrSessionToken,
|
|
24
|
+
}: MessageWidgetProps): AIMessageWidget {
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
26
|
+
const [errorMessage, setErrorMessage] = useState<string>('');
|
|
27
|
+
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/no-empty-function
|
|
29
|
+
const fileToWidget = (file: File, context: IChatMessage[]): void => {};
|
|
30
|
+
|
|
31
|
+
const renderWidget = (): JSX.Element => {
|
|
32
|
+
if (errorMessage && errorMessage.length > 0) {
|
|
33
|
+
const errorsDescriptions:
|
|
34
|
+
| { title: string; action: () => void }[]
|
|
35
|
+
| undefined = [];
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<ErrorMessageIcon
|
|
39
|
+
errorMessageText={errorMessage}
|
|
40
|
+
errorsDescriptions={errorsDescriptions}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return <AIWidgetIcon applyZoom color="green" />;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const [textFromWidgetToContent, setTextFromWidgetToContent] = useState('');
|
|
49
|
+
const textToWidget = async (
|
|
50
|
+
textToSend: string,
|
|
51
|
+
context: IChatMessage[],
|
|
52
|
+
): Promise<string> => {
|
|
53
|
+
if (textToSend && textToSend.length > 0) {
|
|
54
|
+
const openAIModel = 'gpt-3.5-turbo';
|
|
55
|
+
|
|
56
|
+
const useCaseAIAnswerAssist = new AIAnswerAssistWithProxyUseCase(
|
|
57
|
+
textToSend,
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
59
|
+
context,
|
|
60
|
+
servername,
|
|
61
|
+
api,
|
|
62
|
+
port,
|
|
63
|
+
apiKeyOrSessionToken,
|
|
64
|
+
openAIModel,
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
// eslint-disable-next-line no-return-await
|
|
68
|
+
return await useCaseAIAnswerAssist.execute().then((data) => {
|
|
69
|
+
setTextFromWidgetToContent(data);
|
|
70
|
+
|
|
71
|
+
return data;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return '';
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
textToContent: textFromWidgetToContent,
|
|
80
|
+
renderWidget,
|
|
81
|
+
textToWidget,
|
|
82
|
+
};
|
|
83
|
+
}
|