ai-chat-bot-interface 1.3.0 → 1.3.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/package.json +1 -1
- package/src/App.vue +7 -1
- package/src/ChatUi.less +2 -0
- package/src/ChatUi.vue +23 -2
- package/src/components/OperateModule.vue +7 -3
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -4,7 +4,13 @@ import ChatUi from './ChatUi.vue';
|
|
|
4
4
|
|
|
5
5
|
<template>
|
|
6
6
|
<div style="width: 100vw; height: 100vh">
|
|
7
|
-
<chat-ui
|
|
7
|
+
<chat-ui
|
|
8
|
+
bot-id="000"
|
|
9
|
+
token="pat_8888"
|
|
10
|
+
uid="262598"
|
|
11
|
+
:def-msg="{ placeholder: '发消息...' }"
|
|
12
|
+
:show-header="true"
|
|
13
|
+
/>
|
|
8
14
|
</div>
|
|
9
15
|
</template>
|
|
10
16
|
<style></style>
|
package/src/ChatUi.less
CHANGED
package/src/ChatUi.vue
CHANGED
|
@@ -136,6 +136,7 @@
|
|
|
136
136
|
:new-chat="!showHeader"
|
|
137
137
|
:token="token"
|
|
138
138
|
:tag-list="tagList"
|
|
139
|
+
:def-msg="finalDefMsg"
|
|
139
140
|
@send="chatConv"
|
|
140
141
|
@tag="handleTagSel"
|
|
141
142
|
@call="handleCall"
|
|
@@ -175,6 +176,12 @@ const conversationId = ref('');
|
|
|
175
176
|
const isAnswering = ref(false);
|
|
176
177
|
const historyList = ref([]);
|
|
177
178
|
|
|
179
|
+
const msgObj = {
|
|
180
|
+
placeholder: '發消息⋯',
|
|
181
|
+
fileText: '請根據我上傳的體檢報告為我生成飲食方案',
|
|
182
|
+
uploadingTips: '文件正在上傳,請稍候...',
|
|
183
|
+
};
|
|
184
|
+
|
|
178
185
|
const props = defineProps({
|
|
179
186
|
logo: {
|
|
180
187
|
type: String,
|
|
@@ -213,10 +220,21 @@ const props = defineProps({
|
|
|
213
220
|
{ name: '体检报告', value: 'exam', type: 'upload', msg: '体检报告' },
|
|
214
221
|
],
|
|
215
222
|
},
|
|
223
|
+
defMsg: {
|
|
224
|
+
type: Object,
|
|
225
|
+
default: () => ({}),
|
|
226
|
+
},
|
|
216
227
|
});
|
|
217
228
|
|
|
218
229
|
const Emits = defineEmits(['call']);
|
|
219
230
|
|
|
231
|
+
const finalDefMsg = computed(() => {
|
|
232
|
+
return {
|
|
233
|
+
...msgObj,
|
|
234
|
+
...props.defMsg,
|
|
235
|
+
};
|
|
236
|
+
});
|
|
237
|
+
|
|
220
238
|
const endTarget = ref(null);
|
|
221
239
|
const inputText = ref('');
|
|
222
240
|
const botInfo = ref({});
|
|
@@ -285,7 +303,7 @@ const createConv = async () => {
|
|
|
285
303
|
|
|
286
304
|
const chatConv = async (data) => {
|
|
287
305
|
let isInCode = Array.isArray(data); // data.hasOwnProperty('text') && data.hasOwnProperty('code');
|
|
288
|
-
|
|
306
|
+
const botId = props.botId;
|
|
289
307
|
if (!(!isAnswering.value && (inputText.value || isInCode))) {
|
|
290
308
|
return;
|
|
291
309
|
}
|
|
@@ -308,7 +326,7 @@ const chatConv = async (data) => {
|
|
|
308
326
|
if (item.hasOwnProperty('content') && item.content) {
|
|
309
327
|
if (item.hasOwnProperty('type') && item.type === 'object_string') {
|
|
310
328
|
console.log('=== item ====', item);
|
|
311
|
-
botId = '7474884145253023795';
|
|
329
|
+
// botId = '7474884145253023795';
|
|
312
330
|
additional_messages.push({
|
|
313
331
|
content: JSON.stringify(
|
|
314
332
|
item.content.map((con) => ({
|
|
@@ -428,6 +446,7 @@ const chatConv = async (data) => {
|
|
|
428
446
|
) {
|
|
429
447
|
historyList.value[idx].status = 'thinking';
|
|
430
448
|
historyList.value[idx].reasoning_content += strObj.reasoning_content;
|
|
449
|
+
scrollToEnd();
|
|
431
450
|
} else if (
|
|
432
451
|
strObj.hasOwnProperty('content') &&
|
|
433
452
|
strObj.hasOwnProperty('content_type') &&
|
|
@@ -565,6 +584,8 @@ const queryBotInfo = async () => {
|
|
|
565
584
|
|
|
566
585
|
const handleText = (str) => {
|
|
567
586
|
// console.log(str);
|
|
587
|
+
let txt = '';
|
|
588
|
+
|
|
568
589
|
return str.replaceAll(
|
|
569
590
|
/\[([^\]]+)\]\((https?:\/\/[^)]+)\)/gi,
|
|
570
591
|
'<a href="$2" target="_blank">[$1]</a>',
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
ref="txtEle"
|
|
53
53
|
class="input"
|
|
54
54
|
rows="1"
|
|
55
|
-
placeholder="
|
|
55
|
+
:placeholder="defMsg.placeholder"
|
|
56
56
|
@input="handleInput"
|
|
57
57
|
@keyup.enter="sendMsg"
|
|
58
58
|
/>
|
|
@@ -140,6 +140,10 @@ const props = defineProps({
|
|
|
140
140
|
type: Boolean,
|
|
141
141
|
default: false,
|
|
142
142
|
},
|
|
143
|
+
defMsg: {
|
|
144
|
+
type: Object,
|
|
145
|
+
required: true,
|
|
146
|
+
},
|
|
143
147
|
});
|
|
144
148
|
const Emits = defineEmits(['update:modelValue', 'send', 'tag', 'call']);
|
|
145
149
|
|
|
@@ -194,7 +198,7 @@ const sendMsg = () => {
|
|
|
194
198
|
uFileList.value.findIndex((f) => f.percent < 100) > -1
|
|
195
199
|
) {
|
|
196
200
|
Emits('call', {
|
|
197
|
-
message:
|
|
201
|
+
message: props.defMsg.uploadingTips,
|
|
198
202
|
reason: 'is_uploading',
|
|
199
203
|
value: 'toast',
|
|
200
204
|
type: 'call',
|
|
@@ -245,7 +249,7 @@ const handleUpload = async (idx) => {
|
|
|
245
249
|
const file = uFileList.value[idx].file;
|
|
246
250
|
console.log('========', file);
|
|
247
251
|
if (!textValue.value) {
|
|
248
|
-
textValue.value =
|
|
252
|
+
textValue.value = props.defMsg.fileText;
|
|
249
253
|
}
|
|
250
254
|
const formDate = new FormData();
|
|
251
255
|
formDate.append('file', file);
|