@5minds/node-red-dashboard-2-processcube-chat 0.1.1-develop-bd0cb7-mcvkuzxr → 0.1.1-develop-e94793-mcvyrm7g
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.
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div ref="deepChatContainer" class="ui-deepchat-container" :style="containerStyle">
|
|
3
|
-
<deep-chat
|
|
3
|
+
<deep-chat width="100%"
|
|
4
4
|
ref="deepChat"
|
|
5
|
+
:style="deepChatStyle"
|
|
5
6
|
:intro-message="config.introMessage"
|
|
6
|
-
:
|
|
7
|
-
:text-input="config.textInput"
|
|
7
|
+
:text-input="textInputConfig"
|
|
8
8
|
:speech-to-text="speechToTextConfig"
|
|
9
9
|
:camera="cameraConfig"
|
|
10
10
|
:microphone="microphoneConfig"
|
|
11
|
-
:
|
|
11
|
+
:mixed-files="attachmentsConfig"
|
|
12
12
|
:avatars="config.avatars"
|
|
13
13
|
:names="config.names"
|
|
14
14
|
:timestamps="config.timestamps"
|
|
@@ -24,10 +24,12 @@
|
|
|
24
24
|
</template>
|
|
25
25
|
|
|
26
26
|
<script>
|
|
27
|
+
import 'deep-chat'
|
|
28
|
+
|
|
27
29
|
export default {
|
|
28
30
|
name: 'UIDeepChat',
|
|
29
31
|
props: ['id', 'props', 'state'],
|
|
30
|
-
|
|
32
|
+
inject: ['$socket'],
|
|
31
33
|
data() {
|
|
32
34
|
return {
|
|
33
35
|
config: {
|
|
@@ -46,7 +48,6 @@ export default {
|
|
|
46
48
|
timestamps: false,
|
|
47
49
|
stream: false
|
|
48
50
|
},
|
|
49
|
-
isDeepChatLoaded: false,
|
|
50
51
|
messages: []
|
|
51
52
|
}
|
|
52
53
|
},
|
|
@@ -59,6 +60,53 @@ export default {
|
|
|
59
60
|
minHeight: '400px'
|
|
60
61
|
}
|
|
61
62
|
},
|
|
63
|
+
|
|
64
|
+
deepChatStyle() {
|
|
65
|
+
return {
|
|
66
|
+
width: '300px',
|
|
67
|
+
height: '300px',
|
|
68
|
+
flex: '1',
|
|
69
|
+
border: 'none',
|
|
70
|
+
borderRadius: '8px'
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
speechToTextConfig() {
|
|
75
|
+
return this.config.speechToText ? {
|
|
76
|
+
button: true,
|
|
77
|
+
displayInterimResults: true
|
|
78
|
+
} : false
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
cameraConfig() {
|
|
82
|
+
return this.config.camera ? {
|
|
83
|
+
button: true
|
|
84
|
+
} : false
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
microphoneConfig() {
|
|
88
|
+
return this.config.microphone ? {
|
|
89
|
+
button: true,
|
|
90
|
+
audio: true
|
|
91
|
+
} : false
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
attachmentsConfig() {
|
|
95
|
+
return this.config.attachments ? {
|
|
96
|
+
button: true,
|
|
97
|
+
acceptedFormats: ".jpeg,.jpg,.png,.gif,.pdf,.txt,.doc,.docx"
|
|
98
|
+
} : false
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
textInputConfig() {
|
|
102
|
+
if (!this.config.textInput) return false
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
placeholder: {
|
|
106
|
+
text: this.config.placeholder
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
},
|
|
62
110
|
|
|
63
111
|
speechToTextConfig() {
|
|
64
112
|
return this.config.speechToText ? {
|
|
@@ -114,7 +162,6 @@ export default {
|
|
|
114
162
|
},
|
|
115
163
|
|
|
116
164
|
mounted() {
|
|
117
|
-
this.loadDeepChat()
|
|
118
165
|
this.setupSocketListeners()
|
|
119
166
|
this.applyConfiguration()
|
|
120
167
|
},
|
|
@@ -124,42 +171,6 @@ export default {
|
|
|
124
171
|
},
|
|
125
172
|
|
|
126
173
|
methods: {
|
|
127
|
-
async loadDeepChat() {
|
|
128
|
-
try {
|
|
129
|
-
// Deep Chat von CDN laden
|
|
130
|
-
if (!window.DeepChat) {
|
|
131
|
-
const script = document.createElement('script')
|
|
132
|
-
script.src = 'https://unpkg.com/deep-chat@latest/dist/deepChat.bundle.js'
|
|
133
|
-
script.onload = () => {
|
|
134
|
-
this.isDeepChatLoaded = true
|
|
135
|
-
this.$nextTick(() => {
|
|
136
|
-
this.initializeDeepChat()
|
|
137
|
-
})
|
|
138
|
-
}
|
|
139
|
-
document.head.appendChild(script)
|
|
140
|
-
} else {
|
|
141
|
-
this.isDeepChatLoaded = true
|
|
142
|
-
this.$nextTick(() => {
|
|
143
|
-
this.initializeDeepChat()
|
|
144
|
-
})
|
|
145
|
-
}
|
|
146
|
-
} catch (error) {
|
|
147
|
-
console.error('Error loading Deep Chat:', error)
|
|
148
|
-
}
|
|
149
|
-
},
|
|
150
|
-
|
|
151
|
-
initializeDeepChat() {
|
|
152
|
-
if (this.$refs.deepChat) {
|
|
153
|
-
// Deep Chat ist bereit
|
|
154
|
-
console.log('Deep Chat initialized for widget:', this.id)
|
|
155
|
-
|
|
156
|
-
// Intro Message senden falls konfiguriert
|
|
157
|
-
if (this.config.introMessage) {
|
|
158
|
-
this.addMessage(this.config.introMessage, 'ai')
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
|
|
163
174
|
setupSocketListeners() {
|
|
164
175
|
// Neue Nachricht von Node-RED empfangen
|
|
165
176
|
this.$socket.on('deepchat-newMessage:' + this.id, (data) => {
|
|
@@ -169,7 +180,7 @@ export default {
|
|
|
169
180
|
// Konfiguration aktualisieren
|
|
170
181
|
this.$socket.on('deepchat-updateConfig:' + this.id, (newConfig) => {
|
|
171
182
|
this.config = { ...this.config, ...newConfig }
|
|
172
|
-
this.
|
|
183
|
+
this.updateConfiguration()
|
|
173
184
|
})
|
|
174
185
|
|
|
175
186
|
// Chat löschen
|
|
@@ -184,6 +195,7 @@ export default {
|
|
|
184
195
|
}
|
|
185
196
|
if (msg.config) {
|
|
186
197
|
this.config = { ...this.config, ...msg.config }
|
|
198
|
+
this.updateConfiguration()
|
|
187
199
|
}
|
|
188
200
|
if (msg.clear) {
|
|
189
201
|
this.clearMessages()
|
|
@@ -209,32 +221,6 @@ export default {
|
|
|
209
221
|
}
|
|
210
222
|
},
|
|
211
223
|
|
|
212
|
-
addMessage(content, role = 'ai', isHtml = false, files = []) {
|
|
213
|
-
try {
|
|
214
|
-
if (this.$refs.deepChat) {
|
|
215
|
-
const message = {
|
|
216
|
-
text: content,
|
|
217
|
-
role: role
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if (isHtml) {
|
|
221
|
-
message.html = content
|
|
222
|
-
delete message.text
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
if (files && files.length > 0) {
|
|
226
|
-
message.files = files
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// Nachricht zu Deep Chat hinzufügen
|
|
230
|
-
this.$refs.deepChat.addMessage(message)
|
|
231
|
-
this.messages.push(message)
|
|
232
|
-
}
|
|
233
|
-
} catch (error) {
|
|
234
|
-
console.error('Error adding message to Deep Chat:', error)
|
|
235
|
-
}
|
|
236
|
-
},
|
|
237
|
-
|
|
238
224
|
clearMessages() {
|
|
239
225
|
try {
|
|
240
226
|
if (this.$refs.deepChat) {
|
|
@@ -246,6 +232,13 @@ export default {
|
|
|
246
232
|
}
|
|
247
233
|
},
|
|
248
234
|
|
|
235
|
+
updateConfiguration() {
|
|
236
|
+
if (this.deepChatInstance) {
|
|
237
|
+
// Bestehende Instanz aktualisieren
|
|
238
|
+
this.applyConfigToElement(this.deepChatInstance)
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
|
|
249
242
|
handleCustomConnection(body, signals) {
|
|
250
243
|
// Node-RED Integration: Nachricht an Node-RED senden
|
|
251
244
|
this.$socket.emit('chat-message', this.id, {
|