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
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import { AIMessageWidget } from './AIMessageWidget';
|
|
2
|
+
import { AIMessageWidget, MessageWidgetProps } from './AIMessageWidget';
|
|
3
3
|
import ErrorMessageIcon from './ErrorMessageIcon';
|
|
4
4
|
import AIWidgetIcon from '../../../svgs/Icons/AIWidgets/AIWidget';
|
|
5
|
-
import { Tone
|
|
6
|
-
import {
|
|
5
|
+
import { Tone } from './Tone';
|
|
6
|
+
import { IChatMessage } from '../../../../../../Data/source/AISource';
|
|
7
|
+
import { AIRephraseUseCase } from '../../../../../../Domain/use_cases/ai/AIRephraseUseCase';
|
|
7
8
|
|
|
8
|
-
interface MessageWidgetProps {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
9
|
+
// interface MessageWidgetProps {
|
|
10
|
+
// servername: string;
|
|
11
|
+
// api: string;
|
|
12
|
+
// port: string;
|
|
13
|
+
// apiKeyOrSessionToken: string;
|
|
14
|
+
// apiKey: string;
|
|
15
|
+
// }
|
|
15
16
|
|
|
16
17
|
export default function UseDefaultAIRephraseMessageWidget({
|
|
17
18
|
servername,
|
|
18
19
|
api,
|
|
19
20
|
port,
|
|
20
|
-
|
|
21
|
-
apiKey,
|
|
21
|
+
apiKeyOrSessionToken,
|
|
22
22
|
}: MessageWidgetProps): AIMessageWidget {
|
|
23
23
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
24
24
|
const [errorMessage, setErrorMessage] = useState<string>('');
|
|
@@ -51,42 +51,24 @@ export default function UseDefaultAIRephraseMessageWidget({
|
|
|
51
51
|
additionalSettings?: { [key: string]: any },
|
|
52
52
|
): Promise<string> => {
|
|
53
53
|
if (textToSend && textToSend.length > 0) {
|
|
54
|
-
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}"`;
|
|
55
54
|
const { tone } = additionalSettings || {};
|
|
56
55
|
|
|
57
|
-
|
|
58
|
-
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(
|
|
59
|
-
tone as Tone,
|
|
60
|
-
)} 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}"`;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (apiKey.length > 0) {
|
|
64
|
-
// eslint-disable-next-line no-return-await
|
|
65
|
-
return await AISource.getData(
|
|
66
|
-
prompt,
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
68
|
-
context,
|
|
69
|
-
servername,
|
|
70
|
-
api,
|
|
71
|
-
port,
|
|
72
|
-
sessionToken,
|
|
73
|
-
).then((data) => {
|
|
74
|
-
setTextFromWidgetToContent(data);
|
|
56
|
+
const openAIModel = 'gpt-3.5-turbo';
|
|
75
57
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
// eslint-disable-next-line no-return-await
|
|
81
|
-
return await AISource.getDataWithProxyServer(
|
|
82
|
-
prompt,
|
|
83
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
58
|
+
// AIRephraseWithProxyUseCase
|
|
59
|
+
const useCaseAIRephrase = new AIRephraseUseCase(
|
|
60
|
+
textToSend,
|
|
61
|
+
tone as Tone,
|
|
84
62
|
context,
|
|
85
63
|
servername,
|
|
86
64
|
api,
|
|
87
65
|
port,
|
|
88
|
-
|
|
89
|
-
|
|
66
|
+
apiKeyOrSessionToken,
|
|
67
|
+
openAIModel,
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
// eslint-disable-next-line no-return-await
|
|
71
|
+
return await useCaseAIRephrase.execute().then((data) => {
|
|
90
72
|
setTextFromWidgetToContent(data);
|
|
91
73
|
|
|
92
74
|
return data;
|
|
@@ -97,9 +79,26 @@ export default function UseDefaultAIRephraseMessageWidget({
|
|
|
97
79
|
return '';
|
|
98
80
|
};
|
|
99
81
|
|
|
82
|
+
// const tonesToWidget = (): Tone[] => {
|
|
83
|
+
// return [
|
|
84
|
+
// Tone.Professional,
|
|
85
|
+
// Tone.Friendly,
|
|
86
|
+
// Tone.Encouraging,
|
|
87
|
+
// Tone.Empathetic,
|
|
88
|
+
// Tone.Assertive,
|
|
89
|
+
// Tone.Neutral,
|
|
90
|
+
// Tone.Instructive,
|
|
91
|
+
// Tone.Persuasive,
|
|
92
|
+
// Tone.Sarcastic,
|
|
93
|
+
// Tone.Poetic,
|
|
94
|
+
// Tone.Unchanged,
|
|
95
|
+
// ];
|
|
96
|
+
// };
|
|
97
|
+
|
|
100
98
|
return {
|
|
101
99
|
textToContent: textFromWidgetToContent,
|
|
102
100
|
renderWidget,
|
|
103
101
|
textToWidget,
|
|
102
|
+
// tonesToWidget,
|
|
104
103
|
};
|
|
105
104
|
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { AIMessageWidget, MessageWidgetProps } from './AIMessageWidget';
|
|
3
|
+
import ErrorMessageIcon from './ErrorMessageIcon';
|
|
4
|
+
import AIWidgetIcon from '../../../svgs/Icons/AIWidgets/AIWidget';
|
|
5
|
+
import { Tone } from './Tone';
|
|
6
|
+
import { IChatMessage } from '../../../../../../Data/source/AISource';
|
|
7
|
+
import { AIRephraseWithProxyUseCase } from '../../../../../../Domain/use_cases/ai/AIRephraseWithProxyUseCase';
|
|
8
|
+
|
|
9
|
+
// interface MessageWidgetProps {
|
|
10
|
+
// servername: string;
|
|
11
|
+
// api: string;
|
|
12
|
+
// port: string;
|
|
13
|
+
// apiKeyOrSessionToken: string;
|
|
14
|
+
// apiKey: string;
|
|
15
|
+
// }
|
|
16
|
+
|
|
17
|
+
export default function UseDefaultAIRephraseMessageWidgetWithProxy({
|
|
18
|
+
servername,
|
|
19
|
+
api,
|
|
20
|
+
port,
|
|
21
|
+
apiKeyOrSessionToken,
|
|
22
|
+
}: MessageWidgetProps): AIMessageWidget {
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
24
|
+
const [errorMessage, setErrorMessage] = useState<string>('');
|
|
25
|
+
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/no-empty-function
|
|
27
|
+
const fileToWidget = (file: File, context: IChatMessage[]): void => {};
|
|
28
|
+
|
|
29
|
+
const renderWidget = (): JSX.Element => {
|
|
30
|
+
if (errorMessage && errorMessage.length > 0) {
|
|
31
|
+
const errorsDescriptions:
|
|
32
|
+
| { title: string; action: () => void }[]
|
|
33
|
+
| undefined = [];
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<ErrorMessageIcon
|
|
37
|
+
errorMessageText={errorMessage}
|
|
38
|
+
errorsDescriptions={errorsDescriptions}
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return <AIWidgetIcon applyZoom color="green" />;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const [textFromWidgetToContent, setTextFromWidgetToContent] = useState('');
|
|
47
|
+
|
|
48
|
+
const textToWidget = async (
|
|
49
|
+
textToSend: string,
|
|
50
|
+
context: IChatMessage[],
|
|
51
|
+
additionalSettings?: { [key: string]: any },
|
|
52
|
+
): Promise<string> => {
|
|
53
|
+
if (textToSend && textToSend.length > 0) {
|
|
54
|
+
const { tone } = additionalSettings || {};
|
|
55
|
+
|
|
56
|
+
const openAIModel = 'gpt-3.5-turbo';
|
|
57
|
+
|
|
58
|
+
const useCaseAIRephrase = new AIRephraseWithProxyUseCase(
|
|
59
|
+
textToSend,
|
|
60
|
+
tone as Tone,
|
|
61
|
+
context,
|
|
62
|
+
servername,
|
|
63
|
+
api,
|
|
64
|
+
port,
|
|
65
|
+
apiKeyOrSessionToken,
|
|
66
|
+
openAIModel,
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
// eslint-disable-next-line no-return-await
|
|
70
|
+
return await useCaseAIRephrase.execute().then((data) => {
|
|
71
|
+
setTextFromWidgetToContent(data);
|
|
72
|
+
|
|
73
|
+
return data;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//
|
|
78
|
+
return '';
|
|
79
|
+
};
|
|
80
|
+
// const tonesToWidget = (): Tone[] => {
|
|
81
|
+
// return [
|
|
82
|
+
// Tone.Professional,
|
|
83
|
+
// Tone.Friendly,
|
|
84
|
+
// Tone.Encouraging,
|
|
85
|
+
// Tone.Empathetic,
|
|
86
|
+
// Tone.Assertive,
|
|
87
|
+
// Tone.Neutral,
|
|
88
|
+
// Tone.Instructive,
|
|
89
|
+
// Tone.Persuasive,
|
|
90
|
+
// Tone.Sarcastic,
|
|
91
|
+
// Tone.Poetic,
|
|
92
|
+
// Tone.Unchanged,
|
|
93
|
+
// ];
|
|
94
|
+
// };
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
textToContent: textFromWidgetToContent,
|
|
98
|
+
renderWidget,
|
|
99
|
+
textToWidget,
|
|
100
|
+
// tonesToWidget,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
2
|
import AIWidgetIcon from '../../../svgs/Icons/AIWidgets/AIWidget';
|
|
3
3
|
import ErrorMessageIcon from './ErrorMessageIcon';
|
|
4
|
-
import { AIMessageWidget } from './AIMessageWidget';
|
|
5
|
-
import {
|
|
4
|
+
import { AIMessageWidget, MessageWidgetProps } from './AIMessageWidget';
|
|
5
|
+
import { IChatMessage } from '../../../../../../Data/source/AISource';
|
|
6
|
+
import { AITranslateUseCase } from '../../../../../../Domain/use_cases/ai/AITranslateUseCase';
|
|
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 UseDefaultAITranslateWidget({
|
|
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>('');
|
|
@@ -53,42 +53,25 @@ export default function UseDefaultAITranslateWidget({
|
|
|
53
53
|
): Promise<string> => {
|
|
54
54
|
if (textToSend && textToSend.length > 0) {
|
|
55
55
|
// eslint-disable-next-line no-return-await
|
|
56
|
-
let prompt = `Please, translate the next text in english and give me just only translated text. Text to translate is: "${textToSend}"`;
|
|
57
56
|
const { language } = additionalSettings || {};
|
|
57
|
+
//
|
|
58
|
+
const openAIModel = 'gpt-3.5-turbo';
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
} and give me just only translated text. Text to translate is: "${textToSend}"`;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (apiKey.length > 0) {
|
|
66
|
-
// eslint-disable-next-line no-return-await
|
|
67
|
-
return await AISource.getData(
|
|
68
|
-
prompt,
|
|
69
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
70
|
-
context,
|
|
71
|
-
servername,
|
|
72
|
-
api,
|
|
73
|
-
port,
|
|
74
|
-
sessionToken,
|
|
75
|
-
).then((data) => {
|
|
76
|
-
setTextFromWidgetToContent(data);
|
|
77
|
-
|
|
78
|
-
return data;
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// eslint-disable-next-line no-return-await
|
|
83
|
-
return await AISource.getDataWithProxyServer(
|
|
84
|
-
prompt,
|
|
60
|
+
// AIRephraseWithProxyUseCase
|
|
61
|
+
const useCaseAITranslate = new AITranslateUseCase(
|
|
62
|
+
textToSend,
|
|
85
63
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
64
|
+
language,
|
|
86
65
|
context,
|
|
87
66
|
servername,
|
|
88
67
|
api,
|
|
89
68
|
port,
|
|
90
|
-
|
|
91
|
-
|
|
69
|
+
apiKeyOrSessionToken,
|
|
70
|
+
openAIModel,
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
// eslint-disable-next-line no-return-await
|
|
74
|
+
return await useCaseAITranslate.execute().then((data) => {
|
|
92
75
|
setTextFromWidgetToContent(data);
|
|
93
76
|
|
|
94
77
|
return data;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import AIWidgetIcon from '../../../svgs/Icons/AIWidgets/AIWidget';
|
|
3
|
+
import ErrorMessageIcon from './ErrorMessageIcon';
|
|
4
|
+
import { AIMessageWidget, MessageWidgetProps } from './AIMessageWidget';
|
|
5
|
+
import { IChatMessage } from '../../../../../../Data/source/AISource';
|
|
6
|
+
import { AITranslateWithProxyUseCase } from '../../../../../../Domain/use_cases/ai/AITranslateWithProxyUseCase';
|
|
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 UseDefaultAITranslateWidgetWithProxy({
|
|
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
|
+
additionalSettings?: { [key: string]: any },
|
|
53
|
+
): Promise<string> => {
|
|
54
|
+
if (textToSend && textToSend.length > 0) {
|
|
55
|
+
// eslint-disable-next-line no-return-await
|
|
56
|
+
const { language } = additionalSettings || {};
|
|
57
|
+
//
|
|
58
|
+
const openAIModel = 'gpt-3.5-turbo';
|
|
59
|
+
|
|
60
|
+
// AIRephraseWithProxyUseCase
|
|
61
|
+
const useCaseAITranslate = new AITranslateWithProxyUseCase(
|
|
62
|
+
textToSend,
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
64
|
+
language,
|
|
65
|
+
context,
|
|
66
|
+
servername,
|
|
67
|
+
api,
|
|
68
|
+
port,
|
|
69
|
+
apiKeyOrSessionToken,
|
|
70
|
+
openAIModel,
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
// eslint-disable-next-line no-return-await
|
|
74
|
+
return await useCaseAITranslate.execute().then((data) => {
|
|
75
|
+
setTextFromWidgetToContent(data);
|
|
76
|
+
|
|
77
|
+
return data;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return '';
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
textToContent: textFromWidgetToContent,
|
|
86
|
+
renderWidget,
|
|
87
|
+
textToWidget,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
.default-attachment-component-container,
|
|
2
|
+
.default-attachment-component-container * {
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
}
|
|
5
|
+
.default-attachment-component-container {
|
|
6
|
+
// background: var(--incoming-background, #e4e6e8);
|
|
7
|
+
border-radius: 22px 22px 22px 0px;
|
|
8
|
+
padding: 8px 16px 8px 1px;
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: row;
|
|
11
|
+
gap: 8px;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: flex-start;
|
|
14
|
+
flex-shrink: 0;
|
|
15
|
+
position: relative;
|
|
16
|
+
|
|
17
|
+
&--file-wrapper {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: row;
|
|
20
|
+
gap: 8px;
|
|
21
|
+
align-items: center;
|
|
22
|
+
justify-content: flex-start;
|
|
23
|
+
align-self: stretch;
|
|
24
|
+
flex-shrink: 0;
|
|
25
|
+
position: relative;
|
|
26
|
+
|
|
27
|
+
&--placeholder {
|
|
28
|
+
flex-shrink: 0;
|
|
29
|
+
width: 32px;
|
|
30
|
+
height: 32px;
|
|
31
|
+
position: static;
|
|
32
|
+
|
|
33
|
+
&__bg {
|
|
34
|
+
background: var(--field-border, #90979f);
|
|
35
|
+
border-radius: 8px;
|
|
36
|
+
width: 32px;
|
|
37
|
+
height: 32px;
|
|
38
|
+
position: absolute;
|
|
39
|
+
left: 0px;
|
|
40
|
+
top: 0px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&__icon {
|
|
44
|
+
border-radius: 4px;
|
|
45
|
+
padding: 4px;
|
|
46
|
+
display: flex;
|
|
47
|
+
flex-direction: row;
|
|
48
|
+
gap: 0px;
|
|
49
|
+
align-items: center;
|
|
50
|
+
justify-content: center;
|
|
51
|
+
width: 24px;
|
|
52
|
+
height: 24px;
|
|
53
|
+
position: absolute;
|
|
54
|
+
left: 4px;
|
|
55
|
+
top: 4px;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&--file-d {
|
|
60
|
+
color: var(--secondary-elements, #202f3e);
|
|
61
|
+
text-align: left;
|
|
62
|
+
font: 400 14px/20px "Roboto", sans-serif;
|
|
63
|
+
position: relative;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
.media-text-document {
|
|
71
|
+
align-self: stretch;
|
|
72
|
+
flex: 1;
|
|
73
|
+
position: relative;
|
|
74
|
+
overflow: visible;
|
|
75
|
+
}
|
|
76
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './DefaultAttachmentComponent.scss';
|
|
3
|
+
import TextDocument from '../../../svgs/Icons/Media/TextDocument';
|
|
4
|
+
|
|
5
|
+
type DefaultAttachmentComponentProps = {
|
|
6
|
+
fileName: string;
|
|
7
|
+
};
|
|
8
|
+
// eslint-disable-next-line react/function-component-definition
|
|
9
|
+
const DefaultAttachmentComponent: React.FC<DefaultAttachmentComponentProps> = ({
|
|
10
|
+
fileName,
|
|
11
|
+
}: DefaultAttachmentComponentProps) => {
|
|
12
|
+
return (
|
|
13
|
+
<div className="default-attachment-component-container">
|
|
14
|
+
<div className="default-attachment-component-container--file-wrapper">
|
|
15
|
+
<div className="default-attachment-component-container--file-wrapper--placeholder">
|
|
16
|
+
<div className="default-attachment-component-container--file-wrapper--placeholder__bg" />
|
|
17
|
+
<div className="default-attachment-component-container--file-wrapper--placeholder__icon">
|
|
18
|
+
<TextDocument
|
|
19
|
+
width="16"
|
|
20
|
+
height="16"
|
|
21
|
+
applyZoom
|
|
22
|
+
color="var(--incoming-background)"
|
|
23
|
+
/>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
<div className="default-attachment-component-container--file-wrapper__file-d">
|
|
27
|
+
{fileName}
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default DefaultAttachmentComponent;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
.error-toast,
|
|
2
|
+
.error-toast * {
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
}
|
|
5
|
+
.error-toast {
|
|
6
|
+
background: var(--color-background-overlay);
|
|
7
|
+
border-radius: 4px;
|
|
8
|
+
opacity: 0.6000000238418579;
|
|
9
|
+
padding: 4px 12px 4px 12px;
|
|
10
|
+
// margin-top: 36px;
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
gap: 10px;
|
|
14
|
+
align-items: flex-start;
|
|
15
|
+
justify-content: flex-start;
|
|
16
|
+
position: relative;
|
|
17
|
+
}
|
|
18
|
+
.translation-failed-try-again {
|
|
19
|
+
color: var(--color-background);
|
|
20
|
+
text-align: left;
|
|
21
|
+
font: 500 12px/16px "Roboto", sans-serif;
|
|
22
|
+
position: relative;
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
justify-content: flex-start;
|
|
26
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './ErrorToast.scss';
|
|
3
|
+
|
|
4
|
+
type ErrorToastProps = {
|
|
5
|
+
messageText: string;
|
|
6
|
+
// displayTimeout: number;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
// eslint-disable-next-line react/function-component-definition
|
|
10
|
+
export const ErrorToast: React.FC<ErrorToastProps> = ({
|
|
11
|
+
messageText,
|
|
12
|
+
}: // displayTimeout,
|
|
13
|
+
ErrorToastProps) => {
|
|
14
|
+
return (
|
|
15
|
+
// <div>
|
|
16
|
+
// {messageText} - {displayTimeout}
|
|
17
|
+
// </div>
|
|
18
|
+
|
|
19
|
+
<div className="error-toast">
|
|
20
|
+
<div className="translation-failed-try-again">
|
|
21
|
+
{messageText} Try again.
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
};
|
package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.scss
CHANGED
|
@@ -289,7 +289,7 @@
|
|
|
289
289
|
font: var(--label-label-small, 500 11px/16px "Roboto", sans-serif);
|
|
290
290
|
position: relative;
|
|
291
291
|
}
|
|
292
|
-
.icon {
|
|
292
|
+
.icon-translate {
|
|
293
293
|
border-radius: 4px;
|
|
294
294
|
display: flex;
|
|
295
295
|
flex-direction: row;
|
|
@@ -349,16 +349,15 @@
|
|
|
349
349
|
}
|
|
350
350
|
|
|
351
351
|
.ai-translate-action {
|
|
352
|
-
color: var(--
|
|
352
|
+
color: var(--tertiary-elements);
|
|
353
353
|
text-align: right;
|
|
354
|
-
font:
|
|
354
|
+
font: 500 11px/16px "Roboto", sans-serif;
|
|
355
355
|
position: relative;
|
|
356
|
-
cursor: pointer;
|
|
357
356
|
}
|
|
358
357
|
|
|
359
358
|
|
|
360
359
|
// --- AIAssist
|
|
361
|
-
.assist-answer {
|
|
360
|
+
.ai-assist-answer {
|
|
362
361
|
display: flex;
|
|
363
362
|
flex-direction: row;
|
|
364
363
|
gap: 10px;
|
|
@@ -367,7 +366,6 @@
|
|
|
367
366
|
align-self: stretch;
|
|
368
367
|
flex-shrink: 0;
|
|
369
368
|
position: relative;
|
|
370
|
-
cursor: pointer;
|
|
371
369
|
}
|
|
372
370
|
.icon {
|
|
373
371
|
border-radius: 4px;
|