@quidgest/chatbot 0.4.0 → 0.5.0
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/components/ChatBot/ChatBot.vue.d.ts +53 -0
- package/dist/components/ChatBot/types.d.ts +48 -0
- package/dist/components/ChatBotInput/ChatBotInput.vue.d.ts +17 -0
- package/dist/components/ChatBotInput/index.d.ts +5 -0
- package/dist/components/ChatBotInput/types.d.ts +28 -0
- package/dist/components/ChatBotMessage/ChatBotMessage.vue.d.ts +41 -0
- package/dist/components/ChatBotMessage/ChatBotMessageButtons.vue.d.ts +21 -0
- package/dist/components/ChatBotMessage/index.d.ts +6 -0
- package/dist/components/ChatBotMessage/types.d.ts +46 -0
- package/dist/components/ChatToolBar/ChatToolBar.vue.d.ts +39 -0
- package/dist/components/ChatToolBar/index.d.ts +5 -0
- package/dist/components/ChatToolBar/types.d.ts +16 -0
- package/dist/components/FieldPreview/FieldPreview.vue.d.ts +17 -0
- package/dist/components/FieldPreview/index.d.ts +5 -0
- package/dist/components/FieldPreview/types.d.ts +7 -0
- package/dist/components/MarkdownRender/MarkdownRender.vue.d.ts +13 -0
- package/dist/components/MarkdownRender/index.d.ts +5 -0
- package/dist/components/MarkdownRender/types.d.ts +7 -0
- package/dist/composables/useChatApi.d.ts +23 -0
- package/dist/composables/useChatMessages.d.ts +11 -0
- package/dist/composables/useSSE.d.ts +10 -0
- package/dist/composables/useTexts.d.ts +26 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +27 -47
- package/dist/index.mjs +2651 -8663
- package/dist/style.css +1 -1
- package/dist/utils/helper.d.ts +1 -0
- package/package.json +5 -5
- package/src/assets/chatbot_profile.svg +1 -0
- package/src/assets/styles/styles.scss +10 -42
- package/src/components/ChatBot/ChatBot.vue +375 -0
- package/src/components/ChatBot/types.ts +55 -0
- package/src/components/ChatBotInput/ChatBotInput.vue +195 -0
- package/src/components/ChatBotInput/index.ts +5 -0
- package/src/components/ChatBotInput/types.ts +33 -0
- package/src/components/ChatBotMessage/ChatBotMessage.vue +139 -0
- package/src/components/ChatBotMessage/ChatBotMessageButtons.vue +169 -0
- package/src/components/ChatBotMessage/index.ts +8 -0
- package/src/components/ChatBotMessage/types.ts +70 -0
- package/src/components/ChatToolBar/ChatToolBar.vue +82 -0
- package/src/components/ChatToolBar/index.ts +5 -0
- package/src/components/ChatToolBar/types.ts +18 -0
- package/src/components/FieldPreview/FieldPreview.vue +78 -0
- package/src/components/FieldPreview/field-preview.scss +34 -0
- package/src/components/FieldPreview/index.ts +5 -0
- package/src/components/FieldPreview/types.ts +7 -0
- package/src/components/MarkdownRender/MarkdownRender.vue +25 -0
- package/src/components/MarkdownRender/index.ts +5 -0
- package/src/components/MarkdownRender/markdown-render.scss +24 -0
- package/src/components/MarkdownRender/types.ts +7 -0
- package/src/components/PulseDots/PulseDots.vue +24 -0
- package/src/components/PulseDots/pulse-dots.scss +37 -0
- package/src/composables/useChatApi.ts +156 -0
- package/src/composables/useChatMessages.ts +58 -0
- package/src/composables/useSSE.ts +90 -0
- package/src/composables/useTexts.ts +32 -0
- package/src/index.ts +1 -1
- package/src/utils/helper.ts +12 -0
- package/dist/components/CBMessage.vue.d.ts +0 -95
- package/dist/components/ChatBot.vue.d.ts +0 -65
- package/dist/components/index.d.ts +0 -4
- package/dist/types/chatbot.type.d.ts +0 -14
- package/dist/types/message.type.d.ts +0 -34
- package/dist/types/texts.type.d.ts +0 -3
- package/src/assets/chatbot.png +0 -0
- package/src/components/CBMessage.vue +0 -276
- package/src/components/ChatBot.vue +0 -496
- package/src/components/PulseDots.vue +0 -15
- package/src/components/index.ts +0 -4
- package/src/types/chatbot.type.ts +0 -15
- package/src/types/message.type.ts +0 -55
- package/src/types/texts.type.ts +0 -3
- /package/dist/components/{PulseDots.vue.d.ts → PulseDots/PulseDots.vue.d.ts} +0 -0
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { ChatBotMessageSender } from '../types/message.type';
|
|
2
|
-
import { ResourceStrings } from '../types/texts.type';
|
|
3
|
-
|
|
4
|
-
export interface CBMessageProps {
|
|
5
|
-
sender?: ChatBotMessageSender;
|
|
6
|
-
message?: string;
|
|
7
|
-
date?: Date;
|
|
8
|
-
loading?: boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Project locale
|
|
11
|
-
*/
|
|
12
|
-
dateFormat?: string;
|
|
13
|
-
/**
|
|
14
|
-
* Image preview URL
|
|
15
|
-
*/
|
|
16
|
-
imagePreviewUrl?: string;
|
|
17
|
-
/**
|
|
18
|
-
* Default chatBot texts
|
|
19
|
-
*/
|
|
20
|
-
texts?: ResourceStrings;
|
|
21
|
-
/**
|
|
22
|
-
* Default api endpoint
|
|
23
|
-
*/
|
|
24
|
-
apiEndpoint?: String;
|
|
25
|
-
/**
|
|
26
|
-
* Session ID
|
|
27
|
-
*/
|
|
28
|
-
sessionID?: String;
|
|
29
|
-
/**
|
|
30
|
-
* User image
|
|
31
|
-
*/
|
|
32
|
-
userImage: string;
|
|
33
|
-
/**
|
|
34
|
-
* Chatbot image
|
|
35
|
-
*/
|
|
36
|
-
chatbotImage: string;
|
|
37
|
-
/**
|
|
38
|
-
* Flag to mark welcome messages
|
|
39
|
-
*/
|
|
40
|
-
isWelcomeMessage?: boolean;
|
|
41
|
-
}
|
|
42
|
-
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<CBMessageProps>, {
|
|
43
|
-
sender: string;
|
|
44
|
-
userImage: undefined;
|
|
45
|
-
date: () => Date;
|
|
46
|
-
texts: () => {
|
|
47
|
-
commentDialogTitle: string;
|
|
48
|
-
commentPlaceholder: string;
|
|
49
|
-
goodResponse: string;
|
|
50
|
-
badResponse: string;
|
|
51
|
-
copyResponse: string;
|
|
52
|
-
submitButton: string;
|
|
53
|
-
cancelButton: string;
|
|
54
|
-
senderImage: string;
|
|
55
|
-
imagePreview: string;
|
|
56
|
-
};
|
|
57
|
-
}>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<CBMessageProps>, {
|
|
58
|
-
sender: string;
|
|
59
|
-
userImage: undefined;
|
|
60
|
-
date: () => Date;
|
|
61
|
-
texts: () => {
|
|
62
|
-
commentDialogTitle: string;
|
|
63
|
-
commentPlaceholder: string;
|
|
64
|
-
goodResponse: string;
|
|
65
|
-
badResponse: string;
|
|
66
|
-
copyResponse: string;
|
|
67
|
-
submitButton: string;
|
|
68
|
-
cancelButton: string;
|
|
69
|
-
senderImage: string;
|
|
70
|
-
imagePreview: string;
|
|
71
|
-
};
|
|
72
|
-
}>>> & Readonly<{}>, {
|
|
73
|
-
sender: ChatBotMessageSender;
|
|
74
|
-
date: Date;
|
|
75
|
-
texts: ResourceStrings;
|
|
76
|
-
userImage: string;
|
|
77
|
-
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
78
|
-
export default _default;
|
|
79
|
-
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
80
|
-
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
81
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
82
|
-
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
83
|
-
} : {
|
|
84
|
-
type: import('vue').PropType<T[K]>;
|
|
85
|
-
required: true;
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
type __VLS_WithDefaults<P, D> = {
|
|
89
|
-
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
90
|
-
default: D[K];
|
|
91
|
-
}> : P[K];
|
|
92
|
-
};
|
|
93
|
-
type __VLS_Prettify<T> = {
|
|
94
|
-
[K in keyof T]: T[K];
|
|
95
|
-
} & {};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { ChatBotProps } from '../types/chatbot.type';
|
|
2
|
-
|
|
3
|
-
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<ChatBotProps>, {
|
|
4
|
-
apiEndpoint: string;
|
|
5
|
-
userImage: string;
|
|
6
|
-
chatbotImage: string;
|
|
7
|
-
mode: string;
|
|
8
|
-
texts: () => {
|
|
9
|
-
chatbotTitle: string;
|
|
10
|
-
sendMessage: string;
|
|
11
|
-
clearChat: string;
|
|
12
|
-
inputLabel: string;
|
|
13
|
-
imageUpload: string;
|
|
14
|
-
imageUploadQButton: string;
|
|
15
|
-
goodResponse: string;
|
|
16
|
-
badResponse: string;
|
|
17
|
-
initialMessage: string;
|
|
18
|
-
initialAgentMessage: string;
|
|
19
|
-
loginError: string;
|
|
20
|
-
botIsSick: string;
|
|
21
|
-
};
|
|
22
|
-
}>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<ChatBotProps>, {
|
|
23
|
-
apiEndpoint: string;
|
|
24
|
-
userImage: string;
|
|
25
|
-
chatbotImage: string;
|
|
26
|
-
mode: string;
|
|
27
|
-
texts: () => {
|
|
28
|
-
chatbotTitle: string;
|
|
29
|
-
sendMessage: string;
|
|
30
|
-
clearChat: string;
|
|
31
|
-
inputLabel: string;
|
|
32
|
-
imageUpload: string;
|
|
33
|
-
imageUploadQButton: string;
|
|
34
|
-
goodResponse: string;
|
|
35
|
-
badResponse: string;
|
|
36
|
-
initialMessage: string;
|
|
37
|
-
initialAgentMessage: string;
|
|
38
|
-
loginError: string;
|
|
39
|
-
botIsSick: string;
|
|
40
|
-
};
|
|
41
|
-
}>>> & Readonly<{}>, {
|
|
42
|
-
texts: import('../types/texts.type').ResourceStrings;
|
|
43
|
-
apiEndpoint: string;
|
|
44
|
-
userImage: string;
|
|
45
|
-
chatbotImage: string;
|
|
46
|
-
mode: import('../types/chatbot.type').ChatBotMode;
|
|
47
|
-
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
48
|
-
export default _default;
|
|
49
|
-
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
50
|
-
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
51
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
52
|
-
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
53
|
-
} : {
|
|
54
|
-
type: import('vue').PropType<T[K]>;
|
|
55
|
-
required: true;
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
type __VLS_WithDefaults<P, D> = {
|
|
59
|
-
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
60
|
-
default: D[K];
|
|
61
|
-
}> : P[K];
|
|
62
|
-
};
|
|
63
|
-
type __VLS_Prettify<T> = {
|
|
64
|
-
[K in keyof T]: T[K];
|
|
65
|
-
} & {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ResourceStrings } from './texts.type';
|
|
2
|
-
|
|
3
|
-
export type ChatBotProps = {
|
|
4
|
-
apiEndpoint?: string;
|
|
5
|
-
controllerEndpoint?: string;
|
|
6
|
-
texts?: ResourceStrings;
|
|
7
|
-
username: string;
|
|
8
|
-
projectPath: string;
|
|
9
|
-
userImage?: string;
|
|
10
|
-
chatbotImage?: string;
|
|
11
|
-
dateFormat?: string;
|
|
12
|
-
mode?: ChatBotMode;
|
|
13
|
-
};
|
|
14
|
-
export type ChatBotMode = 'chat' | 'agent';
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export type ChatBotMessage = {
|
|
2
|
-
id: number;
|
|
3
|
-
message: string;
|
|
4
|
-
date: Date;
|
|
5
|
-
sender: ChatBotMessageSender;
|
|
6
|
-
sessionID: string;
|
|
7
|
-
imagePreviewUrl?: string;
|
|
8
|
-
isWelcomeMessage?: boolean;
|
|
9
|
-
};
|
|
10
|
-
export type ChatBotMessageContent = {
|
|
11
|
-
content: string;
|
|
12
|
-
type: string;
|
|
13
|
-
sessionID: string;
|
|
14
|
-
imageUrl?: string;
|
|
15
|
-
};
|
|
16
|
-
export type ChatBotMessageSender = 'bot' | 'user';
|
|
17
|
-
export interface CBMessageProps {
|
|
18
|
-
sender?: ChatBotMessageSender;
|
|
19
|
-
message?: string;
|
|
20
|
-
date?: Date;
|
|
21
|
-
loading?: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Project locale
|
|
24
|
-
*/
|
|
25
|
-
dateFormat?: string;
|
|
26
|
-
/**
|
|
27
|
-
* User image
|
|
28
|
-
*/
|
|
29
|
-
userImage: string;
|
|
30
|
-
/**
|
|
31
|
-
* Chatbot image
|
|
32
|
-
*/
|
|
33
|
-
chatbotImage: string;
|
|
34
|
-
}
|
package/src/assets/chatbot.png
DELETED
|
Binary file
|
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="q-chatbot__message-container">
|
|
3
|
-
<q-icon
|
|
4
|
-
type="img"
|
|
5
|
-
:icon="messageImage"
|
|
6
|
-
:alt="props.texts.senderImage"
|
|
7
|
-
class="q-chatbot__profile" />
|
|
8
|
-
|
|
9
|
-
<div class="q-chatbot__message-wrapper">
|
|
10
|
-
<div
|
|
11
|
-
v-if="props.imagePreviewUrl && props.imagePreviewUrl.length > 0"
|
|
12
|
-
class="q-chatbot__image-preview">
|
|
13
|
-
<img
|
|
14
|
-
:src="props.imagePreviewUrl"
|
|
15
|
-
:alt="props.texts.imagePreview" />
|
|
16
|
-
</div>
|
|
17
|
-
<!-- Message body -->
|
|
18
|
-
<div class="q-chatbot__message">
|
|
19
|
-
<!-- When loading is true, show bouncing dots animation -->
|
|
20
|
-
<pulse-dots v-if="loading" />
|
|
21
|
-
<template v-else>
|
|
22
|
-
<vue-markdown-render
|
|
23
|
-
v-if="props.sender === 'bot'"
|
|
24
|
-
class="q-chatbot__text"
|
|
25
|
-
:source="props.message || ''" />
|
|
26
|
-
|
|
27
|
-
<div
|
|
28
|
-
v-else
|
|
29
|
-
class="q-chatbot__text">
|
|
30
|
-
{{ props.message }}
|
|
31
|
-
</div>
|
|
32
|
-
</template>
|
|
33
|
-
</div>
|
|
34
|
-
<q-dialog
|
|
35
|
-
id="comment-dialog"
|
|
36
|
-
v-model="showDialog"
|
|
37
|
-
:buttons="commentButtons">
|
|
38
|
-
<template #body.content>
|
|
39
|
-
<div class="q-chatbot__dialog-title">
|
|
40
|
-
{{ props.texts.commentDialogTitle }}
|
|
41
|
-
</div>
|
|
42
|
-
<q-text-field
|
|
43
|
-
v-model="feedbackComment"
|
|
44
|
-
:maxLength="150"
|
|
45
|
-
size="large"
|
|
46
|
-
:placeholder="props.texts.commentPlaceholder" />
|
|
47
|
-
</template>
|
|
48
|
-
</q-dialog>
|
|
49
|
-
|
|
50
|
-
<!-- Thumbs up and down buttons, only for bot messages -->
|
|
51
|
-
<div
|
|
52
|
-
v-if="isBotMessageAndNotDefault"
|
|
53
|
-
class="q-chatbot__feedback-buttons">
|
|
54
|
-
<q-button-group>
|
|
55
|
-
<q-button
|
|
56
|
-
:title="props.texts.goodResponse"
|
|
57
|
-
borderless
|
|
58
|
-
:disabled="loading"
|
|
59
|
-
@click="openFeedbackDialog(1)">
|
|
60
|
-
<q-icon icon="thumb-up" />
|
|
61
|
-
</q-button>
|
|
62
|
-
<q-button
|
|
63
|
-
:title="props.texts.badResponse"
|
|
64
|
-
borderless
|
|
65
|
-
:disabled="loading"
|
|
66
|
-
@click="openFeedbackDialog(0)">
|
|
67
|
-
<q-icon icon="thumb-down" />
|
|
68
|
-
</q-button>
|
|
69
|
-
<q-button
|
|
70
|
-
:title="props.texts.copyResponse"
|
|
71
|
-
borderless
|
|
72
|
-
:disabled="loading"
|
|
73
|
-
@click="copyResponse">
|
|
74
|
-
<q-icon icon="copy-content" />
|
|
75
|
-
</q-button>
|
|
76
|
-
</q-button-group>
|
|
77
|
-
</div>
|
|
78
|
-
<div class="q-chatbot__sender">
|
|
79
|
-
{{ messageDate }}
|
|
80
|
-
</div>
|
|
81
|
-
</div>
|
|
82
|
-
</div>
|
|
83
|
-
</template>
|
|
84
|
-
|
|
85
|
-
<script setup lang="ts">
|
|
86
|
-
import { computed, ref } from 'vue'
|
|
87
|
-
import {
|
|
88
|
-
QButton,
|
|
89
|
-
QIcon,
|
|
90
|
-
QDialog,
|
|
91
|
-
QTextField
|
|
92
|
-
} from '@quidgest/ui/components'
|
|
93
|
-
import PulseDots from '@/components/PulseDots.vue'
|
|
94
|
-
import type { ChatBotMessageSender } from '@/types/message.type'
|
|
95
|
-
import { ResourceStrings } from '@/types/texts.type'
|
|
96
|
-
import VueMarkdownRender from 'vue-markdown-render'
|
|
97
|
-
import Axios from 'axios'
|
|
98
|
-
|
|
99
|
-
export interface CBMessageProps {
|
|
100
|
-
/*
|
|
101
|
-
* Sender of the message
|
|
102
|
-
*/
|
|
103
|
-
sender?: ChatBotMessageSender
|
|
104
|
-
|
|
105
|
-
/*
|
|
106
|
-
* Message to be displayed
|
|
107
|
-
*/
|
|
108
|
-
message?: string
|
|
109
|
-
|
|
110
|
-
/*
|
|
111
|
-
* Date of when the message was sent
|
|
112
|
-
*/
|
|
113
|
-
date?: Date
|
|
114
|
-
|
|
115
|
-
/*
|
|
116
|
-
* If the message is loading
|
|
117
|
-
*/
|
|
118
|
-
loading?: boolean
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Project locale
|
|
122
|
-
*/
|
|
123
|
-
dateFormat?: string
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Image preview URL
|
|
127
|
-
*/
|
|
128
|
-
imagePreviewUrl?: string
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Default chatBot texts
|
|
132
|
-
*/
|
|
133
|
-
texts?: ResourceStrings
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Default api endpoint
|
|
137
|
-
*/
|
|
138
|
-
apiEndpoint?: String
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Session ID
|
|
142
|
-
*/
|
|
143
|
-
sessionID?: String
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* User image
|
|
147
|
-
*/
|
|
148
|
-
userImage: string
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Chatbot image
|
|
152
|
-
*/
|
|
153
|
-
chatbotImage: string
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Flag to mark welcome messages
|
|
157
|
-
*/
|
|
158
|
-
isWelcomeMessage?: boolean
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
const props = withDefaults(defineProps<CBMessageProps>(), {
|
|
162
|
-
sender: 'user',
|
|
163
|
-
userImage: undefined,
|
|
164
|
-
date: () => new Date(),
|
|
165
|
-
texts: () => ({
|
|
166
|
-
commentDialogTitle: 'Would you like to add a comment?',
|
|
167
|
-
commentPlaceholder: 'Type your comment here (optional)...',
|
|
168
|
-
goodResponse: 'Good response',
|
|
169
|
-
badResponse: 'Bad response',
|
|
170
|
-
copyResponse: 'Copy response',
|
|
171
|
-
submitButton: 'Submit',
|
|
172
|
-
cancelButton: 'Cancel',
|
|
173
|
-
senderImage: 'Sender Image',
|
|
174
|
-
imagePreview: 'Image preview'
|
|
175
|
-
})
|
|
176
|
-
})
|
|
177
|
-
|
|
178
|
-
const showDialog = ref(false)
|
|
179
|
-
const feedbackComment = ref('')
|
|
180
|
-
const currentFeedback = ref<number | null>(null)
|
|
181
|
-
const commentButtons = [
|
|
182
|
-
{
|
|
183
|
-
id: 'confirm-btn',
|
|
184
|
-
action: submitFeedback,
|
|
185
|
-
props: {
|
|
186
|
-
label: props.texts.submitButton,
|
|
187
|
-
'variant': 'bold',
|
|
188
|
-
},
|
|
189
|
-
icon: {
|
|
190
|
-
icon: 'submit'
|
|
191
|
-
}
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
id: 'cancel-btn',
|
|
195
|
-
props: {
|
|
196
|
-
label: props.texts.cancelButton
|
|
197
|
-
},
|
|
198
|
-
icon: {
|
|
199
|
-
icon: 'cancel'
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
]
|
|
203
|
-
|
|
204
|
-
const isBotMessageAndNotDefault = computed(() => {
|
|
205
|
-
return (
|
|
206
|
-
props.sender === 'bot' &&
|
|
207
|
-
!Object.values(props.texts || {}).includes(props.message || '') &&
|
|
208
|
-
!props.isWelcomeMessage
|
|
209
|
-
)
|
|
210
|
-
})
|
|
211
|
-
|
|
212
|
-
const getLocaleDate = computed(() => {
|
|
213
|
-
if (!props.dateFormat) return props.date.toLocaleString()
|
|
214
|
-
|
|
215
|
-
return formatDate(props.date, 'HH:mm')
|
|
216
|
-
})
|
|
217
|
-
|
|
218
|
-
const messageDate = computed(() => {
|
|
219
|
-
return `${getLocaleDate.value}`
|
|
220
|
-
})
|
|
221
|
-
|
|
222
|
-
const messageImage = computed(() =>
|
|
223
|
-
props.sender === 'bot' ? props.chatbotImage : props.userImage
|
|
224
|
-
)
|
|
225
|
-
|
|
226
|
-
function formatDate(date: Date, format: string) {
|
|
227
|
-
const day = date.getDate().toString().padStart(2, '0')
|
|
228
|
-
const month = (date.getMonth() + 1).toString().padStart(2, '0')
|
|
229
|
-
const year = date.getFullYear().toString().padStart(2, '0')
|
|
230
|
-
const hours = date.getHours().toString().padStart(2, '0')
|
|
231
|
-
const minutes = date.getMinutes().toString().padStart(2, '0')
|
|
232
|
-
const seconds = date.getSeconds().toString().padStart(2, '0')
|
|
233
|
-
|
|
234
|
-
return format
|
|
235
|
-
.replace('dd', day)
|
|
236
|
-
.replace('MM', month)
|
|
237
|
-
.replace('yyyy', year)
|
|
238
|
-
.replace('HH', hours)
|
|
239
|
-
.replace('mm', minutes)
|
|
240
|
-
.replace('ss', seconds)
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
function openFeedbackDialog(feedback: number) {
|
|
244
|
-
showDialog.value = true
|
|
245
|
-
feedbackComment.value = ''
|
|
246
|
-
currentFeedback.value = feedback
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
function submitFeedback() {
|
|
250
|
-
if (currentFeedback.value != null) {
|
|
251
|
-
handleFeedback(currentFeedback.value, feedbackComment.value)
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
function handleFeedback(feedback: number, comment: string) {
|
|
255
|
-
Axios.post(props.apiEndpoint + '/prompt/feedback', {
|
|
256
|
-
messageSessionID: props.sessionID,
|
|
257
|
-
feedbackValue: feedback,
|
|
258
|
-
feedbackComment: comment
|
|
259
|
-
}).catch((error) => {
|
|
260
|
-
console.error('Error sending message feedback: ', error)
|
|
261
|
-
})
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
function copyResponse() {
|
|
265
|
-
if (!props.message) return
|
|
266
|
-
|
|
267
|
-
navigator.clipboard
|
|
268
|
-
.writeText(props.message)
|
|
269
|
-
.then(() => {
|
|
270
|
-
console.log('Message copied to clipboard')
|
|
271
|
-
})
|
|
272
|
-
.catch((error) => {
|
|
273
|
-
console.error('Failed to copy message to clipboard: ', error)
|
|
274
|
-
})
|
|
275
|
-
}
|
|
276
|
-
</script>
|