quickblox-react-ui-kit 0.2.0 → 0.2.2
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 +47 -0
- package/dist/Data/DefaultConfigurations.d.ts +7 -0
- package/dist/Data/Stubs.d.ts +1 -1
- package/dist/Data/source/AISource.d.ts +13 -0
- package/dist/Domain/entity/MessageEntity.d.ts +1 -1
- package/dist/Presentation/Views/Base/BaseViewModel.d.ts +10 -6
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIMessageWidget.d.ts +16 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIWidgetActions/AIWidgetActions.d.ts +14 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/SliderMenu.d.ts +23 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone.d.ts +15 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidget.d.ts +10 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidget.d.ts +10 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidget.d.ts +10 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/useDefaultVoiceInputWidget.d.ts +2 -2
- package/dist/Presentation/components/UI/Dialogs/MessagesView/ContextMenu.d.ts +2 -1
- package/dist/Presentation/components/UI/Dialogs/MessagesView/DropDownMenu/DropDownMenu.d.ts +26 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/DropDownMenu/ItemDropDownMenu/ItemDropDownMenu.d.ts +11 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/AvatarContentIncomingUser/AvatarContentIncomingUser.d.ts +3 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.d.ts +15 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/MessagesView.d.ts +5 -5
- package/dist/Presentation/components/UI/Dialogs/MessagesView/OutGoingMessage/OutGoingMessage.d.ts +9 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/BookIcon/BookIcon.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/HammerIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/HandshakeIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/MuscleIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/NecktieIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/NeutralFaceIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/PalmsUpTogetherIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/PerformingArtsIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/PointUpIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/SmileyIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/SmirkIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/WhiteCheckMarkIcon/index.d.ts +3 -0
- package/dist/Presentation/components/UI/svgs/Icons/Actions/AssistAnswer/index.d.ts +4 -0
- package/dist/Presentation/components/UI/svgs/Icons/Actions/Summarize/index.d.ts +4 -0
- package/dist/Presentation/components/UI/svgs/Icons/Actions/Tone/index.d.ts +4 -0
- package/dist/Presentation/components/UI/svgs/Icons/Media/Translate/index.d.ts +4 -0
- package/dist/Presentation/components/layouts/Desktop/QuickBloxUIKitDesktopLayout.d.ts +5 -5
- package/dist/Presentation/components/providers/QuickBloxUIKitProvider/QuickBloxUIKitProvider.d.ts +1 -1
- package/dist/QBconfig.d.ts +23 -0
- package/dist/index-ui.d.ts +5 -1
- package/dist/index-ui.js +361 -42
- package/global.d.ts +48 -6
- package/package.json +1 -1
- package/src/App.tsx +20 -14
- package/src/CommonTypes/FunctionResult.ts +54 -0
- package/src/Data/DefaultConfigurations.ts +197 -0
- package/src/Data/Stubs.ts +15 -15
- package/src/Data/mapper/MessageLocalDTOMapper.ts +3 -2
- package/src/Data/mapper/MessageRemoteDTOMapper.ts +3 -2
- package/src/Data/source/AISource.ts +133 -0
- package/src/Data/source/remote/Mapper/MessageDTOMapper.ts +3 -3
- package/src/Domain/entity/MessageEntity.ts +1 -1
- package/src/Presentation/Views/Base/BaseViewModel.ts +9 -4
- package/src/Presentation/Views/Dialogs/Dialogs.tsx +37 -21
- package/src/Presentation/components/UI/Dialogs/HeaderDialogs/HeaderDialogs.scss +2 -2
- package/src/Presentation/components/UI/Dialogs/HeaderDialogs/HeaderDialogs.tsx +5 -5
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/{AIWidget.ts → AIMessageWidget.ts} +14 -3
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIWidgetActions/AIWidgetActions.scss +55 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIWidgetActions/AIWidgetActions.tsx +116 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/SliderMenu.tsx +172 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone.ts +21 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidget.tsx +99 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidget.tsx +105 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidget.tsx +106 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/useDefaultVoiceInputWidget.tsx +7 -6
- package/src/Presentation/components/UI/Dialogs/MessagesView/ContextMenu.tsx +5 -6
- package/src/Presentation/components/UI/Dialogs/MessagesView/DropDownMenu/DropDownMenu.scss +84 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/DropDownMenu/DropDownMenu.tsx +105 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/DropDownMenu/ItemDropDownMenu/ItemDropDownMenu.scss +50 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/DropDownMenu/ItemDropDownMenu/ItemDropDownMenu.tsx +43 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/HeaderMessages/HeaderMessages.tsx +14 -11
- package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/AvatarContentIncomingUser/AvatarContentIncomingUser.scss +39 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/AvatarContentIncomingUser/AvatarContentIncomingUser.tsx +26 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.scss +394 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.tsx +747 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/MessagesView.scss +88 -4
- package/src/Presentation/components/UI/Dialogs/MessagesView/MessagesView.tsx +589 -246
- package/src/Presentation/components/UI/Dialogs/MessagesView/OutGoingMessage/OutGoingMessage.scss +7 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/OutGoingMessage/OutGoingMessage.tsx +99 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/useMessagesViewModel.ts +7 -5
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/BookIcon/BookIcon.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/HammerIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/HandshakeIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/MuscleIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/NecktieIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/NeutralFaceIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/PalmsUpTogetherIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/PerformingArtsIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/PointUpIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/SmileyIcon/index.tsx +20 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/SmirkIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/AIWidgets/WhiteCheckMarkIcon/index.tsx +7 -0
- package/src/Presentation/components/UI/svgs/Icons/Actions/AssistAnswer/AssistAnswer.svg +3 -0
- package/src/Presentation/components/UI/svgs/Icons/Actions/AssistAnswer/index.tsx +93 -0
- package/src/Presentation/components/UI/svgs/Icons/Actions/Summarize/Summarize.svg +6 -0
- package/src/Presentation/components/UI/svgs/Icons/Actions/Summarize/index.tsx +58 -0
- package/src/Presentation/components/UI/svgs/Icons/Actions/Tone/Tone.svg +3 -0
- package/src/Presentation/components/UI/svgs/Icons/Actions/Tone/index.tsx +34 -0
- package/src/Presentation/components/UI/svgs/Icons/Media/Translate/Translate.svg +3 -0
- package/src/Presentation/components/UI/svgs/Icons/Media/Translate/index.tsx +35 -0
- package/src/Presentation/components/layouts/Desktop/QuickBloxUIKitDesktopLayout.tsx +110 -36
- package/src/Presentation/components/providers/QuickBloxUIKitProvider/QuickBloxUIKitProvider.tsx +7 -6
- package/src/QBconfig.ts +33 -3
- package/src/index-ui.ts +9 -0
- package/src/utils/parse.ts +1 -1
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIWidget.d.ts +0 -8
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidgetWithProxy.d.ts +0 -9
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultTextInputWidget.d.ts +0 -2
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidgetWithProxy.tsx +0 -136
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultTextInputWidget.tsx +0 -60
- /package/dist/Presentation/components/UI/svgs/Icons/{Media → AIWidgets}/AIWidget/index.d.ts +0 -0
- /package/src/Presentation/components/UI/svgs/Icons/{Media → AIWidgets}/AIWidget/Send.svg +0 -0
- /package/src/Presentation/components/UI/svgs/Icons/{Media → AIWidgets}/AIWidget/index.tsx +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
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 const toneToString = (tone: Tone): string => {
|
|
16
|
+
return tone;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const stringToTone = (toneStr: string): Tone | undefined => {
|
|
20
|
+
return Tone[toneStr as keyof typeof Tone];
|
|
21
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { AIMessageWidget } from './AIMessageWidget';
|
|
3
|
+
import AIWidgetIcon from '../../../svgs/Icons/AIWidgets/AIWidget';
|
|
4
|
+
import ErrorMessageIcon from './ErrorMessageIcon';
|
|
5
|
+
import { AISource, IChatMessage } from '../../../../../../Data/source/AISource';
|
|
6
|
+
|
|
7
|
+
interface MessageWidgetProps {
|
|
8
|
+
// https://api.openai.com/v1/chat/completions'
|
|
9
|
+
// api: 'v1/chat/completions',
|
|
10
|
+
// servername: 'https://myproxy.com',
|
|
11
|
+
// https://func270519800.azurewebsites.net/api/TranslateTextToEng
|
|
12
|
+
servername: string;
|
|
13
|
+
api: string;
|
|
14
|
+
port: string;
|
|
15
|
+
sessionToken: string;
|
|
16
|
+
apiKey: string;
|
|
17
|
+
}
|
|
18
|
+
export default function UseDefaultAIAssistAnswerWidget({
|
|
19
|
+
servername,
|
|
20
|
+
api,
|
|
21
|
+
port,
|
|
22
|
+
sessionToken,
|
|
23
|
+
apiKey,
|
|
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 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}"`;
|
|
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
|
+
}
|
|
72
|
+
|
|
73
|
+
// eslint-disable-next-line no-return-await
|
|
74
|
+
return await AISource.getDataWithProxyServer(
|
|
75
|
+
prompt,
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
77
|
+
context,
|
|
78
|
+
servername,
|
|
79
|
+
api,
|
|
80
|
+
port,
|
|
81
|
+
sessionToken,
|
|
82
|
+
).then((data) => {
|
|
83
|
+
setTextFromWidgetToContent(data);
|
|
84
|
+
|
|
85
|
+
return data;
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// eslint-disable-next-line no-return-await
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return '';
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
textToContent: textFromWidgetToContent,
|
|
96
|
+
renderWidget,
|
|
97
|
+
textToWidget,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { AIMessageWidget } from './AIMessageWidget';
|
|
3
|
+
import ErrorMessageIcon from './ErrorMessageIcon';
|
|
4
|
+
import AIWidgetIcon from '../../../svgs/Icons/AIWidgets/AIWidget';
|
|
5
|
+
import { Tone, toneToString } from './Tone';
|
|
6
|
+
import { AISource, IChatMessage } from '../../../../../../Data/source/AISource';
|
|
7
|
+
|
|
8
|
+
interface MessageWidgetProps {
|
|
9
|
+
servername: string;
|
|
10
|
+
api: string;
|
|
11
|
+
port: string;
|
|
12
|
+
sessionToken: string;
|
|
13
|
+
apiKey: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default function UseDefaultAIRephraseMessageWidget({
|
|
17
|
+
servername,
|
|
18
|
+
api,
|
|
19
|
+
port,
|
|
20
|
+
sessionToken,
|
|
21
|
+
apiKey,
|
|
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
|
+
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
|
+
const { tone } = additionalSettings || {};
|
|
56
|
+
|
|
57
|
+
if (tone) {
|
|
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);
|
|
75
|
+
|
|
76
|
+
return data;
|
|
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
|
|
84
|
+
context,
|
|
85
|
+
servername,
|
|
86
|
+
api,
|
|
87
|
+
port,
|
|
88
|
+
sessionToken,
|
|
89
|
+
).then((data) => {
|
|
90
|
+
setTextFromWidgetToContent(data);
|
|
91
|
+
|
|
92
|
+
return data;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
//
|
|
97
|
+
return '';
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
textToContent: textFromWidgetToContent,
|
|
102
|
+
renderWidget,
|
|
103
|
+
textToWidget,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import AIWidgetIcon from '../../../svgs/Icons/AIWidgets/AIWidget';
|
|
3
|
+
import ErrorMessageIcon from './ErrorMessageIcon';
|
|
4
|
+
import { AIMessageWidget } from './AIMessageWidget';
|
|
5
|
+
import { AISource, IChatMessage } from '../../../../../../Data/source/AISource';
|
|
6
|
+
|
|
7
|
+
interface MessageWidgetProps {
|
|
8
|
+
// https://api.openai.com/v1/chat/completions'
|
|
9
|
+
// api: 'v1/chat/completions',
|
|
10
|
+
// servername: 'https://myproxy.com',
|
|
11
|
+
// https://func270519800.azurewebsites.net/api/TranslateTextToEng
|
|
12
|
+
servername: string;
|
|
13
|
+
api: string;
|
|
14
|
+
port: string;
|
|
15
|
+
sessionToken: string;
|
|
16
|
+
apiKey: string;
|
|
17
|
+
}
|
|
18
|
+
export default function UseDefaultAITranslateWidget({
|
|
19
|
+
servername,
|
|
20
|
+
api,
|
|
21
|
+
port,
|
|
22
|
+
sessionToken,
|
|
23
|
+
apiKey,
|
|
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
|
+
let prompt = `Please, translate the next text in english and give me just only translated text. Text to translate is: "${textToSend}"`;
|
|
57
|
+
const { language } = additionalSettings || {};
|
|
58
|
+
|
|
59
|
+
if (language) {
|
|
60
|
+
prompt = `Please, translate the next text in ${
|
|
61
|
+
language as string
|
|
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,
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
86
|
+
context,
|
|
87
|
+
servername,
|
|
88
|
+
api,
|
|
89
|
+
port,
|
|
90
|
+
sessionToken,
|
|
91
|
+
).then((data) => {
|
|
92
|
+
setTextFromWidgetToContent(data);
|
|
93
|
+
|
|
94
|
+
return data;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return '';
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
textToContent: textFromWidgetToContent,
|
|
103
|
+
renderWidget,
|
|
104
|
+
textToWidget,
|
|
105
|
+
};
|
|
106
|
+
}
|
package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/useDefaultVoiceInputWidget.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { AIAttachmentWidget } from './AIMessageWidget';
|
|
3
3
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
4
4
|
import VoiceIcon from '../../../svgs/Icons/Actions/Voice';
|
|
5
5
|
|
|
6
|
-
export default function useDefaultVoiceInputWidget():
|
|
6
|
+
export default function useDefaultVoiceInputWidget(): AIAttachmentWidget {
|
|
7
7
|
const renderWidget = (): JSX.Element => {
|
|
8
8
|
// return <VoiceIcon width="21" height="18" applyZoom color="red" />;
|
|
9
9
|
return (
|
|
@@ -32,7 +32,7 @@ export default function useDefaultVoiceInputWidget(): AIWidget {
|
|
|
32
32
|
|
|
33
33
|
const [audioFromWidgetToInput, setAudioFromWidgetToInput] = useState<File>();
|
|
34
34
|
|
|
35
|
-
async function sendFile(file: File): Promise<
|
|
35
|
+
async function sendFile(file: File): Promise<string> {
|
|
36
36
|
if (file) {
|
|
37
37
|
// Создание объекта FormData и добавление файла
|
|
38
38
|
const formData = new FormData();
|
|
@@ -57,8 +57,10 @@ export default function useDefaultVoiceInputWidget(): AIWidget {
|
|
|
57
57
|
JSON.stringify(data.replaceAll('\n\n', '')),
|
|
58
58
|
);
|
|
59
59
|
|
|
60
|
-
return data.replaceAll('\n\n', '');
|
|
60
|
+
return data.replaceAll('\n\n', '') || '';
|
|
61
61
|
}
|
|
62
|
+
|
|
63
|
+
return '';
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
const fileToWidget = (file: File): void => {
|
|
@@ -68,6 +70,7 @@ export default function useDefaultVoiceInputWidget(): AIWidget {
|
|
|
68
70
|
console.log(fileInfo);
|
|
69
71
|
if (file) {
|
|
70
72
|
// Отправка файла и получение результата
|
|
73
|
+
// eslint-disable-next-line promise/catch-or-return,promise/always-return
|
|
71
74
|
sendFile(file).then((result) => {
|
|
72
75
|
// Обработка результата
|
|
73
76
|
console.log(result);
|
|
@@ -78,9 +81,7 @@ export default function useDefaultVoiceInputWidget(): AIWidget {
|
|
|
78
81
|
|
|
79
82
|
return {
|
|
80
83
|
fileToContent: audioFromWidgetToInput,
|
|
81
|
-
textToContent: textFromWidgetToInput,
|
|
82
84
|
fileToWidget,
|
|
83
85
|
renderWidget,
|
|
84
|
-
textToWidget,
|
|
85
86
|
};
|
|
86
87
|
}
|
|
@@ -7,6 +7,7 @@ type MenuItem = {
|
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
type ContextMenuProps = {
|
|
10
|
+
widgetToRender?: JSX.Element;
|
|
10
11
|
items?: MenuItem[];
|
|
11
12
|
};
|
|
12
13
|
|
|
@@ -14,8 +15,8 @@ const ContextMenuStyles: { [key: string]: CSSProperties } = {
|
|
|
14
15
|
contextMenuIcon: {
|
|
15
16
|
display: 'inline-block',
|
|
16
17
|
position: 'relative',
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
maxWidth: '42px',
|
|
19
|
+
maxHeight: '42px',
|
|
19
20
|
cursor: 'pointer',
|
|
20
21
|
},
|
|
21
22
|
contextMenuContent: {
|
|
@@ -32,7 +33,7 @@ const ContextMenuStyles: { [key: string]: CSSProperties } = {
|
|
|
32
33
|
},
|
|
33
34
|
};
|
|
34
35
|
|
|
35
|
-
function ContextMenu({ items }: ContextMenuProps) {
|
|
36
|
+
function ContextMenu({ items, widgetToRender }: ContextMenuProps) {
|
|
36
37
|
const [menuVisible, setMenuVisible] = useState(false);
|
|
37
38
|
const contextMenuRef = useRef<HTMLDivElement | null>(null);
|
|
38
39
|
|
|
@@ -68,9 +69,7 @@ function ContextMenu({ items }: ContextMenuProps) {
|
|
|
68
69
|
...ContextMenuStyles.contextMenuIcon,
|
|
69
70
|
}}
|
|
70
71
|
>
|
|
71
|
-
<div onClick={handleClick}>
|
|
72
|
-
<EditDots />
|
|
73
|
-
</div>
|
|
72
|
+
<div onClick={handleClick}>{widgetToRender || <EditDots />}</div>
|
|
74
73
|
{menuVisible && (
|
|
75
74
|
<div ref={contextMenuRef} style={ContextMenuStyles.contextMenuContent}>
|
|
76
75
|
{items?.map((item, index) => (
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
.popup-container {
|
|
2
|
+
position: inherit;
|
|
3
|
+
width: 100%;
|
|
4
|
+
height: 100%;
|
|
5
|
+
top: 0;
|
|
6
|
+
left: 0;
|
|
7
|
+
right: 0;
|
|
8
|
+
bottom: 0;
|
|
9
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
10
|
+
}
|
|
11
|
+
.popup-body {
|
|
12
|
+
position: absolute;
|
|
13
|
+
left: 30%;
|
|
14
|
+
right: 30%;
|
|
15
|
+
bottom: 30%;
|
|
16
|
+
top: 30%;
|
|
17
|
+
text-align: center;
|
|
18
|
+
margin: auto;
|
|
19
|
+
border-radius: 15px;
|
|
20
|
+
border-color: black;
|
|
21
|
+
background: white;
|
|
22
|
+
box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;
|
|
23
|
+
color: #FF766E;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.drop-down-menu-container {
|
|
27
|
+
position:relative;
|
|
28
|
+
width:200px;
|
|
29
|
+
|
|
30
|
+
//box-shadow:0px 8px 10px rgba(0, 0, 0, 0.11999999731779099);
|
|
31
|
+
//background-color:rgba(255, 255, 255, 1);
|
|
32
|
+
//width:135px;
|
|
33
|
+
//height:112px;
|
|
34
|
+
//border-radius: 4px;
|
|
35
|
+
////position:absolute;
|
|
36
|
+
//position: relative;
|
|
37
|
+
//border: var(--outgoing-background);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.drop-down-menu2-container {
|
|
41
|
+
width: 135px;
|
|
42
|
+
min-width: 135px;
|
|
43
|
+
max-width: 135px;
|
|
44
|
+
//
|
|
45
|
+
position: fixed;
|
|
46
|
+
z-index: 100;
|
|
47
|
+
//
|
|
48
|
+
//
|
|
49
|
+
//display: flex;
|
|
50
|
+
//flex-direction: column;
|
|
51
|
+
|
|
52
|
+
display: inline-flex;
|
|
53
|
+
padding: 8px 0px;
|
|
54
|
+
flex-direction: column;
|
|
55
|
+
align-items: flex-end;
|
|
56
|
+
//
|
|
57
|
+
//display: flex;
|
|
58
|
+
//flex-direction: column;
|
|
59
|
+
//justify-content: flex-end;
|
|
60
|
+
|
|
61
|
+
border-radius: 4px;
|
|
62
|
+
//background-color: #FF766E;
|
|
63
|
+
//background: #49CF77;
|
|
64
|
+
background: var(--dropdown-background, #FFF);
|
|
65
|
+
box-shadow: 0px 3px 5px 0px rgba(0, 0, 0, 0.04), 0px 3px 14px 0px rgba(0, 0, 0, 0.08), 0px 8px 10px 0px rgba(0, 0, 0, 0.12);
|
|
66
|
+
|
|
67
|
+
//border: 3px solid green;
|
|
68
|
+
|
|
69
|
+
&--divider{
|
|
70
|
+
|
|
71
|
+
display: flex;
|
|
72
|
+
padding: 4px 8px 4px 16px;
|
|
73
|
+
justify-content: flex-end;
|
|
74
|
+
align-items: center;
|
|
75
|
+
align-self: stretch;
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
width: 111px;
|
|
79
|
+
height: 3px;
|
|
80
|
+
|
|
81
|
+
flex-shrink: 0;
|
|
82
|
+
color: var(--divider);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import './DropDownMenu.scss';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ItemDropDownMenu } from './ItemDropDownMenu/ItemDropDownMenu';
|
|
4
|
+
import { FunctionTypeVoidToVoid } from '../../../../../Views/Base/BaseViewModel';
|
|
5
|
+
import { MessageEntity } from '../../../../../../Domain/entity/MessageEntity';
|
|
6
|
+
import ForwardFilled from '../../../svgs/Icons/Actions/ForwardFilled';
|
|
7
|
+
|
|
8
|
+
export type ContextMessageMenu = {
|
|
9
|
+
title: string;
|
|
10
|
+
message?: MessageEntity;
|
|
11
|
+
icon?: React.ReactNode;
|
|
12
|
+
clickHandler?: FunctionTypeVoidToVoid;
|
|
13
|
+
touchHandler?: FunctionTypeVoidToVoid;
|
|
14
|
+
};
|
|
15
|
+
export type ContextMessageMenuAI = {
|
|
16
|
+
title: string;
|
|
17
|
+
message?: MessageEntity;
|
|
18
|
+
icon?: React.ReactNode;
|
|
19
|
+
clickHandler?: FunctionTypeVoidToVoid;
|
|
20
|
+
touchHandler?: FunctionTypeVoidToVoid;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const contextMessageMenu: ContextMessageMenu[] = [
|
|
24
|
+
{
|
|
25
|
+
title: 'Reply',
|
|
26
|
+
// icon: 'ic1',
|
|
27
|
+
clickHandler: () => {
|
|
28
|
+
console.log('click Reply');
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
title: 'Forward',
|
|
33
|
+
icon: <ForwardFilled />,
|
|
34
|
+
clickHandler: () => {
|
|
35
|
+
console.log('click Forward');
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
title: 'Copy',
|
|
40
|
+
// icon: 'ic2',
|
|
41
|
+
clickHandler: () => {
|
|
42
|
+
console.log('click Copy');
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
export const contextMessageMenuAI: ContextMessageMenuAI[] = [
|
|
48
|
+
// {
|
|
49
|
+
// title: 'Translate',
|
|
50
|
+
// // icon: ,
|
|
51
|
+
// clickHandler: () => {
|
|
52
|
+
// console.log('click Translate');
|
|
53
|
+
// },
|
|
54
|
+
// },
|
|
55
|
+
// {
|
|
56
|
+
// title: 'Answer',
|
|
57
|
+
// // icon: 'ic2',
|
|
58
|
+
// clickHandler: () => {
|
|
59
|
+
// console.log('click Answer');
|
|
60
|
+
// },
|
|
61
|
+
// },
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
type DropDownMenuProps = {
|
|
65
|
+
items: ContextMessageMenu[];
|
|
66
|
+
itemsAI?: ContextMessageMenuAI[];
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// eslint-disable-next-line react/function-component-definition
|
|
70
|
+
export const DropDownMenu: React.FC<DropDownMenuProps> = ({
|
|
71
|
+
items,
|
|
72
|
+
itemsAI,
|
|
73
|
+
}: DropDownMenuProps) => {
|
|
74
|
+
console.log(itemsAI);
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<div className="drop-down-menu2-container">
|
|
78
|
+
{items.map((item, index) => {
|
|
79
|
+
return (
|
|
80
|
+
<ItemDropDownMenu
|
|
81
|
+
key={index}
|
|
82
|
+
item={item.title}
|
|
83
|
+
icon={item.icon}
|
|
84
|
+
clickAction={item.clickHandler}
|
|
85
|
+
touchAction={item.touchHandler}
|
|
86
|
+
/>
|
|
87
|
+
);
|
|
88
|
+
})}
|
|
89
|
+
<div className="drop-down-menu2-container--divider" />
|
|
90
|
+
{itemsAI && itemsAI?.length > 0
|
|
91
|
+
? itemsAI?.map((itemAI, indexAI) => {
|
|
92
|
+
return (
|
|
93
|
+
<ItemDropDownMenu
|
|
94
|
+
key={indexAI}
|
|
95
|
+
item={itemAI.title}
|
|
96
|
+
icon={itemAI.icon}
|
|
97
|
+
clickAction={itemAI.clickHandler}
|
|
98
|
+
touchAction={itemAI.touchHandler}
|
|
99
|
+
/>
|
|
100
|
+
);
|
|
101
|
+
})
|
|
102
|
+
: null}
|
|
103
|
+
</div>
|
|
104
|
+
);
|
|
105
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
.item-drop-down-menu-container {
|
|
2
|
+
//width:135px;
|
|
3
|
+
//height:32px;
|
|
4
|
+
//position:absolute;
|
|
5
|
+
//left:0px;
|
|
6
|
+
//top:8px;ß
|
|
7
|
+
|
|
8
|
+
//min-height: 36px;
|
|
9
|
+
//display: flex;
|
|
10
|
+
//flex-direction: row;
|
|
11
|
+
//flex-wrap: nowrap;
|
|
12
|
+
//justify-content: flex-start;
|
|
13
|
+
//align-items: center;
|
|
14
|
+
//gap: 16px;
|
|
15
|
+
//color: firebrick;
|
|
16
|
+
|
|
17
|
+
display: flex;
|
|
18
|
+
padding: 4px 8px 4px 16px;
|
|
19
|
+
justify-content: flex-end;
|
|
20
|
+
align-items: center;
|
|
21
|
+
align-self: flex-start;
|
|
22
|
+
|
|
23
|
+
//border: 1px solid blue;
|
|
24
|
+
|
|
25
|
+
&--title {
|
|
26
|
+
color: var(--main-text);
|
|
27
|
+
text-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
|
|
28
|
+
min-width: 80px;
|
|
29
|
+
max-width: 80px;
|
|
30
|
+
width: 80px;
|
|
31
|
+
|
|
32
|
+
/* Body/Body Medium */
|
|
33
|
+
font-family: Roboto;
|
|
34
|
+
text-align: left;
|
|
35
|
+
font-size: 14px;
|
|
36
|
+
font-style: normal;
|
|
37
|
+
font-weight: 400;
|
|
38
|
+
line-height: 20px; /* 142.857% */
|
|
39
|
+
letter-spacing: 0.25px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&--icon {
|
|
43
|
+
display: flex;
|
|
44
|
+
width: 24px;
|
|
45
|
+
height: 24px;
|
|
46
|
+
padding: 4px;
|
|
47
|
+
justify-content: center;
|
|
48
|
+
align-items: center;
|
|
49
|
+
}
|
|
50
|
+
}
|