quickblox-react-ui-kit 0.2.1 → 0.2.3
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 +2 -6
- package/dist/Data/source/remote/Mapper/MessageDTOMapper.d.ts +3 -1
- package/dist/Domain/use_cases/ai/AIRephraseUseCase.d.ts +15 -0
- package/dist/Domain/use_cases/ai/AIRephraseWithProxyUseCase.d.ts +15 -0
- package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIMessageWidget.d.ts +6 -0
- 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/providers/QuickBloxUIKitProvider/QuickBloxUIKitProvider.d.ts +1 -1
- package/dist/QBconfig.d.ts +1 -0
- package/dist/index-ui.js +82 -16
- package/global.d.ts +48 -6
- package/package.json +1 -1
- package/src/App.tsx +9 -14
- package/src/CommonTypes/FunctionResult.ts +54 -0
- package/src/Data/DefaultConfigurations.ts +79 -10
- package/src/Data/source/AISource.ts +3 -3
- package/src/Data/source/remote/Mapper/DialogDTOMapper.ts +3 -0
- package/src/Data/source/remote/Mapper/MessageDTOMapper.ts +57 -4
- package/src/Data/source/remote/RemoteDataSource.ts +2 -1
- package/src/Domain/use_cases/ai/AIRephraseUseCase.ts +87 -0
- package/src/Domain/use_cases/ai/AIRephraseWithProxyUseCase.ts +71 -0
- package/src/Presentation/Views/Dialogs/Dialogs.tsx +1 -1
- package/src/Presentation/Views/Dialogs/useDialogsViewModel.ts +4 -1
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIMessageWidget.ts +11 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidget.tsx +15 -35
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidgetWithProxy.tsx +79 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidget.tsx +23 -41
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidgetWithProxy.tsx +86 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidget.tsx +15 -33
- package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidgetWithProxy.tsx +88 -0
- package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.scss +2 -2
- package/src/Presentation/components/UI/Dialogs/MessagesView/MessagesView.tsx +19 -17
- package/src/Presentation/components/UI/Dialogs/MessagesView/VideoAttachmentComponent/VideoAttachmentComponent.scss +6 -2
- package/src/Presentation/components/UI/Dialogs/MessagesView/useMessagesViewModel.ts +18 -6
- package/src/Presentation/components/layouts/Desktop/QuickBloxUIKitDesktopLayout.tsx +42 -38
- package/src/Presentation/components/providers/QuickBloxUIKitProvider/QuickBloxUIKitProvider.tsx +8 -7
- package/src/QBconfig.ts +4 -3
- package/src/utils/parse.ts +1 -1
|
@@ -1,26 +1,25 @@
|
|
|
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
5
|
import { AISource, IChatMessage } from '../../../../../../Data/source/AISource';
|
|
6
6
|
|
|
7
|
-
interface MessageWidgetProps {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
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
|
+
// apiKeyOrSessionToken: string;
|
|
16
|
+
// apiKey: string;
|
|
17
|
+
// }
|
|
18
18
|
export default function UseDefaultAIAssistAnswerWidget({
|
|
19
19
|
servername,
|
|
20
20
|
api,
|
|
21
21
|
port,
|
|
22
|
-
|
|
23
|
-
apiKey,
|
|
22
|
+
apiKeyOrSessionToken,
|
|
24
23
|
}: MessageWidgetProps): AIMessageWidget {
|
|
25
24
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
26
25
|
const [errorMessage, setErrorMessage] = useState<string>('');
|
|
@@ -53,39 +52,20 @@ export default function UseDefaultAIAssistAnswerWidget({
|
|
|
53
52
|
if (textToSend && textToSend.length > 0) {
|
|
54
53
|
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
54
|
|
|
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
55
|
// eslint-disable-next-line no-return-await
|
|
74
|
-
return await AISource.
|
|
56
|
+
return await AISource.getData(
|
|
75
57
|
prompt,
|
|
76
58
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
77
59
|
context,
|
|
78
60
|
servername,
|
|
79
61
|
api,
|
|
80
62
|
port,
|
|
81
|
-
|
|
63
|
+
apiKeyOrSessionToken,
|
|
82
64
|
).then((data) => {
|
|
83
65
|
setTextFromWidgetToContent(data);
|
|
84
66
|
|
|
85
67
|
return data;
|
|
86
68
|
});
|
|
87
|
-
|
|
88
|
-
// eslint-disable-next-line no-return-await
|
|
89
69
|
}
|
|
90
70
|
|
|
91
71
|
return '';
|
|
@@ -0,0 +1,79 @@
|
|
|
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 { 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
|
+
// apiKeyOrSessionToken: string;
|
|
16
|
+
// apiKey: string;
|
|
17
|
+
// }
|
|
18
|
+
export default function UseDefaultAIAssistAnswerWidgetWithProxy({
|
|
19
|
+
servername,
|
|
20
|
+
api,
|
|
21
|
+
port,
|
|
22
|
+
apiKeyOrSessionToken,
|
|
23
|
+
}: MessageWidgetProps): AIMessageWidget {
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
25
|
+
const [errorMessage, setErrorMessage] = useState<string>('');
|
|
26
|
+
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/no-empty-function
|
|
28
|
+
const fileToWidget = (file: File, context: IChatMessage[]): void => {};
|
|
29
|
+
|
|
30
|
+
const renderWidget = (): JSX.Element => {
|
|
31
|
+
if (errorMessage && errorMessage.length > 0) {
|
|
32
|
+
const errorsDescriptions:
|
|
33
|
+
| { title: string; action: () => void }[]
|
|
34
|
+
| undefined = [];
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<ErrorMessageIcon
|
|
38
|
+
errorMessageText={errorMessage}
|
|
39
|
+
errorsDescriptions={errorsDescriptions}
|
|
40
|
+
/>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return <AIWidgetIcon applyZoom color="green" />;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const [textFromWidgetToContent, setTextFromWidgetToContent] = useState('');
|
|
48
|
+
const textToWidget = async (
|
|
49
|
+
textToSend: string,
|
|
50
|
+
context: IChatMessage[],
|
|
51
|
+
): Promise<string> => {
|
|
52
|
+
if (textToSend && textToSend.length > 0) {
|
|
53
|
+
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}"`;
|
|
54
|
+
|
|
55
|
+
// eslint-disable-next-line no-return-await
|
|
56
|
+
return await AISource.getDataWithProxyServer(
|
|
57
|
+
prompt,
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
59
|
+
context,
|
|
60
|
+
servername,
|
|
61
|
+
api,
|
|
62
|
+
port,
|
|
63
|
+
apiKeyOrSessionToken,
|
|
64
|
+
).then((data) => {
|
|
65
|
+
setTextFromWidgetToContent(data);
|
|
66
|
+
|
|
67
|
+
return data;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return '';
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
textToContent: textFromWidgetToContent,
|
|
76
|
+
renderWidget,
|
|
77
|
+
textToWidget,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
@@ -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;
|
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
|
|
81
|
+
return {
|
|
82
|
+
textToContent: textFromWidgetToContent,
|
|
83
|
+
renderWidget,
|
|
84
|
+
textToWidget,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
@@ -1,26 +1,25 @@
|
|
|
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';
|
|
4
|
+
import { AIMessageWidget, MessageWidgetProps } from './AIMessageWidget';
|
|
5
5
|
import { AISource, IChatMessage } from '../../../../../../Data/source/AISource';
|
|
6
6
|
|
|
7
|
-
interface MessageWidgetProps {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
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
|
+
// apiKeyOrSessionToken: string;
|
|
16
|
+
// apiKey: string;
|
|
17
|
+
// }
|
|
18
18
|
export default function UseDefaultAITranslateWidget({
|
|
19
19
|
servername,
|
|
20
20
|
api,
|
|
21
21
|
port,
|
|
22
|
-
|
|
23
|
-
apiKey,
|
|
22
|
+
apiKeyOrSessionToken,
|
|
24
23
|
}: MessageWidgetProps): AIMessageWidget {
|
|
25
24
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
26
25
|
const [errorMessage, setErrorMessage] = useState<string>('');
|
|
@@ -62,32 +61,15 @@ export default function UseDefaultAITranslateWidget({
|
|
|
62
61
|
} and give me just only translated text. Text to translate is: "${textToSend}"`;
|
|
63
62
|
}
|
|
64
63
|
|
|
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
64
|
// eslint-disable-next-line no-return-await
|
|
83
|
-
return await AISource.
|
|
65
|
+
return await AISource.getData(
|
|
84
66
|
prompt,
|
|
85
67
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
86
68
|
context,
|
|
87
69
|
servername,
|
|
88
70
|
api,
|
|
89
71
|
port,
|
|
90
|
-
|
|
72
|
+
apiKeyOrSessionToken,
|
|
91
73
|
).then((data) => {
|
|
92
74
|
setTextFromWidgetToContent(data);
|
|
93
75
|
|
|
@@ -0,0 +1,88 @@
|
|
|
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 { 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
|
+
// apiKeyOrSessionToken: string;
|
|
16
|
+
// apiKey: string;
|
|
17
|
+
// }
|
|
18
|
+
export default function UseDefaultAITranslateWidgetWithProxy({
|
|
19
|
+
servername,
|
|
20
|
+
api,
|
|
21
|
+
port,
|
|
22
|
+
apiKeyOrSessionToken,
|
|
23
|
+
}: MessageWidgetProps): AIMessageWidget {
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
25
|
+
const [errorMessage, setErrorMessage] = useState<string>('');
|
|
26
|
+
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/no-empty-function
|
|
28
|
+
const fileToWidget = (file: File, context: IChatMessage[]): void => {};
|
|
29
|
+
|
|
30
|
+
const renderWidget = (): JSX.Element => {
|
|
31
|
+
if (errorMessage && errorMessage.length > 0) {
|
|
32
|
+
const errorsDescriptions:
|
|
33
|
+
| { title: string; action: () => void }[]
|
|
34
|
+
| undefined = [];
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<ErrorMessageIcon
|
|
38
|
+
errorMessageText={errorMessage}
|
|
39
|
+
errorsDescriptions={errorsDescriptions}
|
|
40
|
+
/>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return <AIWidgetIcon applyZoom color="green" />;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const [textFromWidgetToContent, setTextFromWidgetToContent] = useState('');
|
|
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
|
+
// eslint-disable-next-line no-return-await
|
|
55
|
+
let prompt = `Please, translate the next text in english and give me just only translated text. Text to translate is: "${textToSend}"`;
|
|
56
|
+
const { language } = additionalSettings || {};
|
|
57
|
+
|
|
58
|
+
if (language) {
|
|
59
|
+
prompt = `Please, translate the next text in ${
|
|
60
|
+
language as string
|
|
61
|
+
} and give me just only translated text. Text to translate is: "${textToSend}"`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// eslint-disable-next-line no-return-await
|
|
65
|
+
return await AISource.getDataWithProxyServer(
|
|
66
|
+
prompt,
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
68
|
+
context,
|
|
69
|
+
servername,
|
|
70
|
+
api,
|
|
71
|
+
port,
|
|
72
|
+
apiKeyOrSessionToken,
|
|
73
|
+
).then((data) => {
|
|
74
|
+
setTextFromWidgetToContent(data);
|
|
75
|
+
|
|
76
|
+
return data;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return '';
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
textToContent: textFromWidgetToContent,
|
|
85
|
+
renderWidget,
|
|
86
|
+
textToWidget,
|
|
87
|
+
};
|
|
88
|
+
}
|
package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.scss
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
box-sizing: border-box;
|
|
32
32
|
}
|
|
33
33
|
.incoming-text-message {
|
|
34
|
-
background: var(--
|
|
34
|
+
background: var(--secondary-background);
|
|
35
35
|
padding: 0px 16px 8px 8px;
|
|
36
36
|
display: flex;
|
|
37
37
|
flex-direction: row;
|
|
@@ -241,7 +241,7 @@
|
|
|
241
241
|
position: relative;
|
|
242
242
|
}
|
|
243
243
|
.chat-bubble-background {
|
|
244
|
-
background: var(--
|
|
244
|
+
background: var(--incoming-background);
|
|
245
245
|
border-radius: 22px 22px 22px 0px;
|
|
246
246
|
padding: 8px 12px 8px 12px;
|
|
247
247
|
display: flex;
|
|
@@ -61,6 +61,8 @@ import SmirkIcon from '../../svgs/Icons/AIWidgets/SmirkIcon';
|
|
|
61
61
|
import PerformingArtsIcon from '../../svgs/Icons/AIWidgets/PerformingArtsIcon';
|
|
62
62
|
import { FunctionTypeVoidToVoid } from '../../../../Views/Base/BaseViewModel';
|
|
63
63
|
import { IChatMessage } from '../../../../../Data/source/AISource';
|
|
64
|
+
import AIWidgetActions from './AIWidgets/AIWidgetActions/AIWidgetActions';
|
|
65
|
+
import ToneIcon from '../../svgs/Icons/Actions/Tone';
|
|
64
66
|
// import ToneIcon from '../../svgs/Icons/Actions/Tone';
|
|
65
67
|
// import AIWidgetActions from './AIWidgets/AIWidgetActions/AIWidgetActions';
|
|
66
68
|
|
|
@@ -1183,23 +1185,23 @@ const MessagesView: React.FC<HeaderDialogsMessagesProps> = ({
|
|
|
1183
1185
|
placeholder="enter text to send"
|
|
1184
1186
|
/>
|
|
1185
1187
|
</div>
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1188
|
+
<div className="right">
|
|
1189
|
+
{AIRephrase && (
|
|
1190
|
+
<div className="icon">
|
|
1191
|
+
<AIWidgetActions
|
|
1192
|
+
widgetToRender={
|
|
1193
|
+
<ToneIcon
|
|
1194
|
+
width="24"
|
|
1195
|
+
height="24"
|
|
1196
|
+
applyZoom
|
|
1197
|
+
color={theme ? theme.mainText() : 'var(--main-text)'}
|
|
1198
|
+
/>
|
|
1199
|
+
}
|
|
1200
|
+
items={getAIEditingMessagesItems()}
|
|
1201
|
+
/>
|
|
1202
|
+
</div>
|
|
1203
|
+
)}
|
|
1204
|
+
</div>
|
|
1203
1205
|
</div>
|
|
1204
1206
|
)}
|
|
1205
1207
|
|
|
@@ -295,7 +295,7 @@ export default function useMessagesViewModel(
|
|
|
295
295
|
const sendTypingTextMessage = () => {
|
|
296
296
|
console.log('call release in MessagesViewModelWithMockUseCase');
|
|
297
297
|
userTypingMessageUseCase.execute().catch((reason) => {
|
|
298
|
-
const errorMessage = stringifyError(reason);
|
|
298
|
+
const errorMessage: string = stringifyError(reason);
|
|
299
299
|
|
|
300
300
|
console.log('have exception in sendTypingTextMessage: ', errorMessage);
|
|
301
301
|
|
|
@@ -344,7 +344,7 @@ export default function useMessagesViewModel(
|
|
|
344
344
|
sendTextMessageUseCase
|
|
345
345
|
.execute()
|
|
346
346
|
.catch((reason) => {
|
|
347
|
-
const errorMessage = stringifyError(reason);
|
|
347
|
+
const errorMessage: string = stringifyError(reason);
|
|
348
348
|
|
|
349
349
|
console.log(
|
|
350
350
|
'exception in sendMessage in useMessagesViewModel',
|
|
@@ -399,12 +399,18 @@ export default function useMessagesViewModel(
|
|
|
399
399
|
.then((fileMessage: FileEntity) => {
|
|
400
400
|
console.log(JSON.stringify(fileMessage));
|
|
401
401
|
// '[attachment]'
|
|
402
|
+
const recipientId =
|
|
403
|
+
dialog.type === DialogType.private
|
|
404
|
+
? (dialog as PrivateDialogEntity).participantId
|
|
405
|
+
: currentUserId;
|
|
406
|
+
|
|
407
|
+
// eslint-disable-next-line promise/always-return
|
|
408
|
+
const messageBody = fileMessage.name || '[attachment]';
|
|
402
409
|
const messageToSend: MessageEntity =
|
|
403
410
|
Stubs.createMessageEntityWithParams(
|
|
404
411
|
'',
|
|
405
412
|
dialog.id,
|
|
406
|
-
|
|
407
|
-
fileMessage.name || '[attachment]',
|
|
413
|
+
messageBody,
|
|
408
414
|
Date.now().toString(),
|
|
409
415
|
Date.now(),
|
|
410
416
|
Date.now().toString(),
|
|
@@ -412,7 +418,8 @@ export default function useMessagesViewModel(
|
|
|
412
418
|
[],
|
|
413
419
|
1,
|
|
414
420
|
currentUserId,
|
|
415
|
-
|
|
421
|
+
// eslint-disable-next-line promise/always-return
|
|
422
|
+
recipientId,
|
|
416
423
|
[],
|
|
417
424
|
'',
|
|
418
425
|
DialogType.group,
|
|
@@ -421,16 +428,21 @@ export default function useMessagesViewModel(
|
|
|
421
428
|
messageToSend.dialogType = dialog.type;
|
|
422
429
|
const attachments: ChatMessageAttachmentEntity[] = [
|
|
423
430
|
{
|
|
424
|
-
id: fileMessage.
|
|
431
|
+
id: fileMessage.id as string,
|
|
432
|
+
uid: fileMessage.uid,
|
|
425
433
|
type: fileMessage.type!,
|
|
426
434
|
file: fileMessage,
|
|
427
435
|
name: fileMessage.name,
|
|
428
436
|
size: fileMessage.size,
|
|
437
|
+
url: fileMessage.url,
|
|
429
438
|
},
|
|
430
439
|
];
|
|
431
440
|
|
|
432
441
|
messageToSend.attachments = attachments;
|
|
433
442
|
|
|
443
|
+
messageToSend.message = `MediaContentEntity|${messageBody}|${
|
|
444
|
+
fileMessage.uid
|
|
445
|
+
}|${fileMessage.type!.toString()}`;
|
|
434
446
|
sendMessage(messageToSend);
|
|
435
447
|
//
|
|
436
448
|
})
|